diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2008-12-26 23:38:52 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2008-12-26 23:38:52 +0300 |
commit | 82cf2aebba1c340c1c4fffde1e89fc80a4591fea (patch) | |
tree | 18d58c3ce61401b4fcd077f902e06235cab737be /source/blender/makesrna/intern/rna_define.c | |
parent | 254fc41b56e8c4f828e9721a045c8c5108044d0a (diff) |
RNA:
* Added support for using pointers + collections as operator properties,
but with the restriction that they must point to other type derived from
ID property groups. The "add" function for these properties will allocate
a new ID property group and point to that.
* Added support for arrays with type IDP_GROUP in ID properties.
* Fix bug getting/setting float array values.
Example code for collections, note the "OperatorMousePath" type is defined
in rna_wm.c and has a float[2] property named "loc".
Defining the operator property:
prop= RNA_def_property(ot->srna, "path", PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_runtime(prop, &RNA_OperatorMousePath);
Adding values:
PointerRNA itemptr;
float loc[2] = {1, 1},
RNA_collection_add(op->ptr, "path", &itemptr);
RNA_float_set_array(&itemptr, "loc", loc);
Iterating:
RNA_BEGIN(op->ptr, itemptr, "path") {
float loc[2];
RNA_float_get_array(&itemptr, "loc", loc);
printf("Location: %f %f\n", loc[0], loc[1]);
}
RNA_END;
Diffstat (limited to 'source/blender/makesrna/intern/rna_define.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_define.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_define.c b/source/blender/makesrna/intern/rna_define.c index 14e4763d2c0..05dba91757b 100644 --- a/source/blender/makesrna/intern/rna_define.c +++ b/source/blender/makesrna/intern/rna_define.c @@ -804,6 +804,33 @@ void RNA_def_property_struct_type(PropertyRNA *prop, const char *type) } } +void RNA_def_property_struct_runtime(PropertyRNA *prop, StructRNA *type) +{ + StructRNA *srna= DefRNA.laststruct; + + if(DefRNA.preprocess) { + fprintf(stderr, "RNA_def_property_struct_runtime: only at runtime.\n"); + return; + } + + switch(prop->type) { + case PROP_POINTER: { + PointerPropertyRNA *pprop= (PointerPropertyRNA*)prop; + pprop->structtype = type; + break; + } + case PROP_COLLECTION: { + CollectionPropertyRNA *cprop= (CollectionPropertyRNA*)prop; + cprop->structtype = type; + break; + } + default: + fprintf(stderr, "RNA_def_property_struct_runtime: %s.%s, invalid type for struct type.\n", srna->identifier, prop->identifier); + DefRNA.error= 1; + break; + } +} + void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item) { StructRNA *srna= DefRNA.laststruct; |