diff --git a/source/blender/editors/interface/interface_widgets.cc b/source/blender/editors/interface/interface_widgets.cc index 37e5ce652a9..6e12e4d4b28 100644 --- a/source/blender/editors/interface/interface_widgets.cc +++ b/source/blender/editors/interface/interface_widgets.cc @@ -2633,6 +2633,21 @@ static float widget_radius_from_rcti(const rcti *rect, const uiWidgetColors *wco /** \} */ +/* -------------------------------------------------------------------- */ +/** \name Widget Emboss Helper + * + * The emboss is supposed to indicate a shadow under the bottom edge of buttons to help them stand + * out. For multiple vertically aligned buttons it's only meant to display under the buttons in the + * bottom most row. + * \{ */ + +static bool button_is_in_bottom_row(const uiBut *but) +{ + return (but->rect.ymin - but->block->rect.ymin) < U.widget_unit; +} + +/** \} */ + /* -------------------------------------------------------------------- */ /** \name Widget Types * \{ */ @@ -3481,16 +3496,12 @@ static void widget_numbut_draw(const uiBut *but, /* outline */ wtb.draw_inner = false; - const bool horizontal = BLI_rctf_size_x(&but->block->rect) > - BLI_rctf_size_y(&but->block->rect); - wtb.draw_emboss = horizontal || (roundboxalign & (UI_CNR_BOTTOM_LEFT | UI_CNR_BOTTOM_RIGHT)); + wtb.draw_emboss = button_is_in_bottom_row(but); widgetbase_draw(&wtb, wcol); } else { /* inner and outline */ - const bool horizontal = BLI_rctf_size_x(&but->block->rect) > - BLI_rctf_size_y(&but->block->rect); - wtb.draw_emboss = horizontal || (roundboxalign & (UI_CNR_BOTTOM_LEFT | UI_CNR_BOTTOM_RIGHT)); + wtb.draw_emboss = button_is_in_bottom_row(but); widgetbase_draw(&wtb, wcol); } @@ -4408,8 +4419,7 @@ static void widget_box(uiBut *but, const float rad = widget_radius_from_zoom(zoom, wcol); round_box_edges(&wtb, roundboxalign, rect, rad); - const bool horizontal = BLI_rctf_size_x(&but->block->rect) > BLI_rctf_size_y(&but->block->rect); - wtb.draw_emboss = horizontal || (roundboxalign & (UI_CNR_BOTTOM_LEFT | UI_CNR_BOTTOM_RIGHT)); + wtb.draw_emboss = button_is_in_bottom_row(but); widgetbase_draw(&wtb, wcol); copy_v3_v3_uchar(wcol->inner, old_col); @@ -4465,8 +4475,7 @@ static void widget_roundbut_exec(uiBut *but, /* half rounded */ round_box_edges(&wtb, roundboxalign, rect, rad); - const bool horizontal = BLI_rctf_size_x(&but->block->rect) > BLI_rctf_size_y(&but->block->rect); - wtb.draw_emboss = horizontal || (roundboxalign & (UI_CNR_BOTTOM_LEFT | UI_CNR_BOTTOM_RIGHT)); + wtb.draw_emboss = button_is_in_bottom_row(but); widgetbase_draw(&wtb, wcol); }