UI: fix display of menu buttons without text and icon, and only a down arrow.

Differential Revision: https://developer.blender.org/D4123
This commit is contained in:
Harley Acheson 2018-12-27 13:58:02 +01:00 committed by Brecht Van Lommel
parent e07b58537c
commit 4f98266cf6
2 changed files with 18 additions and 11 deletions

View File

@ -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);

View File

@ -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;
for (a = 0; a < 6; a++) {
if (width > height * 1.1f) {
/* For wider buttons align tighter to the right. */
tria->center[0] = centx = rect->xmax - 0.32f * height;
}
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;
}