Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2009-11-13 19:08:03 +0300
committerCampbell Barton <ideasman42@gmail.com>2009-11-13 19:08:03 +0300
commit91352006c4ba8276ff2c7c8ae21461d16cf3f702 (patch)
tree6eb2a8d52e697c045eadca8e9e122e14dc73a4a6 /source/blender/makesrna/intern/rna_group.c
parent6df83fba020c596aaf242271237f333d178e4c0e (diff)
arbitrary property and function support for rna properties (arrays and collections), this means functions can be easily added.
eg. scene.objects.link() object.constraints.new() mesh.verts.transform(...) mesh.faces.active PropertyRNA stores an StructRNA pointer where these can be defined.
Diffstat (limited to 'source/blender/makesrna/intern/rna_group.c')
-rw-r--r--source/blender/makesrna/intern/rna_group.c61
1 files changed, 39 insertions, 22 deletions
diff --git a/source/blender/makesrna/intern/rna_group.c b/source/blender/makesrna/intern/rna_group.c
index 8babb9593a0..a1b5bf85bf7 100644
--- a/source/blender/makesrna/intern/rna_group.c
+++ b/source/blender/makesrna/intern/rna_group.c
@@ -49,13 +49,13 @@ static PointerRNA rna_Group_objects_get(CollectionPropertyIterator *iter)
return rna_pointer_inherit_refine(&iter->parent, &RNA_Object, ((GroupObject*)internal->link)->ob);
}
-static int rna_Group_objects_add(Group *group, bContext *C, Object *object)
+static int rna_Group_objects_link(Group *group, bContext *C, Object *object)
{
WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, &object->id);
return add_to_group(group, object, CTX_data_scene(C), NULL);
}
-static int rna_Group_objects_remove(Group *group, bContext *C, Object *object)
+static int rna_Group_objects_unlink(Group *group, bContext *C, Object *object)
{
WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, &object->id);
return rem_from_group(group, object, CTX_data_scene(C), NULL);
@@ -63,56 +63,73 @@ static int rna_Group_objects_remove(Group *group, bContext *C, Object *object)
#else
-void RNA_def_group(BlenderRNA *brna)
+/* group.objects */
+static void rna_def_group_objects(BlenderRNA *brna, PropertyRNA *cprop)
{
StructRNA *srna;
- PropertyRNA *prop;
+// PropertyRNA *prop;
FunctionRNA *func;
PropertyRNA *parm;
-
- srna= RNA_def_struct(brna, "Group", "ID");
- RNA_def_struct_ui_text(srna, "Group", "Group of Object datablocks.");
- RNA_def_struct_ui_icon(srna, ICON_GROUP);
-
- prop= RNA_def_property(srna, "dupli_offset", PROP_FLOAT, PROP_TRANSLATION);
- RNA_def_property_float_sdna(prop, NULL, "dupli_ofs");
- RNA_def_property_ui_text(prop, "Dupli Offset", "Offset from the center to use when instancing as DupliGroup.");
- RNA_def_property_ui_range(prop, -10000.0, 10000.0, 10, 4);
- prop= RNA_def_property(srna, "layer", PROP_BOOLEAN, PROP_LAYER);
- RNA_def_property_boolean_sdna(prop, NULL, "layer", 1);
- RNA_def_property_array(prop, 20);
- RNA_def_property_ui_text(prop, "Dupli Layers", "Layers visible when this groups is instanced as a dupli.");
+ srna= RNA_def_struct(brna, "GroupObjectCollection", NULL);
+ RNA_def_struct_sdna(srna, "Group");
+ RNA_def_struct_ui_text(srna, "GroupObjects", "Collection of group objects.");
+ RNA_def_property_srna(cprop, "GroupObjectCollection");
/* add object */
- func= RNA_def_function(srna, "objects__add", "rna_Group_objects_add");
+ func= RNA_def_function(srna, "link", "rna_Group_objects_link");
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
RNA_def_function_ui_description(func, "Add this object to a group");
/* return type */
- parm= RNA_def_boolean(func, "success", 0, "Success", "Newly created Group Target.");
+ parm= RNA_def_boolean(func, "success", 0, "Success", "");
RNA_def_function_return(func, parm);
/* object to add */
parm= RNA_def_pointer(func, "object", "Object", "", "Object to add.");
RNA_def_property_flag(parm, PROP_REQUIRED);
/* remove object */
- func= RNA_def_function(srna, "objects__remove", "rna_Group_objects_remove");
+ func= RNA_def_function(srna, "unlink", "rna_Group_objects_unlink");
RNA_def_function_ui_description(func, "Remove this object to a group");
RNA_def_function_flag(func, FUNC_USE_CONTEXT);
/* return type */
- parm= RNA_def_boolean(func, "success", 0, "Success", "Newly created Group Target.");
+ parm= RNA_def_boolean(func, "success", 0, "Success", "");
RNA_def_function_return(func, parm);
/* object to remove */
parm= RNA_def_pointer(func, "object", "Object", "", "Object to remove.");
RNA_def_property_flag(parm, PROP_REQUIRED);
+}
+
+
+void RNA_def_group(BlenderRNA *brna)
+{
+ StructRNA *srna;
+ PropertyRNA *prop;
+
+ srna= RNA_def_struct(brna, "Group", "ID");
+ RNA_def_struct_ui_text(srna, "Group", "Group of Object datablocks.");
+ RNA_def_struct_ui_icon(srna, ICON_GROUP);
+
+ prop= RNA_def_property(srna, "dupli_offset", PROP_FLOAT, PROP_TRANSLATION);
+ RNA_def_property_float_sdna(prop, NULL, "dupli_ofs");
+ RNA_def_property_ui_text(prop, "Dupli Offset", "Offset from the center to use when instancing as DupliGroup.");
+ RNA_def_property_ui_range(prop, -10000.0, 10000.0, 10, 4);
+
+ prop= RNA_def_property(srna, "layer", PROP_BOOLEAN, PROP_LAYER);
+ RNA_def_property_boolean_sdna(prop, NULL, "layer", 1);
+ RNA_def_property_array(prop, 20);
+ RNA_def_property_ui_text(prop, "Dupli Layers", "Layers visible when this groups is instanced as a dupli.");
+
prop= RNA_def_property(srna, "objects", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "gobject", NULL);
RNA_def_property_struct_type(prop, "Object");
RNA_def_property_ui_text(prop, "Objects", "A collection of this groups objects.");
- RNA_def_property_collection_funcs(prop, 0, 0, 0, "rna_Group_objects_get", 0, 0, 0, "objects__add", "objects__remove");
+ RNA_def_property_collection_funcs(prop, 0, 0, 0, "rna_Group_objects_get", 0, 0, 0);
+
+ rna_def_group_objects(brna, prop);
+
}
#endif