diff options
author | Campbell Barton <ideasman42@gmail.com> | 2017-11-04 06:10:04 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2017-11-04 06:13:04 +0300 |
commit | 25f56d7a7bc72e0029d561ff142682c59979c7fd (patch) | |
tree | 3eddb75f0026e3463650840f9ba587838ef4d3ce | |
parent | 33b5e8daff2cfe269bdb527cf0de6dd083b01daf (diff) |
UI: correct flag re-use
Adding ability to show a button as pressed w/o UI_SELECT set caused
other flags to be cleared that shouldn't have been.
-rw-r--r-- | source/blender/editors/interface/interface_widgets.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 692d5811831..39ee8e2885d 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -66,16 +66,18 @@ /* icons are 80% of height of button (16 pixels inside 20 height) */ #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_DRAW) - -/* Don't overlap w/ UI_BUT_FLAGS_PUBLIC bits. */ +/* Button state argument shares bits with 'uiBut.flag'. + * reuse flags that aren't needed for drawing to avoid collision. */ enum { /* Show that holding the button opens a menu. */ - UI_STATE_HOLD_ACTION = (1 << 6), - UI_STATE_TEXT_INPUT = (1 << 7), -}; + UI_STATE_HOLD_ACTION = UI_BUT_UPDATE_DELAY, + UI_STATE_TEXT_INPUT = UI_BUT_UNDO, + UI_STATE_FLAGS_ALL = (UI_STATE_HOLD_ACTION | UI_STATE_TEXT_INPUT), +}; +/* Prevent accidental use. */ +#define UI_BUT_UPDATE_DELAY ((void)0) +#define UI_BUT_UNDO ((void)0) /* ************** widget base functions ************** */ /** @@ -3907,7 +3909,8 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct roundboxalign = widget_roundbox_set(but, rect); - state = but->flag & UI_BUT_FLAGS_PUBLIC; + /* Mask out flags re-used for local state. */ + state = but->flag & ~UI_STATE_FLAGS_ALL; if (state & UI_SELECT_DRAW) { state |= UI_SELECT; |