diff options
author | Julian Eisel <eiseljulian@gmail.com> | 2018-07-06 20:26:12 +0300 |
---|---|---|
committer | Julian Eisel <eiseljulian@gmail.com> | 2018-07-06 20:33:13 +0300 |
commit | 29b8adec61b2c88a07d29b78b26aeca26658a166 (patch) | |
tree | 145479afe7116421b2128ec151dc160b21991528 /source/blender/editors/interface/interface_widgets.c | |
parent | 2a199f5093cf6dc537047f9456adffa52b6aa005 (diff) |
UI: Add extra padding to menus to draw sub-menu triangles in
Shortcut strings would be offset to the left to make space for the triangles,
breaking the alignment with other shortcut strings. Now this alignment is kept
by making menus slightly wider if there's a sub-menu triangle visible, making
room for the triangle.
Diffstat (limited to 'source/blender/editors/interface/interface_widgets.c')
-rw-r--r-- | source/blender/editors/interface/interface_widgets.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index c70b9b72a07..4e15737c3e5 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -1359,7 +1359,7 @@ static void widget_draw_submenu_tria(const uiBut *but, const rcti *rect, const u const float aspect = but->block->aspect / UI_DPI_FAC; const int tria_height = (int)(ICON_DEFAULT_HEIGHT / aspect); const int tria_width = (int)(ICON_DEFAULT_WIDTH / aspect) - 2 * U.pixelsize; - const int xs = rect->xmax - UI_DPI_ICON_SIZE - aspect; + const int xs = rect->xmax - tria_width; const int ys = (rect->ymin + rect->ymax - tria_height) / 2.0f; float col[4]; rctf tria_rect; @@ -2088,6 +2088,7 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB widget_draw_icon(but, icon, alpha, rect); if (show_menu_icon) { + BLI_assert(but->block->content_hints & BLOCK_CONTAINS_SUBMENU_BUT); widget_draw_submenu_tria(but, rect, wcol); } @@ -2096,10 +2097,6 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB #endif rect->xmin += icon_size; - /* without this menu keybindings will overlap the arrow icon [#38083] */ - if (show_menu_icon) { - rect->xmax -= icon_size / 2.0f; - } } if (but->editstr || (but->drawflag & UI_BUT_TEXT_LEFT)) { @@ -2109,6 +2106,12 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB rect->xmax -= (UI_TEXT_MARGIN_X * U.widget_unit) / but->block->aspect; } + /* Menu contains sub-menu items with triangle icon on their right. Shortcut + * strings should be drawn with some padding to the right then. */ + if (ui_block_is_menu(but->block) && (but->block->content_hints & BLOCK_CONTAINS_SUBMENU_BUT)) { + rect->xmax -= UI_MENU_SUBMENU_PADDING; + } + /* extra icons, e.g. 'x' icon to clear text or icon for eyedropper */ if (extra_icon_type != UI_BUT_ICONEXTRA_NONE) { rcti temp = *rect; |