diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-03-24 15:36:12 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-03-24 15:36:12 +0300 |
commit | 422f1674bb84e8f96629e8c70e90339696af68fb (patch) | |
tree | d853dbf20681c11845cb00eda1029b6e4694c402 | |
parent | da4023b6554b237fe04debf05000bba37408ad3e (diff) |
fix for using uiItemIntO for an enum, added uiItemEnumO_value function.
-rw-r--r-- | source/blender/editors/animation/keyingsets.c | 2 | ||||
-rw-r--r-- | source/blender/editors/include/UI_interface.h | 1 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_layout.c | 27 |
3 files changed, 29 insertions, 1 deletions
diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c index 324e9e39fc4..04565b4c236 100644 --- a/source/blender/editors/animation/keyingsets.c +++ b/source/blender/editors/animation/keyingsets.c @@ -795,7 +795,7 @@ void ANIM_keying_sets_menu_setup (bContext *C, const char title[], const char op for (ks= builtin_keyingsets.first; ks; ks= ks->next) { /* only show KeyingSet if context is suitable */ if (ANIM_keyingset_context_ok_poll(C, ks)) - uiItemIntO(layout, ks->name, ICON_NONE, op_name, "type", i--); + uiItemEnumO_value(layout, ks->name, ICON_NONE, op_name, "type", i--); } uiPupMenuEnd(C, pup); diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index e938192c5aa..e0f34410673 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -720,6 +720,7 @@ void uiTemplateList(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr /* items */ void uiItemO(uiLayout *layout, const char *name, int icon, const char *opname); void uiItemEnumO(uiLayout *layout, const char *opname, const char *name, int icon, const char *propname, int value); +void uiItemEnumO_value(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, int value); void uiItemEnumO_string(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, const char *value); void uiItemsEnumO(uiLayout *layout, const char *opname, const char *propname); void uiItemBooleanO(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, int value); diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 1e94824a9f9..c94c3a7813a 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -781,6 +781,33 @@ void uiItemsEnumO(uiLayout *layout, const char *opname, const char *propname) } /* for use in cases where we have */ +void uiItemEnumO_value(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, int value) +{ + PointerRNA ptr; + + /* for getting the enum */ + PropertyRNA *prop; + + WM_operator_properties_create(&ptr, opname); + + /* enum lookup */ + if((prop= RNA_struct_find_property(&ptr, propname))) { + /* pass */ + } + else { + printf("uiItemEnumO_value: %s.%s not found.\n", RNA_struct_identifier(ptr.type), propname); + return; + } + + RNA_property_enum_set(&ptr, prop, value); + + /* same as uiItemEnumO */ + if(!name) + name= ui_menu_enumpropname(layout, opname, propname, value); + + uiItemFullO(layout, opname, name, icon, ptr.data, layout->root->opcontext, 0); +} + void uiItemEnumO_string(uiLayout *layout, const char *name, int icon, const char *opname, const char *propname, const char *value_str) { PointerRNA ptr; |