[Bf-blender-cvs] [4f98266cf6c] master: UI: fix display of menu buttons without text and icon, and only a down arrow.

Harley Acheson noreply at git.blender.org
Thu Dec 27 14:25:24 CET 2018


Commit: 4f98266cf6c7c40f1d4de4fb847d3d61644144de
Author: Harley Acheson
Date:   Thu Dec 27 13:58:02 2018 +0100
Branches: master
https://developer.blender.org/rB4f98266cf6c7c40f1d4de4fb847d3d61644144de

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

Differential Revision: https://developer.blender.org/D4123

===================================================================

M	source/blender/editors/interface/interface_layout.c
M	source/blender/editors/interface/interface_widgets.c

===================================================================

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;
 	}



More information about the Bf-blender-cvs mailing list