From 344449e483fa943ae3eb5acb446dd45ca1cfaca2 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Sat, 11 Apr 2009 01:43:50 +0000 Subject: RNA: * Added REQUIRED flag for function parameters. * Made dupliframes/verts/faces/groups an enum, and make it editable. * Enum bitflags were broken, fixed. --- source/blender/makesrna/RNA_access.h | 1 + source/blender/makesrna/RNA_types.h | 3 +++ source/blender/makesrna/intern/Makefile | 2 +- source/blender/makesrna/intern/rna_ID.c | 3 ++- source/blender/makesrna/intern/rna_access.c | 7 ++++++ source/blender/makesrna/intern/rna_define.c | 2 +- source/blender/makesrna/intern/rna_object.c | 38 ++++++++++++++--------------- 7 files changed, 34 insertions(+), 22 deletions(-) (limited to 'source') diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index df9671d0167..2ffc68a0ba1 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -348,6 +348,7 @@ const struct ListBase *RNA_struct_defined_functions(StructRNA *srna); const char *RNA_property_identifier(PointerRNA *ptr, PropertyRNA *prop); PropertyType RNA_property_type(PointerRNA *ptr, PropertyRNA *prop); PropertySubType RNA_property_subtype(PointerRNA *ptr, PropertyRNA *prop); +int RNA_property_flag(PointerRNA *ptr, PropertyRNA *prop); int RNA_property_array_length(PointerRNA *ptr, PropertyRNA *prop); diff --git a/source/blender/makesrna/RNA_types.h b/source/blender/makesrna/RNA_types.h index 4ea97041f83..2020ca1edb8 100644 --- a/source/blender/makesrna/RNA_types.h +++ b/source/blender/makesrna/RNA_types.h @@ -89,6 +89,9 @@ typedef enum PropertyFlag { * and collections */ PROP_ANIMATEABLE = 2, + /* function paramater flags */ + PROP_REQUIRED = 4, + /* internal flags */ PROP_BUILTIN = 128, PROP_EXPORT = 256, diff --git a/source/blender/makesrna/intern/Makefile b/source/blender/makesrna/intern/Makefile index f5df20fcc9f..241067692ff 100644 --- a/source/blender/makesrna/intern/Makefile +++ b/source/blender/makesrna/intern/Makefile @@ -77,7 +77,7 @@ clean:: # we want the .o's to be in the makesrna/ directory, but the # .c's are in the editors/*/ directories -$(DIR)/$(DEBUG_DIR)%_api.o: ../../editors/interface/*_api.c +$(DIR)/$(DEBUG_DIR)%_api.o: ../../editors/interface/%_api.c ifdef NAN_DEPEND @set -e; $(CC) -M $(CPPFLAGS) $< 2>/dev/null \ | sed 's@\($*\)\.o[ :]*@$(DIR)/$(DEBUG_DIR)\1.o : @g' \ diff --git a/source/blender/makesrna/intern/rna_ID.c b/source/blender/makesrna/intern/rna_ID.c index cdae8d78ffe..3146c20a715 100644 --- a/source/blender/makesrna/intern/rna_ID.c +++ b/source/blender/makesrna/intern/rna_ID.c @@ -198,7 +198,8 @@ static void rna_def_ID(BlenderRNA *brna) /* XXX temporary for testing */ func= RNA_def_function(srna, "rename", "rename_id"); RNA_def_function_ui_description(func, "Rename this ID datablock."); - RNA_def_string(func, "name", "", 0, "", "New name for the datablock."); + prop= RNA_def_string(func, "name", "", 0, "", "New name for the datablock."); + RNA_def_property_flag(prop, PROP_REQUIRED); } static void rna_def_library(BlenderRNA *brna) diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index d08516c4a62..6b4e4fb5921 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -401,6 +401,13 @@ PropertySubType RNA_property_subtype(PointerRNA *ptr, PropertyRNA *prop) return prop->subtype; } +int RNA_property_flag(PointerRNA *ptr, PropertyRNA *prop) +{ + rna_idproperty_check(&prop, ptr); + + return prop->flag; +} + int RNA_property_array_length(PointerRNA *ptr, PropertyRNA *prop) { IDProperty *idprop; diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c index 31f7509981e..bfe7705818a 100644 --- a/source/blender/makesrna/intern/rna_define.c +++ b/source/blender/makesrna/intern/rna_define.c @@ -1404,7 +1404,7 @@ void RNA_def_property_enum_bitflag_sdna(PropertyRNA *prop, const char *structnam dp= rna_find_struct_property_def(prop); if(dp) - dp->booleannegative= 1; + dp->enumbitflags= 1; } void RNA_def_property_string_sdna(PropertyRNA *prop, const char *structname, const char *propname) diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index c1c19b3ffdf..1df01e4cabf 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -48,6 +48,12 @@ static void rna_Object_update(bContext *C, PointerRNA *ptr) DAG_object_flush_update(CTX_data_scene(C), ptr->id.data, OB_RECALC_OB); } +static void rna_Object_scene_update(bContext *C, PointerRNA *ptr) +{ + DAG_object_flush_update(CTX_data_scene(C), ptr->id.data, OB_RECALC_OB); + DAG_scene_sort(CTX_data_scene(C)); +} + static int rna_VertexGroup_index_get(PointerRNA *ptr) { Object *ob= (Object*)ptr->id.data; @@ -483,6 +489,14 @@ static StructRNA *rna_def_object(BlenderRNA *brna) {1, "OBJECT", "Object", ""}, {0, NULL, NULL, NULL}}; + static EnumPropertyItem dupli_items[] = { + {0, "NONE", "None", ""}, + {OB_DUPLIFRAMES, "FRAMES", "Frames", "Make copy of object for every frame."}, + {OB_DUPLIVERTS, "VERTS", "Verts", "Duplicate child objects on all vertices."}, + {OB_DUPLIFACES, "FACES", "Faces", "Duplicate child objects on all faces."}, + {OB_DUPLIGROUP, "GROUP", "Group", "Enable group instancing."}, + {0, NULL, NULL, NULL}}; + srna= RNA_def_struct(brna, "Object", "ID"); RNA_def_struct_ui_text(srna, "Object", "Object datablock defining an object in a scene.."); @@ -720,25 +734,11 @@ static StructRNA *rna_def_object(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "partype", PARSLOW); RNA_def_property_ui_text(prop, "Slow Parent", "Create a delay in the parent relationship."); - prop= RNA_def_property(srna, "dupli_frames", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "transflag", OB_DUPLIFRAMES); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); // clear other flags - RNA_def_property_ui_text(prop, "Dupli Frames", "Make copy of object for every frame."); - - prop= RNA_def_property(srna, "dupli_verts", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "transflag", OB_DUPLIVERTS); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); // clear other flags - RNA_def_property_ui_text(prop, "Dupli Verts", "Duplicate child objects on all vertices."); - - prop= RNA_def_property(srna, "dupli_faces", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "transflag", OB_DUPLIFACES); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); // clear other flags - RNA_def_property_ui_text(prop, "Dupli Faces", "Duplicate child objects on all faces."); - - prop= RNA_def_property(srna, "use_dupli_group", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "transflag", OB_DUPLIGROUP); - RNA_def_property_clear_flag(prop, PROP_EDITABLE); // clear other flags - RNA_def_property_ui_text(prop, "Use Dupli Group", "Enable group instancing."); + prop= RNA_def_property(srna, "dupli_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_bitflag_sdna(prop, NULL, "transflag"); + RNA_def_property_enum_items(prop, dupli_items); + RNA_def_property_ui_text(prop, "Dupli Type", "If not None, object duplication method to use."); + RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, "rna_Object_scene_update"); prop= RNA_def_property(srna, "dupli_frames_no_speed", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "transflag", OB_DUPLINOSPEED); -- cgit v1.2.3