diff options
author | Alexander Gavrilov <angavrilov@gmail.com> | 2019-05-03 16:15:11 +0300 |
---|---|---|
committer | Alexander Gavrilov <angavrilov@gmail.com> | 2019-05-03 16:49:30 +0300 |
commit | e185a6afa3e78f3b28b930e4f00602cfa1824e27 (patch) | |
tree | fd1eb31bbad91827a3bd7c6babec27bcf1118308 /source | |
parent | 1006767678eb940c161e538c09b86404f7f1b5ca (diff) |
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.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/interface/interface_layout.c | 12 |
1 files changed, 8 insertions, 4 deletions
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; |