[Bf-blender-cvs] [e185a6afa3e] master: Fix width of compact buttons with icons, e.g. layout.menu().
Alexander Gavrilov
noreply at git.blender.org
Fri May 3 15:49:57 CEST 2019
Commit: e185a6afa3e78f3b28b930e4f00602cfa1824e27
Author: Alexander Gavrilov
Date: Fri May 3 16:15:11 2019 +0300
Branches: master
https://developer.blender.org/rBe185a6afa3e78f3b28b930e4f00602cfa1824e27
Fix width of compact buttons with icons, e.g. layout.menu().
As mentioned in the comment, the icon width computation relies on
big enough margins; however in compact mode they aren't big enough
and the label gets truncated.
===================================================================
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 41001ff6d14..15e507483ad 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -304,10 +304,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 (unit_x / 4)
- * but taking margins into account its fine */
- return (UI_fontstyle_string_width(fstyle, name) +
- (unit_x * ((compact ? 1.25f : 1.50f) + (icon ? 0.25f : 0.0f))));
+ float margin = compact ? 1.25 : 1.50;
+ if (icon) {
+ /* It may seem odd that the icon only adds (unit_x / 4)
+ * but taking margins into account its fine, except
+ * in compact mode a bit more margin is required. */
+ margin += compact ? 0.35 : 0.25;
+ }
+ return UI_fontstyle_string_width(fstyle, name) + (unit_x * margin);
}
else {
return unit_x * 10;
More information about the Bf-blender-cvs
mailing list