From adff6aeb1c749183921c0facd373972bbeb874b4 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sun, 19 Apr 2009 13:37:59 +0000 Subject: RNA: Generic Type Registration The Python API to define Panels and Operators is based on subclassing, this makes that system more generic, and based on RNA. Hopefully that will make it easy to make various parts of Blender more extensible. * The system simply uses RNA properties and functions and marks them with REGISTER to make them part of the type registration process. Additionally, the struct must provide a register/unregister callback to create/free the PanelType or similar. * From the python side there were some small changes, mainly that registration now goes trough bpy.types.register instead of bpy.ui.addPanel. * Only Panels have been wrapped this way now. Check rna_ui.c to see how this code works. There's still some rough edges and possibilities to make it cleaner, though it works without any manual python code. * Started some docs here: http://wiki.blender.org/index.php/BlenderDev/Blender2.5/RNATypeRegistration * Also changed some RNA_property and RNA_struct functions to not require a PointerRNA anymore, where they were not required (which is actually the cause of most changed files). --- source/blender/editors/interface/interface_regions.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'source/blender/editors/interface/interface_regions.c') diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index 47afd03d051..73fdb7fd83c 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -1861,7 +1861,7 @@ static uiBlock *ui_block_func_MENU_ITEM(bContext *C, uiPopupBlockHandle *handle, else if(item->type==MENU_ITEM_RNA_BOOL) { PropertyRNA *prop= RNA_struct_find_property(&item->rnapoin, item->propname); - if(prop && RNA_property_type(&item->rnapoin, prop) == PROP_BOOLEAN) { + if(prop && RNA_property_type(prop) == PROP_BOOLEAN) { icon= (RNA_property_boolean_get(&item->rnapoin, prop))? ICON_CHECKBOX_HLT: ICON_CHECKBOX_DEHLT; uiDefIconTextButR(block, TOG, 0, icon, NULL, x1, y1, width+16, MENU_BUTTON_HEIGHT-1, &item->rnapoin, item->propname, 0, 0, 0, 0, 0, NULL); } @@ -1876,7 +1876,7 @@ static uiBlock *ui_block_func_MENU_ITEM(bContext *C, uiPopupBlockHandle *handle, else if(item->type==MENU_ITEM_RNA_ENUM) { PropertyRNA *prop= RNA_struct_find_property(&item->rnapoin, item->propname); - if(prop && RNA_property_type(&item->rnapoin, prop) == PROP_ENUM) { + if(prop && RNA_property_type(prop) == PROP_ENUM) { icon= (RNA_property_enum_get(&item->rnapoin, prop) == item->enumval)? ICON_CHECKBOX_HLT: ICON_CHECKBOX_DEHLT; uiDefIconTextButR(block, ROW, 0, icon, NULL, x1, y1, width+16, MENU_BUTTON_HEIGHT-1, &item->rnapoin, item->propname, 0, 0, item->enumval, 0, 0, NULL); } @@ -2074,7 +2074,7 @@ void uiMenuItemsEnumO(uiMenuItem *head, char *opname, char *propname) RNA_pointer_create(NULL, ot->srna, NULL, &ptr); prop= RNA_struct_find_property(&ptr, propname); - if(prop && RNA_property_type(&ptr, prop) == PROP_ENUM) { + if(prop && RNA_property_type(prop) == PROP_ENUM) { const EnumPropertyItem *item; int totitem, i; @@ -2112,7 +2112,7 @@ void uiMenuItemsEnumR(uiMenuItem *head, PointerRNA *ptr, char *propname) prop= RNA_struct_find_property(ptr, propname); - if(prop && RNA_property_type(ptr, prop) == PROP_ENUM) { + if(prop && RNA_property_type(prop) == PROP_ENUM) { const EnumPropertyItem *item; int totitem, i; @@ -2156,7 +2156,7 @@ void uiMenuLevelEnumR(uiMenuItem *head, PointerRNA *ptr, char *propname) item->type = MENU_ITEM_LEVEL_RNA_ENUM; prop= RNA_struct_find_property(ptr, propname); if(prop) - BLI_strncpy(item->name, RNA_property_ui_name(ptr, prop), MAX_MENU_STR); + BLI_strncpy(item->name, RNA_property_ui_name(prop), MAX_MENU_STR); item->rnapoin= *ptr; item->propname= propname; // static! -- cgit v1.2.3