Blender V5.3
rna_ui_api.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2009 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include <cstdlib>
10
11#include "RNA_define.hh"
12#include "RNA_enum_types.hh"
13
14#include "DNA_screen_types.h"
15
16#include "UI_interface.hh"
17#include "UI_interface_c.hh"
19#include "UI_resources.hh"
20
21#include "rna_internal.hh"
22
23#define DEF_ICON(name) {ICON_##name, (#name), 0, (#name), ""},
24#define DEF_ICON_VECTOR(name) {ICON_##name, (#name), 0, (#name), ""},
25#define DEF_ICON_COLOR(name) {ICON_##name, (#name), 0, (#name), ""},
26#define DEF_ICON_BLANK(name)
27
28namespace blender {
29
31#include "UI_icons.hh"
32
33 {0, nullptr, 0, nullptr, nullptr},
34};
35
38 "VERTICAL",
39 0,
40 "Vertical",
41 "Draw popup panel above or below the button"},
43 "HORIZONTAL",
44 0,
45 "Horizontal",
46 "Draw popup panel to the side of the button"},
47 {0, nullptr, 0, nullptr, nullptr},
48};
49
51 {int(ui::RecentFilesFilter::All), "ALL", 0, "All", "All recent files"},
53 "PROJECT",
54 0,
55 "Project",
56 "Recent files in the active project"},
58 "OTHER",
59 0,
60 "Other",
61 "Recent files not in the active project"},
62 {0, nullptr, 0, nullptr, nullptr},
63};
64} // namespace blender
65
66enum class TextAlignAnchor : int {
67 Left = 0,
68 Right = 1,
69};
70
71#ifdef RNA_RUNTIME
72
73# include "BLT_translation.hh"
74
75# include "DNA_asset_types.h"
76
77# include "BKE_report.hh"
78
79# include "ED_asset_filter.hh"
80# include "ED_geometry.hh"
81# include "ED_node.hh"
82# include "ED_object.hh"
83
84# include "WM_api.hh"
85
86namespace blender {
87
88using ui::Layout;
89
90std::optional<StringRefNull> rna_translate_ui_text(
91 const char *text, const char *text_ctxt, StructRNA *type, PropertyRNA *prop, bool translate)
92{
93 if (!text) {
94 return std::nullopt;
95 }
96 /* Also return text if UI labels translation is disabled. */
97 if (!text[0] || !translate || !BLT_translate_iface()) {
98 return text;
99 }
100
101 /* If a text_ctxt is specified, use it! */
102 if (text_ctxt && text_ctxt[0]) {
103 return BLT_pgettext(text_ctxt, text);
104 }
105
106 /* Else, if an RNA type or property is specified, use its context. */
107# if 0
108 /* XXX Disabled for now. Unfortunately, their is absolutely no way from py code to get the RNA
109 * struct corresponding to the 'data' (in functions like prop() & co),
110 * as this is pure runtime data. Hence, messages extraction script can't determine the
111 * correct context it should use for such 'text' messages...
112 * So for now, one have to explicitly specify the 'text_ctxt' when using prop() etc.
113 * functions, if default context is not suitable.
114 */
115 if (prop) {
117 }
118# else
119 (void)prop;
120# endif
121 if (type) {
123 }
124
125 /* Else, default context! */
127}
128
129static void rna_uiItemTextBox(Layout *layout,
130 bContext *C,
131 PointerRNA *ptr,
132 const char *propname,
133 const char *name,
134 const char *text_ctxt,
135 bool translate,
136 const int initial_visible_lines,
137 const char *placeholder)
138{
139 PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
140
141 if (!prop) {
142 RNA_warning_bare("UILayout.textbox(): property not found: %s.%s",
143 RNA_struct_identifier(ptr->type),
144 propname);
145 return;
146 }
147
148 std::optional<StringRefNull> text = rna_translate_ui_text(
149 name, text_ctxt, nullptr, prop, translate);
150
151 std::optional<StringRefNull> placeholder_opt = std::nullopt;
152 if (placeholder) {
153 placeholder_opt = rna_translate_ui_text(placeholder, text_ctxt, nullptr, prop, translate);
154 }
155 layout->textbox(C, ptr, propname, text, placeholder_opt, initial_visible_lines);
156}
157
158static void rna_uiItemTextBoxWithState(Layout *layout,
159 PointerRNA *ptr,
160 const char *propname,
161 const char *name,
162 const char *text_ctxt,
163 bool translate,
164 PointerRNA *state_ptr,
165 const char *placeholder)
166{
167 PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
168
169 if (!prop) {
170 RNA_warning_bare("UILayout.textbox_with_state(): property not found: %s.%s",
171 RNA_struct_identifier(ptr->type),
172 propname);
173 return;
174 }
175
176 std::optional<StringRefNull> text = rna_translate_ui_text(
177 name, text_ctxt, nullptr, prop, translate);
178
179 std::optional<StringRefNull> placeholder_opt = std::nullopt;
180
181 if (placeholder) {
182 placeholder_opt = rna_translate_ui_text(placeholder, text_ctxt, nullptr, prop, translate);
183 }
184
185 layout->textbox_with_state(
186 ptr, propname, state_ptr->data_as<TextboxState>(), text, placeholder_opt);
187}
188
189static void rna_uiItemR(Layout *layout,
190 PointerRNA *ptr,
191 const char *propname,
192 const char *name,
193 const char *text_ctxt,
194 bool translate,
195 int icon,
196 const char *placeholder,
197 bool expand,
198 bool slider,
199 int toggle,
200 bool icon_only,
201 bool event,
202 bool full_event,
203 bool emboss,
204 int index,
205 int icon_value,
206 bool invert_checkbox,
207 int align)
208{
209 PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
211
212 if (!prop) {
214 "UILayout.prop(): property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
215 return;
216 }
217
218 if (icon_value && !icon) {
219 icon = icon_value;
220 }
221
222 /* Get translated name (label). */
223 std::optional<StringRefNull> text = rna_translate_ui_text(
224 name, text_ctxt, nullptr, prop, translate);
225 std::optional<StringRefNull> placeholder_str = rna_translate_ui_text(
226 placeholder, text_ctxt, nullptr, prop, translate);
227
228 if (slider) {
229 flag |= ui::ITEM_R_SLIDER;
230 }
231 if (expand) {
232 flag |= ui::ITEM_R_EXPAND;
233 }
234
235 if (toggle == 1) {
236 flag |= ui::ITEM_R_TOGGLE;
237 }
238 else if (toggle == 0) {
239 flag |= ui::ITEM_R_ICON_NEVER;
240 }
241
242 if (icon_only) {
243 flag |= ui::ITEM_R_ICON_ONLY;
244 }
245 if (event) {
246 flag |= ui::ITEM_R_EVENT;
247 }
248 if (full_event) {
249 flag |= ui::ITEM_R_FULL_EVENT;
250 }
251 if (emboss == false) {
252 flag |= ui::ITEM_R_NO_BG;
253 }
254 if (invert_checkbox) {
256 }
257 if (align == int(TextAlignAnchor::Right)) {
258 flag |= ui::ITEM_R_TEXT_RIGHT;
259 }
260
261 layout->prop(ptr, prop, index, 0, flag, text, icon, placeholder_str);
262}
263
264static void rna_uiItemR_with_popover(Layout *layout,
265 PointerRNA *ptr,
266 const char *propname,
267 const char *name,
268 const char *text_ctxt,
269 bool translate,
270 int icon,
271 bool icon_only,
272 const char *panel_type)
273{
274 PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
275
276 if (!prop) {
277 RNA_warning_bare("UILayout.prop_with_popover(): property not found: %s.%s",
278 RNA_struct_identifier(ptr->type),
279 propname);
280 return;
281 }
282 if ((RNA_property_type(prop) != PROP_ENUM) &&
284 {
285 RNA_warning_bare("UILayout.prop_with_popover(): property is not an enum or color: %s.%s",
286 RNA_struct_identifier(ptr->type),
287 propname);
288 return;
289 }
291 if (icon_only) {
292 flag |= ui::ITEM_R_ICON_ONLY;
293 }
294
295 /* Get translated name (label). */
296 std::optional<StringRefNull> text = rna_translate_ui_text(
297 name, text_ctxt, nullptr, prop, translate);
298 layout->prop_with_popover(ptr, prop, -1, 0, flag, text, icon, panel_type);
299}
300
301static void rna_uiItemR_with_menu(Layout *layout,
302 PointerRNA *ptr,
303 const char *propname,
304 const char *name,
305 const char *text_ctxt,
306 bool translate,
307 int icon,
308 bool icon_only,
309 const char *menu_type)
310{
311 PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
312
313 if (!prop) {
314 RNA_warning_bare("UILayout.prop_with_menu(): property not found: %s.%s",
315 RNA_struct_identifier(ptr->type),
316 propname);
317 return;
318 }
319 if (RNA_property_type(prop) != PROP_ENUM) {
320 RNA_warning_bare("UILayout.prop_with_menu(): property is not an enum: %s.%s",
321 RNA_struct_identifier(ptr->type),
322 propname);
323 return;
324 }
326 if (icon_only) {
327 flag |= ui::ITEM_R_ICON_ONLY;
328 }
329
330 /* Get translated name (label). */
331 std::optional<StringRefNull> text = rna_translate_ui_text(
332 name, text_ctxt, nullptr, prop, translate);
333 layout->prop_with_menu(ptr, prop, -1, 0, flag, text, icon, menu_type);
334}
335
336static void rna_uiItemMenuEnumR(Layout *layout,
337 PointerRNA *ptr,
338 const char *propname,
339 const char *name,
340 const char *text_ctxt,
341 bool translate,
342 int icon)
343{
344 PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
345
346 if (!prop) {
347 RNA_warning_bare("UILayout.prop_menu_enum(): property not found: %s.%s",
348 RNA_struct_identifier(ptr->type),
349 propname);
350 return;
351 }
352
353 /* Get translated name (label). */
354 std::optional<StringRefNull> text = rna_translate_ui_text(
355 name, text_ctxt, nullptr, prop, translate);
356 layout->prop_menu_enum(ptr, prop, text, icon);
357}
358
359static void rna_uiItemTabsEnumR(Layout *layout,
360 bContext *C,
361 PointerRNA *ptr,
362 const char *propname,
363 PointerRNA *ptr_highlight,
364 const char *propname_highlight,
365 bool icon_only,
366 int expand_as)
367{
368 PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
369
370 if (!prop) {
371 RNA_warning_bare("UILayout.prop_tabs_enum(): property not found: %s.%s",
372 RNA_struct_identifier(ptr->type),
373 propname);
374 return;
375 }
376 if (RNA_property_type(prop) != PROP_ENUM) {
377 RNA_warning_bare("UILayout.prop_tabs_enum(): property is not an enum: %s.%s",
378 RNA_struct_identifier(ptr->type),
379 propname);
380 return;
381 }
382
383 /* Get the highlight property used to gray out some of the tabs. */
384 PropertyRNA *prop_highlight = nullptr;
385 if (*ptr_highlight) {
386 prop_highlight = RNA_struct_find_property(ptr_highlight, propname_highlight);
387 if (!prop_highlight) {
388 RNA_warning_bare("UILayout.prop_tabs_enum(): property not found: %s.%s",
389 RNA_struct_identifier(ptr_highlight->type),
390 propname_highlight);
391 return;
392 }
393 if (RNA_property_type(prop_highlight) != PROP_BOOLEAN) {
394 RNA_warning_bare("UILayout.prop_tabs_enum(): property is not a boolean: %s.%s",
395 RNA_struct_identifier(ptr_highlight->type),
396 propname_highlight);
397 return;
398 }
399 if (!RNA_property_array_check(prop_highlight)) {
400 RNA_warning_bare("UILayout.prop_tabs_enum(): property is not an array: %s.%s",
401 RNA_struct_identifier(ptr_highlight->type),
402 propname_highlight);
403 return;
404 }
405 }
406
407 layout->prop_tabs_enum(
408 C, ptr, prop, ptr_highlight, prop_highlight, icon_only, ui::EnumTabExpand(expand_as));
409}
410
411static void rna_uiItemEnumR_string(Layout *layout,
412 PointerRNA *ptr,
413 const char *propname,
414 const char *value,
415 const char *name,
416 const char *text_ctxt,
417 bool translate,
418 int icon)
419{
420 PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
421
422 if (!prop) {
423 RNA_warning_bare("UILayout.prop_enum(): property not found: %s.%s",
424 RNA_struct_identifier(ptr->type),
425 propname);
426 return;
427 }
428
429 /* Get translated name (label). */
430 std::optional<StringRefNull> text = rna_translate_ui_text(
431 name, text_ctxt, nullptr, prop, translate);
432
433 layout->prop_enum(ptr, prop, value, text, icon);
434}
435
436static void rna_uiItemsEnumR(Layout *layout, PointerRNA *ptr, const char *propname)
437{
438 layout->props_enum(ptr, propname);
439}
440
441static void rna_uiItemPointerR(Layout *layout,
442 PointerRNA *ptr,
443 const char *propname,
444 PointerRNA *searchptr,
445 const char *searchpropname,
446 const char *name,
447 const char *text_ctxt,
448 bool translate,
449 int icon,
450 const bool results_are_suggestions,
451 const char *item_searchpropname)
452{
453 PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
454 if (!prop) {
455 RNA_warning_bare("UILayout.prop_search(): property not found: %s.%s",
456 RNA_struct_identifier(ptr->type),
457 propname);
458 return;
459 }
460 PropertyRNA *searchprop = RNA_struct_find_property(searchptr, searchpropname);
461 if (!searchprop) {
462 RNA_warning_bare("UILayout.prop_search(): property not found: %s.%s",
463 RNA_struct_identifier(searchptr->type),
464 searchpropname);
465 return;
466 }
467
468 PropertyRNA *item_searchprop = nullptr;
469 if (item_searchpropname && item_searchpropname[0]) {
470 StructRNA *collection_item_type = RNA_property_pointer_type(searchptr, searchprop);
471 item_searchprop = RNA_struct_type_find_property(collection_item_type, item_searchpropname);
472 if (!item_searchprop) {
473 RNA_warning_bare("UILayout.prop_search(): Collection items search property not found: %s.%s",
474 RNA_struct_identifier(collection_item_type),
475 item_searchpropname);
476 }
477 }
478
479 /* Get translated name (label). */
480 std::optional<StringRefNull> text = rna_translate_ui_text(
481 name, text_ctxt, nullptr, prop, translate);
482
483 layout->prop_search(
484 ptr, prop, searchptr, searchprop, item_searchprop, text, icon, results_are_suggestions);
485}
486
487void rna_uiLayoutDecorator(Layout *layout, PointerRNA *ptr, const char *propname, int index)
488{
489 layout->decorator(ptr, propname, index);
490}
491
492static PointerRNA rna_uiItemO(Layout *layout,
493 const char *opname,
494 const char *name,
495 const char *text_ctxt,
496 bool translate,
497 int icon,
498 bool emboss,
499 bool depress,
500 int icon_value,
501 const float search_weight)
502{
503 wmOperatorType *ot;
504
505 ot = WM_operatortype_find(opname, false); /* print error next */
506 if (!ot || !ot->srna) {
508 "UILayout.operator(): %s '%s'", ot ? "operator missing srna" : "unknown operator", opname);
509 return {};
510 }
511
512 /* Get translated name (label). */
513 std::optional<StringRefNull> text = rna_translate_ui_text(
514 name, text_ctxt, ot->srna, nullptr, translate);
515
516 if (icon_value && !icon) {
517 icon = icon_value;
518 }
520 if (emboss == false) {
521 flag |= ui::ITEM_R_NO_BG;
522 }
523 if (depress) {
524 flag |= ui::ITEM_O_DEPRESS;
525 }
526
527 const float prev_weight = layout->search_weight();
528 layout->search_weight_set(search_weight);
529
530 PointerRNA opptr = layout->op(ot, text, icon, layout->operator_context(), flag);
531
532 layout->search_weight_set(prev_weight);
533 return opptr;
534}
535
536static PointerRNA rna_uiItemOMenuHold(Layout *layout,
537 const char *opname,
538 const char *name,
539 const char *text_ctxt,
540 bool translate,
541 int icon,
542 bool emboss,
543 bool depress,
544 int icon_value,
545 const char *menu)
546{
547 wmOperatorType *ot = WM_operatortype_find(opname, false); /* print error next */
548 if (!ot || !ot->srna) {
549 RNA_warning_bare("UILayout.operator_menu_hold(): %s '%s'",
550 ot ? "operator missing srna" : "unknown operator",
551 opname);
552 return {};
553 }
554
555 /* Get translated name (label). */
556 std::optional<StringRefNull> text = rna_translate_ui_text(
557 name, text_ctxt, ot->srna, nullptr, translate);
558 if (icon_value && !icon) {
559 icon = icon_value;
560 }
562 if (emboss == false) {
563 flag |= ui::ITEM_R_NO_BG;
564 }
565 if (depress) {
566 flag |= ui::ITEM_O_DEPRESS;
567 }
568
569 return layout->op_menu_hold(ot, text, icon, layout->operator_context(), flag, menu);
570}
571
572static void rna_uiItemsEnumO(Layout *layout,
573 const char *opname,
574 const char *propname,
575 const bool icon_only)
576{
578 layout->op_enum(opname, propname, nullptr, layout->operator_context(), flag);
579}
580
581static PointerRNA rna_uiItemMenuEnumO(Layout *layout,
582 bContext *C,
583 const char *opname,
584 const char *propname,
585 const char *name,
586 const char *text_ctxt,
587 bool translate,
588 int icon)
589{
590 wmOperatorType *ot = WM_operatortype_find(opname, false); /* print error next */
591
592 if (!ot || !ot->srna) {
593 RNA_warning_bare("UILayout.operator_menu_enum(): %s '%s'",
594 ot ? "operator missing srna" : "unknown operator",
595 opname);
596 return {};
597 }
598
599 /* Get translated name (label). */
600 std::optional<StringRefNull> text = rna_translate_ui_text(
601 name, text_ctxt, ot->srna, nullptr, translate);
602
603 return layout->op_menu_enum(C, ot, propname, text, icon);
604}
605
606static void rna_uiItemL(Layout *layout,
607 const char *name,
608 const char *text_ctxt,
609 bool translate,
610 int icon,
611 int icon_value)
612{
613 /* Get translated name (label). */
614 std::optional<StringRefNull> text = rna_translate_ui_text(
615 name, text_ctxt, nullptr, nullptr, translate);
616
617 if (icon_value && !icon) {
618 icon = icon_value;
619 }
620
621 layout->label(text.value_or(""), icon);
622}
623
624static void rna_layout_label_multiline(Layout *layout,
625 const char *name,
626 const char *text_ctxt,
627 bool translate,
628 int icon,
629 int icon_value,
630 int alignment,
631 int max_lines)
632{
633 /* Get translated name (label). */
634 std::optional<StringRefNull> text = rna_translate_ui_text(
635 name, text_ctxt, nullptr, nullptr, translate);
636 if (icon_value && !icon) {
637 icon = icon_value;
638 }
639 layout->label_multiline(text.value_or(""), icon, ui::FontStyleAlign(alignment), max_lines);
640}
641
642static void rna_layout_label_markdown(Layout *layout,
643 const char *name,
644 const char *text_ctxt,
645 bool translate)
646{
647 std::optional<StringRefNull> text = rna_translate_ui_text(
648 name, text_ctxt, nullptr, nullptr, translate);
649 layout->label_markdown(text.value_or(""));
650}
651
652static void rna_layout_link(Layout *layout,
653 const char *url,
654 const char *name,
655 const char *text_ctxt,
656 bool translate,
657 int icon,
658 int icon_value)
659{
660 /* Get translated name (label). */
661 std::optional<StringRefNull> text = rna_translate_ui_text(
662 name, text_ctxt, nullptr, nullptr, translate);
663
664 if (icon_value && !icon) {
665 icon = icon_value;
666 }
667
668 layout->link(url, text.value_or(""), icon);
669}
670
671static void rna_uiItemM(Layout *layout,
672 const char *menuname,
673 const char *name,
674 const char *text_ctxt,
675 bool translate,
676 int icon,
677 int icon_value)
678{
679 /* Get translated name (label). */
680 std::optional<StringRefNull> text = rna_translate_ui_text(
681 name, text_ctxt, nullptr, nullptr, translate);
682
683 if (icon_value && !icon) {
684 icon = icon_value;
685 }
686
687 layout->menu(menuname, text, icon);
688}
689
690static void rna_uiItemM_contents(Layout *layout, const char *menuname)
691{
692 layout->menu_contents(menuname);
693}
694
695static void rna_uiItemPopoverPanel(Layout *layout,
696 bContext *C,
697 const char *panel_type,
698 const char *name,
699 const char *text_ctxt,
700 bool translate,
701 int icon,
702 int icon_value,
703 int direction = int(ui::PopupAttachDirection::Vertical))
704{
705 /* Get translated name (label). */
706 std::optional<StringRefNull> text = rna_translate_ui_text(
707 name, text_ctxt, nullptr, nullptr, translate);
708
709 if (icon_value && !icon) {
710 icon = icon_value;
711 }
712
713 layout->popover(C, panel_type, text, icon, ui::PopupAttachDirection(direction));
714}
715
716static void rna_uiItemPopoverPanelFromGroup(Layout *layout,
717 bContext *C,
718 int space_id,
719 int region_id,
720 const char *context,
721 const char *category)
722{
723 layout->popover_group(C, space_id, region_id, context, category);
724}
725
726static void rna_uiItemProgress(Layout *layout,
727 const char *text,
728 const char *text_ctxt,
729 bool translate,
730 float factor,
731 int progress_type)
732{
734 text = BLT_pgettext((text_ctxt && text_ctxt[0]) ? text_ctxt : BLT_I18NCONTEXT_DEFAULT, text);
735 }
736
737 layout->progress_indicator(text, factor, ui::ButProgressType(progress_type));
738}
739
740static void rna_uiItemSeparator(Layout *layout, float factor, int type)
741{
742 layout->separator(factor, ui::LayoutSeparatorType(type));
743}
744
745static void rna_uiLayoutContextPointerSet(Layout *layout, const char *name, PointerRNA *ptr)
746{
747 layout->context_ptr_set(name, ptr);
748}
749
750static void rna_uiLayoutContextStringSet(Layout *layout, const char *name, const char *value)
751{
752 layout->context_string_set(name, value);
753}
754
755static void rna_uiLayoutSeparatorSpacer(Layout *layout)
756{
757 layout->separator_spacer();
758}
759
760static void rna_uiTemplateID(Layout *layout,
761 bContext *C,
762 PointerRNA *ptr,
763 const char *propname,
764 const char *newop,
765 const char *openop,
766 const char *unlinkop,
767 int filter,
768 const bool live_icon,
769 const char *name,
770 const char *text_ctxt,
771 bool translate)
772{
773 PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
774
775 if (!prop) {
776 RNA_warning_bare("UILayout.template_ID(): property not found: %s.%s",
777 RNA_struct_identifier(ptr->type),
778 propname);
779 return;
780 }
781
782 /* Get translated name (label). */
783 std::optional<StringRefNull> text = rna_translate_ui_text(
784 name, text_ctxt, nullptr, prop, translate);
785
786 template_id(layout, C, ptr, propname, newop, openop, unlinkop, filter, live_icon, text);
787}
788
789static void rna_ui_template_ID_session_uid(
790 Layout *layout, bContext *C, PointerRNA *ptr, const char *propname, int idcode)
791{
792 template_ID_session_uid(*layout, C, ptr, propname, idcode);
793}
794
795static void rna_uiTemplateAnyID(Layout *layout,
796 PointerRNA *ptr,
797 const char *propname,
798 const char *proptypename,
799 const char *name,
800 const char *text_ctxt,
801 bool translate)
802{
803 PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
804
805 if (!prop) {
806 RNA_warning_bare("UILayout.template_any_ID(): property not found: %s.%s",
807 RNA_struct_identifier(ptr->type),
808 propname);
809 return;
810 }
811
812 /* Get translated name (label). */
813 std::optional<StringRefNull> text = rna_translate_ui_text(
814 name, text_ctxt, nullptr, prop, translate);
815
816 /* XXX This will search property again :( */
817 template_any_id(layout, ptr, propname, proptypename, text);
818}
819
820static void rna_uiTemplateAction(Layout *layout,
821 bContext *C,
822 ID *id,
823 const char *newop,
824 const char *unlinkop,
825 const char *name,
826 const char *text_ctxt,
827 const bool translate)
828{
829 std::optional<StringRefNull> text = rna_translate_ui_text(
830 name, text_ctxt, nullptr, nullptr, translate);
831 template_action(layout, C, id, newop, unlinkop, text);
832}
833
834static void rna_uiTemplateSearch(Layout *layout,
835 const bContext *C,
836 PointerRNA *ptr,
837 const char *propname,
838 PointerRNA *searchptr,
839 const char *searchpropname,
840 const char *newop,
841 const char *unlinkop,
842 const char *name,
843 const char *text_ctxt,
844 bool translate)
845{
846 PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
847
848 if (!prop) {
849 RNA_warning_bare("UILayout.template_search(): property not found: %s.%s",
850 RNA_struct_identifier(ptr->type),
851 propname);
852 return;
853 }
854
855 /* Get translated name (label). */
856 std::optional<StringRefNull> text = rna_translate_ui_text(
857 name, text_ctxt, nullptr, prop, translate);
858
859 template_search(layout, C, ptr, propname, searchptr, searchpropname, newop, unlinkop, text);
860}
861
862static void rna_uiTemplateSearchPreview(Layout *layout,
863 bContext *C,
864 PointerRNA *ptr,
865 const char *propname,
866 PointerRNA *searchptr,
867 const char *searchpropname,
868 const char *newop,
869 const char *unlinkop,
870 const char *name,
871 const char *text_ctxt,
872 bool translate,
873 const int rows,
874 const int cols)
875{
876 PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
877
878 if (!prop) {
879 RNA_warning_bare("UILayout.template_search_preview(): property not found: %s.%s",
880 RNA_struct_identifier(ptr->type),
881 propname);
882 return;
883 }
884
885 /* Get translated name (label). */
886 std::optional<StringRefNull> text = rna_translate_ui_text(
887 name, text_ctxt, nullptr, prop, translate);
888
890 layout, C, ptr, propname, searchptr, searchpropname, newop, unlinkop, rows, cols, text);
891}
892
893static void rna_uiTemplateFilePath(Layout *layout,
894 const bContext *C,
895 PointerRNA *ptr,
896 const char *propname,
897 const char *pathselect_op,
898 const char *filter_glob,
899 const char *text,
900 const char *text_ctxt,
901 bool translate,
902 const char *placeholder,
903 const bool split_name)
904{
905 PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
906
907 if (!prop) {
908 RNA_warning_bare("UILayout.template_filepath(): property not found: %s.%s",
909 RNA_struct_identifier(ptr->type),
910 propname);
911 return;
912 }
913
914 /* Get translated name (label). */
915 std::optional<StringRefNull> text_final = rna_translate_ui_text(
916 text, text_ctxt, nullptr, prop, translate);
917 std::optional<StringRefNull> placeholder_final = std::nullopt;
918 if (placeholder) {
919 placeholder_final = rna_translate_ui_text(placeholder, text_ctxt, nullptr, prop, translate);
920 }
921
922 template_filepath(layout,
923 C,
924 ptr,
925 propname,
926 pathselect_op,
927 filter_glob,
928 text_final,
929 placeholder_final,
930 split_name);
931}
932
933void rna_template_list(Layout *layout,
934 bContext *C,
935 const char *listtype_name,
936 const char *list_id,
937 PointerRNA *dataptr,
938 const char *propname,
939 PointerRNA *active_dataptr,
940 const char *active_propname,
941 const char *item_dyntip_propname,
942 const int rows,
943 const int maxrows,
944 const int layout_type,
945 const int /*columns*/,
946 const bool sort_reverse,
947 const bool sort_lock)
948{
950 if (sort_reverse) {
952 }
953 if (sort_lock) {
955 }
956
957 ui::template_uilist(layout,
958 C,
959 listtype_name,
960 list_id,
961 dataptr,
962 propname,
963 active_dataptr,
964 active_propname,
965 item_dyntip_propname,
966 rows,
967 maxrows,
968 layout_type,
969 flags);
970}
971
972static void rna_template_cache_file(Layout *layout,
973 bContext *C,
974 PointerRNA *ptr,
975 const char *propname)
976{
977 PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
978
979 if (!prop) {
980 RNA_warning_bare("UILayout.template_cache_file(): property not found: %s.%s",
981 RNA_struct_identifier(ptr->type),
982 propname);
983 return;
984 }
985
986 ui::template_cache_file(layout, C, ptr, propname);
987}
988
989static void rna_template_cache_file_velocity(Layout *layout, PointerRNA *ptr, const char *propname)
990{
991 PointerRNA fileptr;
992 if (!ui::template_cache_file_pointer(ptr, propname, &fileptr)) {
993 return;
994 }
995
996 ui::template_cache_file_velocity(layout, &fileptr);
997}
998
999static void rna_template_cache_file_time_settings(Layout *layout,
1000 PointerRNA *ptr,
1001 const char *propname)
1002{
1003 PointerRNA fileptr;
1004 if (!ui::template_cache_file_pointer(ptr, propname, &fileptr)) {
1005 return;
1006 }
1007
1008 ui::template_cache_file_time_settings(layout, &fileptr);
1009}
1010
1011static void rna_template_uilist_flags(Layout *layout,
1012 bContext *C,
1013 PointerRNA *ptr,
1014 const char *propname)
1015{
1016 PointerRNA fileptr;
1017 if (!ui::template_cache_file_pointer(ptr, propname, &fileptr)) {
1018 return;
1019 }
1020
1021 ui::template_uilist_flags(layout, C, &fileptr);
1022}
1023
1024static void rna_uiTemplatePathBuilder(Layout *layout,
1025 PointerRNA *ptr,
1026 const char *propname,
1027 PointerRNA *root_ptr,
1028 const char *name,
1029 const char *text_ctxt,
1030 bool translate)
1031{
1032 PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
1033
1034 if (!prop) {
1035 RNA_warning_bare("UILayout.template_path_builder(): property not found: %s.%s",
1036 RNA_struct_identifier(ptr->type),
1037 propname);
1038 return;
1039 }
1040
1041 /* Get translated name (label). */
1042 std::optional<StringRefNull> text = rna_translate_ui_text(
1043 name, text_ctxt, nullptr, prop, translate);
1044
1045 /* XXX This will search property again :( */
1046 ui::template_path_builder(layout, ptr, propname, root_ptr, text);
1047}
1048
1049static void rna_template_event_from_keymap_item(
1050 Layout *layout, wmKeyMapItem *kmi, const char *name, const char *text_ctxt, bool translate)
1051{
1052 /* Get translated name (label). */
1053 std::optional<StringRefNull> text = rna_translate_ui_text(
1054 name, text_ctxt, nullptr, nullptr, translate);
1055 ui::template_event_from_keymap_item(layout, text.value_or(""), kmi, true);
1056}
1057
1058static Layout *rna_uiLayoutBox(Layout *layout)
1059{
1060 return &layout->box();
1061}
1062
1063static Layout *rna_uiLayoutSplit(Layout *layout, float factor, bool align)
1064{
1065 return &layout->split(factor, align);
1066}
1067
1068static Layout *rna_uiLayoutRowWithHeading(
1069 Layout *layout, bool align, const char *heading, const char *heading_ctxt, bool translate)
1070{
1071 /* Get translated heading. */
1072 std::optional<StringRefNull> text = rna_translate_ui_text(
1073 heading, heading_ctxt, nullptr, nullptr, translate);
1074 return &layout->row(align, text.value_or(""));
1075}
1076
1077static Layout *rna_uiLayoutColumnWithHeading(
1078 Layout *layout, bool align, const char *heading, const char *heading_ctxt, bool translate)
1079{
1080 /* Get translated heading. */
1081 std::optional<StringRefNull> text = rna_translate_ui_text(
1082 heading, heading_ctxt, nullptr, nullptr, translate);
1083 return &layout->column(align, text.value_or(""));
1084}
1085
1086static Layout *rna_uiLayoutColumnFlow(Layout *layout, int number, bool align)
1087{
1088 return &layout->column_flow(number, align);
1089}
1090
1091static Layout *rna_uiLayoutGridFlow(
1092 Layout *layout, bool row_major, int columns_len, bool even_columns, bool even_rows, bool align)
1093{
1094 return &layout->grid_flow(row_major, columns_len, even_columns, even_rows, align);
1095}
1096
1097static Layout *rna_uiLayoutMenuPie(Layout *layout)
1098{
1099 return &layout->menu_pie();
1100}
1101
1102void rna_uiLayoutPanelProp(Layout *layout,
1103 bContext *C,
1104 ReportList *reports,
1106 const char *property,
1107 Layout **r_layout_header,
1108 Layout **r_layout_body)
1109{
1110 Panel *panel = layout->root_panel();
1111 if (panel == nullptr) {
1112 BKE_reportf(reports, RPT_ERROR, "Layout panels can not be used in this context");
1113 *r_layout_header = nullptr;
1114 *r_layout_body = nullptr;
1115 return;
1116 }
1117
1118 ui::PanelLayout panel_layout = layout->panel_prop(C, data, property);
1119 *r_layout_header = panel_layout.header;
1120 *r_layout_body = panel_layout.body;
1121}
1122
1123void rna_uiLayoutPanel(Layout *layout,
1124 bContext *C,
1125 ReportList *reports,
1126 const char *idname,
1127 const bool default_closed,
1128 Layout **r_layout_header,
1129 Layout **r_layout_body)
1130{
1131 Panel *panel = layout->root_panel();
1132 if (panel == nullptr) {
1133 BKE_reportf(reports, RPT_ERROR, "Layout panels can not be used in this context");
1134 *r_layout_header = nullptr;
1135 *r_layout_body = nullptr;
1136 return;
1137 }
1138 ui::PanelLayout panel_layout = layout->panel(C, idname, default_closed);
1139 *r_layout_header = panel_layout.header;
1140 *r_layout_body = panel_layout.body;
1141}
1142
1143static void rna_uiLayout_template_node_operator_registration_errors(Layout *layout,
1144 const char *idname)
1145{
1146 if (!idname) {
1147 return;
1148 }
1150}
1151
1152static void rna_uiLayout_template_node_asset_menu_items(Layout *layout,
1153 bContext *C,
1154 const char *catalog_path,
1155 const int operator_type)
1156{
1158 *layout, *C, StringRef(catalog_path), ui::NodeAssetMenuOperatorType(operator_type));
1159}
1160
1161static void rna_uiLayout_template_node_operator_asset_menu_items(Layout *layout,
1162 bContext *C,
1163 const char *catalog_path)
1164{
1166}
1167
1168static void rna_uiLayout_template_modifier_asset_menu_items(Layout *layout,
1169 bContext *C,
1170 const char *catalog_path,
1171 const bool skip_essentials)
1172{
1174 *C, *layout, StringRef(catalog_path), skip_essentials);
1175}
1176
1177static void rna_uiLayout_template_node_operator_root_items(Layout *layout, bContext *C)
1178{
1180}
1181
1182static int rna_ui_get_rnaptr_icon(bContext *C, PointerRNA *ptr_icon)
1183{
1184 return ui::icon_from_rnaptr(C, ptr_icon, RNA_struct_ui_icon(ptr_icon->type), false);
1185}
1186
1187static const char *rna_ui_get_enum_name(bContext *C,
1188 PointerRNA *ptr,
1189 const char *propname,
1190 const char *identifier)
1191{
1192 PropertyRNA *prop = nullptr;
1193 const EnumPropertyItem *items = nullptr;
1194 bool free;
1195 const char *name = "";
1196
1197 prop = RNA_struct_find_property(ptr, propname);
1198 if (!prop || (RNA_property_type(prop) != PROP_ENUM)) {
1199 RNA_warning_bare("UILayout.enum_item_name(): Property not found or not an enum: %s.%s",
1200 RNA_struct_identifier(ptr->type),
1201 propname);
1202 return name;
1203 }
1204
1205 RNA_property_enum_items_gettexted(C, ptr, prop, &items, nullptr, &free);
1206
1207 if (items) {
1208 const int index = RNA_enum_from_identifier(items, identifier);
1209 if (index != -1) {
1210 name = items[index].name;
1211 }
1212 if (free) {
1213 MEM_delete(items);
1214 }
1215 }
1216
1217 return name;
1218}
1219
1220static const char *rna_ui_get_enum_description(bContext *C,
1221 PointerRNA *ptr,
1222 const char *propname,
1223 const char *identifier)
1224{
1225 PropertyRNA *prop = nullptr;
1226 const EnumPropertyItem *items = nullptr;
1227 bool free;
1228 const char *desc = "";
1229
1230 prop = RNA_struct_find_property(ptr, propname);
1231 if (!prop || (RNA_property_type(prop) != PROP_ENUM)) {
1232 RNA_warning_bare("UILayout.enum_item_description(): Property not found or not an enum: %s.%s",
1233 RNA_struct_identifier(ptr->type),
1234 propname);
1235 return desc;
1236 }
1237
1238 RNA_property_enum_items_gettexted(C, ptr, prop, &items, nullptr, &free);
1239
1240 if (items) {
1241 const int index = RNA_enum_from_identifier(items, identifier);
1242 if (index != -1) {
1243 desc = items[index].description;
1244 }
1245 if (free) {
1246 MEM_delete(items);
1247 }
1248 }
1249
1250 return desc;
1251}
1252
1253static int rna_ui_get_enum_icon(bContext *C,
1254 PointerRNA *ptr,
1255 const char *propname,
1256 const char *identifier)
1257{
1258 PropertyRNA *prop = nullptr;
1259 const EnumPropertyItem *items = nullptr;
1260 bool free;
1261 int icon = ICON_NONE;
1262
1263 prop = RNA_struct_find_property(ptr, propname);
1264 if (!prop || (RNA_property_type(prop) != PROP_ENUM)) {
1265 RNA_warning_bare("UILayout.enum_item_icon(): Property not found or not an enum: %s.%s",
1266 RNA_struct_identifier(ptr->type),
1267 propname);
1268 return icon;
1269 }
1270
1271 RNA_property_enum_items(C, ptr, prop, &items, nullptr, &free);
1272
1273 if (items) {
1274 const int index = RNA_enum_from_identifier(items, identifier);
1275 if (index != -1) {
1276 icon = items[index].icon;
1277 }
1278 if (free) {
1279 MEM_delete(items);
1280 }
1281 }
1282
1283 return icon;
1284}
1285
1286void rna_uiTemplateAssetShelfPopover(Layout *layout,
1287 bContext *C,
1288 const char *asset_shelf_id,
1289 const char *name,
1290 BIFIconID icon,
1291 int icon_value)
1292{
1293 if (icon_value && !icon) {
1294 icon = icon_value;
1295 }
1296
1297 ui::template_asset_shelf_popover(*layout, *C, asset_shelf_id, name ? name : "", icon);
1298}
1299
1300PointerRNA rna_uiTemplatePopupConfirm(Layout *layout,
1301 ReportList *reports,
1302 const char *opname,
1303 const char *text,
1304 const char *text_ctxt,
1305 bool translate,
1306 int icon,
1307 const char *cancel_text,
1308 bool cancel_default)
1309{
1310 PointerRNA opptr = {};
1311
1312 /* This allows overriding buttons in `WM_operator_props_dialog_popup` and other popups. */
1313 wmOperatorType *ot = nullptr;
1314 if (opname[0]) {
1315 /* Confirming is optional. */
1316 ot = WM_operatortype_find(opname, false); /* print error next */
1317 }
1318 else {
1319 text = "";
1320 }
1321
1322 if (opname[0] ? (!ot || !ot->srna) : false) {
1323 RNA_warning_bare("UILayout.template_popup_confirm(): %s '%s'",
1324 ot ? "operator missing srna" : "unknown operator",
1325 opname);
1326 }
1327 else if (!popup_block_template_confirm_is_supported(layout->block())) {
1328 BKE_reportf(reports, RPT_ERROR, "template_popup_confirm used outside of a popup");
1329 }
1330 else {
1331 std::optional<StringRefNull> text_str = rna_translate_ui_text(
1332 text, text_ctxt, nullptr, nullptr, translate);
1333 std::optional<StringRefNull> cancel_text_str = cancel_text ? std::make_optional<StringRefNull>(
1334 cancel_text) :
1335 std::nullopt;
1336 if (cancel_text_str && !cancel_text_str->is_empty()) {
1337 cancel_text_str = rna_translate_ui_text(cancel_text, text_ctxt, nullptr, nullptr, translate);
1338 }
1339
1341 layout, ot, text_str, cancel_text_str, icon, cancel_default, &opptr);
1342 }
1343 return opptr;
1344}
1345
1346static int rna_uiTemplateRecentFiles(ui::Layout *layout,
1347 const int rows,
1348 const int filter,
1349 const float project_ratio)
1350{
1351 return ui::template_recent_files(layout, rows, ui::RecentFilesFilter(filter), project_ratio);
1352}
1353
1354} // namespace blender
1355
1356#else
1357
1358namespace blender {
1359
1361{
1362 RNA_def_string(func,
1363 "heading",
1364 nullptr,
1366 "Heading",
1367 "Label to insert into the layout for this sub-layout");
1368 RNA_def_string(func,
1369 "heading_ctxt",
1370 nullptr,
1371 0,
1372 "",
1373 "Override automatic translation context of the given heading");
1375 func, "translate", true, "", "Translate the given heading, when UI translation is enabled");
1376}
1377
1379{
1380 PropertyRNA *prop = RNA_def_string(func,
1381 "text_ctxt",
1382 nullptr,
1383 0,
1384 "",
1385 "Override automatic translation context of the given text");
1388 func, "translate", true, "", "Translate the given text, when UI translation is enabled");
1389}
1390
1392{
1393 PropertyRNA *prop;
1394
1395 prop = RNA_def_string(func, "text", nullptr, 0, "", "Override automatic text of the item");
1398}
1399
1401{
1402 PropertyRNA *prop;
1403
1405
1406 prop = RNA_def_property(func, "icon", PROP_ENUM, PROP_NONE);
1408 RNA_def_property_ui_text(prop, "Icon", "Override automatic icon of the item");
1409}
1410
1411static void api_ui_item_op(FunctionRNA *func)
1412{
1413 PropertyRNA *parm;
1414 parm = RNA_def_string(func, "operator", nullptr, 0, "", "Identifier of the operator");
1416}
1417
1419{
1420 api_ui_item_op(func);
1421 api_ui_item_common(func);
1422}
1423
1425{
1426 PropertyRNA *parm;
1427
1428 parm = RNA_def_pointer(func, "data", "AnyType", "", "Data from which to take property");
1430 parm = RNA_def_string(func, "property", nullptr, 0, "", "Identifier of property in data");
1432}
1433
1435{
1436 FunctionRNA *func;
1437 PropertyRNA *parm;
1438
1439 static const EnumPropertyItem curve_type_items[] = {
1440 {0, "NONE", 0, "None", ""},
1441 {'v', "VECTOR", 0, "Vector", ""},
1442 {'c', "COLOR", 0, "Color", ""},
1443 {'h', "HUE", 0, "Hue", ""},
1444 {0, nullptr, 0, nullptr, nullptr},
1445 };
1446
1447 static const EnumPropertyItem id_template_filter_items[] = {
1448 {ui::TEMPLATE_ID_FILTER_ALL, "ALL", 0, "All", ""},
1449 {ui::TEMPLATE_ID_FILTER_AVAILABLE, "AVAILABLE", 0, "Available", ""},
1450 {0, nullptr, 0, nullptr, nullptr},
1451 };
1452
1453 static const EnumPropertyItem progress_type_items[] = {
1454 {int(ui::ButProgressType::Bar), "BAR", 0, "Bar", ""},
1455 {int(ui::ButProgressType::Ring), "RING", 0, "Ring", ""},
1456 {0, nullptr, 0, nullptr, nullptr},
1457 };
1458
1459 static const EnumPropertyItem rna_enum_separator_type_items[] = {
1461 "AUTO",
1462 0,
1463 "Auto",
1464 "Best guess at what type of separator is needed."},
1466 "SPACE",
1467 0,
1468 "Empty space",
1469 "Horizontal or Vertical empty space, depending on layout direction."},
1471 "LINE",
1472 0,
1473 "Line",
1474 "Horizontal or Vertical line, depending on layout direction."},
1475 {0, nullptr, 0, nullptr, nullptr},
1476 };
1477
1478 static const EnumPropertyItem rna_enum_template_node_operator_type[] = {
1480 "ADD",
1481 0,
1482 "Add Node",
1483 "Add a node to the active tree."},
1485 "SWAP",
1486 0,
1487 "Swap Node",
1488 "Replace the selected nodes with the specified type."},
1489 {0, nullptr, 0, nullptr, nullptr},
1490 };
1491 static const EnumPropertyItem rna_enum_text_align[] = {
1492 {int(ui::UI_STYLE_TEXT_LEFT), "LEFT", 0, "LEFT", ""},
1493 {int(ui::UI_STYLE_TEXT_RIGHT), "RIGHT", 0, "RIGHT", ""},
1494 {int(ui::UI_STYLE_TEXT_CENTER), "CENTER", 0, "CENTER", ""},
1495 {0, nullptr, 0, nullptr, nullptr},
1496 };
1497
1498 static const float node_socket_color_default[] = {0.0f, 0.0f, 0.0f, 1.0f};
1499
1500 /* simple layout specifiers */
1501 func = RNA_def_function(srna, "row", "rna_uiLayoutRowWithHeading");
1502 parm = RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in");
1504 RNA_def_function_return(func, parm);
1506 func,
1507 "Sub-layout. Items placed in this sublayout are placed next to each other "
1508 "in a row.");
1509 RNA_def_boolean(func, "align", false, "", "Align buttons to each other");
1511
1512 func = RNA_def_function(srna, "column", "rna_uiLayoutColumnWithHeading");
1513 parm = RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in");
1515 RNA_def_function_return(func, parm);
1517 func,
1518 "Sub-layout. Items placed in this sublayout are placed under each other "
1519 "in a column.");
1520 RNA_def_boolean(func, "align", false, "", "Align buttons to each other");
1522
1523 func = RNA_def_function(srna, "panel", "rna_uiLayoutPanel");
1525 func,
1526 "Creates a collapsible panel. Whether it is open or closed is stored in the region using "
1527 "the given idname. This can only be used when the panel has the full width of the panel "
1528 "region available to it. So it can't be used in e.g. in a box or columns.");
1530 parm = RNA_def_string(func, "idname", nullptr, 0, "", "Identifier of the panel");
1532 RNA_def_boolean(func,
1533 "default_closed",
1534 false,
1535 "Open by Default",
1536 "When true, the panel will be open the first time it is shown");
1537 parm = RNA_def_pointer(func, "layout_header", "UILayout", "", "Sub-layout to put items in");
1539 RNA_def_function_output(func, parm);
1540 parm = RNA_def_pointer(func,
1541 "layout_body",
1542 "UILayout",
1543 "",
1544 "Sub-layout to put items in. Will be none if the panel is collapsed.");
1545 RNA_def_function_output(func, parm);
1546
1547 func = RNA_def_function(srna, "panel_prop", "rna_uiLayoutPanelProp");
1549 func,
1550 "Similar to ``.panel(...)`` but instead of storing whether it is open or closed in the "
1551 "region, it is stored in the provided boolean property. This should be used when multiple "
1552 "instances of the same panel can exist. For example one for every item in a collection "
1553 "property or list. This can only be used when the panel has the full width of the panel "
1554 "region available to it. So it can't be used in e.g. in a box or columns.");
1556 parm = RNA_def_pointer(
1557 func, "data", "AnyType", "", "Data from which to take the open-state property");
1559 parm = RNA_def_string(
1560 func,
1561 "property",
1562 nullptr,
1563 0,
1564 "",
1565 "Identifier of the boolean property that determines whether the panel is open or closed");
1567 parm = RNA_def_pointer(
1568 func,
1569 "layout_header",
1570 "UILayout",
1571 "",
1572 "Sub-layout to put items in. Will be none if the property does not exists.");
1573 RNA_def_function_output(func, parm);
1574 parm = RNA_def_pointer(func,
1575 "layout_body",
1576 "UILayout",
1577 "",
1578 "Sub-layout to put items in. Will be none if the panel is collapsed.");
1579 RNA_def_function_output(func, parm);
1580
1581 func = RNA_def_function(srna, "column_flow", "rna_uiLayoutColumnFlow");
1582 RNA_def_int(func, "columns", 0, 0, INT_MAX, "", "Number of columns, 0 is automatic", 0, INT_MAX);
1583 parm = RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in");
1585 RNA_def_function_return(func, parm);
1586 RNA_def_boolean(func, "align", false, "", "Align buttons to each other");
1587
1588 func = RNA_def_function(srna, "grid_flow", "rna_uiLayoutGridFlow");
1589 RNA_def_boolean(func, "row_major", false, "", "Fill row by row, instead of column by column");
1591 func,
1592 "columns",
1593 0,
1594 INT_MIN,
1595 INT_MAX,
1596 "",
1597 "Number of columns, positive are absolute fixed numbers, 0 is automatic, negative are "
1598 "automatic multiple numbers along major axis (e.g. -2 will only produce 2, 4, 6 etc. "
1599 "columns for row major layout, and 2, 4, 6 etc. rows for column major layout).",
1600 INT_MIN,
1601 INT_MAX);
1602 RNA_def_boolean(func, "even_columns", false, "", "All columns will have the same width");
1603 RNA_def_boolean(func, "even_rows", false, "", "All rows will have the same height");
1604 RNA_def_boolean(func, "align", false, "", "Align buttons to each other");
1605 parm = RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in");
1607 RNA_def_function_return(func, parm);
1608
1609 /* box layout */
1610 func = RNA_def_function(srna, "box", "rna_uiLayoutBox");
1611 parm = RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in");
1613 RNA_def_function_return(func, parm);
1615 "Sublayout (items placed in this sublayout are placed "
1616 "under each other in a column and are surrounded by a box)");
1617
1618 /* split layout */
1619 func = RNA_def_function(srna, "split", "rna_uiLayoutSplit");
1620 parm = RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in");
1622 RNA_def_function_return(func, parm);
1623 RNA_def_float(func,
1624 "factor",
1625 0.0f,
1626 0.0f,
1627 1.0f,
1628 "Percentage",
1629 "Percentage of width to split at (leave unset for automatic calculation)",
1630 0.0f,
1631 1.0f);
1632 RNA_def_boolean(func, "align", false, "", "Align buttons to each other");
1633
1634 /* radial/pie layout */
1635 func = RNA_def_function(srna, "menu_pie", "rna_uiLayoutMenuPie");
1636 parm = RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in");
1638 RNA_def_function_return(func, parm);
1640 "Sublayout. Items placed in this sublayout are placed "
1641 "in a radial fashion around the menu center).");
1642
1643 /* Icon of a rna pointer */
1644 func = RNA_def_function(srna, "icon", "rna_ui_get_rnaptr_icon");
1645 parm = RNA_def_int(func, "icon_value", ICON_NONE, 0, INT_MAX, "", "Icon identifier", 0, INT_MAX);
1646 RNA_def_function_return(func, parm);
1648 parm = RNA_def_pointer(func, "data", "AnyType", "", "Data from which to take the icon");
1651 "Return the custom icon for this data, "
1652 "use it e.g. to get materials or texture icons.");
1653
1654 /* UI name, description and icon of an enum item */
1655 func = RNA_def_function(srna, "enum_item_name", "rna_ui_get_enum_name");
1656 parm = RNA_def_string(func, "name", nullptr, 0, "", "UI name of the enum item");
1657 RNA_def_function_return(func, parm);
1660 parm = RNA_def_string(func, "identifier", nullptr, 0, "", "Identifier of the enum item");
1662 RNA_def_function_ui_description(func, "Return the UI name for this enum item");
1663
1664 func = RNA_def_function(srna, "enum_item_description", "rna_ui_get_enum_description");
1665 parm = RNA_def_string(func, "description", nullptr, 0, "", "UI description of the enum item");
1666 RNA_def_function_return(func, parm);
1669 parm = RNA_def_string(func, "identifier", nullptr, 0, "", "Identifier of the enum item");
1671 RNA_def_function_ui_description(func, "Return the UI description for this enum item");
1672
1673 func = RNA_def_function(srna, "enum_item_icon", "rna_ui_get_enum_icon");
1674 parm = RNA_def_int(func, "icon_value", ICON_NONE, 0, INT_MAX, "", "Icon identifier", 0, INT_MAX);
1675 RNA_def_function_return(func, parm);
1678 parm = RNA_def_string(func, "identifier", nullptr, 0, "", "Identifier of the enum item");
1680 RNA_def_function_ui_description(func, "Return the icon for this enum item");
1681
1682 /* items */
1683 func = RNA_def_function(srna, "textbox", "rna_uiItemTextBox");
1685 "Exposes an RNA string property in the layout using a text-box "
1686 "widget with multi-line support. Text-box state will be stored "
1687 "in the current context region.");
1691 parm = RNA_def_int(
1692 func, "initial_visible_lines", 3, 1, INT_MAX, "Initial Visible Lines", "", 1, INT_MAX);
1693 parm = RNA_def_string(
1694 func, "placeholder", nullptr, 0, "", "Hint describing the expected value when empty");
1696
1697 func = RNA_def_function(srna, "textbox_with_state", "rna_uiItemTextBoxWithState");
1699 "Exposes an RNA string property in the layout using a text-box "
1700 "widget with multi-line support");
1703 parm = RNA_def_pointer(func,
1704 "textbox_state",
1705 "TextboxState",
1706 "",
1707 "Pointer to a pre-allocated text-box state storage (builtin)");
1709 parm = RNA_def_string(
1710 func, "placeholder", nullptr, 0, "", "Hint describing the expected value when empty");
1712
1713 func = RNA_def_function(srna, "prop", "rna_uiItemR");
1715 "Item. Exposes an RNA item and places it into the layout.");
1717 api_ui_item_common(func);
1719 func, "placeholder", nullptr, 0, "", "Hint describing the expected value when empty");
1721 RNA_def_boolean(func, "expand", false, "", "Expand button to show more detail");
1722 RNA_def_boolean(func, "slider", false, "", "Use slider widget for numeric values");
1723 RNA_def_int(func,
1724 "toggle",
1725 -1,
1726 -1,
1727 1,
1728 "",
1729 "Use toggle widget for boolean values, "
1730 "or a checkbox when disabled "
1731 "(the default is -1 which uses toggle only when an icon is displayed)",
1732 -1,
1733 1);
1734 RNA_def_boolean(func, "icon_only", false, "", "Draw only icons in buttons, no text");
1735 RNA_def_boolean(func, "event", false, "", "Use button to input key events");
1737 func, "full_event", false, "", "Use button to input full events including modifiers");
1738 RNA_def_boolean(func,
1739 "emboss",
1740 true,
1741 "",
1742 "Draw the button itself, not just the icon/text. When false, corresponds to the "
1743 "'NONE_OR_STATUS' layout emboss type.");
1744 RNA_def_int(func,
1745 "index",
1746 /* RNA_NO_INDEX == -1 */
1747 -1,
1748 -2,
1749 INT_MAX,
1750 "",
1751 "The index of this button, when set a single member of an array can be accessed, "
1752 "when set to -1 all array members are used",
1753 -2,
1754 INT_MAX);
1755 parm = RNA_def_property(func, "icon_value", PROP_INT, PROP_UNSIGNED);
1756 RNA_def_property_ui_text(parm, "Icon Value", "Override automatic icon of the item");
1757 RNA_def_boolean(func, "invert_checkbox", false, "", "Draw checkbox value inverted");
1758 static const EnumPropertyItem rna_enum_prop_align[] = {
1759 {int(TextAlignAnchor::Left), "LEFT", 0, "", ""},
1760 {int(TextAlignAnchor::Right), "RIGHT", 0, "", ""},
1761 {0, nullptr, 0, nullptr, nullptr},
1762 };
1763 parm = RNA_def_enum(func, "text_align", rna_enum_prop_align, 0, "", "Text alignment");
1764
1765 func = RNA_def_function(srna, "props_enum", "rna_uiItemsEnumR");
1767
1768 func = RNA_def_function(srna, "prop_menu_enum", "rna_uiItemMenuEnumR");
1770 api_ui_item_common(func);
1771
1772 func = RNA_def_function(srna, "prop_with_popover", "rna_uiItemR_with_popover");
1774 api_ui_item_common(func);
1775 RNA_def_boolean(func, "icon_only", false, "", "Draw only icons in tabs, no text");
1776 parm = RNA_def_string(func, "panel", nullptr, 0, "", "Identifier of the panel");
1778
1779 func = RNA_def_function(srna, "prop_with_menu", "rna_uiItemR_with_menu");
1781 api_ui_item_common(func);
1782 RNA_def_boolean(func, "icon_only", false, "", "Draw only icons in tabs, no text");
1783 parm = RNA_def_string(func, "menu", nullptr, 0, "", "Identifier of the menu");
1785
1786 func = RNA_def_function(srna, "prop_tabs_enum", "rna_uiItemTabsEnumR");
1789 parm = RNA_def_pointer(
1790 func, "data_highlight", "AnyType", "", "Data from which to take highlight property");
1792 parm = RNA_def_string(
1793 func, "property_highlight", nullptr, 0, "", "Identifier of highlight property in data");
1794 RNA_def_boolean(func, "icon_only", false, "", "Draw only icons in tabs, no text");
1795
1796 static const EnumPropertyItem rna_enum_prop_tabs_enum_expand_as[] = {
1797 {int(ui::EnumTabExpand::Default), "DEFAULT", 0, "", ""},
1798 {int(ui::EnumTabExpand::Row), "ROW", 0, "", ""},
1799 {0, nullptr, 0, nullptr, nullptr},
1800 };
1801 parm = RNA_def_enum(func,
1802 "expand_as",
1803 rna_enum_prop_tabs_enum_expand_as,
1805 "",
1806 "");
1807
1808 func = RNA_def_function(srna, "prop_enum", "rna_uiItemEnumR_string");
1810 parm = RNA_def_string(func, "value", nullptr, 0, "", "Enum property value");
1812 api_ui_item_common(func);
1813
1814 func = RNA_def_function(srna, "prop_search", "rna_uiItemPointerR");
1816 parm = RNA_def_pointer(
1817 func, "search_data", "AnyType", "", "Data from which to take collection to search in");
1819 parm = RNA_def_string(
1820 func, "search_property", nullptr, 0, "", "Identifier of search collection property");
1822 api_ui_item_common(func);
1824 func, "results_are_suggestions", false, "", "Accept inputs that do not match any item");
1825 parm = RNA_def_string(func,
1826 "item_search_property",
1827 nullptr,
1828 0,
1829 "",
1830 "Identifier of the string property in each collection's items to use for "
1831 "searching (defaults to the items' type 'name property')");
1832
1833 func = RNA_def_function(srna, "prop_decorator", "rna_uiLayoutDecorator");
1835 RNA_def_int(func,
1836 "index",
1837 /* RNA_NO_INDEX == -1 */
1838 -1,
1839 -2,
1840 INT_MAX,
1841 "",
1842 "The index of this button, when set a single member of an array can be accessed, "
1843 "when set to -1 all array members are used",
1844 -2,
1845 INT_MAX);
1846
1847 for (int is_menu_hold = 0; is_menu_hold < 2; is_menu_hold++) {
1848 func = (is_menu_hold) ? RNA_def_function(srna, "operator_menu_hold", "rna_uiItemOMenuHold") :
1849 RNA_def_function(srna, "operator", "rna_uiItemO");
1851 RNA_def_boolean(func, "emboss", true, "", "Draw the button itself, not just the icon/text");
1852 RNA_def_boolean(func, "depress", false, "", "Draw pressed in");
1853 parm = RNA_def_property(func, "icon_value", PROP_INT, PROP_UNSIGNED);
1854 RNA_def_property_ui_text(parm, "Icon Value", "Override automatic icon of the item");
1855 if (is_menu_hold) {
1856 parm = RNA_def_string(func, "menu", nullptr, 0, "", "Identifier of the menu");
1858 }
1859 else {
1860 RNA_def_float(func,
1861 "search_weight",
1862 0.0f,
1863 -FLT_MAX,
1864 FLT_MAX,
1865 "Search Weight",
1866 "Influences the sorting when using menu-search",
1867 -FLT_MAX,
1868 FLT_MAX);
1869 }
1870 parm = RNA_def_pointer(
1871 func, "properties", "OperatorProperties", "", "Operator properties to fill in");
1873 RNA_def_function_return(func, parm);
1875 "Item. Places a button into the layout to call an Operator.");
1876 }
1877
1878 func = RNA_def_function(srna, "operator_enum", "rna_uiItemsEnumO");
1879 parm = RNA_def_string(func, "operator", nullptr, 0, "", "Identifier of the operator");
1881 parm = RNA_def_string(func, "property", nullptr, 0, "", "Identifier of property in operator");
1883 RNA_def_boolean(func, "icon_only", false, "", "Draw only icons in buttons, no text");
1884
1885 func = RNA_def_function(srna, "operator_menu_enum", "rna_uiItemMenuEnumO");
1887 /* Can't use #api_ui_item_op_common because property must come right after. */
1888 api_ui_item_op(func);
1889 parm = RNA_def_string(func, "property", nullptr, 0, "", "Identifier of property in operator");
1891 api_ui_item_common(func);
1892 parm = RNA_def_pointer(
1893 func, "properties", "OperatorProperties", "", "Operator properties to fill in");
1895 RNA_def_function_return(func, parm);
1896
1897 func = RNA_def_function(srna, "label", "rna_uiItemL");
1898 RNA_def_function_ui_description(func, "Item. Displays text and/or icon in the layout.");
1899 api_ui_item_common(func);
1900 parm = RNA_def_property(func, "icon_value", PROP_INT, PROP_UNSIGNED);
1901 RNA_def_property_ui_text(parm, "Icon Value", "Override automatic icon of the item");
1902
1903 func = RNA_def_function(srna, "label_multiline", "rna_layout_label_multiline");
1904 RNA_def_function_ui_description(func, "Displays multiline text in the layout.");
1905 api_ui_item_common(func);
1906 parm = RNA_def_property(func, "icon_value", PROP_INT, PROP_UNSIGNED);
1907 RNA_def_property_ui_text(parm, "Icon Value", "Override automatic icon of the item");
1908 parm = RNA_def_enum(func, "alignment", rna_enum_text_align, 0, "", "");
1909 parm = RNA_def_property(func, "max_lines", PROP_INT, PROP_UNSIGNED);
1911 RNA_def_property_ui_text(parm, "", "Maximum number of lines to display, 0 means all");
1912
1913 func = RNA_def_function(srna, "label_markdown", "rna_layout_label_markdown");
1915 func,
1916 "Displays markdown-formatted text in the layout. Only a subset of markdown is supported "
1917 "including headers, lists, bold/italic/code text, links, quotes, horizontal rules.");
1919
1920 func = RNA_def_function(srna, "link", "rna_layout_link");
1921 RNA_def_function_ui_description(func, "Item. Displays a url that can be clicked in the layout.");
1922 prop = RNA_def_string(func, "url", nullptr, 0, "", "");
1924 prop = RNA_def_string(func, "text", nullptr, 0, "", "Override automatic text of the item");
1927 prop = RNA_def_property(func, "icon", PROP_ENUM, PROP_NONE);
1929 RNA_def_property_ui_text(prop, "Icon", "Override automatic icon of the item");
1930 parm = RNA_def_property(func, "icon_value", PROP_INT, PROP_UNSIGNED);
1931 RNA_def_property_ui_text(parm, "Icon Value", "Override automatic icon of the item");
1932
1933 func = RNA_def_function(srna, "menu", "rna_uiItemM");
1934 parm = RNA_def_string(func, "menu", nullptr, 0, "", "Identifier of the menu");
1935 api_ui_item_common(func);
1937 parm = RNA_def_property(func, "icon_value", PROP_INT, PROP_UNSIGNED);
1938 RNA_def_property_ui_text(parm, "Icon Value", "Override automatic icon of the item");
1939
1940 func = RNA_def_function(srna, "menu_contents", "rna_uiItemM_contents");
1941 parm = RNA_def_string(func, "menu", nullptr, 0, "", "Identifier of the menu");
1943
1944 func = RNA_def_function(srna, "popover", "rna_uiItemPopoverPanel");
1946 parm = RNA_def_string(func, "panel", nullptr, 0, "", "Identifier of the panel");
1947 api_ui_item_common(func);
1949 parm = RNA_def_property(func, "icon_value", PROP_INT, PROP_UNSIGNED);
1950 RNA_def_property_ui_text(parm, "Icon Value", "Override automatic icon of the item");
1951 parm = RNA_def_enum(
1952 func,
1953 "direction",
1955 0,
1956 "Popup Direction",
1957 "The direction in which the popup panel is drawn relative to button position");
1958
1959 func = RNA_def_function(srna, "popover_group", "rna_uiItemPopoverPanelFromGroup");
1961 parm = RNA_def_enum(func, "space_type", rna_enum_space_type_items, 0, "Space Type", "");
1963 parm = RNA_def_enum(
1964 func, "region_type", rna_enum_region_type_items, RGN_TYPE_WINDOW, "Region Type", "");
1966 parm = RNA_def_string(func, "context", nullptr, 0, "", "panel type context");
1968 parm = RNA_def_string(func, "category", nullptr, 0, "", "panel type category");
1970
1971 func = RNA_def_function(srna, "separator", "rna_uiItemSeparator");
1973 "Item. Inserts empty space into the layout between items.");
1974 RNA_def_float(func,
1975 "factor",
1976 1.0f,
1977 0.0f,
1978 FLT_MAX,
1979 "Percentage",
1980 "Percentage of width to space (leave unset for default space)",
1981 0.0f,
1982 FLT_MAX);
1983 RNA_def_enum(func,
1984 "type",
1985 rna_enum_separator_type_items,
1987 "Type",
1988 "The type of the separator");
1989
1990 func = RNA_def_function(srna, "separator_spacer", "rna_uiLayoutSeparatorSpacer");
1992 func, "Item. Inserts horizontal spacing empty space into the layout between items.");
1993
1994 func = RNA_def_function(srna, "progress", "rna_uiItemProgress");
1995 RNA_def_function_ui_description(func, "Progress indicator");
1997 RNA_def_float(func,
1998 "factor",
1999 0.0f,
2000 0.0f,
2001 1.0f,
2002 "Factor",
2003 "Amount of progress from 0.0f to 1.0f",
2004 0.0f,
2005 1.0f);
2006 RNA_def_enum(func,
2007 "type",
2008 progress_type_items,
2010 "Type",
2011 "The type of progress indicator");
2012
2013 /* context */
2014 func = RNA_def_function(srna, "context_pointer_set", "rna_uiLayoutContextPointerSet");
2015 parm = RNA_def_string(func, "name", nullptr, 0, "Name", "Name of entry in the context");
2017 parm = RNA_def_pointer(func, "data", "AnyType", "", "Pointer to put in context");
2019
2020 func = RNA_def_function(srna, "context_string_set", "rna_uiLayoutContextStringSet");
2021 parm = RNA_def_string(func, "name", nullptr, 0, "Name", "Name of entry in the context");
2023 parm = RNA_def_string(func, "value", nullptr, 0, "Value", "String to put in context");
2025
2026 /* templates */
2027 func = RNA_def_function(srna, "template_header", "template_header");
2029 RNA_def_function_ui_description(func, "Inserts common Space header UI (editor type selector)");
2030
2031 func = RNA_def_function(srna, "template_ID", "rna_uiTemplateID");
2034 RNA_def_string(func, "new", nullptr, 0, "", "Operator identifier to create a new ID block");
2035 RNA_def_string(func,
2036 "open",
2037 nullptr,
2038 0,
2039 "",
2040 "Operator identifier to open a file for creating a new ID block");
2041 RNA_def_string(func, "unlink", nullptr, 0, "", "Operator identifier to unlink the ID block");
2042 RNA_def_enum(func,
2043 "filter",
2044 id_template_filter_items,
2046 "",
2047 "Optionally limit the items which can be selected");
2048 RNA_def_boolean(func, "live_icon", false, "", "Show preview instead of fixed icon");
2050
2051 func = RNA_def_function(srna, "template_ID_session_uid", "rna_ui_template_ID_session_uid");
2053 "Template ID search menu button for session_uid Int properties");
2056 parm = RNA_def_enum(
2057 func, "id_type", rna_enum_id_type_items, 0, "", "Type of ID to display in the search list");
2060
2061 func = RNA_def_function(srna, "template_ID_preview", "template_id_preview");
2064 RNA_def_string(func, "new", nullptr, 0, "", "Operator identifier to create a new ID block");
2065 RNA_def_string(func,
2066 "open",
2067 nullptr,
2068 0,
2069 "",
2070 "Operator identifier to open a file for creating a new ID block");
2071 RNA_def_string(func, "unlink", nullptr, 0, "", "Operator identifier to unlink the ID block");
2073 func, "rows", 0, 0, INT_MAX, "Number of thumbnail preview rows to display", "", 0, INT_MAX);
2074 RNA_def_int(func,
2075 "cols",
2076 0,
2077 0,
2078 INT_MAX,
2079 "Number of thumbnail preview columns to display",
2080 "",
2081 0,
2082 INT_MAX);
2083 RNA_def_enum(func,
2084 "filter",
2085 id_template_filter_items,
2087 "",
2088 "Optionally limit the items which can be selected");
2089 RNA_def_boolean(func, "hide_buttons", false, "", "Show only list, no buttons");
2090
2091 func = RNA_def_function(srna, "template_matrix", "template_matrix");
2093 func,
2094 "Insert a readonly Matrix UI. "
2095 "The UI displays the matrix components - translation, rotation and scale. "
2096 "The **property** argument must be the identifier of an existing 4x4 float vector "
2097 "property of subtype 'MATRIX'.");
2099
2100 func = RNA_def_function(srna, "template_any_ID", "rna_uiTemplateAnyID");
2101 parm = RNA_def_pointer(func, "data", "AnyType", "", "Data from which to take property");
2103 parm = RNA_def_string(func, "property", nullptr, 0, "", "Identifier of property in data");
2105 parm = RNA_def_string(func,
2106 "type_property",
2107 nullptr,
2108 0,
2109 "",
2110 "Identifier of property in data giving the type of the ID-blocks to use");
2113
2114 func = RNA_def_function(srna, "template_ID_tabs", "template_id_tabs");
2117 RNA_def_string(func, "new", nullptr, 0, "", "Operator identifier to create a new ID block");
2118 RNA_def_string(func, "menu", nullptr, 0, "", "Context menu identifier");
2119 RNA_def_enum(func,
2120 "filter",
2121 id_template_filter_items,
2123 "",
2124 "Optionally limit the items which can be selected");
2125
2126 func = RNA_def_function(srna, "template_action", "rna_uiTemplateAction");
2128 parm = RNA_def_pointer(func, "id", "ID", "", "The data-block for which to select an Action");
2130 RNA_def_string(func, "new", nullptr, 0, "", "Operator identifier to create a new ID block");
2131 RNA_def_string(func, "unlink", nullptr, 0, "", "Operator identifier to unlink the ID block");
2133
2134 func = RNA_def_function(srna, "template_search", "rna_uiTemplateSearch");
2137 parm = RNA_def_pointer(
2138 func, "search_data", "AnyType", "", "Data from which to take collection to search in");
2140 parm = RNA_def_string(
2141 func, "search_property", nullptr, 0, "", "Identifier of search collection property");
2144 func, "new", nullptr, 0, "", "Operator identifier to create a new item for the collection");
2145 RNA_def_string(func,
2146 "unlink",
2147 nullptr,
2148 0,
2149 "",
2150 "Operator identifier to unlink or delete the active "
2151 "item from the collection");
2153
2154 func = RNA_def_function(srna, "template_search_preview", "rna_uiTemplateSearchPreview");
2157 parm = RNA_def_pointer(
2158 func, "search_data", "AnyType", "", "Data from which to take collection to search in");
2160 parm = RNA_def_string(
2161 func, "search_property", nullptr, 0, "", "Identifier of search collection property");
2164 func, "new", nullptr, 0, "", "Operator identifier to create a new item for the collection");
2165 RNA_def_string(func,
2166 "unlink",
2167 nullptr,
2168 0,
2169 "",
2170 "Operator identifier to unlink or delete the active "
2171 "item from the collection");
2174 func, "rows", 0, 0, INT_MAX, "Number of thumbnail preview rows to display", "", 0, INT_MAX);
2175 RNA_def_int(func,
2176 "cols",
2177 0,
2178 0,
2179 INT_MAX,
2180 "Number of thumbnail preview columns to display",
2181 "",
2182 0,
2183 INT_MAX);
2184
2185 func = RNA_def_function(srna, "template_filepath", "rna_uiTemplateFilePath");
2188 "Define a file or directory path text widget, with a button to "
2189 "its right to open a filebrowser. Only for String properties "
2190 "with a Filepath or Dirpath subtype.");
2192 prop = RNA_def_string(func,
2193 "open",
2194 nullptr,
2195 0,
2196 "",
2197 "Operator identifier to select a filepath (if unset, the relevant generic "
2198 "path selection operator is used)");
2200 prop = RNA_def_string(func,
2201 "filter_glob",
2202 nullptr,
2203 0,
2204 "",
2205 "If set, controls which file extensions are shown in the filebrowser, for "
2206 "Filepath properties only (e.g. '*.glb;*.gltf')");
2209 prop = RNA_def_string(func,
2210 "placeholder",
2211 nullptr,
2212 0,
2213 "",
2214 "Placeholder text to display in the text widget when no path is set");
2216 RNA_def_boolean(func,
2217 "split_name",
2218 false,
2219 "",
2220 "Edit the parent directory and the file or directory name in separate text "
2221 "widgets");
2222
2223 func = RNA_def_function(srna, "template_path_builder", "rna_uiTemplatePathBuilder");
2224 parm = RNA_def_pointer(func, "data", "AnyType", "", "Data from which to take property");
2226 parm = RNA_def_string(func, "property", nullptr, 0, "", "Identifier of property in data");
2228 parm = RNA_def_pointer(func, "root", "ID", "", "ID-block from which path is evaluated from");
2231
2232 func = RNA_def_function(srna, "template_modifiers", "template_modifiers");
2234 RNA_def_function_ui_description(func, "Generates the UI layout for the modifier stack");
2235
2236 func = RNA_def_function(srna, "template_strip_modifiers", "template_strip_modifiers");
2238 RNA_def_function_ui_description(func, "Generates the UI layout for the strip modifier stack");
2239
2240 func = RNA_def_function(
2241 srna, "template_scene_compositor_effects", "template_scene_compositor_effects");
2244 func, "Generates the UI layout for the scene compositor effects stack");
2245
2246 func = RNA_def_function(srna, "template_collection_importer", "template_collection_importer");
2248 RNA_def_function_ui_description(func, "Generates the UI layout for the collection importer");
2249
2250 func = RNA_def_function(srna, "template_collection_exporters", "template_collection_exporters");
2252 RNA_def_function_ui_description(func, "Generates the UI layout for collection exporters");
2253
2254 func = RNA_def_function(srna, "template_constraints", "template_constraints");
2256 RNA_def_function_ui_description(func, "Generates the panels for the constraint stack");
2257 RNA_def_boolean(func,
2258 "use_bone_constraints",
2259 true,
2260 "",
2261 "Add panels for bone constraints instead of object constraints");
2262
2263 func = RNA_def_function(srna, "template_shaderfx", "template_shader_fx");
2265 RNA_def_function_ui_description(func, "Generates the panels for the shader effect stack");
2266
2267 func = RNA_def_function(
2268 srna, "template_greasepencil_color", "template_greasepencil_color_preview");
2272 func, "rows", 0, 0, INT_MAX, "Number of thumbnail preview rows to display", "", 0, INT_MAX);
2273 RNA_def_int(func,
2274 "cols",
2275 0,
2276 0,
2277 INT_MAX,
2278 "Number of thumbnail preview columns to display",
2279 "",
2280 0,
2281 INT_MAX);
2282 RNA_def_float(func, "scale", 1.0f, 0.1f, 1.5f, "Scale of the image thumbnails", "", 0.5f, 1.0f);
2283 RNA_def_enum(func,
2284 "filter",
2285 id_template_filter_items,
2287 "",
2288 "Optionally limit the items which can be selected");
2289
2290 func = RNA_def_function(srna, "template_constraint_header", "template_constraint_header");
2291 RNA_def_function_ui_description(func, "Generates the header for constraint panels");
2292 parm = RNA_def_pointer(func, "data", "Constraint", "", "Constraint data");
2294
2295 func = RNA_def_function(srna, "template_preview", "template_preview");
2297 func, "Item. A preview window for materials, textures, lights or worlds.");
2299 parm = RNA_def_pointer(func, "id", "ID", "", "ID data-block");
2301 RNA_def_boolean(func, "show_buttons", true, "", "Show preview buttons?");
2302 RNA_def_pointer(func, "parent", "ID", "", "ID data-block");
2303 RNA_def_pointer(func, "slot", "TextureSlot", "", "Texture slot");
2305 func,
2306 "preview_id",
2307 nullptr,
2308 0,
2309 "",
2310 "Identifier of this preview widget, if not set the ID type will be used "
2311 "(i.e. all previews of materials without explicit ID will have the same size...).");
2312
2313 func = RNA_def_function(srna, "template_curve_mapping", "template_curve_mapping");
2315 func, "Item. A curve mapping widget used for e.g falloff curves for lights.");
2317 RNA_def_enum(func, "type", curve_type_items, 0, "Type", "Type of curves to display");
2318 RNA_def_boolean(func, "levels", false, "", "Show black/white levels");
2319 RNA_def_boolean(func, "brush", false, "", "Show brush options");
2320 RNA_def_boolean(func, "use_negative_slope", false, "", "Use a negative slope by default");
2321 RNA_def_boolean(func, "show_tone", false, "", "Show tone options");
2322 RNA_def_boolean(func, "show_presets", false, "", "Show preset options");
2323
2324 func = RNA_def_function(srna, "template_curveprofile", "template_curve_profile");
2325 RNA_def_function_ui_description(func, "A profile path editor used for custom profiles");
2327
2328 func = RNA_def_function(srna, "template_color_ramp", "template_color_ramp");
2329 RNA_def_function_ui_description(func, "Item. A color ramp widget.");
2331 RNA_def_boolean(func, "expand", false, "", "Expand button to show more detail");
2332
2333 func = RNA_def_function(srna, "template_icon", "template_icon");
2334 RNA_def_function_ui_description(func, "Display a large icon");
2335 parm = RNA_def_int(func, "icon_value", 0, 0, INT_MAX, "Icon to display", "", 0, INT_MAX);
2337 RNA_def_float(func,
2338 "scale",
2339 1.0f,
2340 1.0f,
2341 100.0f,
2342 "Scale",
2343 "Scale the icon size (by the button size)",
2344 1.0f,
2345 100.0f);
2346
2347 func = RNA_def_function(srna, "template_icon_view", "template_icon_view");
2348 RNA_def_function_ui_description(func, "Enum. Large widget showing Icon previews.");
2350 RNA_def_boolean(func, "show_labels", false, "", "Show enum label in preview buttons");
2351 RNA_def_float(func,
2352 "scale",
2353 6.0f,
2354 1.0f,
2355 100.0f,
2356 "UI Units",
2357 "Scale the button icon size (by the button size)",
2358 1.0f,
2359 100.0f);
2360 RNA_def_float(func,
2361 "scale_popup",
2362 5.0f,
2363 1.0f,
2364 100.0f,
2365 "Scale",
2366 "Scale the popup icon size (by the button size)",
2367 1.0f,
2368 100.0f);
2369
2370 func = RNA_def_function(srna, "template_histogram", "template_histogram");
2371 RNA_def_function_ui_description(func, "Item. A histogram widget to analyze image data.");
2373
2374 func = RNA_def_function(srna, "template_waveform", "template_waveform");
2375 RNA_def_function_ui_description(func, "Item. A waveform widget to analyze image data.");
2377
2378 func = RNA_def_function(srna, "template_vectorscope", "template_vectorscope");
2379 RNA_def_function_ui_description(func, "Item. A vectorscope widget to analyze image data.");
2381
2382 func = RNA_def_function(srna, "template_layers", "template_layers");
2384 parm = RNA_def_pointer(
2385 func, "used_layers_data", "AnyType", "", "Data from which to take property");
2387 parm = RNA_def_string(
2388 func, "used_layers_property", nullptr, 0, "", "Identifier of property in data");
2390 parm = RNA_def_int(func, "active_layer", 0, 0, INT_MAX, "Active Layer", "", 0, INT_MAX);
2392
2393 func = RNA_def_function(srna, "template_color_picker", "template_color_picker");
2394 RNA_def_function_ui_description(func, "Item. A color wheel widget to pick colors.");
2397 func, "value_slider", false, "", "Display the value slider to the right of the color wheel");
2398 RNA_def_boolean(func,
2399 "lock",
2400 false,
2401 "",
2402 "Lock the color wheel display to value 1.0 regardless of actual color");
2404 func, "lock_luminosity", false, "", "Keep the color at its original vector length");
2405 RNA_def_boolean(func, "cubic", false, "", "Cubic saturation for picking values close to white");
2406
2407 func = RNA_def_function(srna, "template_palette", "template_palette");
2408 RNA_def_function_ui_description(func, "Item. A palette used to pick colors.");
2410
2411 func = RNA_def_function(srna, "template_image_layers", "uiTemplateImageLayers");
2413 parm = RNA_def_pointer(func, "image", "Image", "", "Image data-block to display layers for");
2415 parm = RNA_def_pointer(func, "image_user", "ImageUser", "", "Image user reading from the image");
2417
2418 func = RNA_def_function(srna, "template_image", "uiTemplateImage");
2420 func, "Item(s). User interface for selecting images and their source paths.");
2423 parm = RNA_def_pointer(func, "image_user", "ImageUser", "", "");
2425 RNA_def_boolean(func, "compact", false, "", "Use more compact layout");
2426 RNA_def_boolean(func, "multiview", false, "", "Expose Multi-View options");
2427
2428 func = RNA_def_function(srna, "template_image_settings", "uiTemplateImageSettings");
2430 RNA_def_function_ui_description(func, "User interface for setting image format options");
2431 parm = RNA_def_pointer(func, "image_settings", "ImageFormatSettings", "", "");
2433 RNA_def_boolean(func, "color_management", false, "", "Show color management settings");
2434
2435 func = RNA_def_function(srna, "template_image_stereo_3d", "uiTemplateImageStereo3d");
2436 RNA_def_function_ui_description(func, "User interface for setting image stereo 3d options");
2437 parm = RNA_def_pointer(func, "stereo_3d_format", "Stereo3dFormat", "", "");
2439
2440 func = RNA_def_function(srna, "template_image_views", "uiTemplateImageViews");
2441 RNA_def_function_ui_description(func, "User interface for setting image views output options");
2442 parm = RNA_def_pointer(func, "image_settings", "ImageFormatSettings", "", "");
2444
2445 func = RNA_def_function(srna, "template_movieclip", "uiTemplateMovieClip");
2447 func, "Item(s). User interface for selecting movie clips and their source paths.");
2450 RNA_def_boolean(func, "compact", false, "", "Use more compact layout");
2451
2452 func = RNA_def_function(srna, "template_track", "uiTemplateTrack");
2453 RNA_def_function_ui_description(func, "Item. A movie-track widget to preview tracking image.");
2455
2456 func = RNA_def_function(srna, "template_marker", "uiTemplateMarker");
2457 RNA_def_function_ui_description(func, "Item. A widget to control single marker settings.");
2459 parm = RNA_def_pointer(func, "clip_user", "MovieClipUser", "", "");
2461 parm = RNA_def_pointer(func, "track", "MovieTrackingTrack", "", "");
2463 RNA_def_boolean(func, "compact", false, "", "Use more compact layout");
2464
2465 func = RNA_def_function(
2466 srna, "template_movieclip_information", "uiTemplateMovieclipInformation");
2467 RNA_def_function_ui_description(func, "Item. Movie clip information data.");
2469 parm = RNA_def_pointer(func, "clip_user", "MovieClipUser", "", "");
2471
2472 func = RNA_def_function(srna, "template_list", "rna_template_list");
2473 RNA_def_function_ui_description(func, "Item. A list widget to display data, e.g. vertexgroups.");
2475 parm = RNA_def_string(
2476 func, "listtype_name", nullptr, 0, "", "Identifier of the list type to use");
2478 parm = RNA_def_string(
2479 func,
2480 "list_id",
2481 nullptr,
2482 0,
2483 "",
2484 "Identifier of this list widget. Necessary to tell apart different list widgets. Mandatory "
2485 "when using default \"" UI_UL_DEFAULT_CLASS_NAME
2486 "\" class. "
2487 "If this not an empty string, the uilist gets a custom ID, otherwise it takes the "
2488 "name of the class used to define the uilist (for example, if the "
2489 "class name is \"OBJECT_UL_vgroups\", and list_id is not set by the "
2490 "script, then bl_idname = \"OBJECT_UL_vgroups\")");
2492 parm = RNA_def_pointer(
2493 func, "dataptr", "AnyType", "", "Data from which to take the Collection property");
2495 parm = RNA_def_string(
2496 func, "propname", nullptr, 0, "", "Identifier of the Collection property in data");
2498 parm = RNA_def_pointer(func,
2499 "active_dataptr",
2500 "AnyType",
2501 "",
2502 "Data from which to take the integer property, index of the active item");
2504 parm = RNA_def_string(
2505 func,
2506 "active_propname",
2507 nullptr,
2508 0,
2509 "",
2510 "Identifier of the integer property in active_data, index of the active item");
2512 RNA_def_string(func,
2513 "item_dyntip_propname",
2514 nullptr,
2515 0,
2516 "",
2517 "Identifier of a string property in items, to use as tooltip content");
2518 RNA_def_int(func,
2519 "rows",
2520 5,
2521 0,
2522 INT_MAX,
2523 "",
2524 "Default and minimum number of rows to display",
2525 0,
2526 INT_MAX);
2528 func, "maxrows", 5, 0, INT_MAX, "", "Default maximum number of rows to display", 0, INT_MAX);
2529 RNA_def_enum(func,
2530 "type",
2533 "Type",
2534 "Type of layout to use");
2535 parm = RNA_def_int(func,
2536 "columns",
2537 9,
2538 0,
2539 INT_MAX,
2540 "",
2541 "Number of items to display per row, for GRID layout",
2542 0,
2543 INT_MAX);
2545 "Unused but kept for compatibility reasons. Setting the parameter "
2546 "has no effect, there will always be a single column.",
2547 501,
2548 600);
2549 RNA_def_boolean(func, "sort_reverse", false, "", "Display items in reverse order by default");
2550 RNA_def_boolean(func, "sort_lock", false, "", "Lock display order to default value");
2551
2552 func = RNA_def_function(srna, "template_running_jobs", "template_running_jobs");
2554
2555 RNA_def_function(srna, "template_operator_search", "uiTemplateOperatorSearch");
2556 RNA_def_function(srna, "template_menu_search", "uiTemplateMenuSearch");
2557
2558 func = RNA_def_function(srna, "template_header_3D_mode", "template_header3D_mode");
2561
2562 func = RNA_def_function(srna, "template_edit_mode_selection", "uiTemplateEditModeSelection");
2565 func, "Inserts common 3DView Edit modes header UI (selector for selection mode)");
2566
2567 func = RNA_def_function(srna, "template_reports_banner", "uiTemplateReportsBanner");
2569
2570 func = RNA_def_function(srna, "template_input_status", "uiTemplateInputStatus");
2572
2573 func = RNA_def_function(srna, "template_status_info", "uiTemplateStatusInfo");
2575
2576 func = RNA_def_function(srna, "template_node_link", "uiTemplateNodeLink");
2578 parm = RNA_def_pointer(func, "ntree", "NodeTree", "", "Node tree containing the node");
2580 parm = RNA_def_pointer(func, "node", "Node", "", "Node owning the socket");
2582 parm = RNA_def_pointer(func, "socket", "NodeSocket", "", "Socket to display the link for");
2584
2585 func = RNA_def_function(srna, "template_node_view", "uiTemplateNodeView");
2587 parm = RNA_def_pointer(func, "ntree", "NodeTree", "", "Node tree containing the node");
2589 parm = RNA_def_pointer(func, "node", "Node", "", "Node to display");
2591 parm = RNA_def_pointer(func, "socket", "NodeSocket", "", "Socket to display");
2593
2594 func = RNA_def_function(srna,
2595 "template_node_operator_registration_errors",
2596 "rna_uiLayout_template_node_operator_registration_errors");
2597 parm = RNA_def_string(func, "idname", nullptr, 0, "", "");
2598
2599 func = RNA_def_function(
2600 srna, "template_node_asset_menu_items", "rna_uiLayout_template_node_asset_menu_items");
2602 parm = RNA_def_string(func, "catalog_path", nullptr, 0, "", "");
2603 parm = RNA_def_enum(func,
2604 "operator",
2605 rna_enum_template_node_operator_type,
2607 "Operator",
2608 "The operator the asset menu will use");
2609
2610 func = RNA_def_function(srna,
2611 "template_modifier_asset_menu_items",
2612 "rna_uiLayout_template_modifier_asset_menu_items");
2614 parm = RNA_def_string(func, "catalog_path", nullptr, 0, "", "");
2615 parm = RNA_def_boolean(func, "skip_essentials", false, "", "");
2616
2617 func = RNA_def_function(srna,
2618 "template_node_operator_asset_menu_items",
2619 "rna_uiLayout_template_node_operator_asset_menu_items");
2621 parm = RNA_def_string(func, "catalog_path", nullptr, 0, "", "");
2622
2623 func = RNA_def_function(srna,
2624 "template_node_operator_asset_root_items",
2625 "rna_uiLayout_template_node_operator_root_items");
2627
2628 func = RNA_def_function(srna, "template_texture_user", "uiTemplateTextureUser");
2630
2631 func = RNA_def_function(
2632 srna, "template_keymap_item_properties", "uiTemplateKeymapItemProperties");
2633 parm = RNA_def_pointer(func, "item", "KeyMapItem", "", "");
2635
2636 func = RNA_def_function(srna, "template_component_menu", "template_component_menu");
2637 RNA_def_function_ui_description(func, "Item. Display expanded property in a popup menu");
2638 parm = RNA_def_pointer(func, "data", "AnyType", "", "Data from which to take property");
2640 parm = RNA_def_string(func, "property", nullptr, 0, "", "Identifier of property in data");
2642 RNA_def_string(func, "name", nullptr, 0, "", "");
2643
2644 /* color management templates */
2645 func = RNA_def_function(srna, "template_colorspace_settings", "template_colorspace_settings");
2646 RNA_def_function_ui_description(func, "Item. A widget to control input color space settings.");
2648
2649 func = RNA_def_function(
2650 srna, "template_colormanaged_view_settings", "template_colormanaged_view_settings");
2651 RNA_def_function_ui_description(func, "Item. A widget to control color managed view settings.");
2654# if 0
2655 RNA_def_boolean(func,
2656 "show_global_settings",
2657 false,
2658 "",
2659 "Show widgets to control global color management settings");
2660# endif
2661
2662 /* node socket icon */
2663 func = RNA_def_function(srna, "template_node_socket", "template_node_socket");
2664 RNA_def_function_ui_description(func, "Node Socket Icon");
2667 func, "color", 4, node_socket_color_default, 0.0f, 1.0f, "Color", "", 0.0f, 1.0f);
2668
2669 func = RNA_def_function(srna, "template_cache_file", "rna_template_cache_file");
2671 func, "Item(s). User interface for selecting cache files and their source paths");
2674
2675 func = RNA_def_function(
2676 srna, "template_cache_file_velocity", "rna_template_cache_file_velocity");
2677 RNA_def_function_ui_description(func, "Show cache files velocity properties");
2679
2680 func = RNA_def_function(
2681 srna, "template_cache_file_time_settings", "rna_template_cache_file_time_settings");
2682 RNA_def_function_ui_description(func, "Show cache files time settings");
2684
2685 func = RNA_def_function(srna, "template_cache_file_layers", "rna_template_uilist_flags");
2686 RNA_def_function_ui_description(func, "Show cache files override layers properties");
2689
2690 func = RNA_def_function(srna, "template_recent_files", "rna_uiTemplateRecentFiles");
2692 func, "Show list of recently saved .blend files, with active project files first");
2693 RNA_def_int(func, "rows", 6, 1, INT_MAX, "", "Maximum number of items to show", 1, INT_MAX);
2694 RNA_def_enum(func,
2695 "filter",
2698 "",
2699 "Files to show, with rows distributed as if showing all files");
2701 "project_ratio",
2702 0.5f,
2703 0.0f,
2704 1.0f,
2705 "",
2706 "Ratio of rows reserved for project files, relative to other recent files",
2707 0.0f,
2708 1.0f);
2709 parm = RNA_def_int(func, "found", 0, 0, INT_MAX, "", "Number of items drawn", 0, INT_MAX);
2710 RNA_def_function_return(func, parm);
2711
2712 func = RNA_def_function(srna, "template_recent_projects", "template_recent_projects");
2713 RNA_def_function_ui_description(func, "Show list of recently opened projects");
2714 RNA_def_int(func, "rows", 6, 1, INT_MAX, "", "Maximum number of items to show", 1, INT_MAX);
2715 parm = RNA_def_int(func, "found", 0, 0, INT_MAX, "", "Number of items drawn", 0, INT_MAX);
2716 RNA_def_function_return(func, parm);
2717
2718 func = RNA_def_function(srna, "template_project_splash", "template_project_splash");
2721 func, "Show the splash artwork of the active project, with buttons to set and clear it");
2722
2723 func = RNA_def_function(srna, "template_file_select_path", "template_file_select_path");
2725 "Item. A text button to set the active file browser path.");
2726 parm = RNA_def_pointer(
2727 func, "params", "FileSelectParams", "", "File browser parameters whose path is edited");
2730
2731 func = RNA_def_function(
2732 srna, "template_event_from_keymap_item", "rna_template_event_from_keymap_item");
2733 RNA_def_function_ui_description(func, "Display keymap item as icons/text");
2734 parm = RNA_def_property(func, "item", PROP_POINTER, PROP_NONE);
2735 RNA_def_property_struct_type(parm, "KeyMapItem");
2736 RNA_def_property_ui_text(parm, "Item", "");
2739
2740 func = RNA_def_function(
2741 srna, "template_light_linking_collection", "template_light_linking_collection");
2743 "Visualization of a content of a light linking collection");
2745 parm = RNA_def_pointer(func,
2746 "context_layout",
2747 "UILayout",
2748 "",
2749 "Layout to set active list element as context properties");
2752
2753 func = RNA_def_function(srna, "template_bone_collection_tree", "template_bone_collection_tree");
2754 RNA_def_function_ui_description(func, "Show bone collections tree");
2756
2757 func = RNA_def_function(
2758 srna, "template_project_asset_libraries_tree", "template_project_asset_libraries_tree");
2759 RNA_def_function_ui_description(func, "Show current project's asset library tree");
2761
2762 func = RNA_def_function(
2763 srna, "template_grease_pencil_layer_tree", "template_grease_pencil_layer_tree");
2764 RNA_def_function_ui_description(func, "View of the active Grease Pencil layer tree");
2766
2767 func = RNA_def_function(srna, "template_node_tree_interface", "template_tree_interface");
2768 RNA_def_function_ui_description(func, "Show a node tree interface");
2770 parm = RNA_def_pointer(func,
2771 "interface",
2772 "NodeTreeInterface",
2773 "Node Tree Interface",
2774 "Interface of a node tree to display");
2776
2777 func = RNA_def_function(srna, "template_node_inputs", "template_node_inputs");
2778 RNA_def_function_ui_description(func, "Show a node settings and input socket values");
2780 parm = RNA_def_pointer(func, "node", "Node", "Node", "Display inputs of this node");
2782
2783 func = RNA_def_function(
2784 srna, "template_compositor_strip_inputs", "template_compositor_strip_inputs");
2786 func, "Show the compositor node group input values for a compositor effect strip");
2788 parm = RNA_def_pointer(func, "strip", "Strip", "Strip", "Compositor effect strip");
2790
2791 func = RNA_def_function(srna, "template_asset_shelf_popover", "rna_uiTemplateAssetShelfPopover");
2792 RNA_def_function_ui_description(func, "Create a button to open an asset shelf in a popover");
2794 parm = RNA_def_string(func,
2795 "asset_shelf",
2796 nullptr,
2797 0,
2798 "",
2799 "Identifier of the asset shelf to display (``bl_idname``)");
2801 parm = RNA_def_string(
2802 func, "name", nullptr, 0, "", "Optional name to indicate the active asset");
2804 parm = RNA_def_property(func, "icon", PROP_ENUM, PROP_NONE);
2806 RNA_def_property_ui_text(parm, "Icon", "Override automatic icon of the item");
2807 parm = RNA_def_property(func, "icon_value", PROP_INT, PROP_UNSIGNED);
2808 RNA_def_property_ui_text(parm, "Icon Value", "Override automatic icon of the item");
2809
2810 /* A version of `operator` that defines a [Cancel, Confirm] pair of buttons. */
2811 func = RNA_def_function(srna, "template_popup_confirm", "rna_uiTemplatePopupConfirm");
2813 parm = RNA_def_string(func,
2814 "cancel_text",
2815 nullptr,
2816 0,
2817 "",
2818 "Optional text to use for the cancel, not shown when an empty string");
2819 RNA_def_boolean(func, "cancel_default", false, "", "Cancel button by default");
2821 func, "Add confirm & cancel buttons into a popup which will close the popup when pressed");
2823
2824 parm = RNA_def_pointer(
2825 func, "properties", "OperatorProperties", "", "Operator properties to fill in");
2827 RNA_def_function_return(func, parm);
2828
2829 func = RNA_def_function(srna, "template_shape_key_tree", "ed::object::shapekey::template_tree");
2830 RNA_def_function_ui_description(func, "Shape Key tree view");
2832}
2833
2834} // namespace blender
2835
2836#endif
#define BLT_I18NCONTEXT_DEFAULT
#define RNA_warning_bare(format,...)
#define C
Definition RandGen.cpp:29
#define UI_UL_DEFAULT_CLASS_NAME
#define UI_ITEM_NONE
#define UI_MAX_NAME_STR
#define ELEM(...)
constexpr StringRef()
#define FLT_MAX
#define INT_MAX
float4x4 translate(float4x4 mat, float3 translation)
void free(Subdiv *subdiv)
Definition subdiv.cc:192
void ui_template_node_operator_asset_root_items(ui::Layout &layout, const bContext &C)
void ui_template_node_operator_asset_menu_items(ui::Layout &layout, const bContext &C, const StringRef path)
void ui_template_node_operator_registration_errors(ui::Layout &layout, const StringRefNull idname_py)
void ui_template_modifier_asset_menu_items(const bContext &C, ui::Layout &layout, StringRef catalog_path, bool skip_essentials)
void ui_template_node_asset_menu_items(ui::Layout &layout, const bContext &C, StringRef catalog_path, const ui::NodeAssetMenuOperatorType operator_type)
void template_action(Layout *layout, const bContext *C, ID *id, const char *newop, const char *unlinkop, std::optional< StringRef > text)
void template_filepath(Layout *layout, const bContext *C, PointerRNA *ptr, const StringRefNull propname, const char *pathselect_op, const char *filter_glob, const std::optional< StringRef > name, const std::optional< StringRef > placeholder, bool split_name=false)
void template_ID_session_uid(Layout &layout, bContext *C, PointerRNA *ptr, StringRefNull propname, short idcode)
bool template_cache_file_pointer(PointerRNA *ptr, StringRefNull propname, PointerRNA *r_file_ptr)
void template_search_preview(Layout *layout, bContext *C, PointerRNA *ptr, StringRefNull propname, PointerRNA *searchptr, const char *searchpropname, const char *newop, const char *unlinkop, int rows, int cols, std::optional< StringRef > text=std::nullopt)
void popup_block_template_confirm_op(Layout *layout, wmOperatorType *ot, std::optional< StringRef > confirm_text, std::optional< StringRef > cancel_text, const int icon, bool cancel_default, PointerRNA *r_ptr)
void template_uilist_flags(Layout *layout, const bContext *C, PointerRNA *fileptr)
int template_recent_files(Layout *layout, int rows, RecentFilesFilter filter=RecentFilesFilter::All, float project_ratio=0.5f)
void template_uilist(Layout *layout, const bContext *C, const char *listtype_name, const char *list_id, PointerRNA *dataptr, StringRefNull propname, PointerRNA *active_dataptr, StringRefNull active_propname, const char *item_dyntip_propname, int rows, int maxrows, int layout_type, enum TemplateListFlags flags)
void template_id(Layout *layout, const bContext *C, PointerRNA *ptr, StringRefNull propname, const char *newop, const char *openop, const char *unlinkop, int filter=TEMPLATE_ID_FILTER_ALL, bool live_icon=false, std::optional< StringRef > text=std::nullopt)
void template_cache_file(Layout *layout, const bContext *C, PointerRNA *ptr, StringRefNull propname)
void template_cache_file_time_settings(Layout *layout, PointerRNA *fileptr)
bool template_event_from_keymap_item(Layout *layout, StringRefNull text, const wmKeyMapItem *kmi, bool text_fallback)
void template_cache_file_velocity(Layout *layout, PointerRNA *fileptr)
void template_search(Layout *layout, const bContext *C, PointerRNA *ptr, StringRefNull propname, PointerRNA *searchptr, const char *searchpropname, const char *newop, const char *unlinkop, std::optional< StringRef > text=std::nullopt)
int icon_from_rnaptr(const bContext *C, PointerRNA *ptr, int rnaicon, bool big)
bool popup_block_template_confirm_is_supported(const Block *block)
void template_any_id(Layout *layout, PointerRNA *ptr, StringRefNull propname, StringRefNull proptypename, std::optional< StringRef > text)
void template_path_builder(Layout *layout, PointerRNA *ptr, StringRefNull propname, PointerRNA *root_ptr, std::optional< StringRefNull > text)
void template_asset_shelf_popover(Layout &layout, const bContext &C, StringRefNull asset_shelf_id, StringRef name, int icon)
BMesh Iterators.
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
void RNA_def_property_deprecated(PropertyRNA *prop, const char *note, const short version, const short removal_version)
const EnumPropertyItem rna_enum_id_type_items[]
Definition rna_ID.cc:33
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
void RNA_def_function_output(FunctionRNA *, PropertyRNA *ret)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
const EnumPropertyItem rna_enum_space_type_items[]
Definition rna_space.cc:91
PropertyRNA * RNA_def_float_array(StructOrFunctionRNA *cont_, const char *identifier, const int len, const float *default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
void RNA_def_function_ui_description(FunctionRNA *func, const char *description)
void RNA_property_enum_items(bContext *C, PointerRNA *ptr, PropertyRNA *prop, const EnumPropertyItem **r_item, int *r_totitem, bool *r_free)
@ FUNC_USE_REPORTS
@ FUNC_NO_SELF
Definition RNA_types.hh:998
@ FUNC_USE_CONTEXT
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_pointer(StructOrFunctionRNA *cont_, const char *identifier, const char *type, const char *ui_name, const char *ui_description)
static void api_ui_item_op(FunctionRNA *func)
const char * RNA_property_translation_context(const PropertyRNA *prop)
void RNA_def_property_struct_type(PropertyRNA *prop, const char *type)
static void api_ui_item_common_heading(FunctionRNA *func)
std::optional< StringRefNull > rna_translate_ui_text(const char *text, const char *text_ctxt, StructRNA *type, PropertyRNA *prop, bool translate)
static const EnumPropertyItem recent_files_filter_items[]
Definition rna_ui_api.cc:50
bool RNA_property_array_check(PropertyRNA *prop)
static const EnumPropertyItem curve_type_items[]
Definition rna_curve.cc:124
static void api_ui_item_common_text(FunctionRNA *func)
PropertyRNA * RNA_def_float_factor(StructOrFunctionRNA *cont_, const char *identifier, const float default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier_c_str, int type, int subtype)
PropertyType RNA_property_type(PropertyRNA *prop)
static void api_ui_item_rna_common(FunctionRNA *func)
void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item)
int RNA_enum_from_identifier(const EnumPropertyItem *item, const char *identifier)
StructRNA * RNA_property_pointer_type(PointerRNA *ptr, PropertyRNA *prop)
@ PROP_BOOLEAN
Definition RNA_types.hh:210
@ PROP_POINTER
Definition RNA_types.hh:215
void RNA_def_parameter_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
const char * BLT_pgettext(const char *msgctxt, const char *msgid)
BMesh const char void * data
void RNA_def_property_range(PropertyRNA *prop, double min, double max)
void RNA_def_function_return(FunctionRNA *func, PropertyRNA *ret)
PropertyRNA * RNA_struct_type_find_property(StructRNA *srna, const char *identifier)
static const EnumPropertyItem popup_draw_direction_items[]
Definition rna_ui_api.cc:36
void RNA_property_enum_items_gettexted(bContext *C, PointerRNA *ptr, PropertyRNA *prop, const EnumPropertyItem **r_item, int *r_totitem, bool *r_free)
FunctionRNA * RNA_def_function(StructRNA *srna, const char *identifier_c_str, const char *call)
static void api_ui_item_common(FunctionRNA *func)
int RNA_struct_ui_icon(const StructRNA *type)
void api_ui_item_common_translation(FunctionRNA *func)
int BIFIconID
Definition ED_asset.hh:30
void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag)
const char * RNA_struct_identifier(const StructRNA *type)
const EnumPropertyItem rna_enum_region_type_items[]
Definition rna_screen.cc:28
PropertySubType RNA_property_subtype(PropertyRNA *prop)
wmOperatorType * WM_operatortype_find(const char *idname, bool quiet)
void RNA_def_function_flag(FunctionRNA *func, FunctionFlag flag)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
static void api_ui_item_op_common(FunctionRNA *func)
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, const int default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
Definition report.cc:191
void RNA_api_ui_layout(StructRNA *srna)
const EnumPropertyItem rna_enum_uilist_layout_type_items[]
Definition rna_ui.cc:53
@ PROP_NEVER_NULL
Definition RNA_types.hh:447
bool BLT_translate_iface()
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
@ PROP_COLOR_GAMMA
Definition RNA_types.hh:329
@ PROP_UNSIGNED
Definition RNA_types.hh:306
@ PARM_REQUIRED
Definition RNA_types.hh:631
@ PARM_RNAPTR
Definition RNA_types.hh:633
const EnumPropertyItem rna_enum_icon_items[]
Definition rna_ui_api.cc:30
PropertyRNA * RNA_def_float(StructOrFunctionRNA *cont_, const char *identifier, const float default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
const char * RNA_struct_translation_context(const StructRNA *type)
TextAlignAnchor
Definition rna_ui_api.cc:66