diff options
author | Hans Goudey <h.goudey@me.com> | 2020-10-02 21:10:21 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2020-10-02 21:10:21 +0300 |
commit | 933bf62a611f61bd61e3e7745ce6dea58f571e72 (patch) | |
tree | 671de906d3acbea69f32428899bbeb64a009d45c /source | |
parent | 6f96dd85766a8159d5ffb761cbb4dbd20b7cad00 (diff) |
Property Search: Differentiate search filtered and inactive buttons
Currently there's no way to know if a button is inactive when it doesn't
match the search results, because they use the same 50% gray level.
This isn't a huge problem, but it could lead to confusion. This commit
uses a subtle solution, a 25% opacity when the button is inactive and
also filtered by search.
This requires flipping the meaning of the UI_SEARCH_FILTER_MATCHES
flag in the code, and also adding a widget_alpha_factor utility in
the widget code.
Differential Revision: https://developer.blender.org/D8975
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/interface/interface_intern.h | 7 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_layout.c | 19 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_widgets.c | 70 |
3 files changed, 46 insertions, 50 deletions
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 91a71b0ca28..7ac6ca4577e 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -81,11 +81,8 @@ enum { UI_HAS_ICON = (1 << 3), UI_HIDDEN = (1 << 4), UI_SELECT_DRAW = (1 << 5), /* Display selected, doesn't impact interaction. */ - /** - * The button matches the search filter. When property search is active, this - * is used to determine which items to keep enabled and which to disable. - */ - UI_SEARCH_FILTER_MATCHES = (1 << 12), + /** Property search filter is active and the button does not match. */ + UI_SEARCH_FILTER_NO_MATCH = (1 << 12), /* warn: rest of uiBut->flag in UI_interface.h */ }; diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index f8b9f4f0df1..ab641dc74fe 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -5239,26 +5239,19 @@ static bool block_search_filter_tag_buttons(uiBlock *block, const char *search_f LISTBASE_FOREACH (uiLayoutRoot *, root, &block->layouts) { LISTBASE_FOREACH (uiButtonGroup *, button_group, &root->button_groups) { if (button_group_has_search_match(button_group, search_filter)) { + has_result = true; + } + else { LISTBASE_FOREACH (LinkData *, link, &button_group->buttons) { uiBut *but = link->data; - but->flag |= UI_SEARCH_FILTER_MATCHES; + but->flag |= UI_SEARCH_FILTER_NO_MATCH; } - has_result = true; } } } return has_result; } -static void block_search_deactivate_buttons(uiBlock *block) -{ - LISTBASE_FOREACH (uiBut *, but, &block->buttons) { - if (!(but->flag & UI_SEARCH_FILTER_MATCHES)) { - but->flag |= UI_BUT_INACTIVE; - } - } -} - /** * Apply property search behavior, setting panel flags and deactivating buttons that don't match. * @@ -5284,10 +5277,6 @@ bool UI_block_apply_search_filter(uiBlock *block, const char *search_filter) } } - if (!panel_label_matches) { - block_search_deactivate_buttons(block); - } - return has_result; } diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 22e57cf8696..f2081199672 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -1332,6 +1332,22 @@ static void widgetbase_draw(uiWidgetBase *wtb, const uiWidgetColors *wcol) #define PREVIEW_PAD 4 +static float widget_alpha_factor(const int state) +{ + if (state & (UI_BUT_INACTIVE | UI_BUT_DISABLED)) { + if (state & UI_SEARCH_FILTER_NO_MATCH) { + return 0.25f; + } + return 0.5f; + } + + if (state & UI_SEARCH_FILTER_NO_MATCH) { + return 0.5f; + } + + return 1.0f; +} + static void widget_draw_preview(BIFIconID icon, float alpha, const rcti *rect) { int w, h, size; @@ -1400,9 +1416,7 @@ static void widget_draw_icon( } } else if (ELEM(but->type, UI_BTYPE_BUT, UI_BTYPE_DECORATOR)) { - if (but->flag & (UI_BUT_DISABLED | UI_BUT_INACTIVE)) { - alpha *= 0.5f; - } + alpha *= widget_alpha_factor(but->flag); } GPU_blend(GPU_BLEND_ALPHA); @@ -2477,18 +2491,20 @@ static void widget_draw_text_icon(const uiFontStyle *fstyle, * \{ */ /* put all widget colors on half alpha, use local storage */ -static void ui_widget_color_disabled(uiWidgetType *wt) +static void ui_widget_color_disabled(uiWidgetType *wt, const int state) { static uiWidgetColors wcol_theme_s; wcol_theme_s = *wt->wcol_theme; - wcol_theme_s.outline[3] *= 0.5; - wcol_theme_s.inner[3] *= 0.5; - wcol_theme_s.inner_sel[3] *= 0.5; - wcol_theme_s.item[3] *= 0.5; - wcol_theme_s.text[3] *= 0.5; - wcol_theme_s.text_sel[3] *= 0.5; + const float factor = widget_alpha_factor(state); + + wcol_theme_s.outline[3] *= factor; + wcol_theme_s.inner[3] *= factor; + wcol_theme_s.inner_sel[3] *= factor; + wcol_theme_s.item[3] *= factor; + wcol_theme_s.text[3] *= factor; + wcol_theme_s.text_sel[3] *= factor; wt->wcol_theme = &wcol_theme_s; } @@ -2533,8 +2549,8 @@ static void widget_state(uiWidgetType *wt, int state, int drawflag) bTheme *btheme = UI_GetTheme(); wt->wcol_theme = &btheme->tui.wcol_list_item; - if (state & (UI_BUT_DISABLED | UI_BUT_INACTIVE)) { - ui_widget_color_disabled(wt); + if (state & (UI_BUT_DISABLED | UI_BUT_INACTIVE | UI_SEARCH_FILTER_NO_MATCH)) { + ui_widget_color_disabled(wt, state & UI_SEARCH_FILTER_NO_MATCH); } } @@ -3829,14 +3845,11 @@ static void widget_swatch( wcol->shaded = 0; - if (state & (UI_BUT_DISABLED | UI_BUT_INACTIVE)) { - /* Now we reduce alpha of the inner color (i.e. the color shown) - * so that this setting can look grayed out, while retaining - * the checkerboard (for transparent values). This is needed - * here as the effects of ui_widget_color_disabled() are overwritten. - */ - wcol->inner[3] /= 2; - } + /* Now we reduce alpha of the inner color (i.e. the color shown) + * so that this setting can look grayed out, while retaining + * the checkerboard (for transparent values). This is needed + * here as the effects of ui_widget_color_disabled() are overwritten. */ + wcol->inner[3] *= widget_alpha_factor(state); widgetbase_draw_ex(&wtb, wcol, show_alpha_checkers); if (color_but->is_pallete_color && @@ -4771,7 +4784,6 @@ void ui_draw_but(const bContext *C, struct ARegion *region, uiStyle *style, uiBu if (wt) { // rcti disablerect = *rect; /* rect gets clipped smaller for text */ int roundboxalign, state, drawflag; - bool disabled = false; roundboxalign = widget_roundbox_set(but, rect); @@ -4801,9 +4813,11 @@ void ui_draw_but(const bContext *C, struct ARegion *region, uiStyle *style, uiBu } } - if (state & (UI_BUT_DISABLED | UI_BUT_INACTIVE)) { - if (but->emboss != UI_EMBOSS_PULLDOWN) { - disabled = true; + bool use_alpha_blend = false; + if (but->emboss != UI_EMBOSS_PULLDOWN) { + if (state & (UI_BUT_DISABLED | UI_BUT_INACTIVE | UI_SEARCH_FILTER_NO_MATCH)) { + use_alpha_blend = true; + ui_widget_color_disabled(wt, state); } } @@ -4811,10 +4825,6 @@ void ui_draw_but(const bContext *C, struct ARegion *region, uiStyle *style, uiBu state |= UI_STATE_TEXT_BEFORE_WIDGET; } - if (disabled) { - ui_widget_color_disabled(wt); - } - #ifdef USE_UI_POPOVER_ONCE if (but->block->flag & UI_BLOCK_POPOVER_ONCE) { if ((state & UI_ACTIVE) && ui_but_is_popover_once_compat(but)) { @@ -4831,12 +4841,12 @@ void ui_draw_but(const bContext *C, struct ARegion *region, uiStyle *style, uiBu wt->draw(&wt->wcol, rect, state, roundboxalign); } - if (disabled) { + if (use_alpha_blend) { GPU_blend(GPU_BLEND_ALPHA); } wt->text(fstyle, &wt->wcol, but, rect); - if (disabled) { + if (use_alpha_blend) { GPU_blend(GPU_BLEND_NONE); } } |