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

This commit is contained in:
2014-05-01 12:40:49 +10:00
parent 7b0bce1946
commit 4849ca8a56
5 changed files with 18 additions and 7 deletions

View File

@@ -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

View File

@@ -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);
}
}

View File

@@ -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);
}

View File

@@ -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);

View File

@@ -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++;