diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2015-05-24 16:49:04 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2015-05-24 16:49:04 +0300 |
commit | 7456f060979be49937fa2cfc0b939d796cddc536 (patch) | |
tree | 80508517fea9ba2967fc6eb817b864695215441c /source/blender | |
parent | 4737722968e09ec9e693bd80091623d486b7e357 (diff) |
Fix unreported bug with recent enum icon preview changes, would show bad in case of mixing
items with and without label.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/interface/interface_widgets.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 9860c1b70ad..de774178b3d 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -1521,13 +1521,18 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB /* Big previews with optional text label below */ if (but->flag & UI_BUT_ICON_PREVIEW && ui_block_is_menu(but->block)) { const BIFIconID icon = (but->flag & UI_HAS_ICON) ? but->icon + but->iconadd : ICON_NONE; - const float icon_size = 0.8f * BLI_rcti_size_y(rect); - float text_size; + const int icon_size_i = BLI_rcti_size_y(rect); + float icon_size, text_size; - if(but->drawstr[0] != '\0') - text_size = 0.2f * BLI_rcti_size_y(rect); - else + /* This is a bit britle, but avoids adding an 'UI_BUT_HAS_LABEL' flag to but... */ + if(icon_size_i > (float)BLI_rcti_size_x(rect)) { + icon_size = 0.8f * (float)icon_size_i; + text_size = 0.2f * (float)icon_size_i; + } + else { + icon_size = (float)icon_size_i; text_size = 0.0f; + } /* draw icon in rect above the space reserved for the label */ rect->ymin += text_size; |