diff options
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/include/UI_interface.h | 2 | ||||
-rw-r--r-- | source/blender/editors/interface/interface.c | 1 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_widgets.c | 9 |
3 files changed, 9 insertions, 3 deletions
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index e5218e287d4..1ab1c5227ea 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -233,6 +233,8 @@ enum { UI_BUT_ACTIVE_LEFT = (1 << 21), /* Active left part of number button */ UI_BUT_ACTIVE_RIGHT = (1 << 22), /* Active right part of number button */ + + UI_BUT_HAS_SHORTCUT = (1 << 23), /* Button has shortcut text */ }; /* scale fixed button widths by this to account for DPI */ diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 3b2a2e9d3ed..427f5621177 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -943,6 +943,7 @@ void ui_but_add_shortcut(uiBut *but, const char *shortcut_str, const bool do_str MEM_freeN(butstr_orig); but->str = but->strdata; but->flag |= UI_BUT_HAS_SEP_CHAR; + but->drawflag |= UI_BUT_HAS_SHORTCUT; ui_but_update(but); } } diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 4bf2ac4271b..1c6d5c70933 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -1878,7 +1878,7 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b #endif /* cut string in 2 parts - only for menu entries */ - if ((but->block->flag & (UI_BLOCK_LOOP | UI_BLOCK_SHOW_SHORTCUT_ALWAYS)) && + if ((but->drawflag & UI_BUT_HAS_SHORTCUT) && (but->editstr == NULL)) { if (but->flag & UI_BUT_HAS_SEP_CHAR) { @@ -1961,8 +1961,11 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b /* part text right aligned */ if (drawstr_right) { - const char *col = but->block->flag & (UI_BLOCK_LOOP | UI_BLOCK_SHOW_SHORTCUT_ALWAYS) ? - wcol->item : wcol->text; + char col[4]; + copy_v4_v4_char(col, wcol->text); + if (but->drawflag & UI_BUT_HAS_SHORTCUT) { + col[3] *= 0.5f; + } fstyle->align = UI_STYLE_TEXT_RIGHT; rect->xmax -= UI_TEXT_CLIP_MARGIN; |