Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2014-03-12 12:24:47 +0400
committerCampbell Barton <ideasman42@gmail.com>2014-03-12 15:56:10 +0400
commite5e0888a8f024bdc2d3196055762050195bec7a9 (patch)
tree24d5ca5a43fa3e5de2b669c6cc183f72c4d40cd5 /source/blender/editors/interface/interface.c
parenta7faad9aa11c5a8cab4497b7eb8345ce05a09814 (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.c')
-rw-r--r--source/blender/editors/interface/interface.c59
1 files changed, 32 insertions, 27 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index 765a73b7a3b..b8e00022a61 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -3164,33 +3164,36 @@ static uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, const char *s
}
/* use rna values if parameters are not specified */
- if (!str) {
- if (ELEM3(type, MENU, ROW, LISTROW) && proptype == PROP_ENUM) {
- /* MENU is handled a little differently here */
- EnumPropertyItem *item;
- int value;
- bool free;
- int i;
+ if ((proptype == PROP_ENUM) && ELEM3(type, MENU, ROW, LISTROW)) {
+ /* MENU is handled a little differently here */
+ EnumPropertyItem *item;
+ int value;
+ bool free;
+ int i;
- RNA_property_enum_items(block->evil_C, ptr, prop, &item, NULL, &free);
+ RNA_property_enum_items(block->evil_C, ptr, prop, &item, NULL, &free);
- if (type == MENU) {
- value = RNA_property_enum_get(ptr, prop);
- }
- else {
- value = (int)max;
- }
+ if (type == MENU) {
+ value = RNA_property_enum_get(ptr, prop);
+ }
+ else {
+ value = (int)max;
+ }
- i = RNA_enum_from_value(item, value);
- if (i != -1) {
- str = item[i].name;
- icon = item[i].icon;
+ i = RNA_enum_from_value(item, value);
+ if (i != -1) {
+ if (!str) {
+ str = item[i].name;
#ifdef WITH_INTERNATIONAL
str = CTX_IFACE_(RNA_property_translation_context(prop), str);
#endif
}
- else {
+
+ icon = item[i].icon;
+ }
+ else {
+ if (!str) {
if (type == MENU) {
str = "";
}
@@ -3198,19 +3201,21 @@ static uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, const char *s
str = RNA_property_ui_name(prop);
}
}
+ }
- if (type == MENU) {
- func = ui_def_but_rna__menu;
- }
+ if (type == MENU) {
+ func = ui_def_but_rna__menu;
+ }
- if (free) {
- MEM_freeN(item);
- }
+ if (free) {
+ MEM_freeN(item);
}
- else {
+ }
+ else {
+ if (!str) {
str = RNA_property_ui_name(prop);
- icon = RNA_property_ui_icon(prop);
}
+ icon = RNA_property_ui_icon(prop);
}
if (!tip && proptype != PROP_ENUM)