2 * ***** BEGIN GPL LICENSE BLOCK *****
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * The Original Code is Copyright (C) 2009 Blender Foundation.
19 * All rights reserved.
22 * Contributor(s): Blender Foundation
24 * ***** END GPL LICENSE BLOCK *****
27 /** \file blender/makesrna/intern/rna_ui_api.c
35 #include "BLI_utildefines.h"
37 #include "BLF_translation.h"
39 #include "RNA_define.h"
40 #include "RNA_enum_types.h"
42 #include "DNA_screen_types.h"
44 #include "UI_resources.h"
45 #include "UI_interface.h"
46 #include "UI_interface_icons.h"
48 #include "rna_internal.h"
50 #define DEF_ICON_BLANK_SKIP
51 #define DEF_ICON(name) {ICON_##name, (#name), 0, (#name), ""},
52 #define DEF_VICO(name) {VICO_##name, (#name), 0, (#name), ""},
53 EnumPropertyItem icon_items[] = {
55 {0, NULL, 0, NULL, NULL}
57 #undef DEF_ICON_BLANK_SKIP
63 static const char *rna_translate_ui_text(const char *text, const char *text_ctxt, StructRNA *type, PropertyRNA *prop,
66 /* Also return text if UI labels translation is disabled. */
67 if (!text || !text[0] || !translate || !BLF_translate_iface()) {
71 /* If a text_ctxt is specified, use it! */
72 if (text_ctxt && text_ctxt[0]) {
73 return BLF_pgettext(text_ctxt, text);
76 /* Else, if an RNA type or property is specified, use its context. */
78 /* XXX Disabled for now. Unfortunately, their is absolutely no way from py code to get the RNA struct corresponding
79 * to the 'data' (in functions like prop() & co), as this is pure runtime data. Hence, messages extraction
80 * script can't determine the correct context it should use for such 'text' messages...
81 * So for now, one have to explicitly specify the 'text_ctxt' when using prop() etc. functions,
82 * if default context is not suitable.
85 return BLF_pgettext(RNA_property_translation_context(prop), text);
91 return BLF_pgettext(RNA_struct_translation_context(type), text);
94 /* Else, default context! */
95 return BLF_pgettext(BLF_I18NCONTEXT_DEFAULT, text);
98 static void rna_uiItemR(uiLayout *layout, PointerRNA *ptr, const char *propname, const char *name, const char *text_ctxt,
99 int translate, int icon, int expand, int slider, int toggle, int icon_only, int event,
100 int full_event, int emboss, int index)
102 PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
106 RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
110 /* Get translated name (label). */
111 name = rna_translate_ui_text(name, text_ctxt, NULL, prop, translate);
113 flag |= (slider) ? UI_ITEM_R_SLIDER : 0;
114 flag |= (expand) ? UI_ITEM_R_EXPAND : 0;
115 flag |= (toggle) ? UI_ITEM_R_TOGGLE : 0;
116 flag |= (icon_only) ? UI_ITEM_R_ICON_ONLY : 0;
117 flag |= (event) ? UI_ITEM_R_EVENT : 0;
118 flag |= (full_event) ? UI_ITEM_R_FULL_EVENT : 0;
119 flag |= (emboss) ? 0 : UI_ITEM_R_NO_BG;
121 uiItemFullR(layout, ptr, prop, index, 0, flag, name, icon);
124 static void rna_uiItemMenuEnumR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, const char *name,
125 const char *text_ctxt, int translate, int icon)
127 PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
130 RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
134 /* Get translated name (label). */
135 name = rna_translate_ui_text(name, text_ctxt, NULL, prop, translate);
137 /* XXX This will search property again :( */
138 uiItemMenuEnumR(layout, ptr, propname, name, icon);
141 static void rna_uiItemEnumR_string(uiLayout *layout, struct PointerRNA *ptr, const char *propname, const char *value,
142 const char *name, const char *text_ctxt, int translate, int icon)
144 PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
147 RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
151 /* Get translated name (label). */
152 name = rna_translate_ui_text(name, text_ctxt, NULL, prop, translate);
154 /* XXX This will search property again :( */
155 uiItemEnumR_string(layout, ptr, propname, value, name, icon);
158 static void rna_uiItemPointerR(uiLayout *layout, struct PointerRNA *ptr, const char *propname,
159 struct PointerRNA *searchptr, const char *searchpropname,
160 const char *name, const char *text_ctxt, int translate, int icon)
162 PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
165 RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
169 /* Get translated name (label). */
170 name = rna_translate_ui_text(name, text_ctxt, NULL, prop, translate);
172 /* XXX This will search property again :( */
173 uiItemPointerR(layout, ptr, propname, searchptr, searchpropname, name, icon);
176 static PointerRNA rna_uiItemO(uiLayout *layout, const char *opname, const char *name, const char *text_ctxt,
177 int translate, int icon, int emboss)
182 ot = WM_operatortype_find(opname, 0); /* print error next */
183 if (!ot || !ot->srna) {
184 RNA_warning("%s '%s'", ot ? "unknown operator" : "operator missing srna", opname);
185 return PointerRNA_NULL;
188 /* Get translated name (label). */
189 name = rna_translate_ui_text(name, text_ctxt, ot->srna, NULL, translate);
191 flag = UI_ITEM_O_RETURN_PROPS;
192 flag |= (emboss) ? 0 : UI_ITEM_R_NO_BG;
194 return uiItemFullO_ptr(layout, ot, name, icon, NULL, uiLayoutGetOperatorContext(layout), flag);
197 static void rna_uiItemMenuEnumO(uiLayout *layout, bContext *C, const char *opname, const char *propname, const char *name,
198 const char *text_ctxt, int translate, int icon)
200 wmOperatorType *ot = WM_operatortype_find(opname, 0); /* print error next */
202 if (!ot || !ot->srna) {
203 RNA_warning("%s '%s'", ot ? "unknown operator" : "operator missing srna", opname);
207 /* Get translated name (label). */
208 name = rna_translate_ui_text(name, text_ctxt, ot->srna, NULL, translate);
210 /* XXX This will search operator again :( */
211 uiItemMenuEnumO(layout, C, opname, propname, name, icon);
214 static void rna_uiItemL(uiLayout *layout, const char *name, const char *text_ctxt, int translate,
215 int icon, int icon_value)
217 /* Get translated name (label). */
218 name = rna_translate_ui_text(name, text_ctxt, NULL, NULL, translate);
220 if (icon_value && !icon) {
224 uiItemL(layout, name, icon);
227 static void rna_uiItemM(uiLayout *layout, bContext *C, const char *menuname, const char *name, const char *text_ctxt,
228 int translate, int icon)
230 /* Get translated name (label). */
231 name = rna_translate_ui_text(name, text_ctxt, NULL, NULL, translate);
233 uiItemM(layout, C, menuname, name, icon);
236 static void rna_uiTemplateAnyID(uiLayout *layout, PointerRNA *ptr, const char *propname, const char *proptypename,
237 const char *name, const char *text_ctxt, int translate)
239 PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
242 RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
246 /* Get translated name (label). */
247 name = rna_translate_ui_text(name, text_ctxt, NULL, prop, translate);
249 /* XXX This will search property again :( */
250 uiTemplateAnyID(layout, ptr, propname, proptypename, name);
253 static void rna_uiTemplatePathBuilder(uiLayout *layout, PointerRNA *ptr, const char *propname, PointerRNA *root_ptr,
254 const char *name, const char *text_ctxt, int translate)
256 PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
259 RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
263 /* Get translated name (label). */
264 name = rna_translate_ui_text(name, text_ctxt, NULL, prop, translate);
266 /* XXX This will search property again :( */
267 uiTemplatePathBuilder(layout, ptr, propname, root_ptr, name);
270 static int rna_ui_get_rnaptr_icon(bContext *C, PointerRNA *ptr_icon)
272 return UI_rnaptr_icon_get(C, ptr_icon, RNA_struct_ui_icon(ptr_icon->type), false);
275 static const char *rna_ui_get_enum_name(bContext *C, PointerRNA *ptr, const char *propname, const char *identifier)
277 PropertyRNA *prop = NULL;
278 EnumPropertyItem *items = NULL, *item;
280 const char *name = "";
282 prop = RNA_struct_find_property(ptr, propname);
283 if (!prop || (RNA_property_type(prop) != PROP_ENUM)) {
284 RNA_warning("Property not found or not an enum: %s.%s", RNA_struct_identifier(ptr->type), propname);
288 RNA_property_enum_items_gettexted(C, ptr, prop, &items, NULL, &free);
291 for (item = items; item->identifier; item++) {
292 if (item->identifier[0] && strcmp(item->identifier, identifier) == 0) {
305 static const char *rna_ui_get_enum_description(bContext *C, PointerRNA *ptr, const char *propname,
306 const char *identifier)
308 PropertyRNA *prop = NULL;
309 EnumPropertyItem *items = NULL, *item;
311 const char *desc = "";
313 prop = RNA_struct_find_property(ptr, propname);
314 if (!prop || (RNA_property_type(prop) != PROP_ENUM)) {
315 RNA_warning("Property not found or not an enum: %s.%s", RNA_struct_identifier(ptr->type), propname);
319 RNA_property_enum_items_gettexted(C, ptr, prop, &items, NULL, &free);
322 for (item = items; item->identifier; item++) {
323 if (item->identifier[0] && strcmp(item->identifier, identifier) == 0) {
324 desc = item->description;
336 static int rna_ui_get_enum_icon(bContext *C, PointerRNA *ptr, const char *propname, const char *identifier)
338 PropertyRNA *prop = NULL;
339 EnumPropertyItem *items = NULL, *item;
341 int icon = ICON_NONE;
343 prop = RNA_struct_find_property(ptr, propname);
344 if (!prop || (RNA_property_type(prop) != PROP_ENUM)) {
345 RNA_warning("Property not found or not an enum: %s.%s", RNA_struct_identifier(ptr->type), propname);
349 RNA_property_enum_items(C, ptr, prop, &items, NULL, &free);
352 for (item = items; item->identifier; item++) {
353 if (item->identifier[0] && strcmp(item->identifier, identifier) == 0) {
368 static void api_ui_item_common_text(FunctionRNA *func)
370 RNA_def_string(func, "text", "", 0, "", "Override automatic text of the item");
371 RNA_def_string(func, "text_ctxt", "", 0, "", "Override automatic translation context of the given text");
372 RNA_def_boolean(func, "translate", true, "", "Translate the given text, when UI translation is enabled");
375 static void api_ui_item_common(FunctionRNA *func)
379 api_ui_item_common_text(func);
381 prop = RNA_def_property(func, "icon", PROP_ENUM, PROP_NONE);
382 RNA_def_property_enum_items(prop, icon_items);
383 RNA_def_property_ui_text(prop, "Icon", "Override automatic icon of the item");
386 static void api_ui_item_op(FunctionRNA *func)
389 parm = RNA_def_string(func, "operator", "", 0, "", "Identifier of the operator");
390 RNA_def_property_flag(parm, PROP_REQUIRED);
393 static void api_ui_item_op_common(FunctionRNA *func)
395 api_ui_item_op(func);
396 api_ui_item_common(func);
399 static void api_ui_item_rna_common(FunctionRNA *func)
403 parm = RNA_def_pointer(func, "data", "AnyType", "", "Data from which to take property");
404 RNA_def_property_flag(parm, PROP_REQUIRED | PROP_RNAPTR | PROP_NEVER_NULL);
405 parm = RNA_def_string(func, "property", "", 0, "", "Identifier of property in data");
406 RNA_def_property_flag(parm, PROP_REQUIRED);
409 void RNA_api_ui_layout(StructRNA *srna)
414 static EnumPropertyItem curve_type_items[] = {
415 {0, "NONE", 0, "None", ""},
416 {'v', "VECTOR", 0, "Vector", ""},
417 {'c', "COLOR", 0, "Color", ""},
418 {'h', "HUE", 0, "Hue", ""},
419 {0, NULL, 0, NULL, NULL}
422 static float node_socket_color_default[] = { 0.0f, 0.0f, 0.0f, 1.0f };
424 /* simple layout specifiers */
425 func = RNA_def_function(srna, "row", "uiLayoutRow");
426 parm = RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in");
427 RNA_def_function_return(func, parm);
428 RNA_def_function_ui_description(func,
429 "Sub-layout. Items placed in this sublayout are placed next to each other "
431 RNA_def_boolean(func, "align", false, "", "Align buttons to each other");
433 func = RNA_def_function(srna, "column", "uiLayoutColumn");
434 parm = RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in");
435 RNA_def_function_return(func, parm);
436 RNA_def_function_ui_description(func,
437 "Sub-layout. Items placed in this sublayout are placed under each other "
439 RNA_def_boolean(func, "align", false, "", "Align buttons to each other");
441 func = RNA_def_function(srna, "column_flow", "uiLayoutColumnFlow");
442 RNA_def_int(func, "columns", 0, 0, INT_MAX, "", "Number of columns, 0 is automatic", 0, INT_MAX);
443 parm = RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in");
444 RNA_def_function_return(func, parm);
445 RNA_def_boolean(func, "align", false, "", "Align buttons to each other");
448 func = RNA_def_function(srna, "box", "uiLayoutBox");
449 parm = RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in");
450 RNA_def_function_return(func, parm);
451 RNA_def_function_ui_description(func, "Sublayout (items placed in this sublayout are placed "
452 "under each other in a column and are surrounded by a box)");
455 func = RNA_def_function(srna, "split", "uiLayoutSplit");
456 parm = RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in");
457 RNA_def_function_return(func, parm);
458 RNA_def_float(func, "percentage", 0.0f, 0.0f, 1.0f, "Percentage", "Percentage of width to split at", 0.0f, 1.0f);
459 RNA_def_boolean(func, "align", false, "", "Align buttons to each other");
461 /* Icon of a rna pointer */
462 func = RNA_def_function(srna, "icon", "rna_ui_get_rnaptr_icon");
463 parm = RNA_def_int(func, "icon_value", ICON_NONE, 0, INT_MAX, "", "Icon identifier", 0, INT_MAX);
464 RNA_def_function_return(func, parm);
465 RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_USE_CONTEXT);
466 parm = RNA_def_pointer(func, "data", "AnyType", "", "Data from which to take the icon");
467 RNA_def_property_flag(parm, PROP_REQUIRED | PROP_RNAPTR | PROP_NEVER_NULL);
468 RNA_def_function_ui_description(func, "Return the custom icon for this data, "
469 "use it e.g. to get materials or texture icons");
471 /* UI name, description and icon of an enum item */
472 func = RNA_def_function(srna, "enum_item_name", "rna_ui_get_enum_name");
473 parm = RNA_def_string(func, "name", "", 0, "", "UI name of the enum item");
474 RNA_def_function_return(func, parm);
475 RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_USE_CONTEXT);
476 api_ui_item_rna_common(func);
477 parm = RNA_def_string(func, "identifier", "", 0, "", "Identifier of the enum item");
478 RNA_def_property_flag(parm, PROP_REQUIRED);
479 RNA_def_function_ui_description(func, "Return the UI name for this enum item");
481 func = RNA_def_function(srna, "enum_item_description", "rna_ui_get_enum_description");
482 parm = RNA_def_string(func, "description", "", 0, "", "UI description of the enum item");
483 RNA_def_function_return(func, parm);
484 RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_USE_CONTEXT);
485 api_ui_item_rna_common(func);
486 parm = RNA_def_string(func, "identifier", "", 0, "", "Identifier of the enum item");
487 RNA_def_property_flag(parm, PROP_REQUIRED);
488 RNA_def_function_ui_description(func, "Return the UI description for this enum item");
490 func = RNA_def_function(srna, "enum_item_icon", "rna_ui_get_enum_icon");
491 parm = RNA_def_int(func, "icon_value", ICON_NONE, 0, INT_MAX, "", "Icon identifier", 0, INT_MAX);
492 RNA_def_function_return(func, parm);
493 RNA_def_function_flag(func, FUNC_NO_SELF | FUNC_USE_CONTEXT);
494 api_ui_item_rna_common(func);
495 parm = RNA_def_string(func, "identifier", "", 0, "", "Identifier of the enum item");
496 RNA_def_property_flag(parm, PROP_REQUIRED);
497 RNA_def_function_ui_description(func, "Return the icon for this enum item");
500 func = RNA_def_function(srna, "prop", "rna_uiItemR");
501 RNA_def_function_ui_description(func, "Item. Exposes an RNA item and places it into the layout");
502 api_ui_item_rna_common(func);
503 api_ui_item_common(func);
504 RNA_def_boolean(func, "expand", false, "", "Expand button to show more detail");
505 RNA_def_boolean(func, "slider", false, "", "Use slider widget for numeric values");
506 RNA_def_boolean(func, "toggle", false, "", "Use toggle widget for boolean values");
507 RNA_def_boolean(func, "icon_only", false, "", "Draw only icons in buttons, no text");
508 RNA_def_boolean(func, "event", false, "", "Use button to input key events");
509 RNA_def_boolean(func, "full_event", false, "", "Use button to input full events including modifiers");
510 RNA_def_boolean(func, "emboss", true, "", "Draw the button itself, just the icon/text");
511 RNA_def_int(func, "index", -1, -2, INT_MAX, "",
512 "The index of this button, when set a single member of an array can be accessed, "
513 "when set to -1 all array members are used", -2, INT_MAX); /* RNA_NO_INDEX == -1 */
515 func = RNA_def_function(srna, "props_enum", "uiItemsEnumR");
516 api_ui_item_rna_common(func);
518 func = RNA_def_function(srna, "prop_menu_enum", "rna_uiItemMenuEnumR");
519 api_ui_item_rna_common(func);
520 api_ui_item_common(func);
522 func = RNA_def_function(srna, "prop_enum", "rna_uiItemEnumR_string");
523 api_ui_item_rna_common(func);
524 parm = RNA_def_string(func, "value", "", 0, "", "Enum property value");
525 RNA_def_property_flag(parm, PROP_REQUIRED);
526 api_ui_item_common(func);
528 func = RNA_def_function(srna, "prop_search", "rna_uiItemPointerR");
529 api_ui_item_rna_common(func);
530 parm = RNA_def_pointer(func, "search_data", "AnyType", "", "Data from which to take collection to search in");
531 RNA_def_property_flag(parm, PROP_REQUIRED | PROP_RNAPTR | PROP_NEVER_NULL);
532 parm = RNA_def_string(func, "search_property", "", 0, "", "Identifier of search collection property");
533 RNA_def_property_flag(parm, PROP_REQUIRED);
534 api_ui_item_common(func);
536 func = RNA_def_function(srna, "operator", "rna_uiItemO");
537 api_ui_item_op_common(func);
538 RNA_def_boolean(func, "emboss", true, "", "Draw the button itself, just the icon/text");
539 parm = RNA_def_pointer(func, "properties", "OperatorProperties", "",
540 "Operator properties to fill in, return when 'properties' is set to true");
541 RNA_def_property_flag(parm, PROP_REQUIRED | PROP_RNAPTR);
542 RNA_def_function_return(func, parm);
543 RNA_def_function_ui_description(func, "Item. Places a button into the layout to call an Operator");
545 func = RNA_def_function(srna, "operator_enum", "uiItemsEnumO");
546 parm = RNA_def_string(func, "operator", "", 0, "", "Identifier of the operator");
547 RNA_def_property_flag(parm, PROP_REQUIRED);
548 parm = RNA_def_string(func, "property", "", 0, "", "Identifier of property in operator");
549 RNA_def_property_flag(parm, PROP_REQUIRED);
551 func = RNA_def_function(srna, "operator_menu_enum", "rna_uiItemMenuEnumO");
552 RNA_def_function_flag(func, FUNC_USE_CONTEXT);
553 api_ui_item_op(func); /* cant use api_ui_item_op_common because property must come right after */
554 parm = RNA_def_string(func, "property", "", 0, "", "Identifier of property in operator");
555 RNA_def_property_flag(parm, PROP_REQUIRED);
556 api_ui_item_common(func);
558 /* useful in C but not in python */
561 func = RNA_def_function(srna, "operator_enum_single", "uiItemEnumO_string");
562 api_ui_item_op_common(func);
563 parm = RNA_def_string(func, "property", "", 0, "", "Identifier of property in operator");
564 RNA_def_property_flag(parm, PROP_REQUIRED);
565 parm = RNA_def_string(func, "value", "", 0, "", "Enum property value");
566 RNA_def_property_flag(parm, PROP_REQUIRED);
568 func = RNA_def_function(srna, "operator_boolean", "uiItemBooleanO");
569 api_ui_item_op_common(func);
570 parm = RNA_def_string(func, "property", "", 0, "", "Identifier of property in operator");
571 RNA_def_property_flag(parm, PROP_REQUIRED);
572 parm = RNA_def_boolean(func, "value", false, "", "Value of the property to call the operator with");
573 RNA_def_property_flag(parm, PROP_REQUIRED); */
575 func = RNA_def_function(srna, "operator_int", "uiItemIntO");
576 api_ui_item_op_common(func);
577 parm = RNA_def_string(func, "property", "", 0, "", "Identifier of property in operator");
578 RNA_def_property_flag(parm, PROP_REQUIRED);
579 parm = RNA_def_int(func, "value", 0, INT_MIN, INT_MAX, "",
580 "Value of the property to call the operator with", INT_MIN, INT_MAX);
581 RNA_def_property_flag(parm, PROP_REQUIRED); */
583 func = RNA_def_function(srna, "operator_float", "uiItemFloatO");
584 api_ui_item_op_common(func);
585 parm = RNA_def_string(func, "property", "", 0, "", "Identifier of property in operator");
586 RNA_def_property_flag(parm, PROP_REQUIRED);
587 parm = RNA_def_float(func, "value", 0, -FLT_MAX, FLT_MAX, "",
588 "Value of the property to call the operator with", -FLT_MAX, FLT_MAX);
589 RNA_def_property_flag(parm, PROP_REQUIRED); */
591 func = RNA_def_function(srna, "operator_string", "uiItemStringO");
592 api_ui_item_op_common(func);
593 parm = RNA_def_string(func, "property", "", 0, "", "Identifier of property in operator");
594 RNA_def_property_flag(parm, PROP_REQUIRED);
595 parm = RNA_def_string(func, "value", "", 0, "", "Value of the property to call the operator with");
596 RNA_def_property_flag(parm, PROP_REQUIRED);
599 func = RNA_def_function(srna, "label", "rna_uiItemL");
600 RNA_def_function_ui_description(func, "Item. Display text and/or icon in the layout");
601 api_ui_item_common(func);
602 parm = RNA_def_property(func, "icon_value", PROP_INT, PROP_UNSIGNED);
603 RNA_def_property_ui_text(parm, "Icon Value",
604 "Override automatic icon of the item "
605 "(use it e.g. with custom material icons returned by icon()...)");
607 func = RNA_def_function(srna, "menu", "rna_uiItemM");
608 RNA_def_function_flag(func, FUNC_USE_CONTEXT);
609 parm = RNA_def_string(func, "menu", "", 0, "", "Identifier of the menu");
610 api_ui_item_common(func);
611 RNA_def_property_flag(parm, PROP_REQUIRED);
613 func = RNA_def_function(srna, "separator", "uiItemS");
614 RNA_def_function_ui_description(func, "Item. Inserts empty space into the layout between items");
617 func = RNA_def_function(srna, "context_pointer_set", "uiLayoutSetContextPointer");
618 parm = RNA_def_string(func, "name", "", 0, "Name", "Name of entry in the context");
619 RNA_def_property_flag(parm, PROP_REQUIRED);
620 parm = RNA_def_pointer(func, "data", "AnyType", "", "Pointer to put in context");
621 RNA_def_property_flag(parm, PROP_REQUIRED | PROP_RNAPTR);
624 func = RNA_def_function(srna, "template_header", "uiTemplateHeader");
625 RNA_def_function_flag(func, FUNC_USE_CONTEXT);
626 RNA_def_boolean(func, "menus", true, "", "The header has menus, and should show menu expander");
628 func = RNA_def_function(srna, "template_ID", "uiTemplateID");
629 RNA_def_function_flag(func, FUNC_USE_CONTEXT);
630 api_ui_item_rna_common(func);
631 RNA_def_string(func, "new", "", 0, "", "Operator identifier to create a new ID block");
632 RNA_def_string(func, "open", "", 0, "", "Operator identifier to open a file for creating a new ID block");
633 RNA_def_string(func, "unlink", "", 0, "", "Operator identifier to unlink the ID block");
635 func = RNA_def_function(srna, "template_ID_preview", "uiTemplateIDPreview");
636 RNA_def_function_flag(func, FUNC_USE_CONTEXT);
637 api_ui_item_rna_common(func);
638 RNA_def_string(func, "new", "", 0, "", "Operator identifier to create a new ID block");
639 RNA_def_string(func, "open", "", 0, "", "Operator identifier to open a file for creating a new ID block");
640 RNA_def_string(func, "unlink", "", 0, "", "Operator identifier to unlink the ID block");
641 RNA_def_int(func, "rows", 0, 0, INT_MAX, "Number of thumbnail preview rows to display", "", 0, INT_MAX);
642 RNA_def_int(func, "cols", 0, 0, INT_MAX, "Number of thumbnail preview columns to display", "", 0, INT_MAX);
644 func = RNA_def_function(srna, "template_any_ID", "rna_uiTemplateAnyID");
645 parm = RNA_def_pointer(func, "data", "AnyType", "", "Data from which to take property");
646 RNA_def_property_flag(parm, PROP_REQUIRED | PROP_RNAPTR | PROP_NEVER_NULL);
647 parm = RNA_def_string(func, "property", "", 0, "", "Identifier of property in data");
648 RNA_def_property_flag(parm, PROP_REQUIRED);
649 parm = RNA_def_string(func, "type_property", "", 0, "",
650 "Identifier of property in data giving the type of the ID-blocks to use");
651 RNA_def_property_flag(parm, PROP_REQUIRED);
652 api_ui_item_common_text(func);
654 func = RNA_def_function(srna, "template_path_builder", "rna_uiTemplatePathBuilder");
655 parm = RNA_def_pointer(func, "data", "AnyType", "", "Data from which to take property");
656 RNA_def_property_flag(parm, PROP_REQUIRED | PROP_RNAPTR | PROP_NEVER_NULL);
657 parm = RNA_def_string(func, "property", "", 0, "", "Identifier of property in data");
658 RNA_def_property_flag(parm, PROP_REQUIRED);
659 parm = RNA_def_pointer(func, "root", "ID", "", "ID-block from which path is evaluated from");
660 RNA_def_property_flag(parm, PROP_REQUIRED | PROP_RNAPTR);
661 api_ui_item_common_text(func);
663 func = RNA_def_function(srna, "template_modifier", "uiTemplateModifier");
664 RNA_def_function_flag(func, FUNC_USE_CONTEXT);
665 RNA_def_function_ui_description(func, "Layout . Generates the UI layout for modifiers");
666 parm = RNA_def_pointer(func, "data", "Modifier", "", "Modifier data");
667 RNA_def_property_flag(parm, PROP_REQUIRED | PROP_RNAPTR | PROP_NEVER_NULL);
668 parm = RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in");
669 RNA_def_function_return(func, parm);
671 func = RNA_def_function(srna, "template_constraint", "uiTemplateConstraint");
672 RNA_def_function_ui_description(func, "Layout . Generates the UI layout for constraints");
673 parm = RNA_def_pointer(func, "data", "Constraint", "", "Constraint data");
674 RNA_def_property_flag(parm, PROP_REQUIRED | PROP_RNAPTR | PROP_NEVER_NULL);
675 parm = RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in");
676 RNA_def_function_return(func, parm);
678 func = RNA_def_function(srna, "template_preview", "uiTemplatePreview");
679 RNA_def_function_ui_description(func, "Item. A preview window for materials, textures, lamps, etc");
680 parm = RNA_def_pointer(func, "id", "ID", "", "ID datablock");
681 RNA_def_property_flag(parm, PROP_REQUIRED);
682 RNA_def_boolean(func, "show_buttons", true, "", "Show preview buttons?");
683 RNA_def_pointer(func, "parent", "ID", "", "ID datablock");
684 RNA_def_pointer(func, "slot", "TextureSlot", "", "Texture slot");
686 func = RNA_def_function(srna, "template_curve_mapping", "uiTemplateCurveMapping");
687 RNA_def_function_ui_description(func, "Item. A curve mapping widget used for e.g falloff curves for lamps");
688 api_ui_item_rna_common(func);
689 RNA_def_enum(func, "type", curve_type_items, 0, "Type", "Type of curves to display");
690 RNA_def_boolean(func, "levels", false, "", "Show black/white levels");
691 RNA_def_boolean(func, "brush", false, "", "Show brush options");
693 func = RNA_def_function(srna, "template_color_ramp", "uiTemplateColorRamp");
694 RNA_def_function_ui_description(func, "Item. A color ramp widget");
695 api_ui_item_rna_common(func);
696 RNA_def_boolean(func, "expand", false, "", "Expand button to show more detail");
698 func = RNA_def_function(srna, "template_icon_view", "uiTemplateIconView");
699 RNA_def_function_ui_description(func, "Enum. Large widget showing Icon previews");
700 api_ui_item_rna_common(func);
702 func = RNA_def_function(srna, "template_histogram", "uiTemplateHistogram");
703 RNA_def_function_ui_description(func, "Item. A histogramm widget to analyze imaga data");
704 api_ui_item_rna_common(func);
706 func = RNA_def_function(srna, "template_waveform", "uiTemplateWaveform");
707 RNA_def_function_ui_description(func, "Item. A waveform widget to analyze imaga data");
708 api_ui_item_rna_common(func);
710 func = RNA_def_function(srna, "template_vectorscope", "uiTemplateVectorscope");
711 RNA_def_function_ui_description(func, "Item. A vectorscope widget to analyze imaga data");
712 api_ui_item_rna_common(func);
714 func = RNA_def_function(srna, "template_layers", "uiTemplateLayers");
715 api_ui_item_rna_common(func);
716 parm = RNA_def_pointer(func, "used_layers_data", "AnyType", "", "Data from which to take property");
717 RNA_def_property_flag(parm, PROP_REQUIRED | PROP_RNAPTR);
718 parm = RNA_def_string(func, "used_layers_property", "", 0, "", "Identifier of property in data");
719 RNA_def_property_flag(parm, PROP_REQUIRED);
720 parm = RNA_def_int(func, "active_layer", 0, 0, INT_MAX, "Active Layer", "", 0, INT_MAX);
721 RNA_def_property_flag(parm, PROP_REQUIRED);
723 func = RNA_def_function(srna, "template_color_picker", "uiTemplateColorPicker");
724 RNA_def_function_ui_description(func, "Item. A color wheel widget to pick colors");
725 api_ui_item_rna_common(func);
726 RNA_def_boolean(func, "value_slider", false, "", "Display the value slider to the right of the color wheel");
727 RNA_def_boolean(func, "lock", false, "", "Lock the color wheel display to value 1.0 regardless of actual color");
728 RNA_def_boolean(func, "lock_luminosity", false, "", "Keep the color at its original vector length");
729 RNA_def_boolean(func, "cubic", true, "", "Cubic saturation for picking values close to white");
731 func = RNA_def_function(srna, "template_image_layers", "uiTemplateImageLayers");
732 RNA_def_function_flag(func, FUNC_USE_CONTEXT);
733 parm = RNA_def_pointer(func, "image", "Image", "", "");
734 RNA_def_property_flag(parm, PROP_REQUIRED);
735 parm = RNA_def_pointer(func, "image_user", "ImageUser", "", "");
736 RNA_def_property_flag(parm, PROP_REQUIRED);
738 func = RNA_def_function(srna, "template_image", "uiTemplateImage");
739 RNA_def_function_ui_description(func, "Item(s). User interface for selecting images and their source paths");
740 RNA_def_function_flag(func, FUNC_USE_CONTEXT);
741 api_ui_item_rna_common(func);
742 parm = RNA_def_pointer(func, "image_user", "ImageUser", "", "");
743 RNA_def_property_flag(parm, PROP_REQUIRED | PROP_RNAPTR | PROP_NEVER_NULL);
744 RNA_def_boolean(func, "compact", false, "", "Use more compact layout");
746 func = RNA_def_function(srna, "template_image_settings", "uiTemplateImageSettings");
747 RNA_def_function_ui_description(func, "User interface for setting image format options");
748 parm = RNA_def_pointer(func, "image_settings", "ImageFormatSettings", "", "");
749 RNA_def_property_flag(parm, PROP_REQUIRED | PROP_RNAPTR | PROP_NEVER_NULL);
750 RNA_def_boolean(func, "color_management", false, "", "Show color management settings");
752 func = RNA_def_function(srna, "template_movieclip", "uiTemplateMovieClip");
753 RNA_def_function_ui_description(func, "Item(s). User interface for selecting movie clips and their source paths");
754 RNA_def_function_flag(func, FUNC_USE_CONTEXT);
755 api_ui_item_rna_common(func);
756 RNA_def_boolean(func, "compact", false, "", "Use more compact layout");
758 func = RNA_def_function(srna, "template_track", "uiTemplateTrack");
759 RNA_def_function_ui_description(func, "Item. A movie-track widget to preview tracking image.");
760 api_ui_item_rna_common(func);
762 func = RNA_def_function(srna, "template_marker", "uiTemplateMarker");
763 RNA_def_function_ui_description(func, "Item. A widget to control single marker settings.");
764 api_ui_item_rna_common(func);
765 parm = RNA_def_pointer(func, "clip_user", "MovieClipUser", "", "");
766 RNA_def_property_flag(parm, PROP_REQUIRED | PROP_RNAPTR | PROP_NEVER_NULL);
767 parm = RNA_def_pointer(func, "track", "MovieTrackingTrack", "", "");
768 RNA_def_property_flag(parm, PROP_REQUIRED | PROP_RNAPTR | PROP_NEVER_NULL);
769 RNA_def_boolean(func, "compact", false, "", "Use more compact layout");
771 func = RNA_def_function(srna, "template_movieclip_information", "uiTemplateMovieclipInformation");
772 RNA_def_function_ui_description(func, "Item. Movie clip information data.");
773 api_ui_item_rna_common(func);
774 parm = RNA_def_pointer(func, "clip_user", "MovieClipUser", "", "");
775 RNA_def_property_flag(parm, PROP_REQUIRED | PROP_RNAPTR | PROP_NEVER_NULL);
777 func = RNA_def_function(srna, "template_list", "uiTemplateList");
778 RNA_def_function_ui_description(func, "Item. A list widget to display data, e.g. vertexgroups.");
779 RNA_def_function_flag(func, FUNC_USE_CONTEXT);
780 parm = RNA_def_string(func, "listtype_name", "", 0, "", "Identifier of the list type to use");
781 RNA_def_property_flag(parm, PROP_REQUIRED);
782 parm = RNA_def_string(func, "list_id", "", 0, "",
783 "Identifier of this list widget (mandatory when using default \"" UI_UL_DEFAULT_CLASS_NAME
785 "If this is set, the uilist gets a custom ID, otherwise it takes the "
786 "name of the class used to define the uilist (for example, if the "
787 "class name is \"OBJECT_UL_vgroups\", and list_id is not set by the "
788 "script, then bl_idname = \"OBJECT_UL_vgroups\")");
789 parm = RNA_def_pointer(func, "dataptr", "AnyType", "", "Data from which to take the Collection property");
790 RNA_def_property_flag(parm, PROP_REQUIRED | PROP_RNAPTR);
791 parm = RNA_def_string(func, "propname", "", 0, "", "Identifier of the Collection property in data");
792 RNA_def_property_flag(parm, PROP_REQUIRED);
793 parm = RNA_def_pointer(func, "active_dataptr", "AnyType", "",
794 "Data from which to take the integer property, index of the active item");
795 RNA_def_property_flag(parm, PROP_REQUIRED | PROP_RNAPTR | PROP_NEVER_NULL);
796 parm = RNA_def_string(func, "active_propname", "", 0, "",
797 "Identifier of the integer property in active_data, index of the active item");
798 RNA_def_property_flag(parm, PROP_REQUIRED);
799 RNA_def_int(func, "rows", 5, 0, INT_MAX, "", "Number of rows to display", 0, INT_MAX);
800 RNA_def_int(func, "maxrows", 5, 0, INT_MAX, "", "Maximum number of rows to display", 0, INT_MAX);
801 RNA_def_enum(func, "type", uilist_layout_type_items, UILST_LAYOUT_DEFAULT, "Type", "Type of layout to use");
803 func = RNA_def_function(srna, "template_running_jobs", "uiTemplateRunningJobs");
804 RNA_def_function_flag(func, FUNC_USE_CONTEXT);
806 RNA_def_function(srna, "template_operator_search", "uiTemplateOperatorSearch");
808 func = RNA_def_function(srna, "template_header_3D", "uiTemplateHeader3D");
809 RNA_def_function_flag(func, FUNC_USE_CONTEXT);
811 func = RNA_def_function(srna, "template_edit_mode_selection", "uiTemplateEditModeSelection");
812 RNA_def_function_flag(func, FUNC_USE_CONTEXT);
814 func = RNA_def_function(srna, "template_reports_banner", "uiTemplateReportsBanner");
815 RNA_def_function_flag(func, FUNC_USE_CONTEXT);
817 func = RNA_def_function(srna, "template_node_link", "uiTemplateNodeLink");
818 parm = RNA_def_pointer(func, "ntree", "NodeTree", "", "");
819 RNA_def_property_flag(parm, PROP_REQUIRED);
820 parm = RNA_def_pointer(func, "node", "Node", "", "");
821 RNA_def_property_flag(parm, PROP_REQUIRED);
822 parm = RNA_def_pointer(func, "socket", "NodeSocket", "", "");
823 RNA_def_property_flag(parm, PROP_REQUIRED);
825 func = RNA_def_function(srna, "template_node_view", "uiTemplateNodeView");
826 RNA_def_function_flag(func, FUNC_USE_CONTEXT);
827 parm = RNA_def_pointer(func, "ntree", "NodeTree", "", "");
828 RNA_def_property_flag(parm, PROP_REQUIRED);
829 parm = RNA_def_pointer(func, "node", "Node", "", "");
830 RNA_def_property_flag(parm, PROP_REQUIRED);
831 parm = RNA_def_pointer(func, "socket", "NodeSocket", "", "");
832 RNA_def_property_flag(parm, PROP_REQUIRED);
834 func = RNA_def_function(srna, "template_texture_user", "uiTemplateTextureUser");
835 RNA_def_function_flag(func, FUNC_USE_CONTEXT);
837 func = RNA_def_function(srna, "template_keymap_item_properties", "uiTemplateKeymapItemProperties");
838 parm = RNA_def_pointer(func, "item", "KeyMapItem", "", "");
839 RNA_def_property_flag(parm, PROP_REQUIRED | PROP_RNAPTR | PROP_NEVER_NULL);
841 func = RNA_def_function(srna, "template_component_menu", "uiTemplateComponentMenu");
842 RNA_def_function_ui_description(func, "Item. Display expanded property in a popup menu");
843 parm = RNA_def_pointer(func, "data", "AnyType", "", "Data from which to take property");
844 RNA_def_property_flag(parm, PROP_REQUIRED | PROP_RNAPTR);
845 parm = RNA_def_string(func, "property", "", 0, "", "Identifier of property in data");
846 RNA_def_property_flag(parm, PROP_REQUIRED);
847 RNA_def_string(func, "name", "", 0, "", "");
849 func = RNA_def_function(srna, "introspect", "uiLayoutIntrospect");
850 parm = RNA_def_string(func, "string", "", 1024 * 1024, "Descr", "DESCR");
851 RNA_def_function_return(func, parm);
853 /* color management templates */
854 func = RNA_def_function(srna, "template_colorspace_settings", "uiTemplateColorspaceSettings");
855 RNA_def_function_ui_description(func, "Item. A widget to control input color space settings.");
856 api_ui_item_rna_common(func);
858 func = RNA_def_function(srna, "template_colormanaged_view_settings", "uiTemplateColormanagedViewSettings");
859 RNA_def_function_ui_description(func, "Item. A widget to control color managed view settings settings.");
860 RNA_def_function_flag(func, FUNC_USE_CONTEXT);
861 api_ui_item_rna_common(func);
862 /* RNA_def_boolean(func, "show_global_settings", false, "", "Show widgets to control global color management settings"); */
864 /* node socket icon */
865 func = RNA_def_function(srna, "template_node_socket", "uiTemplateNodeSocket");
866 RNA_def_function_ui_description(func, "Node Socket Icon");
867 RNA_def_function_flag(func, FUNC_USE_CONTEXT);
868 RNA_def_float_array(func, "color", 4, node_socket_color_default, 0.0f, 1.0f, "Color", "", 0.0f, 1.0f);