From 8ca9626985f7377272b4e4a9b5000f8a6599b5a0 Mon Sep 17 00:00:00 2001 From: Harley Acheson Date: Sun, 1 Sep 2019 09:40:28 -0700 Subject: UI: Active Default Button Highlight Buttons marked as the default action are shown in full selected color. Simplification of all the related active_default code. Differential Revision: https://developer.blender.org/D5574 Reviewed by Campbell Barton --- release/scripts/addons | 2 +- release/scripts/addons_contrib | 2 +- .../blender/editors/interface/interface_widgets.c | 62 +++++----------------- 3 files changed, 14 insertions(+), 52 deletions(-) diff --git a/release/scripts/addons b/release/scripts/addons index fe627477c25..cbb11b1a597 160000 --- a/release/scripts/addons +++ b/release/scripts/addons @@ -1 +1 @@ -Subproject commit fe627477c2501c1e38311c97b3b5e3ffa731947e +Subproject commit cbb11b1a597366deabfa1cac11989621bf9075c4 diff --git a/release/scripts/addons_contrib b/release/scripts/addons_contrib index 8b5ea4d118e..e479f81053b 160000 --- a/release/scripts/addons_contrib +++ b/release/scripts/addons_contrib @@ -1 +1 @@ -Subproject commit 8b5ea4d118e56111999832dcbc83020483414239 +Subproject commit e479f81053badb6548ca9cb8a6f2b22e0a242cb7 diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 0fafa07a060..8d22c5b85bb 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -2587,6 +2587,10 @@ static void widget_state(uiWidgetType *wt, int state, int drawflag) } } else { + if (state & UI_BUT_ACTIVE_DEFAULT) { + copy_v4_v4_uchar(wt->wcol.inner, wt->wcol.inner_sel); + copy_v4_v4_uchar(wt->wcol.text, wt->wcol.text_sel); + } if (color_blend != NULL) { widget_state_blend(wt->wcol.inner, color_blend, wcol_state->blend); } @@ -3268,20 +3272,6 @@ static void ui_draw_but_HSV_v(uiBut *but, const rcti *rect) ui_hsv_cursor(x, y); } -/* Generic round-box drawing. */ -static void ui_draw_roundbox(const rcti *rect, const float rad, const uiWidgetColors *wcol) -{ - uiWidgetBase wtb; - widget_init(&wtb); - round_box_edges(&wtb, UI_CNR_ALL, rect, rad); - widgetbase_draw(&wtb, wcol); - - /* We are drawing on top of widget bases. Flush cache. */ - GPU_blend(true); - UI_widgetbase_draw_cache_flush(); - GPU_blend(false); -} - /* ************ separator, for menus etc ***************** */ static void ui_draw_separator(const rcti *rect, const uiWidgetColors *wcol) { @@ -4497,10 +4487,6 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct const uiFontStyle *fstyle = &style->widget; uiWidgetType *wt = NULL; -#ifdef USE_UI_POPOVER_ONCE - const rcti rect_orig = *rect; -#endif - /* handle menus separately */ if (but->dt == UI_EMBOSS_PULLDOWN) { switch (but->type) { @@ -4786,6 +4772,14 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct 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)) { + state |= UI_BUT_ACTIVE_DEFAULT; + } + } +#endif + wt->state(wt, state, drawflag); if (wt->custom) { wt->custom(but, &wt->wcol, rect, state, roundboxalign); @@ -4798,42 +4792,10 @@ void ui_draw_but(const bContext *C, ARegion *ar, uiStyle *style, uiBut *but, rct GPU_blend(true); } - bool show_semi_highlight = false; - -#ifdef USE_UI_POPOVER_ONCE - if (but->block->flag & UI_BLOCK_POPOVER_ONCE) { - if ((state & UI_ACTIVE) && ui_but_is_popover_once_compat(but)) { - show_semi_highlight = true; - } - } -#endif - if (but->flag & UI_BUT_ACTIVE_DEFAULT) { - show_semi_highlight = true; - } - - if (show_semi_highlight) { - uiWidgetType wt_back = *wt; - uiWidgetType *wt_temp = widget_type(UI_WTYPE_MENU_ITEM); - wt_temp->state(wt_temp, state, drawflag); - copy_v4_v4_uchar(wt->wcol.inner, wt->wcol.inner_sel); - wt->wcol.inner[3] = 128; - wt->wcol.roundness = 0.5f; - ui_draw_roundbox(&rect_orig, - 0.25f * min_ff(BLI_rcti_size_x(&rect_orig), BLI_rcti_size_y(&rect_orig)), - &wt_temp->wcol); - *wt = wt_back; - } - wt->text(fstyle, &wt->wcol, but, rect); if (disabled) { GPU_blend(false); } - - // if (state & (UI_BUT_DISABLED | UI_BUT_INACTIVE)) { - // if (but->dt != UI_EMBOSS_PULLDOWN) { - // widget_disabled(&disablerect); - // } - // } } } -- cgit v1.2.3