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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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"
34 #include "UI_resources.h"
38 static void rna_uiItemR(uiLayout *layout, PointerRNA *ptr, const char *propname, const char *name, int icon, int expand, int slider, int toggle, int icon_only, int event, int full_event, int emboss, int index)
40 PropertyRNA *prop= RNA_struct_find_property(ptr, propname);
44 printf("rna_uiItemR: property not found: %s.%s\n", RNA_struct_identifier(ptr->type), propname);
48 flag |= (slider)? UI_ITEM_R_SLIDER: 0;
49 flag |= (expand)? UI_ITEM_R_EXPAND: 0;
50 flag |= (toggle)? UI_ITEM_R_TOGGLE: 0;
51 flag |= (icon_only)? UI_ITEM_R_ICON_ONLY: 0;
52 flag |= (event)? UI_ITEM_R_EVENT: 0;
53 flag |= (full_event)? UI_ITEM_R_FULL_EVENT: 0;
54 flag |= (emboss)? 0: UI_ITEM_R_NO_BG;
56 uiItemFullR(layout, ptr, prop, index, 0, flag, name, icon);
59 static PointerRNA rna_uiItemO(uiLayout *layout, const char *opname, const char *name, int icon, int emboss)
61 int flag= UI_ITEM_O_RETURN_PROPS;
62 flag |= (emboss)? 0: UI_ITEM_R_NO_BG;
63 return uiItemFullO(layout, opname, name, icon, NULL, uiLayoutGetOperatorContext(layout), flag);
68 #define DEF_ICON_BLANK_SKIP
69 #define DEF_ICON(name) {ICON_##name, (#name), 0, (#name), ""},
70 #define DEF_VICO(name) {VICO_##name, (#name), 0, (#name), ""},
71 static EnumPropertyItem icon_items[] = {
73 {0, NULL, 0, NULL, NULL}};
74 #undef DEF_ICON_BLANK_SKIP
78 static void api_ui_item_common(FunctionRNA *func)
82 RNA_def_string(func, "text", "", 0, "", "Override automatic text of the item.");
84 prop= RNA_def_property(func, "icon", PROP_ENUM, PROP_NONE);
85 RNA_def_property_enum_items(prop, icon_items);
86 RNA_def_property_ui_text(prop, "Icon", "Override automatic icon of the item");
90 static void api_ui_item_op(FunctionRNA *func)
93 parm= RNA_def_string(func, "operator", "", 0, "", "Identifier of the operator.");
94 RNA_def_property_flag(parm, PROP_REQUIRED);
97 static void api_ui_item_op_common(FunctionRNA *func)
100 api_ui_item_common(func);
103 static void api_ui_item_rna_common(FunctionRNA *func)
107 parm= RNA_def_pointer(func, "data", "AnyType", "", "Data from which to take property.");
108 RNA_def_property_flag(parm, PROP_REQUIRED|PROP_RNAPTR|PROP_NEVER_NULL);
109 parm= RNA_def_string(func, "property", "", 0, "", "Identifier of property in data.");
110 RNA_def_property_flag(parm, PROP_REQUIRED);
113 void RNA_api_ui_layout(StructRNA *srna)
118 static EnumPropertyItem curve_type_items[] = {
119 {0, "NONE", 0, "None", ""},
120 {'v', "VECTOR", 0, "Vector", ""},
121 {'c', "COLOR", 0, "Color", ""},
122 {0, NULL, 0, NULL, NULL}};
124 static EnumPropertyItem list_type_items[] = {
125 {0, "DEFAULT", 0, "None", ""},
126 {'c', "COMPACT", 0, "Compact", ""},
127 {'i', "ICONS", 0, "Icons", ""},
128 {0, NULL, 0, NULL, NULL}};
130 /* simple layout specifiers */
131 func= RNA_def_function(srna, "row", "uiLayoutRow");
132 parm= RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in.");
133 RNA_def_function_return(func, parm);
134 RNA_def_function_ui_description(func, "Sub-layout. Items placed in this sublayout are placed next to each other in a row.");
135 RNA_def_boolean(func, "align", 0, "", "Align buttons to each other.");
137 func= RNA_def_function(srna, "column", "uiLayoutColumn");
138 parm= RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in.");
139 RNA_def_function_return(func, parm);
140 RNA_def_function_ui_description(func, "Sub-layout. Items placed in this sublayout are placed under each other in a column.");
141 RNA_def_boolean(func, "align", 0, "", "Align buttons to each other.");
143 func= RNA_def_function(srna, "column_flow", "uiLayoutColumnFlow");
144 RNA_def_int(func, "columns", 0, 0, INT_MAX, "", "Number of columns, 0 is automatic.", 0, INT_MAX);
145 parm= RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in.");
146 RNA_def_function_return(func, parm);
147 RNA_def_boolean(func, "align", 0, "", "Align buttons to each other.");
150 func= RNA_def_function(srna, "box", "uiLayoutBox");
151 parm= RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in.");
152 RNA_def_function_return(func, parm);
153 RNA_def_function_ui_description(func, "Sublayout. Items placed in this sublayout are placed under each other in a column and are surrounded by a box.");
156 func= RNA_def_function(srna, "split", "uiLayoutSplit");
157 parm= RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in.");
158 RNA_def_function_return(func, parm);
159 RNA_def_float(func, "percentage", 0.0f, 0.0f, 1.0f, "Percentage", "Percentage of width to split at.", 0.0f, 1.0f);
160 RNA_def_boolean(func, "align", 0, "", "Align buttons to each other.");
163 func= RNA_def_function(srna, "prop", "rna_uiItemR");
164 RNA_def_function_ui_description(func, "Item. Exposes an RNA item and places it into the layout.");
165 api_ui_item_rna_common(func);
166 api_ui_item_common(func);
167 RNA_def_boolean(func, "expand", 0, "", "Expand button to show more detail.");
168 RNA_def_boolean(func, "slider", 0, "", "Use slider widget for numeric values.");
169 RNA_def_boolean(func, "toggle", 0, "", "Use toggle widget for boolean values.");
170 RNA_def_boolean(func, "icon_only", 0, "", "Draw only icons in buttons, no text.");
171 RNA_def_boolean(func, "event", 0, "", "Use button to input key events.");
172 RNA_def_boolean(func, "full_event", 0, "", "Use button to input full events including modifiers.");
173 RNA_def_boolean(func, "emboss", 1, "", "Draw the button itself, just the icon/text.");
174 RNA_def_int(func, "index", -1, -2, INT_MAX, "", "The index of this button, when set a single member of an array can be accessed, when set to -1 all array members are used.", -2, INT_MAX); /* RNA_NO_INDEX == -1 */
176 func= RNA_def_function(srna, "props_enum", "uiItemsEnumR");
177 api_ui_item_rna_common(func);
179 func= RNA_def_function(srna, "prop_menu_enum", "uiItemMenuEnumR");
180 api_ui_item_rna_common(func);
181 api_ui_item_common(func);
183 func= RNA_def_function(srna, "prop_enum", "uiItemEnumR_string");
184 api_ui_item_rna_common(func);
185 parm= RNA_def_string(func, "value", "", 0, "", "Enum property value.");
186 RNA_def_property_flag(parm, PROP_REQUIRED);
187 api_ui_item_common(func);
189 func= RNA_def_function(srna, "prop_search", "uiItemPointerR");
190 api_ui_item_rna_common(func);
191 parm= RNA_def_pointer(func, "search_data", "AnyType", "", "Data from which to take collection to search in.");
192 RNA_def_property_flag(parm, PROP_REQUIRED|PROP_RNAPTR|PROP_NEVER_NULL);
193 parm= RNA_def_string(func, "search_property", "", 0, "", "Identifier of search collection property.");
194 RNA_def_property_flag(parm, PROP_REQUIRED);
195 api_ui_item_common(func);
197 func= RNA_def_function(srna, "operator", "rna_uiItemO");
198 api_ui_item_op_common(func);
199 RNA_def_boolean(func, "emboss", 1, "", "Draw the button itself, just the icon/text.");
200 parm= RNA_def_pointer(func, "properties", "OperatorProperties", "", "Operator properties to fill in, return when 'properties' is set to true.");
201 RNA_def_property_flag(parm, PROP_REQUIRED|PROP_RNAPTR);
202 RNA_def_function_return(func, parm);
203 RNA_def_function_ui_description(func, "Item. Places a button into the layout to call an Operator.");
205 /* func= RNA_def_function(srna, "operator_enum_single", "uiItemEnumO_string");
206 api_ui_item_op_common(func);
207 parm= RNA_def_string(func, "property", "", 0, "", "Identifier of property in operator.");
208 RNA_def_property_flag(parm, PROP_REQUIRED);
209 parm= RNA_def_string(func, "value", "", 0, "", "Enum property value.");
210 RNA_def_property_flag(parm, PROP_REQUIRED); */
212 func= RNA_def_function(srna, "operator_enum", "uiItemsEnumO");
213 parm= RNA_def_string(func, "operator", "", 0, "", "Identifier of the operator.");
214 RNA_def_property_flag(parm, PROP_REQUIRED);
215 parm= RNA_def_string(func, "property", "", 0, "", "Identifier of property in operator.");
216 RNA_def_property_flag(parm, PROP_REQUIRED);
218 func= RNA_def_function(srna, "operator_menu_enum", "uiItemMenuEnumO");
219 api_ui_item_op(func); /* cant use api_ui_item_op_common because property must come right after */
220 parm= RNA_def_string(func, "property", "", 0, "", "Identifier of property in operator.");
221 RNA_def_property_flag(parm, PROP_REQUIRED);
222 api_ui_item_common(func);
224 /* func= RNA_def_function(srna, "operator_boolean", "uiItemBooleanO");
225 api_ui_item_op_common(func);
226 parm= RNA_def_string(func, "property", "", 0, "", "Identifier of property in operator.");
227 RNA_def_property_flag(parm, PROP_REQUIRED);
228 parm= RNA_def_boolean(func, "value", 0, "", "Value of the property to call the operator with.");
229 RNA_def_property_flag(parm, PROP_REQUIRED); */
231 /* func= RNA_def_function(srna, "operator_int", "uiItemIntO");
232 api_ui_item_op_common(func);
233 parm= RNA_def_string(func, "property", "", 0, "", "Identifier of property in operator.");
234 RNA_def_property_flag(parm, PROP_REQUIRED);
235 parm= RNA_def_int(func, "value", 0, INT_MIN, INT_MAX, "", "Value of the property to call the operator with.", INT_MIN, INT_MAX);
236 RNA_def_property_flag(parm, PROP_REQUIRED); */
238 /* func= RNA_def_function(srna, "operator_float", "uiItemFloatO");
239 api_ui_item_op_common(func);
240 parm= RNA_def_string(func, "property", "", 0, "", "Identifier of property in operator.");
241 RNA_def_property_flag(parm, PROP_REQUIRED);
242 parm= RNA_def_float(func, "value", 0, -FLT_MAX, FLT_MAX, "", "Value of the property to call the operator with.", -FLT_MAX, FLT_MAX);
243 RNA_def_property_flag(parm, PROP_REQUIRED); */
245 /* func= RNA_def_function(srna, "operator_string", "uiItemStringO");
246 api_ui_item_op_common(func);
247 parm= RNA_def_string(func, "property", "", 0, "", "Identifier of property in operator.");
248 RNA_def_property_flag(parm, PROP_REQUIRED);
249 parm= RNA_def_string(func, "value", "", 0, "", "Value of the property to call the operator with.");
250 RNA_def_property_flag(parm, PROP_REQUIRED); */
252 func= RNA_def_function(srna, "label", "uiItemL");
253 RNA_def_function_ui_description(func, "Item. Display text in the layout.");
254 api_ui_item_common(func);
256 func= RNA_def_function(srna, "menu", "uiItemM");
257 RNA_def_function_flag(func, FUNC_USE_CONTEXT);
258 parm= RNA_def_string(func, "menu", "", 0, "", "Identifier of the menu.");
259 api_ui_item_common(func);
260 RNA_def_property_flag(parm, PROP_REQUIRED);
262 func= RNA_def_function(srna, "separator", "uiItemS");
263 RNA_def_function_ui_description(func, "Item. Inserts empty space into the layout between items.");
266 func= RNA_def_function(srna, "context_pointer_set", "uiLayoutSetContextPointer");
267 parm= RNA_def_string(func, "name", "", 0, "Name", "Name of entry in the context.");
268 RNA_def_property_flag(parm, PROP_REQUIRED);
269 parm= RNA_def_pointer(func, "data", "AnyType", "", "Pointer to put in context.");
270 RNA_def_property_flag(parm, PROP_REQUIRED|PROP_RNAPTR);
273 func= RNA_def_function(srna, "template_header", "uiTemplateHeader");
274 RNA_def_function_flag(func, FUNC_USE_CONTEXT);
275 RNA_def_boolean(func, "menus", 1, "", "The header has menus, and should show menu expander.");
277 func= RNA_def_function(srna, "template_ID", "uiTemplateID");
278 RNA_def_function_flag(func, FUNC_USE_CONTEXT);
279 api_ui_item_rna_common(func);
280 RNA_def_string(func, "new", "", 0, "", "Operator identifier to create a new ID block.");
281 RNA_def_string(func, "open", "", 0, "", "Operator identifier to open a file for creating a new ID block.");
282 RNA_def_string(func, "unlink", "", 0, "", "Operator identifier to unlink the ID block.");
284 func= RNA_def_function(srna, "template_ID_preview", "uiTemplateIDPreview");
285 RNA_def_function_flag(func, FUNC_USE_CONTEXT);
286 api_ui_item_rna_common(func);
287 RNA_def_string(func, "new", "", 0, "", "Operator identifier to create a new ID block.");
288 RNA_def_string(func, "open", "", 0, "", "Operator identifier to open a file for creating a new ID block.");
289 RNA_def_string(func, "unlink", "", 0, "", "Operator identifier to unlink the ID block.");
290 RNA_def_int(func, "rows", 0, 0, INT_MAX, "Number of thumbnail preview rows to display", "", 0, INT_MAX);
291 RNA_def_int(func, "cols", 0, 0, INT_MAX, "Number of thumbnail preview columns to display", "", 0, INT_MAX);
293 func= RNA_def_function(srna, "template_any_ID", "uiTemplateAnyID");
294 parm= RNA_def_pointer(func, "data", "AnyType", "", "Data from which to take property.");
295 RNA_def_property_flag(parm, PROP_REQUIRED|PROP_RNAPTR|PROP_NEVER_NULL);
296 parm= RNA_def_string(func, "property", "", 0, "", "Identifier of property in data.");
297 RNA_def_property_flag(parm, PROP_REQUIRED);
298 parm= RNA_def_string(func, "type_property", "", 0, "", "Identifier of property in data giving the type of the ID-blocks to use.");
299 RNA_def_property_flag(parm, PROP_REQUIRED);
300 RNA_def_string(func, "text", "", 0, "", "Custom label to display in UI.");
302 func= RNA_def_function(srna, "template_path_builder", "uiTemplatePathBuilder");
303 parm= RNA_def_pointer(func, "data", "AnyType", "", "Data from which to take property.");
304 RNA_def_property_flag(parm, PROP_REQUIRED|PROP_RNAPTR|PROP_NEVER_NULL);
305 parm= RNA_def_string(func, "property", "", 0, "", "Identifier of property in data.");
306 RNA_def_property_flag(parm, PROP_REQUIRED);
307 parm= RNA_def_pointer(func, "root", "ID", "", "ID-block from which path is evaluated from.");
308 RNA_def_property_flag(parm, PROP_REQUIRED|PROP_RNAPTR);
309 RNA_def_string(func, "text", "", 0, "", "Custom label to display in UI.");
311 func= RNA_def_function(srna, "template_modifier", "uiTemplateModifier");
312 RNA_def_function_flag(func, FUNC_USE_CONTEXT);
313 RNA_def_function_ui_description(func, "Layout . Generates the UI layout for modifiers.");
314 parm= RNA_def_pointer(func, "data", "Modifier", "", "Modifier data.");
315 RNA_def_property_flag(parm, PROP_REQUIRED|PROP_RNAPTR|PROP_NEVER_NULL);
316 parm= RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in.");
317 RNA_def_function_return(func, parm);
319 func= RNA_def_function(srna, "template_constraint", "uiTemplateConstraint");
320 RNA_def_function_ui_description(func, "Layout . Generates the UI layout for constraints.");
321 parm= RNA_def_pointer(func, "data", "Constraint", "", "Constraint data.");
322 RNA_def_property_flag(parm, PROP_REQUIRED|PROP_RNAPTR|PROP_NEVER_NULL);
323 parm= RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in.");
324 RNA_def_function_return(func, parm);
326 func= RNA_def_function(srna, "template_preview", "uiTemplatePreview");
327 RNA_def_function_ui_description(func, "Item. A preview window for materials, textures, lamps, etc.");
328 parm= RNA_def_pointer(func, "id", "ID", "", "ID datablock.");
329 RNA_def_property_flag(parm, PROP_REQUIRED);
330 RNA_def_boolean(func, "show_buttons", 1, "", "Show preview buttons?");
331 RNA_def_pointer(func, "parent", "ID", "", "ID datablock.");
332 RNA_def_pointer(func, "slot", "TextureSlot", "", "Texture slot.");
334 func= RNA_def_function(srna, "template_curve_mapping", "uiTemplateCurveMapping");
335 RNA_def_function_ui_description(func, "Item. A curve mapping widget used for e.g falloff curves for lamps.");
336 api_ui_item_rna_common(func);
337 RNA_def_enum(func, "type", curve_type_items, 0, "Type", "Type of curves to display.");
338 RNA_def_boolean(func, "levels", 0, "", "Show black/white levels.");
339 RNA_def_boolean(func, "brush", 0, "", "Show brush options.");
341 func= RNA_def_function(srna, "template_color_ramp", "uiTemplateColorRamp");
342 RNA_def_function_ui_description(func, "Item. A color ramp widget.");
343 api_ui_item_rna_common(func);
344 RNA_def_boolean(func, "expand", 0, "", "Expand button to show more detail.");
346 func= RNA_def_function(srna, "template_histogram", "uiTemplateHistogram");
347 RNA_def_function_ui_description(func, "Item. A histogramm widget to analyze imaga data.");
348 api_ui_item_rna_common(func);
350 func= RNA_def_function(srna, "template_waveform", "uiTemplateWaveform");
351 RNA_def_function_ui_description(func, "Item. A waveform widget to analyze imaga data.");
352 api_ui_item_rna_common(func);
354 func= RNA_def_function(srna, "template_vectorscope", "uiTemplateVectorscope");
355 RNA_def_function_ui_description(func, "Item. A vectorscope widget to analyze imaga data.");
356 api_ui_item_rna_common(func);
358 func= RNA_def_function(srna, "template_layers", "uiTemplateLayers");
359 api_ui_item_rna_common(func);
360 parm= RNA_def_pointer(func, "used_layers_data", "AnyType", "", "Data from which to take property.");
361 RNA_def_property_flag(parm, PROP_REQUIRED|PROP_RNAPTR);
362 parm= RNA_def_string(func, "used_layers_property", "", 0, "", "Identifier of property in data.");
363 RNA_def_property_flag(parm, PROP_REQUIRED);
364 parm= RNA_def_int(func, "active_layer", 0, 0, INT_MAX, "Active Layer", "", 0, INT_MAX);
365 RNA_def_property_flag(parm, PROP_REQUIRED);
367 func= RNA_def_function(srna, "template_color_wheel", "uiTemplateColorWheel");
368 RNA_def_function_ui_description(func, "Item. A color wheel widget to pick colors.");
369 api_ui_item_rna_common(func);
370 RNA_def_boolean(func, "value_slider", 0, "", "Display the value slider to the right of the color wheel");
371 RNA_def_boolean(func, "lock", 0, "", "Lock the color wheel display to value 1.0 regardless of actual color");
372 RNA_def_boolean(func, "lock_luminosity", 0, "", "Keep the color at its original vector length");
373 RNA_def_boolean(func, "cubic", 1, "", "Cubic saturation for picking values close to white");
375 func= RNA_def_function(srna, "template_image_layers", "uiTemplateImageLayers");
376 RNA_def_function_flag(func, FUNC_USE_CONTEXT);
377 parm= RNA_def_pointer(func, "image", "Image", "", "");
378 RNA_def_property_flag(parm, PROP_REQUIRED);
379 parm= RNA_def_pointer(func, "image_user", "ImageUser", "", "");
380 RNA_def_property_flag(parm, PROP_REQUIRED);
382 func= RNA_def_function(srna, "template_image", "uiTemplateImage");
383 RNA_def_function_ui_description(func, "Item(s). User interface for selecting images and their source paths.");
384 RNA_def_function_flag(func, FUNC_USE_CONTEXT);
385 api_ui_item_rna_common(func);
386 parm= RNA_def_pointer(func, "image_user", "ImageUser", "", "");
387 RNA_def_property_flag(parm, PROP_REQUIRED|PROP_RNAPTR);
388 RNA_def_boolean(func, "compact", 0, "", "Use more compact layout.");
390 func= RNA_def_function(srna, "template_list", "uiTemplateList");
391 RNA_def_function_ui_description(func, "Item. A list widget to display data. e.g. vertexgroups.");
392 RNA_def_function_flag(func, FUNC_USE_CONTEXT);
393 parm= RNA_def_pointer(func, "data", "AnyType", "", "Data from which to take property.");
394 RNA_def_property_flag(parm, PROP_REQUIRED|PROP_RNAPTR);
395 parm= RNA_def_string(func, "property", "", 0, "", "Identifier of property in data.");
396 RNA_def_property_flag(parm, PROP_REQUIRED);
397 parm= RNA_def_pointer(func, "active_data", "AnyType", "", "Data from which to take property for the active element.");
398 RNA_def_property_flag(parm, PROP_REQUIRED|PROP_RNAPTR|PROP_NEVER_NULL);
399 parm= RNA_def_string(func, "active_property", "", 0, "", "Identifier of property in data, for the active element.");
400 RNA_def_property_flag(parm, PROP_REQUIRED);
401 RNA_def_int(func, "rows", 5, 0, INT_MAX, "", "Number of rows to display.", 0, INT_MAX);
402 RNA_def_int(func, "maxrows", 5, 0, INT_MAX, "", "Maximum number of rows to display.", 0, INT_MAX);
403 RNA_def_enum(func, "type", list_type_items, 0, "Type", "Type of list to use.");
405 func= RNA_def_function(srna, "template_running_jobs", "uiTemplateRunningJobs");
406 RNA_def_function_flag(func, FUNC_USE_CONTEXT);
408 RNA_def_function(srna, "template_operator_search", "uiTemplateOperatorSearch");
410 func= RNA_def_function(srna, "template_header_3D", "uiTemplateHeader3D");
411 RNA_def_function_flag(func, FUNC_USE_CONTEXT);
413 func= RNA_def_function(srna, "template_reports_banner", "uiTemplateReportsBanner");
414 RNA_def_function_flag(func, FUNC_USE_CONTEXT);
416 func= RNA_def_function(srna, "introspect", "uiLayoutIntrospect");
417 parm= RNA_def_string(func, "string", "", 1024*1024, "Descr", "DESCR");
418 RNA_def_function_return(func, parm);