2.5 / RNA / Nodes
[blender-staging.git] / source / blender / makesrna / intern / rna_nodetree.c
1 /**
2  * $Id$
3  *
4  * ***** BEGIN GPL LICENSE BLOCK *****
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software Foundation,
18  * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19  *
20  * Contributor(s): Blender Foundation (2008), Nathan Letwory
21  *
22  * ***** END GPL LICENSE BLOCK *****
23  */
24
25 #include <stdlib.h>
26
27 #include "RNA_define.h"
28 #include "RNA_types.h"
29
30 #include "rna_internal.h"
31
32 #include "DNA_node_types.h"
33 #include "BKE_node.h"
34
35 #ifdef RNA_RUNTIME
36
37 static void rna_Nodetree_nodes_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
38 {
39         bNodeTree *ntree= (bNodeTree*)ptr->data;
40         rna_iterator_listbase_begin(iter, &ntree->nodes, NULL);
41 }
42
43 #else
44
45 static void rna_def_node(BlenderRNA *brna)
46 {
47         StructRNA *srna;
48         PropertyRNA *prop;
49         static EnumPropertyItem node_type_items[] ={
50                 {SH_NODE_OUTPUT, "OUTPUT", "Output", ""},
51                 {SH_NODE_MATERIAL, "MATERIAL", "Material", ""},
52                 {SH_NODE_RGB, "RGB", "RGB", ""},
53                 {SH_NODE_VALUE, "VALUE", "Value", ""},
54                 {SH_NODE_MIX_RGB, "MIXRGB", "Mix", ""},
55                 {SH_NODE_VALTORGB, "VALTORGB", "Value to RGB", ""},
56                 {SH_NODE_RGBTOBW, "RGBTOBW", "RGB to BW", ""},
57                 {SH_NODE_TEXTURE, "TEXTURE", "Texture", ""},
58                 {SH_NODE_NORMAL, "NORMAL", "Normal", ""},
59                 {SH_NODE_GEOMETRY, "GEOMETRY", "Geometry", ""},
60                 {SH_NODE_MAPPING, "MAPPING", "Mapping", ""},
61                 {SH_NODE_CURVE_VEC, "CURVEVEC", "Vector Curves", ""},
62                 {SH_NODE_CURVE_RGB, "CURVERGB", "RGB Curves", ""},
63                 {SH_NODE_CAMERA, "CAMERA", "Camera", ""},
64                 {SH_NODE_MATH, "MATH", "Math", ""},
65                 {SH_NODE_VECT_MATH, "VECTMATH", "Vector Math", ""},
66                 {SH_NODE_SQUEEZE, "SQUEEZE", "Squeeze", ""},
67                 {SH_NODE_MATERIAL_EXT, "MATEXT", "Material Extended", ""},
68                 {SH_NODE_INVERT, "INVERT", "Invert", ""},
69                 {SH_NODE_SEPRGB, "SEPRGB", "Seperate RGB", ""},
70                 {SH_NODE_COMBRGB, "COMBRGB", "Combine RGB", ""},
71                 {SH_NODE_HUE_SAT, "HUESAT", "Hue/Saturation", ""},
72                 {NODE_DYNAMIC, "DYNAMIC", "Scripted Node", ""},
73                 {0, NULL, NULL, NULL}};
74         
75         srna= RNA_def_struct(brna, "Node", NULL);
76         RNA_def_struct_ui_text(srna, "Node", "DOC_BROKEN");
77         RNA_def_struct_sdna(srna, "bNode");
78         
79         prop= RNA_def_property(srna, "location", PROP_FLOAT, PROP_VECTOR);
80         RNA_def_property_float_sdna(prop, NULL, "locx");
81         RNA_def_property_array(prop, 2);
82         RNA_def_property_range(prop, -10000.0f, 10000.0f);
83         RNA_def_property_ui_text(prop, "Location", "");
84         
85         prop= RNA_def_property(srna, "name", PROP_STRING, PROP_NONE);
86         RNA_def_property_ui_text(prop, "Name", "Node name.");
87         RNA_def_struct_name_property(srna, prop);
88         
89         prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
90         RNA_def_property_flag(prop, PROP_NOT_EDITABLE);
91         RNA_def_property_enum_items(prop, node_type_items);
92         RNA_def_property_ui_text(prop, "Type", "");
93 }
94
95 void RNA_def_nodetree(BlenderRNA *brna)
96 {
97         StructRNA *srna;
98         PropertyRNA *prop;
99         
100         srna= RNA_def_struct(brna, "NodeTree", "ID");
101         RNA_def_struct_ui_text(srna, "Node Tree", "DOC_BROKEN");
102         RNA_def_struct_sdna(srna, "bNodeTree");
103
104         prop= RNA_def_property(srna, "nodes", PROP_COLLECTION, PROP_NONE);
105         RNA_def_property_collection_sdna(prop, NULL, "nodes", NULL);
106         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, 0);
107         RNA_def_property_struct_type(prop, "Node");
108         RNA_def_property_ui_text(prop, "Nodes", "");
109         
110         rna_def_node(brna);
111 }
112
113 #endif
114