diff options
author | Harley Acheson <harley.acheson@gmail.com> | 2019-10-30 04:11:19 +0300 |
---|---|---|
committer | Harley Acheson <harley.acheson@gmail.com> | 2019-10-30 04:11:19 +0300 |
commit | dff7abf06109eef72e9ec01c42607a22702dd0a5 (patch) | |
tree | 72c53352a813ce5dbfd7dba4e7a4e764e767ae75 /source/blender/editors/interface | |
parent | 5207b977f7a210852fb05e68e387e0803c510789 (diff) |
UI: Hover States
Hover (active) widget states now affecting more elements and in a more consistent way.
Differential Revision: https://developer.blender.org/D6098
Reviewed by Campbell Barton
Diffstat (limited to 'source/blender/editors/interface')
-rw-r--r-- | source/blender/editors/interface/interface_widgets.c | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index b3e039292e1..4cef9ace66e 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -184,6 +184,18 @@ static void color_ensure_contrast_v3(uchar cp[3], const uchar cp_other[3], int c } } +static void color_mul_hsl_v3(uchar ch[3], float h_factor, float s_factor, float l_factor) +{ + float rgb[3], hsl[3]; + rgb_uchar_to_float(rgb, ch); + rgb_to_hsl_v(rgb, hsl); + hsl[0] *= h_factor; + hsl[1] *= s_factor; + hsl[2] *= l_factor; + hsl_to_rgb_v(hsl, rgb); + rgb_float_to_uchar(ch, rgb); +} + /** \} */ /* -------------------------------------------------------------------- */ @@ -2573,11 +2585,12 @@ static void ui_widget_color_disabled(uiWidgetType *wt) wt->wcol_theme = &wcol_theme_s; } -static void widget_active_color(uchar cp[3]) +static void widget_active_color(uiWidgetColors *wcol) { - cp[0] = cp[0] >= 240 ? 255 : cp[0] + 15; - cp[1] = cp[1] >= 240 ? 255 : cp[1] + 15; - cp[2] = cp[2] >= 240 ? 255 : cp[2] + 15; + bool dark = (rgb_to_grayscale_byte(wcol->text) > rgb_to_grayscale_byte(wcol->inner)); + color_mul_hsl_v3(wcol->inner, 1.0f, 1.15f, dark ? 1.2f : 1.1f); + color_mul_hsl_v3(wcol->outline, 1.0f, 1.15f, 1.15f); + color_mul_hsl_v3(wcol->text, 1.0f, 1.15f, dark ? 1.25f : 0.8f); } static const uchar *widget_color_blend_from_flags(const uiWidgetStateColors *wcol_state, @@ -2641,10 +2654,10 @@ static void widget_state(uiWidgetType *wt, int state, int drawflag) if (color_blend != NULL) { color_blend_v3_v3(wt->wcol.inner, color_blend, wcol_state->blend); } + } - if (state & UI_ACTIVE) { /* mouse over? */ - widget_active_color(wt->wcol.inner); - } + if (state & UI_ACTIVE) { + widget_active_color(&wt->wcol); } if (state & UI_BUT_REDALERT) { @@ -3403,7 +3416,7 @@ static void widget_numbut_draw( wcol_zone = *wcol; copy_v3_v3_uchar(wcol_zone.item, wcol->text); if (state & UI_STATE_ACTIVE_LEFT) { - widget_active_color(wcol_zone.inner); + widget_active_color(&wcol_zone); } rect_zone = *rect; @@ -3423,7 +3436,7 @@ static void widget_numbut_draw( wcol_zone = *wcol; copy_v3_v3_uchar(wcol_zone.item, wcol->text); if (state & UI_STATE_ACTIVE_RIGHT) { - widget_active_color(wcol_zone.inner); + widget_active_color(&wcol_zone); } rect_zone = *rect; @@ -3442,7 +3455,7 @@ static void widget_numbut_draw( wcol_zone = *wcol; copy_v3_v3_uchar(wcol_zone.item, wcol->text); if (!(state & (UI_STATE_ACTIVE_LEFT | UI_STATE_ACTIVE_RIGHT))) { - widget_active_color(wcol_zone.inner); + widget_active_color(&wcol_zone); } rect_zone = *rect; |