* changed NULL properties into UnknownProperty
[blender.git] / source / blender / makesrna / intern / rna_controller.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).
21  *
22  * ***** END GPL LICENSE BLOCK *****
23  */
24
25 #include <stdlib.h>
26
27 #include "RNA_access.h"
28 #include "RNA_define.h"
29 #include "RNA_types.h"
30
31 #include "rna_internal.h"
32
33 #include "DNA_controller_types.h"
34
35 #ifdef RNA_RUNTIME
36 static struct StructRNA* rna_Controller_data_type(struct PointerRNA *ptr)
37 {
38         bController *controller= (bController*)ptr->data;
39         switch(controller->type){
40                 case CONT_LOGIC_AND:
41                 case CONT_LOGIC_OR:
42                 case CONT_LOGIC_NAND:
43                 case CONT_LOGIC_NOR:
44                 case CONT_LOGIC_XOR:
45                 case CONT_LOGIC_XNOR:
46                         return &RNA_UnknownType;
47                 case CONT_EXPRESSION:
48                         return &RNA_ExpressionCont;
49                 case CONT_PYTHON:
50                         return &RNA_PythonCont;
51         }
52         return &RNA_UnknownType;
53 }
54 #else
55
56 void RNA_def_controller(BlenderRNA *brna)
57 {
58         StructRNA *srna;
59         PropertyRNA *prop;
60         static EnumPropertyItem controller_types_items[] ={
61                 {CONT_LOGIC_AND, "LOGICAND", "Logic And", ""},
62                 {CONT_LOGIC_OR, "LOGICOR", "Logic Or", ""},
63                 {CONT_LOGIC_NAND, "LOGICNAND", "Logic Nand", ""},
64                 {CONT_LOGIC_NOR, "LOGICNOR", "Logic Nor", ""},
65                 {CONT_LOGIC_XOR, "LOGICXOR", "Logic Xor", ""},
66                 {CONT_LOGIC_XNOR, "LOGICXNOR", "Logic Xnor", ""},
67                 {CONT_EXPRESSION, "EXPRESSION", "Expression", ""},
68                 {CONT_PYTHON, "PYTHON", "Python Script", ""},
69                 {0, NULL, NULL, NULL}};
70
71         srna= RNA_def_struct(brna, "Controller", NULL , "Controller");
72         RNA_def_struct_sdna(srna, "bController");
73
74         prop= RNA_def_property(srna, "controller_name", PROP_STRING, PROP_NONE);
75         RNA_def_property_string_sdna(prop, NULL, "name");
76         RNA_def_property_string_maxlength(prop, 31);
77         RNA_def_property_ui_text(prop, "Name", "Controller name.");
78
79         /* type is not editable, would need to do proper data free/alloc */
80         prop= RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
81         RNA_def_property_flag(prop, PROP_NOT_EDITABLE);
82         RNA_def_property_enum_items(prop, controller_types_items);
83         RNA_def_property_ui_text(prop, "Controller Types", "Controller types.");
84
85         prop= RNA_def_property(srna, "data", PROP_POINTER, PROP_NONE);
86         RNA_def_property_ui_text(prop, "Data", "Controller data.");
87         RNA_def_property_pointer_funcs(prop, NULL, "rna_Controller_data_type", NULL);
88
89         srna= RNA_def_struct(brna, "ExpressionCont", NULL , "ExpressionCont");
90         RNA_def_struct_sdna(srna, "bExpressionCont");
91
92         prop= RNA_def_property(srna, "expression", PROP_STRING, PROP_NONE);
93         RNA_def_property_string_sdna(prop, NULL, "str");
94         RNA_def_property_string_maxlength(prop, 127);
95         RNA_def_property_ui_text(prop, "Expression", "Expression.");
96
97         srna= RNA_def_struct(brna, "PythonCont", NULL , "PythonCont");
98         RNA_def_struct_sdna(srna, "bPythonCont");
99
100         prop= RNA_def_property(srna, "text", PROP_POINTER, PROP_NONE);
101         RNA_def_property_struct_type(prop, "ID");
102         RNA_def_property_ui_text(prop, "Python Text", "Python text.");
103 }
104
105 #endif
106