diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-08-19 14:16:30 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-08-19 14:16:30 +0400 |
commit | 4e3390437ea9a632339b47d3a99866b6c98f74af (patch) | |
tree | 21297caa5f67dcb0f52a79420019804a1d2be8dc /source/blender/makesrna/intern | |
parent | 98140e234e6d88dc301a3d8663ef54b56520020f (diff) |
- Properties from base classes are now registered too, this allows class mix-in's to define properties.
An example of how this is useful - an importer mixin could define the filepath properties and a generic invoke function which can run the subclasses exec for each selected file.
- Panels and Menus now skip the property check when registering.
- renamed _idproperties_ to _idprops_ in function names, function names were getting very long.
Diffstat (limited to 'source/blender/makesrna/intern')
-rw-r--r-- | source/blender/makesrna/intern/rna_ID.c | 8 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_access.c | 37 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_armature.c | 8 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_define.c | 4 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_internal.h | 4 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_pose.c | 4 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_rna.c | 4 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_ui.c | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_wm.c | 4 |
9 files changed, 41 insertions, 34 deletions
diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c index e0bfb9bd03d..a8b7fb1540b 100644 --- a/source/blender/makesrna/intern/rna_ID.c +++ b/source/blender/makesrna/intern/rna_ID.c @@ -176,7 +176,7 @@ StructRNA *rna_ID_refine(PointerRNA *ptr) return ID_code_to_RNA_type(GS(id->name)); } -IDProperty *rna_ID_idproperties(PointerRNA *ptr, int create) +IDProperty *rna_ID_idprops(PointerRNA *ptr, int create) { return IDP_GetProperties(ptr->data, create); } @@ -195,7 +195,7 @@ void rna_ID_fake_user_set(PointerRNA *ptr, int value) } } -IDProperty *rna_IDPropertyGroup_idproperties(PointerRNA *ptr, int create) +IDProperty *rna_IDPropertyGroup_idprops(PointerRNA *ptr, int create) { return ptr->data; } @@ -317,7 +317,7 @@ static void rna_def_ID_properties(BlenderRNA *brna) * care of the properties here */ srna= RNA_def_struct(brna, "IDPropertyGroup", NULL); RNA_def_struct_ui_text(srna, "ID Property Group", "Group of ID properties"); - RNA_def_struct_idproperties_func(srna, "rna_IDPropertyGroup_idproperties"); + RNA_def_struct_idprops_func(srna, "rna_IDPropertyGroup_idprops"); RNA_def_struct_register_funcs(srna, "rna_IDPropertyGroup_register", "rna_IDPropertyGroup_unregister"); RNA_def_struct_refine_func(srna, "rna_IDPropertyGroup_refine"); @@ -341,7 +341,7 @@ static void rna_def_ID(BlenderRNA *brna) RNA_def_struct_ui_text(srna, "ID", "Base type for datablocks, defining a unique name, linking from other libraries and garbage collection"); RNA_def_struct_flag(srna, STRUCT_ID|STRUCT_ID_REFCOUNT); RNA_def_struct_refine_func(srna, "rna_ID_refine"); - RNA_def_struct_idproperties_func(srna, "rna_ID_idproperties"); + RNA_def_struct_idprops_func(srna, "rna_ID_idprops"); prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); RNA_def_property_ui_text(prop, "Name", "Unique datablock ID name"); diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 050f00b6a38..73af75ca960 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -241,7 +241,7 @@ IDProperty *rna_idproperty_ui(PropertyRNA *prop) return NULL; } -IDProperty *RNA_struct_idproperties(PointerRNA *ptr, int create) +IDProperty *RNA_struct_idprops(PointerRNA *ptr, int create) { StructRNA *type= ptr->type; @@ -251,14 +251,14 @@ IDProperty *RNA_struct_idproperties(PointerRNA *ptr, int create) return NULL; } -int RNA_struct_idproperties_check(StructRNA *srna) +int RNA_struct_idprops_check(StructRNA *srna) { return (srna && srna->idproperties) ? 1 : 0; } static IDProperty *rna_idproperty_find(PointerRNA *ptr, const char *name) { - IDProperty *group= RNA_struct_idproperties(ptr, 0); + IDProperty *group= RNA_struct_idprops(ptr, 0); if(group) return IDP_GetPropertyFromGroup(group, name); @@ -387,7 +387,7 @@ IDProperty *rna_idproperty_check(PropertyRNA **prop, PointerRNA *ptr) IDProperty *idprop= rna_idproperty_find(ptr, (*prop)->identifier); if(idprop && !rna_idproperty_verify_valid(ptr, *prop, idprop)) { - IDProperty *group= RNA_struct_idproperties(ptr, 0); + IDProperty *group= RNA_struct_idprops(ptr, 0); IDP_RemFromGroup(group, idprop); IDP_FreeProperty(idprop); @@ -510,6 +510,11 @@ int RNA_struct_is_ID(StructRNA *type) return (type->flag & STRUCT_ID) != 0; } +int RNA_struct_idprops_register_check(StructRNA *type) +{ + return (type->flag & STRUCT_NO_IDPROPERTIES) == 0; +} + int RNA_struct_is_a(StructRNA *type, StructRNA *srna) { StructRNA *base; @@ -1305,7 +1310,7 @@ void RNA_property_boolean_set(PointerRNA *ptr, PropertyRNA *prop, int value) val.i= value; - group= RNA_struct_idproperties(ptr, 1); + group= RNA_struct_idprops(ptr, 1); if(group) IDP_AddToGroup(group, IDP_New(IDP_INT, val, (char*)prop->identifier)); } @@ -1375,7 +1380,7 @@ void RNA_property_boolean_set_array(PointerRNA *ptr, PropertyRNA *prop, const in val.array.len= prop->totarraylength; val.array.type= IDP_INT; - group= RNA_struct_idproperties(ptr, 1); + group= RNA_struct_idprops(ptr, 1); if(group) { idprop= IDP_New(IDP_ARRAY, val, (char*)prop->identifier); IDP_AddToGroup(group, idprop); @@ -1472,7 +1477,7 @@ void RNA_property_int_set(PointerRNA *ptr, PropertyRNA *prop, int value) val.i= value; - group= RNA_struct_idproperties(ptr, 1); + group= RNA_struct_idprops(ptr, 1); if(group) IDP_AddToGroup(group, IDP_New(IDP_INT, val, (char*)prop->identifier)); } @@ -1542,7 +1547,7 @@ void RNA_property_int_set_array(PointerRNA *ptr, PropertyRNA *prop, const int *v val.array.len= prop->totarraylength; val.array.type= IDP_INT; - group= RNA_struct_idproperties(ptr, 1); + group= RNA_struct_idprops(ptr, 1); if(group) { idprop= IDP_New(IDP_ARRAY, val, (char*)prop->identifier); IDP_AddToGroup(group, idprop); @@ -1648,7 +1653,7 @@ void RNA_property_float_set(PointerRNA *ptr, PropertyRNA *prop, float value) val.f= value; - group= RNA_struct_idproperties(ptr, 1); + group= RNA_struct_idprops(ptr, 1); if(group) IDP_AddToGroup(group, IDP_New(IDP_FLOAT, val, (char*)prop->identifier)); } @@ -1736,7 +1741,7 @@ void RNA_property_float_set_array(PointerRNA *ptr, PropertyRNA *prop, const floa val.array.len= prop->totarraylength; val.array.type= IDP_FLOAT; - group= RNA_struct_idproperties(ptr, 1); + group= RNA_struct_idprops(ptr, 1); if(group) { idprop= IDP_New(IDP_ARRAY, val, (char*)prop->identifier); IDP_AddToGroup(group, idprop); @@ -1861,7 +1866,7 @@ void RNA_property_string_set(PointerRNA *ptr, PropertyRNA *prop, const char *val else if(prop->flag & PROP_EDITABLE) { IDProperty *group; - group= RNA_struct_idproperties(ptr, 1); + group= RNA_struct_idprops(ptr, 1); if(group) IDP_AddToGroup(group, IDP_NewString((char*)value, (char*)prop->identifier, RNA_property_string_maxlength(prop) - 1)); } @@ -1926,7 +1931,7 @@ void RNA_property_enum_set(PointerRNA *ptr, PropertyRNA *prop, int value) val.i= value; - group= RNA_struct_idproperties(ptr, 1); + group= RNA_struct_idprops(ptr, 1); if(group) IDP_AddToGroup(group, IDP_New(IDP_INT, val, (char*)prop->identifier)); } @@ -1999,7 +2004,7 @@ void RNA_property_pointer_add(PointerRNA *ptr, PropertyRNA *prop) val.i= 0; - group= RNA_struct_idproperties(ptr, 1); + group= RNA_struct_idprops(ptr, 1); if(group) IDP_AddToGroup(group, IDP_New(IDP_GROUP, val, (char*)prop->identifier)); } @@ -2012,7 +2017,7 @@ void RNA_property_pointer_remove(PointerRNA *ptr, PropertyRNA *prop) IDProperty *idprop, *group; if((idprop=rna_idproperty_check(&prop, ptr))) { - group= RNA_struct_idproperties(ptr, 0); + group= RNA_struct_idprops(ptr, 0); if(group) { IDP_RemFromGroup(group, idprop); @@ -2125,7 +2130,7 @@ void RNA_property_collection_add(PointerRNA *ptr, PropertyRNA *prop, PointerRNA IDProperty *group, *item; IDPropertyTemplate val = {0}; - group= RNA_struct_idproperties(ptr, 1); + group= RNA_struct_idprops(ptr, 1); if(group) { idprop= IDP_NewIDPArray(prop->identifier); IDP_AddToGroup(group, idprop); @@ -2965,7 +2970,7 @@ int RNA_path_resolve_full(PointerRNA *ptr, const char *path, PointerRNA *r_ptr, return 0; if(use_id_prop) { /* look up property name in current struct */ - IDProperty *group= RNA_struct_idproperties(&curptr, 0); + IDProperty *group= RNA_struct_idprops(&curptr, 0); if(group && rna_token_strip_quotes(token)) prop= (PropertyRNA *)IDP_GetPropertyFromGroup(group, token+1); } diff --git a/source/blender/makesrna/intern/rna_armature.c b/source/blender/makesrna/intern/rna_armature.c index 3217e73e3fb..a2f75a63163 100644 --- a/source/blender/makesrna/intern/rna_armature.c +++ b/source/blender/makesrna/intern/rna_armature.c @@ -123,7 +123,7 @@ static char *rna_Bone_path(PointerRNA *ptr) return BLI_sprintfN("bones[\"%s\"]", ((Bone*)ptr->data)->name); } -static IDProperty *rna_Bone_idproperties(PointerRNA *ptr, int create) +static IDProperty *rna_Bone_idprops(PointerRNA *ptr, int create) { Bone *bone= ptr->data; @@ -135,7 +135,7 @@ static IDProperty *rna_Bone_idproperties(PointerRNA *ptr, int create) return bone->prop; } -static IDProperty *rna_EditBone_idproperties(PointerRNA *ptr, int create) +static IDProperty *rna_EditBone_idprops(PointerRNA *ptr, int create) { EditBone *ebone= ptr->data; @@ -504,7 +504,7 @@ static void rna_def_bone(BlenderRNA *brna) RNA_def_struct_ui_text(srna, "Bone", "Bone in an Armature datablock"); RNA_def_struct_ui_icon(srna, ICON_BONE_DATA); RNA_def_struct_path_func(srna, "rna_Bone_path"); - RNA_def_struct_idproperties_func(srna, "rna_Bone_idproperties"); + RNA_def_struct_idprops_func(srna, "rna_Bone_idprops"); /* pointers/collections */ /* parent (pointer) */ @@ -572,7 +572,7 @@ static void rna_def_edit_bone(BlenderRNA *brna) srna= RNA_def_struct(brna, "EditBone", NULL); RNA_def_struct_sdna(srna, "EditBone"); - RNA_def_struct_idproperties_func(srna, "rna_EditBone_idproperties"); + RNA_def_struct_idprops_func(srna, "rna_EditBone_idprops"); RNA_def_struct_ui_text(srna, "Edit Bone", "Editmode bone in an Armature datablock"); RNA_def_struct_ui_icon(srna, ICON_BONE_DATA); diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c index 6080d02a1c7..43bf40d3965 100644 --- a/source/blender/makesrna/intern/rna_define.c +++ b/source/blender/makesrna/intern/rna_define.c @@ -781,10 +781,10 @@ void RNA_def_struct_refine_func(StructRNA *srna, const char *refine) if(refine) srna->refine= (StructRefineFunc)refine; } -void RNA_def_struct_idproperties_func(StructRNA *srna, const char *idproperties) +void RNA_def_struct_idprops_func(StructRNA *srna, const char *idproperties) { if(!DefRNA.preprocess) { - fprintf(stderr, "RNA_def_struct_idproperties_func: only during preprocessing.\n"); + fprintf(stderr, "RNA_def_struct_idprops_func: only during preprocessing.\n"); return; } diff --git a/source/blender/makesrna/intern/rna_internal.h b/source/blender/makesrna/intern/rna_internal.h index 1a7036c7a36..669fc5d3871 100644 --- a/source/blender/makesrna/intern/rna_internal.h +++ b/source/blender/makesrna/intern/rna_internal.h @@ -189,9 +189,9 @@ void rna_ID_name_get(struct PointerRNA *ptr, char *value); int rna_ID_name_length(struct PointerRNA *ptr); void rna_ID_name_set(struct PointerRNA *ptr, const char *value); struct StructRNA *rna_ID_refine(struct PointerRNA *ptr); -struct IDProperty *rna_ID_idproperties(struct PointerRNA *ptr, int create); +struct IDProperty *rna_ID_idprops(struct PointerRNA *ptr, int create); void rna_ID_fake_user_set(struct PointerRNA *ptr, int value); -struct IDProperty *rna_IDPropertyGroup_idproperties(struct PointerRNA *ptr, int create); +struct IDProperty *rna_IDPropertyGroup_idprops(struct PointerRNA *ptr, int create); void rna_IDPropertyGroup_unregister(const struct bContext *C, struct StructRNA *type); struct StructRNA *rna_IDPropertyGroup_register(const struct bContext *C, struct ReportList *reports, void *data, const char *identifier, StructValidateFunc validate, StructCallbackFunc call, StructFreeFunc free); struct StructRNA* rna_IDPropertyGroup_refine(struct PointerRNA *ptr); diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c index 41adaa7047c..18d0b5658d0 100644 --- a/source/blender/makesrna/intern/rna_pose.c +++ b/source/blender/makesrna/intern/rna_pose.c @@ -120,7 +120,7 @@ static void rna_BoneGroup_color_set_set(PointerRNA *ptr, int value) } } -static IDProperty *rna_PoseBone_idproperties(PointerRNA *ptr, int create) +static IDProperty *rna_PoseBone_idprops(PointerRNA *ptr, int create) { bPoseChannel *pchan= ptr->data; @@ -685,7 +685,7 @@ static void rna_def_pose_channel(BlenderRNA *brna) RNA_def_struct_sdna(srna, "bPoseChannel"); RNA_def_struct_ui_text(srna, "Pose Bone", "Channel defining pose data for a bone in a Pose"); RNA_def_struct_path_func(srna, "rna_PoseBone_path"); - RNA_def_struct_idproperties_func(srna, "rna_PoseBone_idproperties"); + RNA_def_struct_idprops_func(srna, "rna_PoseBone_idprops"); /* Bone Constraints */ prop= RNA_def_property(srna, "constraints", PROP_COLLECTION, PROP_NONE); diff --git a/source/blender/makesrna/intern/rna_rna.c b/source/blender/makesrna/intern/rna_rna.c index 5c8de9c4587..4bfd0e4fd41 100644 --- a/source/blender/makesrna/intern/rna_rna.c +++ b/source/blender/makesrna/intern/rna_rna.c @@ -201,7 +201,7 @@ static void rna_Struct_properties_next(CollectionPropertyIterator *iter) /* try id properties */ if(!iter->valid) { - group= RNA_struct_idproperties(&iter->builtin_parent, 0); + group= RNA_struct_idprops(&iter->builtin_parent, 0); if(group) { rna_iterator_listbase_end(iter); @@ -335,7 +335,7 @@ PointerRNA rna_builtin_properties_lookup_string(PointerRNA *ptr, const char *key if(ptr->data) { IDProperty *group, *idp; - group= RNA_struct_idproperties(ptr, 0); + group= RNA_struct_idprops(ptr, 0); if(group) { for(idp=group->data.group.first; idp; idp=idp->next) { diff --git a/source/blender/makesrna/intern/rna_ui.c b/source/blender/makesrna/intern/rna_ui.c index a9b2672e205..a659ff7c260 100644 --- a/source/blender/makesrna/intern/rna_ui.c +++ b/source/blender/makesrna/intern/rna_ui.c @@ -207,6 +207,7 @@ static StructRNA *rna_Panel_register(const bContext *C, ReportList *reports, voi pt->ext.call= call; pt->ext.free= free; RNA_struct_blender_type_set(pt->ext.srna, pt); + RNA_def_struct_flag(pt->ext.srna, STRUCT_NO_IDPROPERTIES); pt->poll= (have_function[0])? panel_poll: NULL; pt->draw= (have_function[1])? panel_draw: NULL; @@ -418,6 +419,7 @@ static StructRNA *rna_Menu_register(const bContext *C, ReportList *reports, void mt->ext.call= call; mt->ext.free= free; RNA_struct_blender_type_set(mt->ext.srna, mt); + RNA_def_struct_flag(mt->ext.srna, STRUCT_NO_IDPROPERTIES); mt->poll= (have_function[0])? menu_poll: NULL; mt->draw= (have_function[1])? menu_draw: NULL; diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c index 188eda32463..67b8ca057c8 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -324,7 +324,7 @@ static StructRNA *rna_OperatorProperties_refine(PointerRNA *ptr) return ptr->type; } -static IDProperty *rna_OperatorProperties_idproperties(PointerRNA *ptr, int create) +static IDProperty *rna_OperatorProperties_idprops(PointerRNA *ptr, int create) { if(create && !ptr->data) { IDPropertyTemplate val = {0}; @@ -1023,7 +1023,7 @@ static void rna_def_operator(BlenderRNA *brna) srna= RNA_def_struct(brna, "OperatorProperties", NULL); RNA_def_struct_ui_text(srna, "Operator Properties", "Input properties of an Operator"); RNA_def_struct_refine_func(srna, "rna_OperatorProperties_refine"); - RNA_def_struct_idproperties_func(srna, "rna_OperatorProperties_idproperties"); + RNA_def_struct_idprops_func(srna, "rna_OperatorProperties_idprops"); } static void rna_def_macro_operator(BlenderRNA *brna) |