[Bf-blender-cvs] [5b8b3f3] ui-preview-buttons: Fix broken uiTemplateIconView().
Bastien Montagne
noreply at git.blender.org
Wed Apr 22 22:53:44 CEST 2015
Commit: 5b8b3f31de650a16cde82dec4bf652786707f80c
Author: Bastien Montagne
Date: Wed Apr 22 22:40:19 2015 +0200
Branches: ui-preview-buttons
https://developer.blender.org/rB5b8b3f31de650a16cde82dec4bf652786707f80c
Fix broken uiTemplateIconView().
Was using enum **value** as **icon id**... tripple sigh!
Guess it was working for its only current use (matcaps), but still.
===================================================================
M source/blender/editors/interface/interface_templates.c
===================================================================
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c
index c3a9d17..7bd378a 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -1677,16 +1677,22 @@ void uiTemplateIconView(uiLayout *layout, PointerRNA *ptr, const char *propname)
{
PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
RNAUpdateCb *cb;
+ EnumPropertyItem *items;
uiBlock *block;
uiBut *but;
// rctf rect; /* UNUSED */
- int icon;
+ int value, icon = ICON_NONE, tot_items;
+ bool free_items;
if (!prop || RNA_property_type(prop) != PROP_ENUM)
return;
-
- icon = RNA_property_enum_get(ptr, prop);
-
+
+ block = uiLayoutAbsoluteBlock(layout);
+
+ RNA_property_enum_items(block->evil_C, ptr, prop, &items, &tot_items, &free_items);
+ value = RNA_property_enum_get(ptr, prop);
+ RNA_enum_icon_from_value(items, value, &icon);
+
cb = MEM_callocN(sizeof(RNAUpdateCb), "RNAUpdateCb");
cb->ptr = *ptr;
cb->prop = prop;
@@ -1694,8 +1700,6 @@ void uiTemplateIconView(uiLayout *layout, PointerRNA *ptr, const char *propname)
// rect.xmin = 0; rect.xmax = 10.0f * UI_UNIT_X;
// rect.ymin = 0; rect.ymax = 10.0f * UI_UNIT_X;
- block = uiLayoutAbsoluteBlock(layout);
-
but = uiDefBlockButN(block, ui_icon_view_menu_cb, MEM_dupallocN(cb), "", 0, 0, UI_UNIT_X * 6, UI_UNIT_Y * 6, "");
@@ -1707,6 +1711,9 @@ void uiTemplateIconView(uiLayout *layout, PointerRNA *ptr, const char *propname)
UI_but_funcN_set(but, rna_update_cb, MEM_dupallocN(cb), NULL);
MEM_freeN(cb);
+ if (free_items) {
+ MEM_freeN(items);
+ }
}
/********************* Histogram Template ************************/
More information about the Bf-blender-cvs
mailing list