diff options
author | Harley Acheson <harley> | 2018-12-27 15:58:02 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-12-27 16:21:49 +0300 |
commit | 4f98266cf6c7c40f1d4de4fb847d3d61644144de (patch) | |
tree | b6b6b43b4dd9c8694607d4f2f7a1954d38ef0cc1 /source | |
parent | e07b58537c05b4370cd0773cc1d63084e4c4a20a (diff) |
UI: fix display of menu buttons without text and icon, and only a down arrow.
Differential Revision: https://developer.blender.org/D4123
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/interface/interface_layout.c | 4 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_widgets.c | 25 |
2 files changed, 18 insertions, 11 deletions
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 87927ef7643..eb1b86559bf 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -285,8 +285,8 @@ static int ui_text_icon_width(uiLayout *layout, const char *name, int icon, bool bool variable; const int unit_x = UI_UNIT_X * (layout->scale[0] ? layout->scale[0] : 1.0f); - if (icon && !name[0]) - return unit_x; /* icon only */ + if (!name[0]) + return unit_x; /* icon only or empty name */ variable = ui_layout_variable_size(layout); diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index a4ab8910c64..47d74660fe3 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -948,16 +948,23 @@ static void widget_draw_vertex_buffer(unsigned int pos, unsigned int col, int mo static void shape_preset_trias_from_rect_menu(uiWidgetTrias *tria, const rcti *rect) { + float width = BLI_rcti_size_x(rect); + float height = BLI_rcti_size_y(rect); float centx, centy, size; - int a; + tria->type = ROUNDBOX_TRIA_MENU; - /* center position and size */ - tria->center[0] = centx = rect->xmax - 0.32f * BLI_rcti_size_y(rect); - tria->center[1] = centy = rect->ymin + 0.50f * BLI_rcti_size_y(rect); - tria->size = size = 0.4f * BLI_rcti_size_y(rect); + /* Center position and size. */ + tria->center[0] = centx = rect->xmin + 0.52f * BLI_rcti_size_y(rect); + tria->center[1] = centy = rect->ymin + 0.52f * BLI_rcti_size_y(rect); + tria->size = size = 0.4f * height; + + if (width > height * 1.1f) { + /* For wider buttons align tighter to the right. */ + tria->center[0] = centx = rect->xmax - 0.32f * height; + } - for (a = 0; a < 6; a++) { + for (int a = 0; a < 6; a++) { tria->vec[a][0] = size * g_shape_preset_menu_arrow_vert[a][0] + centx; tria->vec[a][1] = size * g_shape_preset_menu_arrow_vert[a][1] + centy; } @@ -969,15 +976,15 @@ static void shape_preset_trias_from_rect_menu(uiWidgetTrias *tria, const rcti *r static void shape_preset_trias_from_rect_checkmark(uiWidgetTrias *tria, const rcti *rect) { float centx, centy, size; - int a; + tria->type = ROUNDBOX_TRIA_CHECK; - /* center position and size */ + /* Center position and size. */ tria->center[0] = centx = rect->xmin + 0.5f * BLI_rcti_size_y(rect); tria->center[1] = centy = rect->ymin + 0.5f * BLI_rcti_size_y(rect); tria->size = size = 0.5f * BLI_rcti_size_y(rect); - for (a = 0; a < 6; a++) { + for (int a = 0; a < 6; a++) { tria->vec[a][0] = size * g_shape_preset_checkmark_vert[a][0] + centx; tria->vec[a][1] = size * g_shape_preset_checkmark_vert[a][1] + centy; } |