Commit: c50e1216a654a93ba8a05f5a1b573e6bdc28c3bd
Author: Brecht Van Lommel
Date:   Tue Jul 3 13:04:21 2018 +0200
Branches: blender2.8
https://developer.blender.org/rBc50e1216a654a93ba8a05f5a1b573e6bdc28c3bd

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.

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

M       source/blender/editors/include/UI_interface.h
M       source/blender/editors/interface/interface.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 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;

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

Reply via email to