diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-03-12 12:24:47 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-03-12 15:56:10 +0400 |
commit | e5e0888a8f024bdc2d3196055762050195bec7a9 (patch) | |
tree | 24d5ca5a43fa3e5de2b669c6cc183f72c4d40cd5 /source/blender/editors/interface/interface_layout.c | |
parent | a7faad9aa11c5a8cab4497b7eb8345ce05a09814 (diff) |
UI: allow passing "" for icon only enum buttons and still get an icon
Enum icon-only buttons were getting their strings set,
then truncated with blenders string shortening methods, then not drawn
because there was no room (since buttons are icon width).
Modify UI code so icon-only buttons don't get names and passing "" to a
button won't have its text set later on.
Diffstat (limited to 'source/blender/editors/interface/interface_layout.c')
-rw-r--r-- | source/blender/editors/interface/interface_layout.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index b5255eb0516..0ba47eb534c 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -1178,12 +1178,18 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index if (icon == ICON_NONE) icon = RNA_property_ui_icon(prop); - if (ELEM4(type, PROP_INT, PROP_FLOAT, PROP_STRING, PROP_POINTER)) + if (flag & UI_ITEM_R_ICON_ONLY) { + /* pass */ + } + else if (ELEM4(type, PROP_INT, PROP_FLOAT, PROP_STRING, PROP_POINTER)) { name = ui_item_name_add_colon(name, namestr); - else if (type == PROP_BOOLEAN && is_array && index == RNA_NO_INDEX) + } + else if (type == PROP_BOOLEAN && is_array && index == RNA_NO_INDEX) { name = ui_item_name_add_colon(name, namestr); - else if (type == PROP_ENUM && index != RNA_ENUM_VALUE) + } + else if (type == PROP_ENUM && index != RNA_ENUM_VALUE) { name = ui_item_name_add_colon(name, namestr); + } if (layout->root->type == UI_LAYOUT_MENU) { if (type == PROP_BOOLEAN && ((is_array == false) || (index != RNA_NO_INDEX))) { @@ -1257,6 +1263,12 @@ void uiItemFullR(uiLayout *layout, PointerRNA *ptr, PropertyRNA *prop, int index if (no_bg) uiBlockSetEmboss(block, UI_EMBOSS); + + /* ensure text isn't added to icon_only buttons */ + if (but && icon_only) { + BLI_assert(but->str[0] == '\0'); + } + } void uiItemR(uiLayout *layout, PointerRNA *ptr, const char *propname, int flag, const char *name, int icon) |