4 * ***** BEGIN GPL LICENSE BLOCK *****
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.
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.
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.
20 * The Original Code is Copyright (C) 2009 Blender Foundation.
21 * All rights reserved.
24 * Contributor(s): Blender Foundation
26 * ***** END GPL LICENSE BLOCK *****
32 #include "RNA_define.h"
33 #include "RNA_types.h"
35 #include "UI_interface.h"
36 #include "UI_resources.h"
42 #define DEF_ICON(name) {name, #name, 0, #name, ""},
43 static EnumPropertyItem icon_items[] = {
45 {0, NULL, 0, NULL, NULL}};
48 static void api_ui_item_common(FunctionRNA *func)
52 RNA_def_string(func, "text", "", 0, "", "Override automatic text of the item.");
54 prop= RNA_def_property(func, "icon", PROP_ENUM, PROP_NONE);
55 RNA_def_property_enum_items(prop, icon_items);
56 RNA_def_property_ui_text(prop, "Icon", "Override automatic icon of the item.");
60 static void api_ui_item_op_common(FunctionRNA *func)
64 api_ui_item_common(func);
65 parm= RNA_def_string(func, "operator", "", 0, "", "Identifier of the operator.");
66 RNA_def_property_flag(parm, PROP_REQUIRED);
69 static void api_ui_item_rna_common(FunctionRNA *func)
73 parm= RNA_def_pointer(func, "data", "AnyType", "", "Data from which to take property.");
74 RNA_def_property_flag(parm, PROP_REQUIRED|PROP_RNAPTR);
75 parm= RNA_def_string(func, "property", "", 0, "", "Identifier of property in data.");
76 RNA_def_property_flag(parm, PROP_REQUIRED);
79 void RNA_api_ui_layout(StructRNA *srna)
84 static EnumPropertyItem curve_type_items[] = {
85 {0, "NONE", 0, "None", ""},
86 {'v', "VECTOR", 0, "Vector", ""},
87 {'c', "COLOR", 0, "Color", ""},
88 {0, NULL, 0, NULL, NULL}};
90 /* simple layout specifiers */
91 func= RNA_def_function(srna, "row", "uiLayoutRow");
92 parm= RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in.");
93 RNA_def_function_return(func, parm);
94 RNA_def_boolean(func, "align", 0, "", "Align buttons to each other.");
96 func= RNA_def_function(srna, "column", "uiLayoutColumn");
97 parm= RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in.");
98 RNA_def_function_return(func, parm);
99 RNA_def_boolean(func, "align", 0, "", "Align buttons to each other.");
101 func= RNA_def_function(srna, "column_flow", "uiLayoutColumnFlow");
102 parm= RNA_def_int(func, "columns", 0, 0, INT_MAX, "", "Number of columns, 0 is automatic.", 0, INT_MAX);
103 parm= RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in.");
104 RNA_def_function_return(func, parm);
105 RNA_def_boolean(func, "align", 0, "", "Align buttons to each other.");
108 func= RNA_def_function(srna, "box", "uiLayoutBox");
109 parm= RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in.");
110 RNA_def_function_return(func, parm);
113 func= RNA_def_function(srna, "split", "uiLayoutSplit");
114 parm= RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in.");
115 RNA_def_function_return(func, parm);
116 RNA_def_float(func, "percentage", 0.5f, 0.0f, 1.0f, "Percentage", "Percentage of width to split at.", 0.0f, 1.0f);
119 func= RNA_def_function(srna, "itemR", "uiItemR");
120 api_ui_item_common(func);
121 api_ui_item_rna_common(func);
122 RNA_def_boolean(func, "expand", 0, "", "Expand button to show more detail.");
123 RNA_def_boolean(func, "slider", 0, "", "Use slider widget for numeric values.");
124 RNA_def_boolean(func, "toggle", 0, "", "Use toggle widget for boolean values.");
126 func= RNA_def_function(srna, "items_enumR", "uiItemsEnumR");
127 api_ui_item_rna_common(func);
129 func= RNA_def_function(srna, "item_menu_enumR", "uiItemMenuEnumR");
130 api_ui_item_common(func);
131 api_ui_item_rna_common(func);
133 /*func= RNA_def_function(srna, "item_enumR", "uiItemEnumR");
134 api_ui_item_common(func);
135 api_ui_item_rna_common(func);
136 parm= RNA_def_string(func, "value", "", 0, "", "Enum property value.");
137 RNA_def_property_flag(parm, PROP_REQUIRED);*/
139 func= RNA_def_function(srna, "itemO", "uiItemO");
140 api_ui_item_op_common(func);
142 func= RNA_def_function(srna, "item_enumO", "uiItemEnumO_string");
143 api_ui_item_op_common(func);
144 parm= RNA_def_string(func, "property", "", 0, "", "Identifier of property in operator.");
145 RNA_def_property_flag(parm, PROP_REQUIRED);
146 parm= RNA_def_string(func, "value", "", 0, "", "Enum property value.");
147 RNA_def_property_flag(parm, PROP_REQUIRED);
149 func= RNA_def_function(srna, "items_enumO", "uiItemsEnumO");
150 parm= RNA_def_string(func, "operator", "", 0, "", "Identifier of the operator.");
151 RNA_def_property_flag(parm, PROP_REQUIRED);
152 parm= RNA_def_string(func, "property", "", 0, "", "Identifier of property in operator.");
153 RNA_def_property_flag(parm, PROP_REQUIRED);
155 func= RNA_def_function(srna, "item_menu_enumO", "uiItemMenuEnumO");
156 api_ui_item_op_common(func);
157 parm= RNA_def_string(func, "property", "", 0, "", "Identifier of property in operator.");
158 RNA_def_property_flag(parm, PROP_REQUIRED);
160 func= RNA_def_function(srna, "item_booleanO", "uiItemBooleanO");
161 api_ui_item_op_common(func);
162 parm= RNA_def_string(func, "property", "", 0, "", "Identifier of property in operator.");
163 RNA_def_property_flag(parm, PROP_REQUIRED);
164 parm= RNA_def_boolean(func, "value", 0, "", "Value of the property to call the operator with.");
165 RNA_def_property_flag(parm, PROP_REQUIRED);
167 func= RNA_def_function(srna, "item_intO", "uiItemIntO");
168 api_ui_item_op_common(func);
169 parm= RNA_def_string(func, "property", "", 0, "", "Identifier of property in operator.");
170 RNA_def_property_flag(parm, PROP_REQUIRED);
171 parm= RNA_def_int(func, "value", 0, INT_MIN, INT_MAX, "", "Value of the property to call the operator with.", INT_MIN, INT_MAX);
172 RNA_def_property_flag(parm, PROP_REQUIRED);
174 func= RNA_def_function(srna, "item_floatO", "uiItemFloatO");
175 api_ui_item_op_common(func);
176 parm= RNA_def_string(func, "property", "", 0, "", "Identifier of property in operator.");
177 RNA_def_property_flag(parm, PROP_REQUIRED);
178 parm= RNA_def_float(func, "value", 0, -FLT_MAX, FLT_MAX, "", "Value of the property to call the operator with.", -FLT_MAX, FLT_MAX);
179 RNA_def_property_flag(parm, PROP_REQUIRED);
181 func= RNA_def_function(srna, "item_stringO", "uiItemStringO");
182 api_ui_item_op_common(func);
183 parm= RNA_def_string(func, "property", "", 0, "", "Identifier of property in operator.");
184 RNA_def_property_flag(parm, PROP_REQUIRED);
185 parm= RNA_def_string(func, "value", "", 0, "", "Value of the property to call the operator with.");
186 RNA_def_property_flag(parm, PROP_REQUIRED);
188 func= RNA_def_function(srna, "itemL", "uiItemL");
189 api_ui_item_common(func);
191 func= RNA_def_function(srna, "itemM", "uiItemM");
192 RNA_def_function_flag(func, FUNC_USE_CONTEXT);
193 api_ui_item_common(func);
194 parm= RNA_def_string(func, "menu", "", 0, "", "Identifier of the menu.");
195 RNA_def_property_flag(parm, PROP_REQUIRED);
197 func= RNA_def_function(srna, "itemS", "uiItemS");
200 func= RNA_def_function(srna, "set_context_pointer", "uiLayoutSetContextPointer");
201 parm= RNA_def_string(func, "name", "", 0, "Name", "Name of entry in the context.");
202 RNA_def_property_flag(parm, PROP_REQUIRED);
203 parm= RNA_def_pointer(func, "data", "AnyType", "", "Pointer to put in context.");
204 RNA_def_property_flag(parm, PROP_REQUIRED|PROP_RNAPTR);
207 func= RNA_def_function(srna, "template_header", "uiTemplateHeader");
208 RNA_def_function_flag(func, FUNC_USE_CONTEXT);
210 func= RNA_def_function(srna, "template_ID", "uiTemplateID");
211 RNA_def_function_flag(func, FUNC_USE_CONTEXT);
212 api_ui_item_rna_common(func);
213 RNA_def_string(func, "new", "", 0, "", "Operator identifier to create a new ID block.");
214 RNA_def_string(func, "open", "", 0, "", "Operator identifier to open a new ID block.");
215 RNA_def_string(func, "unlink", "", 0, "", "Operator identifier to unlink the ID block.");
217 func= RNA_def_function(srna, "template_modifier", "uiTemplateModifier");
218 parm= RNA_def_pointer(func, "data", "Modifier", "", "Modifier data.");
219 RNA_def_property_flag(parm, PROP_REQUIRED|PROP_RNAPTR);
220 parm= RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in.");
221 RNA_def_function_return(func, parm);
223 func= RNA_def_function(srna, "template_constraint", "uiTemplateConstraint");
224 parm= RNA_def_pointer(func, "data", "Constraint", "", "Constraint data.");
225 RNA_def_property_flag(parm, PROP_REQUIRED|PROP_RNAPTR);
226 parm= RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in.");
227 RNA_def_function_return(func, parm);
229 func= RNA_def_function(srna, "template_preview", "uiTemplatePreview");
230 parm= RNA_def_pointer(func, "id", "ID", "", "ID datablock.");
231 RNA_def_property_flag(parm, PROP_REQUIRED);
233 func= RNA_def_function(srna, "template_curve_mapping", "uiTemplateCurveMapping");
234 parm= RNA_def_pointer(func, "curvemap", "CurveMapping", "", "Curve mapping pointer.");
235 RNA_def_property_flag(parm, PROP_REQUIRED);
236 RNA_def_enum(func, "type", curve_type_items, 0, "Type", "Type of curves to display.");
238 func= RNA_def_function(srna, "template_color_ramp", "uiTemplateColorRamp");
239 parm= RNA_def_pointer(func, "ramp", "ColorRamp", "", "Color ramp pointer.");
240 RNA_def_property_flag(parm, PROP_REQUIRED);
241 RNA_def_boolean(func, "expand", 0, "", "Expand button to show more detail.");
243 func= RNA_def_function(srna, "template_layers", "uiTemplateLayers");
244 api_ui_item_rna_common(func);
246 func= RNA_def_function(srna, "template_image_layers", "uiTemplateImageLayers");
247 RNA_def_function_flag(func, FUNC_USE_CONTEXT);
248 parm= RNA_def_pointer(func, "image", "Image", "", "");
249 RNA_def_property_flag(parm, PROP_REQUIRED);
250 parm= RNA_def_pointer(func, "image_user", "ImageUser", "", "");
251 RNA_def_property_flag(parm, PROP_REQUIRED);