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.
This commit is contained in:
parent
1006767678
commit
e185a6afa3
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue