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:
authorJulian Eisel <julian@blender.org>2021-11-25 17:51:03 +0300
committerJulian Eisel <julian@blender.org>2021-11-25 17:55:04 +0300
commit94e8db1e869d8209599f1a40b0e1a25c056d077a (patch)
tree415ea1d9d41a95b38c39239608101623876dca99 /source/blender/editors/interface
parentc91d1961596eb3ac0905010b63551951fc1fece7 (diff)
Fix T92278: Small size of previews in the shading popover
Don't use the side padding for menu item contents when displaying previews or icons in a row or grid layout. This can cause problems for the preview drawing and doesn't make sense to draw there anyway. This not only fixes the mentioned issue, but also too small heighlight for the collection color tag in the Outliner context menu. Alternative to and similar to D13125.
Diffstat (limited to 'source/blender/editors/interface')
-rw-r--r--source/blender/editors/interface/interface_widgets.c40
1 files changed, 37 insertions, 3 deletions
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index 8faafd92b6e..8a73039f029 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -101,6 +101,10 @@ typedef enum {
UI_WTYPE_PULLDOWN,
UI_WTYPE_MENU_ITEM,
+ /* Same as #UI_WTYPE_MENU_ITEM, but doesn't add padding to sides for text & icon inside the
+ * widget. To be used when multiple menu items should be displayed close to each other
+ * horizontally. */
+ UI_WTYPE_MENU_ITEM_UNPADDED,
UI_WTYPE_MENU_ITEM_RADIAL,
UI_WTYPE_MENU_BACK,
@@ -4090,6 +4094,27 @@ static void widget_menu_itembut(uiWidgetColors *wcol,
widgetbase_draw(&wtb, wcol);
}
+static void widget_menu_itembut_unpadded(uiWidgetColors *wcol,
+ rcti *rect,
+ int UNUSED(state),
+ int UNUSED(roundboxalign),
+ const float zoom)
+{
+ /* This function is used for menu items placed close to each other horizontally, e.g. the matcap
+ * preview popup or the row of collection color icons in the Outliner context menu. Don't use
+ * padding on the sides like the normal menu item. */
+
+ uiWidgetBase wtb;
+ widget_init(&wtb);
+
+ /* No outline. */
+ wtb.draw_outline = false;
+ const float rad = widget_radius_from_zoom(zoom, wcol);
+ round_box_edges(&wtb, UI_CNR_ALL, rect, rad);
+
+ widgetbase_draw(&wtb, wcol);
+}
+
static void widget_menu_radial_itembut(uiBut *but,
uiWidgetColors *wcol,
rcti *rect,
@@ -4495,6 +4520,12 @@ static uiWidgetType *widget_type(uiWidgetTypeEnum type)
wt.state = widget_state_menu_item;
break;
+ case UI_WTYPE_MENU_ITEM_UNPADDED:
+ wt.wcol_theme = &btheme->tui.wcol_menu_item;
+ wt.draw = widget_menu_itembut_unpadded;
+ wt.state = widget_state_menu_item;
+ break;
+
case UI_WTYPE_MENU_BACK:
wt.wcol_theme = &btheme->tui.wcol_menu_back;
wt.draw = widget_menu_back;
@@ -4660,9 +4691,12 @@ void ui_draw_but(const bContext *C, struct ARegion *region, uiStyle *style, uiBu
case UI_BTYPE_SEPR_LINE:
ui_draw_separator(rect, &tui->wcol_menu_item);
break;
- default:
- wt = widget_type(UI_WTYPE_MENU_ITEM);
+ default: {
+ const bool use_unpadded = (but->flag & UI_BUT_ICON_PREVIEW) ||
+ ((but->flag & UI_HAS_ICON) && !but->drawstr[0]);
+ wt = widget_type(use_unpadded ? UI_WTYPE_MENU_ITEM_UNPADDED : UI_WTYPE_MENU_ITEM);
break;
+ }
}
}
else if (ELEM(but->emboss, UI_EMBOSS_NONE, UI_EMBOSS_NONE_OR_STATUS)) {
@@ -5543,7 +5577,7 @@ void ui_draw_preview_item(const uiFontStyle *fstyle,
int state,
eFontStyle_Align text_align)
{
- uiWidgetType *wt = widget_type(UI_WTYPE_MENU_ITEM);
+ uiWidgetType *wt = widget_type(UI_WTYPE_MENU_ITEM_UNPADDED);
/* drawing button background */
wt->state(wt, state, 0, UI_EMBOSS_UNDEFINED);