Commit: 4849ca8a567dd6c5d198355f94740c9f19fa5a7c
Author: Campbell Barton
Date:   Thu May 1 12:40:49 2014 +1000
https://developer.blender.org/rB4849ca8a567dd6c5d198355f94740c9f19fa5a7c

Fix T39884: Displaying filenames with '|' failing in menus

===================================================================

M       source/blender/editors/include/UI_interface.h
M       source/blender/editors/interface/interface.c
M       source/blender/editors/interface/interface_handlers.c
M       source/blender/editors/interface/interface_regions.c
M       source/blender/editors/interface/interface_widgets.c

===================================================================

diff --git a/source/blender/editors/include/UI_interface.h 
b/source/blender/editors/include/UI_interface.h
index 32db99f..8de9650 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -174,6 +174,7 @@ enum {
        UI_BUT_LIST_ITEM     = (1 << 24),  /* This but is "inside" a list item 
(currently used to change theme colors). */
        UI_BUT_DRAG_MULTI    = (1 << 25),  /* edit this button as well as the 
active button (not just dragging) */
        UI_BUT_SCA_LINK_GREY = (1 << 26),  /* used to flag if sca links shoud 
be grey out */
+       UI_BUT_HAS_SEP_CHAR  = (1 << 27),  /* but->str contains UI_SEP_CHAR, 
used for key shortcuts */
 };
 
 #define UI_PANEL_WIDTH          340
diff --git a/source/blender/editors/interface/interface.c 
b/source/blender/editors/interface/interface.c
index 16f88bb..3da6b5d 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -886,11 +886,12 @@ static void ui_menu_block_set_keyaccels(uiBlock *block)
 void ui_but_add_shortcut(uiBut *but, const char *shortcut_str, const bool 
do_strip)
 {
 
-       if (do_strip) {
-               char *cpoin = strchr(but->str, UI_SEP_CHAR);
+       if (do_strip && (but->flag & UI_BUT_HAS_SEP_CHAR)) {
+               char *cpoin = strrchr(but->str, UI_SEP_CHAR);
                if (cpoin) {
                        *cpoin = '\0';
                }
+               but->flag &= ~UI_BUT_HAS_SEP_CHAR;
        }
 
        /* without this, just allow stripping of the shortcut */
@@ -909,6 +910,7 @@ void ui_but_add_shortcut(uiBut *but, const char 
*shortcut_str, const bool do_str
                             butstr_orig, shortcut_str);
                MEM_freeN(butstr_orig);
                but->str = but->strdata;
+               but->flag |= UI_BUT_HAS_SEP_CHAR;
                ui_check_but(but);
        }
 }
diff --git a/source/blender/editors/interface/interface_handlers.c 
b/source/blender/editors/interface/interface_handlers.c
index a1f1d35..4c02346 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -5586,6 +5586,14 @@ void ui_panel_menu(bContext *C, ARegion *ar, Panel *pa)
                char tmpstr[80];
                BLI_snprintf(tmpstr, sizeof(tmpstr), "%s" UI_SEP_CHAR_S "%s", 
IFACE_("Pin"), IFACE_("Shift+Left Mouse"));
                uiItemR(layout, &ptr, "use_pin", 0, tmpstr, ICON_NONE);
+
+               /* evil, force shortcut flag */
+               {
+                       uiBlock *block = uiLayoutGetBlock(layout);
+                       uiBut *but = block->buttons.last;
+                       but->flag |= UI_BUT_HAS_SEP_CHAR;
+               }
+
        }
        uiPupMenuEnd(C, pup);
 }
diff --git a/source/blender/editors/interface/interface_regions.c 
b/source/blender/editors/interface/interface_regions.c
index 4a88ac2..ce80727 100644
--- a/source/blender/editors/interface/interface_regions.c
+++ b/source/blender/editors/interface/interface_regions.c
@@ -767,7 +767,7 @@ bool ui_searchbox_apply(uiBut *but, ARegion *ar)
        
        if (data->active != -1) {
                const char *name = data->items.names[data->active];
-               const char *name_sep = data->use_sep ? strchr(name, 
UI_SEP_CHAR) : NULL;
+               const char *name_sep = data->use_sep ? strrchr(name, 
UI_SEP_CHAR) : NULL;
 
                BLI_strncpy(but->editstr, name, name_sep ? (name_sep - name) : 
data->items.maxstrlen);
                
@@ -873,7 +873,7 @@ void ui_searchbox_update(bContext *C, ARegion *ar, uiBut 
*but, const bool reset)
                
                for (a = 0; a < data->items.totitem; a++) {
                        const char *name = data->items.names[a];
-                       const char *name_sep = data->use_sep ? strchr(name, 
UI_SEP_CHAR) : NULL;
+                       const char *name_sep = data->use_sep ? strrchr(name, 
UI_SEP_CHAR) : NULL;
                        if (STREQLEN(but->editstr, name, name_sep ? (name_sep - 
name) : data->items.maxstrlen)) {
                                data->active = a;
                                break;
@@ -2086,7 +2086,7 @@ static unsigned int ui_popup_string_hash(const char *str)
 {
        /* sometimes button contains hotkey, sometimes not, strip for proper 
compare */
        int hash;
-       const char *delimit = strchr(str, UI_SEP_CHAR);
+       const char *delimit = strrchr(str, UI_SEP_CHAR);
 
        if (delimit) {
                hash = BLI_ghashutil_strhash_n(str, delimit - str);
diff --git a/source/blender/editors/interface/interface_widgets.c 
b/source/blender/editors/interface/interface_widgets.c
index c9bff1a..9c5b160 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -1284,8 +1284,8 @@ static void widget_draw_text(uiFontStyle *fstyle, 
uiWidgetColors *wcol, uiBut *b
 
        /* cut string in 2 parts - only for menu entries */
        if ((but->block->flag & UI_BLOCK_LOOP)) {
-               if (ELEM3(but->type, NUM, TEX, NUMSLI) == 0) {
-                       drawstr_right = strchr(drawstr, UI_SEP_CHAR);
+               if (but->flag & UI_BUT_HAS_SEP_CHAR) {
+                       drawstr_right = strrchr(drawstr, UI_SEP_CHAR);
                        if (drawstr_right) {
                                drawstr_left_len = (drawstr_right - drawstr);
                                drawstr_right++;

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to