diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-03-22 17:46:45 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-03-22 17:46:45 +0300 |
commit | 3bf71fbe386cb3fba1896183ea528046f6145b7d (patch) | |
tree | d3a281d82541182ce7bac5b85ba10574dd681ac6 /source | |
parent | 7c86a10aba535dd68c79244487760e5b87c2eed8 (diff) |
RNA: basic code for Node inheritance.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/makesrna/intern/rna_nodetree.c | 58 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_space.c | 10 |
2 files changed, 56 insertions, 12 deletions
diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 1588544966a..5d8516d6aa1 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -34,15 +34,31 @@ #ifdef RNA_RUNTIME -static void rna_Nodetree_nodes_begin(CollectionPropertyIterator *iter, PointerRNA *ptr) +StructRNA *rna_Node_refine(struct PointerRNA *ptr) { - bNodeTree *ntree= (bNodeTree*)ptr->data; - rna_iterator_listbase_begin(iter, &ntree->nodes, NULL); + bNode *node= (bNode*)ptr->data; + + switch(node->type) { + case SH_NODE_OUTPUT: + return &RNA_ShaderNodeOutput; + /* XXX complete here */ + default: + return &RNA_Node; + } } #else -static void rna_def_node(BlenderRNA *brna) +static void rna_def_shader_node_output(BlenderRNA *brna) +{ + StructRNA *srna; + + srna= RNA_def_struct(brna, "ShaderNodeOutput", "ShaderNode"); + RNA_def_struct_ui_text(srna, "Shader Node Output", ""); + RNA_def_struct_sdna(srna, "bNode"); +} + +static void rna_def_shader_node(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; @@ -71,10 +87,29 @@ static void rna_def_node(BlenderRNA *brna) {SH_NODE_HUE_SAT, "HUE_SATURATION", "Hue/Saturation", ""}, {NODE_DYNAMIC, "SCRIPT", "Script", ""}, {0, NULL, NULL, NULL}}; + + srna= RNA_def_struct(brna, "ShaderNode", "Node"); + RNA_def_struct_ui_text(srna, "Shader Node", "Material shader node."); + RNA_def_struct_sdna(srna, "bNode"); + + prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); + RNA_def_property_flag(prop, PROP_NOT_EDITABLE); + RNA_def_property_enum_items(prop, node_type_items); + RNA_def_property_ui_text(prop, "Type", ""); + + /* specific types */ + rna_def_shader_node_output(brna); +} + +static void rna_def_node(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; srna= RNA_def_struct(brna, "Node", NULL); RNA_def_struct_ui_text(srna, "Node", "Node in a node tree."); RNA_def_struct_sdna(srna, "bNode"); + RNA_def_struct_refine_func(srna, "rna_Node_refine"); prop= RNA_def_property(srna, "location", PROP_FLOAT, PROP_VECTOR); RNA_def_property_float_sdna(prop, NULL, "locx"); @@ -85,14 +120,9 @@ static void rna_def_node(BlenderRNA *brna) prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE); RNA_def_property_ui_text(prop, "Name", "Node name."); RNA_def_struct_name_property(srna, prop); - - prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE); - RNA_def_property_flag(prop, PROP_NOT_EDITABLE); - RNA_def_property_enum_items(prop, node_type_items); - RNA_def_property_ui_text(prop, "Type", ""); } -void RNA_def_nodetree(BlenderRNA *brna) +static void rna_def_nodetree(BlenderRNA *brna) { StructRNA *srna; PropertyRNA *prop; @@ -103,11 +133,15 @@ void RNA_def_nodetree(BlenderRNA *brna) prop= RNA_def_property(srna, "nodes", PROP_COLLECTION, PROP_NONE); RNA_def_property_collection_sdna(prop, NULL, "nodes", NULL); - RNA_def_property_collection_funcs(prop, "rna_Nodetree_nodes_begin", "rna_iterator_listbase_next", "rna_iterator_listbase_end", "rna_iterator_listbase_get", 0, 0, 0); RNA_def_property_struct_type(prop, "Node"); RNA_def_property_ui_text(prop, "Nodes", ""); - +} + +void RNA_def_nodetree(BlenderRNA *brna) +{ + rna_def_nodetree(brna); rna_def_node(brna); + rna_def_shader_node(brna); } #endif diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 2639f1b3012..0f78846684d 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -103,6 +103,14 @@ void rna_SpaceTextEditor_word_wrap_set(PointerRNA *ptr, int value) st->left= 0; } +void rna_SpaceTextEditor_text_set(PointerRNA *ptr, PointerRNA value) +{ + SpaceText *st= (SpaceText*)(ptr->data); + + st->text= value.data; + st->top= 0; +} + #else static void rna_def_space(BlenderRNA *brna) @@ -331,6 +339,8 @@ static void rna_def_space_text(BlenderRNA *brna) /* text */ prop= RNA_def_property(srna, "text", PROP_POINTER, PROP_NONE); RNA_def_property_ui_text(prop, "Text", "Text displayed and edited in this space."); + RNA_def_property_pointer_funcs(prop, NULL, "rna_SpaceTextEditor_text_set"); + RNA_def_property_update(prop, NC_TEXT|ND_CURSOR, NULL); /* display */ prop= RNA_def_property(srna, "syntax_highlight", PROP_BOOLEAN, PROP_NONE); |