UI: add UI_SELECT_DRAW flag
authorCampbell Barton <ideasman42@gmail.com>
Thu, 2 Nov 2017 13:45:30 +0000 (00:45 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 2 Nov 2017 13:47:51 +0000 (00:47 +1100)
Allow to draw as pressed w/o interfering with behavior.

Resolves issue where buttons raised on mouse-over.

source/blender/editors/interface/interface_intern.h
source/blender/editors/interface/interface_layout.c
source/blender/editors/interface/interface_widgets.c

index 7ee185493428b913aba33e0780bfcfdad1d2e17c..537ecf8c65bdb30060cfd5fe5930043ddb03cf5c 100644 (file)
@@ -119,6 +119,7 @@ enum {
        UI_ACTIVE       = (1 << 2),
        UI_HAS_ICON     = (1 << 3),
        UI_HIDDEN       = (1 << 4),
        UI_ACTIVE       = (1 << 2),
        UI_HAS_ICON     = (1 << 3),
        UI_HIDDEN       = (1 << 4),
+       UI_SELECT_DRAW  = (1 << 5),  /* Display selected, doesn't impact interaction. */
        /* warn: rest of uiBut->flag in UI_interface.h */
 };
 
        /* warn: rest of uiBut->flag in UI_interface.h */
 };
 
index f0179cb852fd24cbf8cf4892ed2daca21998f31b..a6bbe7254034e9fb3a44f3ed98d480a3a1aadb12 100644 (file)
@@ -846,7 +846,7 @@ static uiBut *uiItemFullO_ptr_ex(
                UI_block_emboss_set(block, UI_EMBOSS);
 
        if (flag & UI_ITEM_O_DEPRESS) {
                UI_block_emboss_set(block, UI_EMBOSS);
 
        if (flag & UI_ITEM_O_DEPRESS) {
-               but->flag |= UI_SELECT;
+               but->flag |= UI_SELECT_DRAW;
        }
 
        if (layout->redalert)
        }
 
        if (layout->redalert)
index 9c80b30100d9b571ae7cebb802a2f0fa489f0eaf..78090c67770cf3d265f7b797617b8e1915be7497 100644 (file)
@@ -67,7 +67,7 @@
 #define ICON_SIZE_FROM_BUTRECT(rect) (0.8f * BLI_rcti_size_y(rect))
 
 #define UI_BUT_FLAGS_PUBLIC \
 #define ICON_SIZE_FROM_BUTRECT(rect) (0.8f * BLI_rcti_size_y(rect))
 
 #define UI_BUT_FLAGS_PUBLIC \
-       (UI_SELECT | UI_SCROLLED | UI_ACTIVE | UI_HAS_ICON | UI_HIDDEN)
+       (UI_SELECT | UI_SCROLLED | UI_ACTIVE | UI_HAS_ICON | UI_HIDDEN | UI_SELECT_DRAW)
 
 /* Don't overlap w/ UI_BUT_FLAGS_PUBLIC buts. */
 enum {
 
 /* Don't overlap w/ UI_BUT_FLAGS_PUBLIC buts. */
 enum {
@@ -3909,6 +3909,10 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct
 
                state = but->flag & UI_BUT_FLAGS_PUBLIC;
 
 
                state = but->flag & UI_BUT_FLAGS_PUBLIC;
 
+               if (state & UI_SELECT_DRAW) {
+                       state |= UI_SELECT;
+               }
+
                if ((but->editstr) ||
                    (UNLIKELY(but->flag & UI_BUT_DRAG_MULTI) && ui_but_drag_multi_edit_get(but)))
                {
                if ((but->editstr) ||
                    (UNLIKELY(but->flag & UI_BUT_DRAG_MULTI) && ui_but_drag_multi_edit_get(but)))
                {