diff options
author | Joshua Leung <aligorith@gmail.com> | 2009-10-14 13:08:53 +0400 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2009-10-14 13:08:53 +0400 |
commit | 1ef163f1e0dd1c535c3c9b81670333f02c45b236 (patch) | |
tree | 7712db76cbd30debb515ce4ab70d028197d55b93 /source/blender/editors/interface | |
parent | daebfaaa49186886af5bef2b579baed7c4c6e93f (diff) |
UI Templates: ('Any ID' Selector)
Added new template for choosing to use any type of ID-block. The first combo box allows you to choose the type of ID-block that gets used, and the second box allows you to choose the ID-block of the type specified by the first one.
This is currently used for setting the ID-block used for Keying Sets, but the main user for this was intended to be the Drivers UI. However, I still need to clear up a few button-event issues there before I can port this over.
Additional Bugfixes:
* Adding new Keying Set path was setting the active path wrong, meaning that you had to click on the list to get some response after adding
* Bone Groups list was being drawn too long by default (when empty)
Diffstat (limited to 'source/blender/editors/interface')
-rw-r--r-- | source/blender/editors/interface/interface_templates.c | 47 |
1 files changed, 46 insertions, 1 deletions
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index c092b1ca68b..a7c586be42a 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -152,6 +152,7 @@ static uiBlock *search_menu(bContext *C, ARegion *ar, void *arg_litem) } /************************ ID Template ***************************/ +/* This is for browsing and editing the ID-blocks used */ /* for new/open operators */ void uiIDContextProperty(bContext *C, PointerRNA *ptr, PropertyRNA **prop) @@ -390,7 +391,10 @@ void uiTemplateID(uiLayout *layout, bContext *C, PointerRNA *ptr, char *propname type= RNA_property_pointer_type(ptr, prop); template->idlb= wich_libbase(CTX_data_main(C), RNA_type_to_ID_code(type)); - + + /* create UI elements for this template + * - template_ID makes a copy of the template data and assigns it to the relevant buttons + */ if(template->idlb) { uiLayoutRow(layout, 1); block= uiLayoutGetBlock(layout); @@ -400,6 +404,47 @@ void uiTemplateID(uiLayout *layout, bContext *C, PointerRNA *ptr, char *propname MEM_freeN(template); } +/************************ ID Chooser Template ***************************/ +/* This is for selecting the type of ID-block to use, and then from the relevant type choosing the block to use */ + +/* - propname: property identifier for property that ID-pointer gets stored to + * - proptypename: property identifier for property used to determine the type of ID-pointer that can be used + */ +void uiTemplateAnyID(uiLayout *layout, bContext *C, PointerRNA *ptr, char *propname, char *proptypename, char *text) +{ + PropertyRNA *propID, *propType; + uiLayout *row; + + /* get properties... */ + propID= RNA_struct_find_property(ptr, propname); + propType= RNA_struct_find_property(ptr, proptypename); + + if (!propID || RNA_property_type(propID) != PROP_POINTER) { + printf("uiTemplateAnyID: pointer property not found: %s\n", propname); + return; + } + if (!propType || RNA_property_type(propType) != PROP_ENUM) { + printf("uiTemplateAnyID: pointer-type property not found: %s\n", proptypename); + return; + } + + /* Start drawing UI Elements using standard defines */ + row= uiLayoutRow(layout, 1); + + /* Label - either use the provided text, or will become "ID-Block:" */ + if (text) + uiItemL(row, text, 0); + else + uiItemL(row, "ID-Block:", 0); + + /* ID-Type Selector - just have a menu of icons */ + // XXX should value really be 0? + uiItemFullR(row, "", 0, ptr, propType, 0, 0, UI_ITEM_R_ICON_ONLY); + + /* ID-Block Selector - just use pointer widget... */ + uiItemFullR(row, "", 0, ptr, propID, 0, 0, 0); +} + /************************ Modifier Template *************************/ #define ERROR_LIBDATA_MESSAGE "Can't edit external libdata" |