Fix dimmed shortcut key display issues in toolbar menu and color picker.

Draw with alpha * 0.5 instead of using item them color, this doesn't work
well in the toolbar menu and highlighted menu items otherwise.
This commit is contained in:
Brecht Van Lommel 2018-07-03 13:04:21 +02:00
parent 48c93640d2
commit c50e1216a6
3 changed files with 9 additions and 3 deletions

View File

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

View File

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

View File

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