[Bf-blender-cvs] [970cf6f7650] blender2.8: UI: use the layouts scale_x to scale icon width

Campbell Barton noreply at git.blender.org
Fri Apr 27 20:03:46 CEST 2018


Commit: 970cf6f76508c459e832a62672a902667d879291
Author: Campbell Barton
Date:   Fri Apr 27 19:57:58 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB970cf6f76508c459e832a62672a902667d879291

UI: use the layouts scale_x to scale icon width

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

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

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

diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index 0163b19d57e..d615bde0f28 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -238,9 +238,10 @@ static int ui_layout_vary_direction(uiLayout *layout)
 static int ui_text_icon_width(uiLayout *layout, const char *name, int icon, bool compact)
 {
 	bool variable;
+	const int unit_x = UI_UNIT_X * (layout->scale[0] ? layout->scale[0] : 1.0f);
 
 	if (icon && !name[0])
-		return UI_UNIT_X;  /* icon only */
+		return unit_x;  /* icon only */
 
 	variable = (ui_layout_vary_direction(layout) == UI_ITEM_VARY_X);
 
@@ -249,14 +250,14 @@ static int ui_text_icon_width(uiLayout *layout, const char *name, int icon, bool
 			layout->item.flag |= UI_ITEM_MIN;
 		}
 		const uiFontStyle *fstyle = UI_FSTYLE_WIDGET;
-		/* it may seem odd that the icon only adds (UI_UNIT_X / 4)
+		/* it may seem odd that the icon only adds (unit_x / 4)
 		 * but taking margins into account its fine */
 		return (UI_fontstyle_string_width(fstyle, name) +
-		        (UI_UNIT_X * ((compact ? 1.25f : 1.50f) +
-		                      (icon    ? 0.25f : 0.0f))));
+		        (unit_x * ((compact ? 1.25f : 1.50f) +
+		                   (icon    ? 0.25f : 0.0f))));
 	}
 	else {
-		return UI_UNIT_X * 10;
+		return unit_x * 10;
 	}
 }



More information about the Bf-blender-cvs mailing list