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:11:09 +0400
committerCampbell Barton <ideasman42@gmail.com>2014-03-12 15:54:26 +0400
commita7faad9aa11c5a8cab4497b7eb8345ce05a09814 (patch)
tree2dcc444de5dc2077e03851e9c11cf185c3fa49e5 /source/blender/editors/interface/interface.c
parent2cbbaea44e1689230a8d2632dfd538642e0eee05 (diff)
Code cleanup: UI - de-duplicate menu/row/listrow enum logic
Diffstat (limited to 'source/blender/editors/interface/interface.c')
-rw-r--r--source/blender/editors/interface/interface.c58
1 files changed, 27 insertions, 31 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index 8751741a58a..765a73b7a3b 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -3165,52 +3165,46 @@ 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 (type == MENU && proptype == PROP_ENUM) {
+ if (ELEM3(type, MENU, ROW, LISTROW) && proptype == PROP_ENUM) {
+ /* MENU is handled a little differently here */
EnumPropertyItem *item;
- int totitem, value;
+ int value;
bool free;
int i;
- RNA_property_enum_items(block->evil_C, ptr, prop, &item, &totitem, &free);
- value = RNA_property_enum_get(ptr, prop);
- i = RNA_enum_from_value(item, value);
- if (i != -1) {
- str = item[i].name;
- icon = item[i].icon;
+ RNA_property_enum_items(block->evil_C, ptr, prop, &item, NULL, &free);
+
+ if (type == MENU) {
+ value = RNA_property_enum_get(ptr, prop);
}
else {
- str = "";
+ value = (int)max;
}
- if (free) {
- MEM_freeN(item);
- }
+ i = RNA_enum_from_value(item, value);
+ if (i != -1) {
+ str = item[i].name;
+ icon = item[i].icon;
#ifdef WITH_INTERNATIONAL
- str = CTX_IFACE_(RNA_property_translation_context(prop), str);
+ str = CTX_IFACE_(RNA_property_translation_context(prop), str);
#endif
-
- func = ui_def_but_rna__menu;
- }
- else if (ELEM(type, ROW, LISTROW) && proptype == PROP_ENUM) {
- EnumPropertyItem *item, *item_array = NULL;
- bool free;
-
- /* get untranslated, then translate the single string we need */
- RNA_property_enum_items(block->evil_C, ptr, prop, &item_array, NULL, &free);
- for (item = item_array; item->identifier; item++) {
- if (item->identifier[0] && item->value == (int)max) {
- str = CTX_IFACE_(RNA_property_translation_context(prop), item->name);
- icon = item->icon;
- break;
+ }
+ else {
+ if (type == MENU) {
+ str = "";
+ }
+ else {
+ str = RNA_property_ui_name(prop);
}
}
- if (!str) {
- str = RNA_property_ui_name(prop);
+ if (type == MENU) {
+ func = ui_def_but_rna__menu;
}
+
if (free) {
- MEM_freeN(item_array);
+ MEM_freeN(item);
}
}
else {
@@ -3275,7 +3269,9 @@ static uiBut *ui_def_but_rna(uiBlock *block, int type, int retval, const char *s
if (icon) {
but->icon = (BIFIconID)icon;
but->flag |= UI_HAS_ICON;
- but->drawflag |= UI_BUT_ICON_LEFT;
+ if (str[0]) {
+ but->drawflag |= UI_BUT_ICON_LEFT;
+ }
}
if ((type == MENU) && (but->dt == UI_EMBOSSP)) {