Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Goudey <h.goudey@me.com>2020-10-02 21:10:21 +0300
committerHans Goudey <h.goudey@me.com>2020-10-02 21:10:21 +0300
commit933bf62a611f61bd61e3e7745ce6dea58f571e72 (patch)
tree671de906d3acbea69f32428899bbeb64a009d45c /source/blender/editors/interface/interface_widgets.c
parent6f96dd85766a8159d5ffb761cbb4dbd20b7cad00 (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/blender/editors/interface/interface_widgets.c')
-rw-r--r--source/blender/editors/interface/interface_widgets.c70
1 files changed, 40 insertions, 30 deletions
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);
}
}