Blender V5.0
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"
18#include "UI_resources.hh"
19
20#include "rna_internal.hh"
21
22#define DEF_ICON(name) {ICON_##name, (#name), 0, (#name), ""},
23#define DEF_ICON_VECTOR(name) {ICON_##name, (#name), 0, (#name), ""},
24#define DEF_ICON_COLOR(name) {ICON_##name, (#name), 0, (#name), ""},
25#define DEF_ICON_BLANK(name)
27#include "UI_icons.hh"
28 {0, nullptr, 0, nullptr, nullptr},
29};
30
31#ifdef RNA_RUNTIME
32
33# include "BLT_translation.hh"
34
35# include "DNA_asset_types.h"
36
37# include "BKE_report.hh"
38
39# include "ED_asset_filter.hh"
40# include "ED_geometry.hh"
41# include "ED_node.hh"
42# include "ED_object.hh"
43
44# include "WM_api.hh"
45
47
48std::optional<StringRefNull> rna_translate_ui_text(
49 const char *text, const char *text_ctxt, StructRNA *type, PropertyRNA *prop, bool translate)
50{
51 if (!text) {
52 return std::nullopt;
53 }
54 /* Also return text if UI labels translation is disabled. */
55 if (!text[0] || !translate || !BLT_translate_iface()) {
56 return text;
57 }
58
59 /* If a text_ctxt is specified, use it! */
60 if (text_ctxt && text_ctxt[0]) {
61 return BLT_pgettext(text_ctxt, text);
62 }
63
64 /* Else, if an RNA type or property is specified, use its context. */
65# if 0
66 /* XXX Disabled for now. Unfortunately, their is absolutely no way from py code to get the RNA
67 * struct corresponding to the 'data' (in functions like prop() & co),
68 * as this is pure runtime data. Hence, messages extraction script can't determine the
69 * correct context it should use for such 'text' messages...
70 * So for now, one have to explicitly specify the 'text_ctxt' when using prop() etc.
71 * functions, if default context is not suitable.
72 */
73 if (prop) {
75 }
76# else
77 (void)prop;
78# endif
79 if (type) {
81 }
82
83 /* Else, default context! */
85}
86
87static void rna_uiItemR(uiLayout *layout,
89 const char *propname,
90 const char *name,
91 const char *text_ctxt,
92 bool translate,
93 int icon,
94 const char *placeholder,
95 bool expand,
96 bool slider,
97 int toggle,
98 bool icon_only,
99 bool event,
100 bool full_event,
101 bool emboss,
102 int index,
103 int icon_value,
104 bool invert_checkbox)
105{
106 PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
108
109 if (!prop) {
110 RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
111 return;
112 }
113
114 if (icon_value && !icon) {
115 icon = icon_value;
116 }
117
118 /* Get translated name (label). */
119 std::optional<StringRefNull> text = rna_translate_ui_text(
120 name, text_ctxt, nullptr, prop, translate);
121 std::optional<StringRefNull> placeholder_str = rna_translate_ui_text(
122 placeholder, text_ctxt, nullptr, prop, translate);
123
124 if (slider) {
126 }
127 if (expand) {
129 }
130
131 if (toggle == 1) {
133 }
134 else if (toggle == 0) {
136 }
137
138 if (icon_only) {
140 }
141 if (event) {
143 }
144 if (full_event) {
146 }
147 if (emboss == false) {
149 }
150 if (invert_checkbox) {
152 }
153
154 layout->prop(ptr, prop, index, 0, flag, text, icon, placeholder_str);
155}
156
157static void rna_uiItemR_with_popover(uiLayout *layout,
159 const char *propname,
160 const char *name,
161 const char *text_ctxt,
162 bool translate,
163 int icon,
164 bool icon_only,
165 const char *panel_type)
166{
167 PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
168
169 if (!prop) {
170 RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
171 return;
172 }
173 if ((RNA_property_type(prop) != PROP_ENUM) &&
175 {
177 "property is not an enum or color: %s.%s", RNA_struct_identifier(ptr->type), propname);
178 return;
179 }
181 if (icon_only) {
183 }
184
185 /* Get translated name (label). */
186 std::optional<StringRefNull> text = rna_translate_ui_text(
187 name, text_ctxt, nullptr, prop, translate);
188 layout->prop_with_popover(ptr, prop, -1, 0, flag, text, icon, panel_type);
189}
190
191static void rna_uiItemR_with_menu(uiLayout *layout,
193 const char *propname,
194 const char *name,
195 const char *text_ctxt,
196 bool translate,
197 int icon,
198 bool icon_only,
199 const char *menu_type)
200{
201 PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
202
203 if (!prop) {
204 RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
205 return;
206 }
207 if (RNA_property_type(prop) != PROP_ENUM) {
208 RNA_warning("property is not an enum: %s.%s", RNA_struct_identifier(ptr->type), propname);
209 return;
210 }
212 if (icon_only) {
214 }
215
216 /* Get translated name (label). */
217 std::optional<StringRefNull> text = rna_translate_ui_text(
218 name, text_ctxt, nullptr, prop, translate);
219 layout->prop_with_menu(ptr, prop, -1, 0, flag, text, icon, menu_type);
220}
221
222static void rna_uiItemMenuEnumR(uiLayout *layout,
224 const char *propname,
225 const char *name,
226 const char *text_ctxt,
227 bool translate,
228 int icon)
229{
230 PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
231
232 if (!prop) {
233 RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
234 return;
235 }
236
237 /* Get translated name (label). */
238 std::optional<StringRefNull> text = rna_translate_ui_text(
239 name, text_ctxt, nullptr, prop, translate);
240 layout->prop_menu_enum(ptr, prop, text, icon);
241}
242
243static void rna_uiItemTabsEnumR(uiLayout *layout,
244 bContext *C,
246 const char *propname,
247 PointerRNA *ptr_highlight,
248 const char *propname_highlight,
249 bool icon_only)
250{
251 PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
252
253 if (!prop) {
254 RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
255 return;
256 }
257 if (RNA_property_type(prop) != PROP_ENUM) {
258 RNA_warning("property is not an enum: %s.%s", RNA_struct_identifier(ptr->type), propname);
259 return;
260 }
261
262 /* Get the highlight property used to gray out some of the tabs. */
263 PropertyRNA *prop_highlight = nullptr;
264 if (!RNA_pointer_is_null(ptr_highlight)) {
265 prop_highlight = RNA_struct_find_property(ptr_highlight, propname_highlight);
266 if (!prop_highlight) {
267 RNA_warning("property not found: %s.%s",
268 RNA_struct_identifier(ptr_highlight->type),
269 propname_highlight);
270 return;
271 }
272 if (RNA_property_type(prop_highlight) != PROP_BOOLEAN) {
273 RNA_warning("property is not a boolean: %s.%s",
274 RNA_struct_identifier(ptr_highlight->type),
275 propname_highlight);
276 return;
277 }
278 if (!RNA_property_array_check(prop_highlight)) {
279 RNA_warning("property is not an array: %s.%s",
280 RNA_struct_identifier(ptr_highlight->type),
281 propname_highlight);
282 return;
283 }
284 }
285
286 layout->prop_tabs_enum(C, ptr, prop, ptr_highlight, prop_highlight, icon_only);
287}
288
289static void rna_uiItemEnumR_string(uiLayout *layout,
291 const char *propname,
292 const char *value,
293 const char *name,
294 const char *text_ctxt,
295 bool translate,
296 int icon)
297{
298 PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
299
300 if (!prop) {
301 RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
302 return;
303 }
304
305 /* Get translated name (label). */
306 std::optional<StringRefNull> text = rna_translate_ui_text(
307 name, text_ctxt, nullptr, prop, translate);
308
309 layout->prop_enum(ptr, prop, value, text, icon);
310}
311
312static void rna_uiItemsEnumR(uiLayout *layout, PointerRNA *ptr, const char *propname)
313{
314 layout->props_enum(ptr, propname);
315}
316
317static void rna_uiItemPointerR(uiLayout *layout,
319 const char *propname,
320 PointerRNA *searchptr,
321 const char *searchpropname,
322 const char *name,
323 const char *text_ctxt,
324 bool translate,
325 int icon,
326 const bool results_are_suggestions,
327 const char *item_searchpropname)
328{
329 PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
330 if (!prop) {
331 RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
332 return;
333 }
334 PropertyRNA *searchprop = RNA_struct_find_property(searchptr, searchpropname);
335 if (!searchprop) {
337 "property not found: %s.%s", RNA_struct_identifier(searchptr->type), searchpropname);
338 return;
339 }
340
341 PropertyRNA *item_searchprop = nullptr;
342 if (item_searchpropname && item_searchpropname[0]) {
343 StructRNA *collection_item_type = RNA_property_pointer_type(searchptr, searchprop);
344 item_searchprop = RNA_struct_type_find_property(collection_item_type, item_searchpropname);
345 if (!item_searchprop) {
346 RNA_warning("Collection items search property not found: %s.%s",
347 RNA_struct_identifier(collection_item_type),
348 item_searchpropname);
349 }
350 }
351
352 /* Get translated name (label). */
353 std::optional<StringRefNull> text = rna_translate_ui_text(
354 name, text_ctxt, nullptr, prop, translate);
355
356 layout->prop_search(
357 ptr, prop, searchptr, searchprop, item_searchprop, text, icon, results_are_suggestions);
358}
359
360void rna_uiLayoutDecorator(uiLayout *layout, PointerRNA *ptr, const char *propname, int index)
361{
362 layout->decorator(ptr, propname, index);
363}
364
365static PointerRNA rna_uiItemO(uiLayout *layout,
366 const char *opname,
367 const char *name,
368 const char *text_ctxt,
369 bool translate,
370 int icon,
371 bool emboss,
372 bool depress,
373 int icon_value,
374 const float search_weight)
375{
377
378 ot = WM_operatortype_find(opname, false); /* print error next */
379 if (!ot || !ot->srna) {
380 RNA_warning("%s '%s'", ot ? "operator missing srna" : "unknown operator", opname);
381 return PointerRNA_NULL;
382 }
383
384 /* Get translated name (label). */
385 std::optional<StringRefNull> text = rna_translate_ui_text(
386 name, text_ctxt, ot->srna, nullptr, translate);
387
388 if (icon_value && !icon) {
389 icon = icon_value;
390 }
392 if (emboss == false) {
394 }
395 if (depress) {
397 }
398
399 const float prev_weight = layout->search_weight();
400 layout->search_weight_set(search_weight);
401
402 PointerRNA opptr = layout->op(ot, text, icon, layout->operator_context(), flag);
403
404 layout->search_weight_set(prev_weight);
405 return opptr;
406}
407
408static PointerRNA rna_uiItemOMenuHold(uiLayout *layout,
409 const char *opname,
410 const char *name,
411 const char *text_ctxt,
412 bool translate,
413 int icon,
414 bool emboss,
415 bool depress,
416 int icon_value,
417 const char *menu)
418{
419 wmOperatorType *ot = WM_operatortype_find(opname, false); /* print error next */
420 if (!ot || !ot->srna) {
421 RNA_warning("%s '%s'", ot ? "operator missing srna" : "unknown operator", opname);
422 return PointerRNA_NULL;
423 }
424
425 /* Get translated name (label). */
426 std::optional<StringRefNull> text = rna_translate_ui_text(
427 name, text_ctxt, ot->srna, nullptr, translate);
428 if (icon_value && !icon) {
429 icon = icon_value;
430 }
432 if (emboss == false) {
434 }
435 if (depress) {
437 }
438
439 return layout->op_menu_hold(ot, text, icon, layout->operator_context(), flag, menu);
440}
441
442static void rna_uiItemsEnumO(uiLayout *layout,
443 const char *opname,
444 const char *propname,
445 const bool icon_only)
446{
448 layout->op_enum(opname, propname, nullptr, layout->operator_context(), flag);
449}
450
451static PointerRNA rna_uiItemMenuEnumO(uiLayout *layout,
452 bContext *C,
453 const char *opname,
454 const char *propname,
455 const char *name,
456 const char *text_ctxt,
457 bool translate,
458 int icon)
459{
460 wmOperatorType *ot = WM_operatortype_find(opname, false); /* print error next */
461
462 if (!ot || !ot->srna) {
463 RNA_warning("%s '%s'", ot ? "operator missing srna" : "unknown operator", opname);
464 return PointerRNA_NULL;
465 }
466
467 /* Get translated name (label). */
468 std::optional<StringRefNull> text = rna_translate_ui_text(
469 name, text_ctxt, ot->srna, nullptr, translate);
470
471 return layout->op_menu_enum(C, ot, propname, text, icon);
472}
473
474static void rna_uiItemL(uiLayout *layout,
475 const char *name,
476 const char *text_ctxt,
477 bool translate,
478 int icon,
479 int icon_value)
480{
481 /* Get translated name (label). */
482 std::optional<StringRefNull> text = rna_translate_ui_text(
483 name, text_ctxt, nullptr, nullptr, translate);
484
485 if (icon_value && !icon) {
486 icon = icon_value;
487 }
488
489 layout->label(text.value_or(""), icon);
490}
491
492static void rna_uiItemM(uiLayout *layout,
493 const char *menuname,
494 const char *name,
495 const char *text_ctxt,
496 bool translate,
497 int icon,
498 int icon_value)
499{
500 /* Get translated name (label). */
501 std::optional<StringRefNull> text = rna_translate_ui_text(
502 name, text_ctxt, nullptr, nullptr, translate);
503
504 if (icon_value && !icon) {
505 icon = icon_value;
506 }
507
508 layout->menu(menuname, text, icon);
509}
510
511static void rna_uiItemM_contents(uiLayout *layout, const char *menuname)
512{
513 layout->menu_contents(menuname);
514}
515
516static void rna_uiItemPopoverPanel(uiLayout *layout,
517 bContext *C,
518 const char *panel_type,
519 const char *name,
520 const char *text_ctxt,
521 bool translate,
522 int icon,
523 int icon_value)
524{
525 /* Get translated name (label). */
526 std::optional<StringRefNull> text = rna_translate_ui_text(
527 name, text_ctxt, nullptr, nullptr, translate);
528
529 if (icon_value && !icon) {
530 icon = icon_value;
531 }
532
533 layout->popover(C, panel_type, text, icon);
534}
535
536static void rna_uiItemPopoverPanelFromGroup(uiLayout *layout,
537 bContext *C,
538 int space_id,
539 int region_id,
540 const char *context,
541 const char *category)
542{
543 layout->popover_group(C, space_id, region_id, context, category);
544}
545
546static void rna_uiItemProgress(uiLayout *layout,
547 const char *text,
548 const char *text_ctxt,
549 bool translate,
550 float factor,
551 int progress_type)
552{
553 if (translate && BLT_translate_iface()) {
554 text = BLT_pgettext((text_ctxt && text_ctxt[0]) ? text_ctxt : BLT_I18NCONTEXT_DEFAULT, text);
555 }
556
557 layout->progress_indicator(text, factor, blender::ui::ButProgressType(progress_type));
558}
559
560static void rna_uiItemSeparator(uiLayout *layout, float factor, int type)
561{
562 layout->separator(factor, LayoutSeparatorType(type));
563}
564
565static void rna_uiLayoutContextPointerSet(uiLayout *layout, const char *name, PointerRNA *ptr)
566{
567 layout->context_ptr_set(name, ptr);
568}
569
570static void rna_uiLayoutContextStringSet(uiLayout *layout, const char *name, const char *value)
571{
572 layout->context_string_set(name, value);
573}
574
575static void rna_uiLayoutSeparatorSpacer(uiLayout *layout)
576{
577 layout->separator_spacer();
578}
579
580static void rna_uiTemplateID(uiLayout *layout,
581 bContext *C,
583 const char *propname,
584 const char *newop,
585 const char *openop,
586 const char *unlinkop,
587 int filter,
588 const bool live_icon,
589 const char *name,
590 const char *text_ctxt,
591 bool translate)
592{
593 PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
594
595 if (!prop) {
596 RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
597 return;
598 }
599
600 /* Get translated name (label). */
601 std::optional<StringRefNull> text = rna_translate_ui_text(
602 name, text_ctxt, nullptr, prop, translate);
603
604 uiTemplateID(layout, C, ptr, propname, newop, openop, unlinkop, filter, live_icon, text);
605}
606
607static void rna_uiTemplateAnyID(uiLayout *layout,
609 const char *propname,
610 const char *proptypename,
611 const char *name,
612 const char *text_ctxt,
613 bool translate)
614{
615 PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
616
617 if (!prop) {
618 RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
619 return;
620 }
621
622 /* Get translated name (label). */
623 std::optional<StringRefNull> text = rna_translate_ui_text(
624 name, text_ctxt, nullptr, prop, translate);
625
626 /* XXX This will search property again :( */
627 uiTemplateAnyID(layout, ptr, propname, proptypename, text);
628}
629
630static void rna_uiTemplateAction(uiLayout *layout,
631 bContext *C,
632 ID *id,
633 const char *newop,
634 const char *unlinkop,
635 const char *name,
636 const char *text_ctxt,
637 const bool translate)
638{
639 std::optional<StringRefNull> text = rna_translate_ui_text(
640 name, text_ctxt, nullptr, nullptr, translate);
641 uiTemplateAction(layout, C, id, newop, unlinkop, text);
642}
643
644static void rna_uiTemplateSearch(uiLayout *layout,
645 const bContext *C,
647 const char *propname,
648 PointerRNA *searchptr,
649 const char *searchpropname,
650 const char *newop,
651 const char *unlinkop,
652 const char *name,
653 const char *text_ctxt,
654 bool translate)
655{
656 PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
657
658 if (!prop) {
659 RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
660 return;
661 }
662
663 /* Get translated name (label). */
664 std::optional<StringRefNull> text = rna_translate_ui_text(
665 name, text_ctxt, nullptr, prop, translate);
666
667 uiTemplateSearch(layout, C, ptr, propname, searchptr, searchpropname, newop, unlinkop, text);
668}
669
670static void rna_uiTemplateSearchPreview(uiLayout *layout,
671 bContext *C,
673 const char *propname,
674 PointerRNA *searchptr,
675 const char *searchpropname,
676 const char *newop,
677 const char *unlinkop,
678 const char *name,
679 const char *text_ctxt,
680 bool translate,
681 const int rows,
682 const int cols)
683{
684 PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
685
686 if (!prop) {
687 RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
688 return;
689 }
690
691 /* Get translated name (label). */
692 std::optional<StringRefNull> text = rna_translate_ui_text(
693 name, text_ctxt, nullptr, prop, translate);
694
696 layout, C, ptr, propname, searchptr, searchpropname, newop, unlinkop, rows, cols, text);
697}
698
699void rna_uiTemplateList(uiLayout *layout,
700 bContext *C,
701 const char *listtype_name,
702 const char *list_id,
703 PointerRNA *dataptr,
704 const char *propname,
705 PointerRNA *active_dataptr,
706 const char *active_propname,
707 const char *item_dyntip_propname,
708 const int rows,
709 const int maxrows,
710 const int layout_type,
711 const int columns,
712 const bool sort_reverse,
713 const bool sort_lock)
714{
716 if (sort_reverse) {
718 }
719 if (sort_lock) {
721 }
722
723 uiTemplateList(layout,
724 C,
725 listtype_name,
726 list_id,
727 dataptr,
728 propname,
729 active_dataptr,
730 active_propname,
731 item_dyntip_propname,
732 rows,
733 maxrows,
734 layout_type,
735 columns,
736 flags);
737}
738
739static void rna_uiTemplateCacheFile(uiLayout *layout,
740 bContext *C,
742 const char *propname)
743{
744 PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
745
746 if (!prop) {
747 RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
748 return;
749 }
750
751 uiTemplateCacheFile(layout, C, ptr, propname);
752}
753
754static void rna_uiTemplateCacheFileVelocity(uiLayout *layout,
756 const char *propname)
757{
758 PointerRNA fileptr;
759 if (!uiTemplateCacheFilePointer(ptr, propname, &fileptr)) {
760 return;
761 }
762
763 uiTemplateCacheFileVelocity(layout, &fileptr);
764}
765
766static void rna_uiTemplateCacheFileTimeSettings(uiLayout *layout,
768 const char *propname)
769{
770 PointerRNA fileptr;
771 if (!uiTemplateCacheFilePointer(ptr, propname, &fileptr)) {
772 return;
773 }
774
775 uiTemplateCacheFileTimeSettings(layout, &fileptr);
776}
777
778static void rna_uiTemplateCacheFileLayers(uiLayout *layout,
779 bContext *C,
781 const char *propname)
782{
783 PointerRNA fileptr;
784 if (!uiTemplateCacheFilePointer(ptr, propname, &fileptr)) {
785 return;
786 }
787
788 uiTemplateCacheFileLayers(layout, C, &fileptr);
789}
790
791static void rna_uiTemplatePathBuilder(uiLayout *layout,
793 const char *propname,
794 PointerRNA *root_ptr,
795 const char *name,
796 const char *text_ctxt,
797 bool translate)
798{
799 PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
800
801 if (!prop) {
802 RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname);
803 return;
804 }
805
806 /* Get translated name (label). */
807 std::optional<StringRefNull> text = rna_translate_ui_text(
808 name, text_ctxt, nullptr, prop, translate);
809
810 /* XXX This will search property again :( */
811 uiTemplatePathBuilder(layout, ptr, propname, root_ptr, text);
812}
813
814static void rna_uiTemplateEventFromKeymapItem(
815 uiLayout *layout, wmKeyMapItem *kmi, const char *name, const char *text_ctxt, bool translate)
816{
817 /* Get translated name (label). */
818 std::optional<StringRefNull> text = rna_translate_ui_text(
819 name, text_ctxt, nullptr, nullptr, translate);
820 uiTemplateEventFromKeymapItem(layout, text.value_or(""), kmi, true);
821}
822
823static uiLayout *rna_uiLayoutBox(uiLayout *layout)
824{
825 return &layout->box();
826}
827
828static uiLayout *rna_uiLayoutSplit(uiLayout *layout, float factor, bool align)
829{
830 return &layout->split(factor, align);
831}
832
833static uiLayout *rna_uiLayoutRowWithHeading(
834 uiLayout *layout, bool align, const char *heading, const char *heading_ctxt, bool translate)
835{
836 /* Get translated heading. */
837 std::optional<StringRefNull> text = rna_translate_ui_text(
838 heading, heading_ctxt, nullptr, nullptr, translate);
839 return &layout->row(align, text.value_or(""));
840}
841
842static uiLayout *rna_uiLayoutColumnWithHeading(
843 uiLayout *layout, bool align, const char *heading, const char *heading_ctxt, bool translate)
844{
845 /* Get translated heading. */
846 std::optional<StringRefNull> text = rna_translate_ui_text(
847 heading, heading_ctxt, nullptr, nullptr, translate);
848 return &layout->column(align, text.value_or(""));
849}
850
851static uiLayout *rna_uiLayoutColumnFlow(uiLayout *layout, int number, bool align)
852{
853 return &layout->column_flow(number, align);
854}
855
856static uiLayout *rna_uiLayoutGridFlow(uiLayout *layout,
857 bool row_major,
858 int columns_len,
859 bool even_columns,
860 bool even_rows,
861 bool align)
862{
863 return &layout->grid_flow(row_major, columns_len, even_columns, even_rows, align);
864}
865
866static uiLayout *rna_uiLayoutMenuPie(uiLayout *layout)
867{
868 return &layout->menu_pie();
869}
870
871void rna_uiLayoutPanelProp(uiLayout *layout,
872 bContext *C,
873 ReportList *reports,
875 const char *property,
876 uiLayout **r_layout_header,
877 uiLayout **r_layout_body)
878{
879 Panel *panel = layout->root_panel();
880 if (panel == nullptr) {
881 BKE_reportf(reports, RPT_ERROR, "Layout panels can not be used in this context");
882 *r_layout_header = nullptr;
883 *r_layout_body = nullptr;
884 return;
885 }
886
887 PanelLayout panel_layout = layout->panel_prop(C, data, property);
888 *r_layout_header = panel_layout.header;
889 *r_layout_body = panel_layout.body;
890}
891
892void rna_uiLayoutPanel(uiLayout *layout,
893 bContext *C,
894 ReportList *reports,
895 const char *idname,
896 const bool default_closed,
897 uiLayout **r_layout_header,
898 uiLayout **r_layout_body)
899{
900 Panel *panel = layout->root_panel();
901 if (panel == nullptr) {
902 BKE_reportf(reports, RPT_ERROR, "Layout panels can not be used in this context");
903 *r_layout_header = nullptr;
904 *r_layout_body = nullptr;
905 return;
906 }
907 PanelLayout panel_layout = layout->panel(C, idname, default_closed);
908 *r_layout_header = panel_layout.header;
909 *r_layout_body = panel_layout.body;
910}
911
912static void rna_uiLayout_template_node_asset_menu_items(uiLayout *layout,
913 bContext *C,
914 const char *catalog_path,
915 const int operator_type)
916{
917 using namespace blender;
919 *layout, *C, StringRef(catalog_path), NodeAssetMenuOperatorType(operator_type));
920}
921
922static void rna_uiLayout_template_node_operator_asset_menu_items(uiLayout *layout,
923 bContext *C,
924 const char *catalog_path)
925{
926 using namespace blender;
928}
929
930static void rna_uiLayout_template_modifier_asset_menu_items(uiLayout *layout,
931 const char *catalog_path,
932 const bool skip_essentials)
933{
934 using namespace blender;
936 *layout, StringRef(catalog_path), skip_essentials);
937}
938
939static void rna_uiLayout_template_node_operator_root_items(uiLayout *layout, bContext *C)
940{
942}
943
944static int rna_ui_get_rnaptr_icon(bContext *C, PointerRNA *ptr_icon)
945{
946 return UI_icon_from_rnaptr(C, ptr_icon, RNA_struct_ui_icon(ptr_icon->type), false);
947}
948
949static const char *rna_ui_get_enum_name(bContext *C,
951 const char *propname,
952 const char *identifier)
953{
954 PropertyRNA *prop = nullptr;
955 const EnumPropertyItem *items = nullptr;
956 bool free;
957 const char *name = "";
958
959 prop = RNA_struct_find_property(ptr, propname);
960 if (!prop || (RNA_property_type(prop) != PROP_ENUM)) {
962 "Property not found or not an enum: %s.%s", RNA_struct_identifier(ptr->type), propname);
963 return name;
964 }
965
966 RNA_property_enum_items_gettexted(C, ptr, prop, &items, nullptr, &free);
967
968 if (items) {
969 const int index = RNA_enum_from_identifier(items, identifier);
970 if (index != -1) {
971 name = items[index].name;
972 }
973 if (free) {
974 MEM_freeN(items);
975 }
976 }
977
978 return name;
979}
980
981static const char *rna_ui_get_enum_description(bContext *C,
983 const char *propname,
984 const char *identifier)
985{
986 PropertyRNA *prop = nullptr;
987 const EnumPropertyItem *items = nullptr;
988 bool free;
989 const char *desc = "";
990
991 prop = RNA_struct_find_property(ptr, propname);
992 if (!prop || (RNA_property_type(prop) != PROP_ENUM)) {
994 "Property not found or not an enum: %s.%s", RNA_struct_identifier(ptr->type), propname);
995 return desc;
996 }
997
998 RNA_property_enum_items_gettexted(C, ptr, prop, &items, nullptr, &free);
999
1000 if (items) {
1001 const int index = RNA_enum_from_identifier(items, identifier);
1002 if (index != -1) {
1003 desc = items[index].description;
1004 }
1005 if (free) {
1006 MEM_freeN(items);
1007 }
1008 }
1009
1010 return desc;
1011}
1012
1013static int rna_ui_get_enum_icon(bContext *C,
1014 PointerRNA *ptr,
1015 const char *propname,
1016 const char *identifier)
1017{
1018 PropertyRNA *prop = nullptr;
1019 const EnumPropertyItem *items = nullptr;
1020 bool free;
1021 int icon = ICON_NONE;
1022
1023 prop = RNA_struct_find_property(ptr, propname);
1024 if (!prop || (RNA_property_type(prop) != PROP_ENUM)) {
1026 "Property not found or not an enum: %s.%s", RNA_struct_identifier(ptr->type), propname);
1027 return icon;
1028 }
1029
1030 RNA_property_enum_items(C, ptr, prop, &items, nullptr, &free);
1031
1032 if (items) {
1033 const int index = RNA_enum_from_identifier(items, identifier);
1034 if (index != -1) {
1035 icon = items[index].icon;
1036 }
1037 if (free) {
1038 MEM_freeN(items);
1039 }
1040 }
1041
1042 return icon;
1043}
1044
1045void rna_uiTemplateAssetShelfPopover(uiLayout *layout,
1046 bContext *C,
1047 const char *asset_shelf_id,
1048 const char *name,
1049 BIFIconID icon,
1050 int icon_value)
1051{
1052 if (icon_value && !icon) {
1053 icon = icon_value;
1054 }
1055
1056 blender::ui::template_asset_shelf_popover(*layout, *C, asset_shelf_id, name ? name : "", icon);
1057}
1058
1059PointerRNA rna_uiTemplatePopupConfirm(uiLayout *layout,
1060 ReportList *reports,
1061 const char *opname,
1062 const char *text,
1063 const char *text_ctxt,
1064 bool translate,
1065 int icon,
1066 const char *cancel_text,
1067 bool cancel_default)
1068{
1070
1071 /* This allows overriding buttons in `WM_operator_props_dialog_popup` and other popups. */
1072 wmOperatorType *ot = nullptr;
1073 if (opname[0]) {
1074 /* Confirming is optional. */
1075 ot = WM_operatortype_find(opname, false); /* print error next */
1076 }
1077 else {
1078 text = "";
1079 }
1080
1081 if (opname[0] ? (!ot || !ot->srna) : false) {
1082 RNA_warning("%s '%s'", ot ? "operator missing srna" : "unknown operator", opname);
1083 }
1085 BKE_reportf(reports, RPT_ERROR, "template_popup_confirm used outside of a popup");
1086 }
1087 else {
1088 std::optional<StringRefNull> text_str = rna_translate_ui_text(
1089 text, text_ctxt, nullptr, nullptr, translate);
1090 std::optional<StringRefNull> cancel_text_str;
1091 if (cancel_text && cancel_text[0]) {
1092 cancel_text_str = rna_translate_ui_text(cancel_text, text_ctxt, nullptr, nullptr, translate);
1093 }
1094
1096 layout, ot, text_str, cancel_text_str, icon, cancel_default, &opptr);
1097 }
1098 return opptr;
1099}
1100
1101#else
1102
1104{
1105 RNA_def_string(func,
1106 "heading",
1107 nullptr,
1109 "Heading",
1110 "Label to insert into the layout for this sub-layout");
1111 RNA_def_string(func,
1112 "heading_ctxt",
1113 nullptr,
1114 0,
1115 "",
1116 "Override automatic translation context of the given heading");
1118 func, "translate", true, "", "Translate the given heading, when UI translation is enabled");
1119}
1120
1122{
1123 PropertyRNA *prop = RNA_def_string(func,
1124 "text_ctxt",
1125 nullptr,
1126 0,
1127 "",
1128 "Override automatic translation context of the given text");
1131 func, "translate", true, "", "Translate the given text, when UI translation is enabled");
1132}
1133
1135{
1136 PropertyRNA *prop;
1137
1138 prop = RNA_def_string(func, "text", nullptr, 0, "", "Override automatic text of the item");
1141}
1142
1144{
1145 PropertyRNA *prop;
1146
1148
1149 prop = RNA_def_property(func, "icon", PROP_ENUM, PROP_NONE);
1151 RNA_def_property_ui_text(prop, "Icon", "Override automatic icon of the item");
1152}
1153
1154static void api_ui_item_op(FunctionRNA *func)
1155{
1156 PropertyRNA *parm;
1157 parm = RNA_def_string(func, "operator", nullptr, 0, "", "Identifier of the operator");
1159}
1160
1162{
1163 api_ui_item_op(func);
1164 api_ui_item_common(func);
1165}
1166
1168{
1169 PropertyRNA *parm;
1170
1171 parm = RNA_def_pointer(func, "data", "AnyType", "", "Data from which to take property");
1173 parm = RNA_def_string(func, "property", nullptr, 0, "", "Identifier of property in data");
1175}
1176
1178{
1179 FunctionRNA *func;
1180 PropertyRNA *parm;
1181
1182 static const EnumPropertyItem curve_type_items[] = {
1183 {0, "NONE", 0, "None", ""},
1184 {'v', "VECTOR", 0, "Vector", ""},
1185 {'c', "COLOR", 0, "Color", ""},
1186 {'h', "HUE", 0, "Hue", ""},
1187 {0, nullptr, 0, nullptr, nullptr},
1188 };
1189
1190 static const EnumPropertyItem id_template_filter_items[] = {
1191 {UI_TEMPLATE_ID_FILTER_ALL, "ALL", 0, "All", ""},
1192 {UI_TEMPLATE_ID_FILTER_AVAILABLE, "AVAILABLE", 0, "Available", ""},
1193 {0, nullptr, 0, nullptr, nullptr},
1194 };
1195
1196 static const EnumPropertyItem progress_type_items[] = {
1197 {int(blender::ui::ButProgressType::Bar), "BAR", 0, "Bar", ""},
1198 {int(blender::ui::ButProgressType::Ring), "RING", 0, "Ring", ""},
1199 {0, nullptr, 0, nullptr, nullptr},
1200 };
1201
1202 static const EnumPropertyItem rna_enum_separator_type_items[] = {
1204 "AUTO",
1205 0,
1206 "Auto",
1207 "Best guess at what type of separator is needed."},
1209 "SPACE",
1210 0,
1211 "Empty space",
1212 "Horizontal or Vertical empty space, depending on layout direction."},
1214 "LINE",
1215 0,
1216 "Line",
1217 "Horizontal or Vertical line, depending on layout direction."},
1218 {0, nullptr, 0, nullptr, nullptr},
1219 };
1220
1221 static const EnumPropertyItem rna_enum_template_node_operator_type[] = {
1223 "ADD",
1224 0,
1225 "Add Node",
1226 "Add a node to the active tree."},
1228 "SWAP",
1229 0,
1230 "Swap Node",
1231 "Replace the selected nodes with the specified type."},
1232 {0, nullptr, 0, nullptr, nullptr},
1233 };
1234
1235 static const float node_socket_color_default[] = {0.0f, 0.0f, 0.0f, 1.0f};
1236
1237 /* simple layout specifiers */
1238 func = RNA_def_function(srna, "row", "rna_uiLayoutRowWithHeading");
1239 parm = RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in");
1240 RNA_def_function_return(func, parm);
1242 func,
1243 "Sub-layout. Items placed in this sublayout are placed next to each other "
1244 "in a row.");
1245 RNA_def_boolean(func, "align", false, "", "Align buttons to each other");
1247
1248 func = RNA_def_function(srna, "column", "rna_uiLayoutColumnWithHeading");
1249 parm = RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in");
1250 RNA_def_function_return(func, parm);
1252 func,
1253 "Sub-layout. Items placed in this sublayout are placed under each other "
1254 "in a column.");
1255 RNA_def_boolean(func, "align", false, "", "Align buttons to each other");
1257
1258 func = RNA_def_function(srna, "panel", "rna_uiLayoutPanel");
1260 func,
1261 "Creates a collapsible panel. Whether it is open or closed is stored in the region using "
1262 "the given idname. This can only be used when the panel has the full width of the panel "
1263 "region available to it. So it can't be used in e.g. in a box or columns.");
1265 parm = RNA_def_string(func, "idname", nullptr, 0, "", "Identifier of the panel");
1267 RNA_def_boolean(func,
1268 "default_closed",
1269 false,
1270 "Open by Default",
1271 "When true, the panel will be open the first time it is shown");
1272 parm = RNA_def_pointer(func, "layout_header", "UILayout", "", "Sub-layout to put items in");
1273 RNA_def_function_output(func, parm);
1274 parm = RNA_def_pointer(func,
1275 "layout_body",
1276 "UILayout",
1277 "",
1278 "Sub-layout to put items in. Will be none if the panel is collapsed.");
1279 RNA_def_function_output(func, parm);
1280
1281 func = RNA_def_function(srna, "panel_prop", "rna_uiLayoutPanelProp");
1283 func,
1284 "Similar to ``.panel(...)`` but instead of storing whether it is open or closed in the "
1285 "region, it is stored in the provided boolean property. This should be used when multiple "
1286 "instances of the same panel can exist. For example one for every item in a collection "
1287 "property or list. This can only be used when the panel has the full width of the panel "
1288 "region available to it. So it can't be used in e.g. in a box or columns.");
1290 parm = RNA_def_pointer(
1291 func, "data", "AnyType", "", "Data from which to take the open-state property");
1293 parm = RNA_def_string(
1294 func,
1295 "property",
1296 nullptr,
1297 0,
1298 "",
1299 "Identifier of the boolean property that determines whether the panel is open or closed");
1301 parm = RNA_def_pointer(func, "layout_header", "UILayout", "", "Sub-layout to put items in");
1302 RNA_def_function_output(func, parm);
1303 parm = RNA_def_pointer(func,
1304 "layout_body",
1305 "UILayout",
1306 "",
1307 "Sub-layout to put items in. Will be none if the panel is collapsed.");
1308 RNA_def_function_output(func, parm);
1309
1310 func = RNA_def_function(srna, "column_flow", "rna_uiLayoutColumnFlow");
1311 RNA_def_int(func, "columns", 0, 0, INT_MAX, "", "Number of columns, 0 is automatic", 0, INT_MAX);
1312 parm = RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in");
1313 RNA_def_function_return(func, parm);
1314 RNA_def_boolean(func, "align", false, "", "Align buttons to each other");
1315
1316 func = RNA_def_function(srna, "grid_flow", "rna_uiLayoutGridFlow");
1317 RNA_def_boolean(func, "row_major", false, "", "Fill row by row, instead of column by column");
1319 func,
1320 "columns",
1321 0,
1322 INT_MIN,
1323 INT_MAX,
1324 "",
1325 "Number of columns, positive are absolute fixed numbers, 0 is automatic, negative are "
1326 "automatic multiple numbers along major axis (e.g. -2 will only produce 2, 4, 6 etc. "
1327 "columns for row major layout, and 2, 4, 6 etc. rows for column major layout).",
1328 INT_MIN,
1329 INT_MAX);
1330 RNA_def_boolean(func, "even_columns", false, "", "All columns will have the same width");
1331 RNA_def_boolean(func, "even_rows", false, "", "All rows will have the same height");
1332 RNA_def_boolean(func, "align", false, "", "Align buttons to each other");
1333 parm = RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in");
1334 RNA_def_function_return(func, parm);
1335
1336 /* box layout */
1337 func = RNA_def_function(srna, "box", "rna_uiLayoutBox");
1338 parm = RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in");
1339 RNA_def_function_return(func, parm);
1341 "Sublayout (items placed in this sublayout are placed "
1342 "under each other in a column and are surrounded by a box)");
1343
1344 /* split layout */
1345 func = RNA_def_function(srna, "split", "rna_uiLayoutSplit");
1346 parm = RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in");
1347 RNA_def_function_return(func, parm);
1348 RNA_def_float(func,
1349 "factor",
1350 0.0f,
1351 0.0f,
1352 1.0f,
1353 "Percentage",
1354 "Percentage of width to split at (leave unset for automatic calculation)",
1355 0.0f,
1356 1.0f);
1357 RNA_def_boolean(func, "align", false, "", "Align buttons to each other");
1358
1359 /* radial/pie layout */
1360 func = RNA_def_function(srna, "menu_pie", "rna_uiLayoutMenuPie");
1361 parm = RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in");
1362 RNA_def_function_return(func, parm);
1364 "Sublayout. Items placed in this sublayout are placed "
1365 "in a radial fashion around the menu center).");
1366
1367 /* Icon of a rna pointer */
1368 func = RNA_def_function(srna, "icon", "rna_ui_get_rnaptr_icon");
1369 parm = RNA_def_int(func, "icon_value", ICON_NONE, 0, INT_MAX, "", "Icon identifier", 0, INT_MAX);
1370 RNA_def_function_return(func, parm);
1372 parm = RNA_def_pointer(func, "data", "AnyType", "", "Data from which to take the icon");
1375 "Return the custom icon for this data, "
1376 "use it e.g. to get materials or texture icons.");
1377
1378 /* UI name, description and icon of an enum item */
1379 func = RNA_def_function(srna, "enum_item_name", "rna_ui_get_enum_name");
1380 parm = RNA_def_string(func, "name", nullptr, 0, "", "UI name of the enum item");
1381 RNA_def_function_return(func, parm);
1384 parm = RNA_def_string(func, "identifier", nullptr, 0, "", "Identifier of the enum item");
1386 RNA_def_function_ui_description(func, "Return the UI name for this enum item");
1387
1388 func = RNA_def_function(srna, "enum_item_description", "rna_ui_get_enum_description");
1389 parm = RNA_def_string(func, "description", nullptr, 0, "", "UI description of the enum item");
1390 RNA_def_function_return(func, parm);
1393 parm = RNA_def_string(func, "identifier", nullptr, 0, "", "Identifier of the enum item");
1395 RNA_def_function_ui_description(func, "Return the UI description for this enum item");
1396
1397 func = RNA_def_function(srna, "enum_item_icon", "rna_ui_get_enum_icon");
1398 parm = RNA_def_int(func, "icon_value", ICON_NONE, 0, INT_MAX, "", "Icon identifier", 0, INT_MAX);
1399 RNA_def_function_return(func, parm);
1402 parm = RNA_def_string(func, "identifier", nullptr, 0, "", "Identifier of the enum item");
1404 RNA_def_function_ui_description(func, "Return the icon for this enum item");
1405
1406 /* items */
1407 func = RNA_def_function(srna, "prop", "rna_uiItemR");
1409 "Item. Exposes an RNA item and places it into the layout.");
1411 api_ui_item_common(func);
1413 func, "placeholder", nullptr, 0, "", "Hint describing the expected value when empty");
1415 RNA_def_boolean(func, "expand", false, "", "Expand button to show more detail");
1416 RNA_def_boolean(func, "slider", false, "", "Use slider widget for numeric values");
1417 RNA_def_int(func,
1418 "toggle",
1419 -1,
1420 -1,
1421 1,
1422 "",
1423 "Use toggle widget for boolean values, "
1424 "or a checkbox when disabled "
1425 "(the default is -1 which uses toggle only when an icon is displayed)",
1426 -1,
1427 1);
1428 RNA_def_boolean(func, "icon_only", false, "", "Draw only icons in buttons, no text");
1429 RNA_def_boolean(func, "event", false, "", "Use button to input key events");
1431 func, "full_event", false, "", "Use button to input full events including modifiers");
1432 RNA_def_boolean(func,
1433 "emboss",
1434 true,
1435 "",
1436 "Draw the button itself, not just the icon/text. When false, corresponds to the "
1437 "'NONE_OR_STATUS' layout emboss type.");
1438 RNA_def_int(func,
1439 "index",
1440 /* RNA_NO_INDEX == -1 */
1441 -1,
1442 -2,
1443 INT_MAX,
1444 "",
1445 "The index of this button, when set a single member of an array can be accessed, "
1446 "when set to -1 all array members are used",
1447 -2,
1448 INT_MAX);
1449 parm = RNA_def_property(func, "icon_value", PROP_INT, PROP_UNSIGNED);
1450 RNA_def_property_ui_text(parm, "Icon Value", "Override automatic icon of the item");
1451 RNA_def_boolean(func, "invert_checkbox", false, "", "Draw checkbox value inverted");
1452
1453 func = RNA_def_function(srna, "props_enum", "rna_uiItemsEnumR");
1455
1456 func = RNA_def_function(srna, "prop_menu_enum", "rna_uiItemMenuEnumR");
1458 api_ui_item_common(func);
1459
1460 func = RNA_def_function(srna, "prop_with_popover", "rna_uiItemR_with_popover");
1462 api_ui_item_common(func);
1463 RNA_def_boolean(func, "icon_only", false, "", "Draw only icons in tabs, no text");
1464 parm = RNA_def_string(func, "panel", nullptr, 0, "", "Identifier of the panel");
1466
1467 func = RNA_def_function(srna, "prop_with_menu", "rna_uiItemR_with_menu");
1469 api_ui_item_common(func);
1470 RNA_def_boolean(func, "icon_only", false, "", "Draw only icons in tabs, no text");
1471 parm = RNA_def_string(func, "menu", nullptr, 0, "", "Identifier of the menu");
1473
1474 func = RNA_def_function(srna, "prop_tabs_enum", "rna_uiItemTabsEnumR");
1477 parm = RNA_def_pointer(
1478 func, "data_highlight", "AnyType", "", "Data from which to take highlight property");
1480 parm = RNA_def_string(
1481 func, "property_highlight", nullptr, 0, "", "Identifier of highlight property in data");
1482 RNA_def_boolean(func, "icon_only", false, "", "Draw only icons in tabs, no text");
1483
1484 func = RNA_def_function(srna, "prop_enum", "rna_uiItemEnumR_string");
1486 parm = RNA_def_string(func, "value", nullptr, 0, "", "Enum property value");
1488 api_ui_item_common(func);
1489
1490 func = RNA_def_function(srna, "prop_search", "rna_uiItemPointerR");
1492 parm = RNA_def_pointer(
1493 func, "search_data", "AnyType", "", "Data from which to take collection to search in");
1495 parm = RNA_def_string(
1496 func, "search_property", nullptr, 0, "", "Identifier of search collection property");
1498 api_ui_item_common(func);
1500 func, "results_are_suggestions", false, "", "Accept inputs that do not match any item");
1501 parm = RNA_def_string(func,
1502 "item_search_property",
1503 nullptr,
1504 0,
1505 "",
1506 "Identifier of the string property in each collection's items to use for "
1507 "searching (defaults to the items' type 'name property')");
1508
1509 func = RNA_def_function(srna, "prop_decorator", "rna_uiLayoutDecorator");
1511 RNA_def_int(func,
1512 "index",
1513 /* RNA_NO_INDEX == -1 */
1514 -1,
1515 -2,
1516 INT_MAX,
1517 "",
1518 "The index of this button, when set a single member of an array can be accessed, "
1519 "when set to -1 all array members are used",
1520 -2,
1521 INT_MAX);
1522
1523 for (int is_menu_hold = 0; is_menu_hold < 2; is_menu_hold++) {
1524 func = (is_menu_hold) ? RNA_def_function(srna, "operator_menu_hold", "rna_uiItemOMenuHold") :
1525 RNA_def_function(srna, "operator", "rna_uiItemO");
1527 RNA_def_boolean(func, "emboss", true, "", "Draw the button itself, not just the icon/text");
1528 RNA_def_boolean(func, "depress", false, "", "Draw pressed in");
1529 parm = RNA_def_property(func, "icon_value", PROP_INT, PROP_UNSIGNED);
1530 RNA_def_property_ui_text(parm, "Icon Value", "Override automatic icon of the item");
1531 if (is_menu_hold) {
1532 parm = RNA_def_string(func, "menu", nullptr, 0, "", "Identifier of the menu");
1534 }
1535 else {
1536 RNA_def_float(func,
1537 "search_weight",
1538 0.0f,
1539 -FLT_MAX,
1540 FLT_MAX,
1541 "Search Weight",
1542 "Influences the sorting when using menu-seach",
1543 -FLT_MAX,
1544 FLT_MAX);
1545 }
1546 parm = RNA_def_pointer(
1547 func, "properties", "OperatorProperties", "", "Operator properties to fill in");
1549 RNA_def_function_return(func, parm);
1551 "Item. Places a button into the layout to call an Operator.");
1552 }
1553
1554 func = RNA_def_function(srna, "operator_enum", "rna_uiItemsEnumO");
1555 parm = RNA_def_string(func, "operator", nullptr, 0, "", "Identifier of the operator");
1557 parm = RNA_def_string(func, "property", nullptr, 0, "", "Identifier of property in operator");
1559 RNA_def_boolean(func, "icon_only", false, "", "Draw only icons in buttons, no text");
1560
1561 func = RNA_def_function(srna, "operator_menu_enum", "rna_uiItemMenuEnumO");
1563 /* Can't use #api_ui_item_op_common because property must come right after. */
1564 api_ui_item_op(func);
1565 parm = RNA_def_string(func, "property", nullptr, 0, "", "Identifier of property in operator");
1567 api_ui_item_common(func);
1568 parm = RNA_def_pointer(
1569 func, "properties", "OperatorProperties", "", "Operator properties to fill in");
1571 RNA_def_function_return(func, parm);
1572
1573 func = RNA_def_function(srna, "label", "rna_uiItemL");
1574 RNA_def_function_ui_description(func, "Item. Displays text and/or icon in the layout.");
1575 api_ui_item_common(func);
1576 parm = RNA_def_property(func, "icon_value", PROP_INT, PROP_UNSIGNED);
1577 RNA_def_property_ui_text(parm, "Icon Value", "Override automatic icon of the item");
1578
1579 func = RNA_def_function(srna, "menu", "rna_uiItemM");
1580 parm = RNA_def_string(func, "menu", nullptr, 0, "", "Identifier of the menu");
1581 api_ui_item_common(func);
1583 parm = RNA_def_property(func, "icon_value", PROP_INT, PROP_UNSIGNED);
1584 RNA_def_property_ui_text(parm, "Icon Value", "Override automatic icon of the item");
1585
1586 func = RNA_def_function(srna, "menu_contents", "rna_uiItemM_contents");
1587 parm = RNA_def_string(func, "menu", nullptr, 0, "", "Identifier of the menu");
1589
1590 func = RNA_def_function(srna, "popover", "rna_uiItemPopoverPanel");
1592 parm = RNA_def_string(func, "panel", nullptr, 0, "", "Identifier of the panel");
1593 api_ui_item_common(func);
1595 parm = RNA_def_property(func, "icon_value", PROP_INT, PROP_UNSIGNED);
1596 RNA_def_property_ui_text(parm, "Icon Value", "Override automatic icon of the item");
1597
1598 func = RNA_def_function(srna, "popover_group", "rna_uiItemPopoverPanelFromGroup");
1600 parm = RNA_def_enum(func, "space_type", rna_enum_space_type_items, 0, "Space Type", "");
1602 parm = RNA_def_enum(
1603 func, "region_type", rna_enum_region_type_items, RGN_TYPE_WINDOW, "Region Type", "");
1605 parm = RNA_def_string(func, "context", nullptr, 0, "", "panel type context");
1607 parm = RNA_def_string(func, "category", nullptr, 0, "", "panel type category");
1609
1610 func = RNA_def_function(srna, "separator", "rna_uiItemSeparator");
1612 "Item. Inserts empty space into the layout between items.");
1613 RNA_def_float(func,
1614 "factor",
1615 1.0f,
1616 0.0f,
1617 FLT_MAX,
1618 "Percentage",
1619 "Percentage of width to space (leave unset for default space)",
1620 0.0f,
1621 FLT_MAX);
1622 RNA_def_enum(func,
1623 "type",
1624 rna_enum_separator_type_items,
1626 "Type",
1627 "The type of the separator");
1628
1629 func = RNA_def_function(srna, "separator_spacer", "rna_uiLayoutSeparatorSpacer");
1631 func, "Item. Inserts horizontal spacing empty space into the layout between items.");
1632
1633 func = RNA_def_function(srna, "progress", "rna_uiItemProgress");
1634 RNA_def_function_ui_description(func, "Progress indicator");
1636 RNA_def_float(func,
1637 "factor",
1638 0.0f,
1639 0.0f,
1640 1.0f,
1641 "Factor",
1642 "Amount of progress from 0.0f to 1.0f",
1643 0.0f,
1644 1.0f);
1645 RNA_def_enum(func,
1646 "type",
1647 progress_type_items,
1649 "Type",
1650 "The type of progress indicator");
1651
1652 /* context */
1653 func = RNA_def_function(srna, "context_pointer_set", "rna_uiLayoutContextPointerSet");
1654 parm = RNA_def_string(func, "name", nullptr, 0, "Name", "Name of entry in the context");
1656 parm = RNA_def_pointer(func, "data", "AnyType", "", "Pointer to put in context");
1658
1659 func = RNA_def_function(srna, "context_string_set", "rna_uiLayoutContextStringSet");
1660 parm = RNA_def_string(func, "name", nullptr, 0, "Name", "Name of entry in the context");
1662 parm = RNA_def_string(func, "value", nullptr, 0, "Value", "String to put in context");
1664
1665 /* templates */
1666 func = RNA_def_function(srna, "template_header", "uiTemplateHeader");
1668 RNA_def_function_ui_description(func, "Inserts common Space header UI (editor type selector)");
1669
1670 func = RNA_def_function(srna, "template_ID", "rna_uiTemplateID");
1673 RNA_def_string(func, "new", nullptr, 0, "", "Operator identifier to create a new ID block");
1674 RNA_def_string(func,
1675 "open",
1676 nullptr,
1677 0,
1678 "",
1679 "Operator identifier to open a file for creating a new ID block");
1680 RNA_def_string(func, "unlink", nullptr, 0, "", "Operator identifier to unlink the ID block");
1681 RNA_def_enum(func,
1682 "filter",
1683 id_template_filter_items,
1685 "",
1686 "Optionally limit the items which can be selected");
1687 RNA_def_boolean(func, "live_icon", false, "", "Show preview instead of fixed icon");
1689
1690 func = RNA_def_function(srna, "template_ID_preview", "uiTemplateIDPreview");
1693 RNA_def_string(func, "new", nullptr, 0, "", "Operator identifier to create a new ID block");
1694 RNA_def_string(func,
1695 "open",
1696 nullptr,
1697 0,
1698 "",
1699 "Operator identifier to open a file for creating a new ID block");
1700 RNA_def_string(func, "unlink", nullptr, 0, "", "Operator identifier to unlink the ID block");
1702 func, "rows", 0, 0, INT_MAX, "Number of thumbnail preview rows to display", "", 0, INT_MAX);
1703 RNA_def_int(func,
1704 "cols",
1705 0,
1706 0,
1707 INT_MAX,
1708 "Number of thumbnail preview columns to display",
1709 "",
1710 0,
1711 INT_MAX);
1712 RNA_def_enum(func,
1713 "filter",
1714 id_template_filter_items,
1716 "",
1717 "Optionally limit the items which can be selected");
1718 RNA_def_boolean(func, "hide_buttons", false, "", "Show only list, no buttons");
1719
1720 func = RNA_def_function(srna, "template_matrix", "uiTemplateMatrix");
1722 func,
1723 "Insert a readonly Matrix UI. "
1724 "The UI displays the matrix components - translation, rotation and scale. "
1725 "The **property** argument must be the identifier of an existing 4x4 float vector "
1726 "property of subtype 'MATRIX'.");
1728
1729 func = RNA_def_function(srna, "template_any_ID", "rna_uiTemplateAnyID");
1730 parm = RNA_def_pointer(func, "data", "AnyType", "", "Data from which to take property");
1732 parm = RNA_def_string(func, "property", nullptr, 0, "", "Identifier of property in data");
1734 parm = RNA_def_string(func,
1735 "type_property",
1736 nullptr,
1737 0,
1738 "",
1739 "Identifier of property in data giving the type of the ID-blocks to use");
1742
1743 func = RNA_def_function(srna, "template_ID_tabs", "uiTemplateIDTabs");
1746 RNA_def_string(func, "new", nullptr, 0, "", "Operator identifier to create a new ID block");
1747 RNA_def_string(func, "menu", nullptr, 0, "", "Context menu identifier");
1748 RNA_def_enum(func,
1749 "filter",
1750 id_template_filter_items,
1752 "",
1753 "Optionally limit the items which can be selected");
1754
1755 func = RNA_def_function(srna, "template_action", "rna_uiTemplateAction");
1757 parm = RNA_def_pointer(func, "id", "ID", "", "The data-block for which to select an Action");
1759 RNA_def_string(func, "new", nullptr, 0, "", "Operator identifier to create a new ID block");
1760 RNA_def_string(func, "unlink", nullptr, 0, "", "Operator identifier to unlink the ID block");
1762
1763 func = RNA_def_function(srna, "template_search", "rna_uiTemplateSearch");
1766 parm = RNA_def_pointer(
1767 func, "search_data", "AnyType", "", "Data from which to take collection to search in");
1769 parm = RNA_def_string(
1770 func, "search_property", nullptr, 0, "", "Identifier of search collection property");
1773 func, "new", nullptr, 0, "", "Operator identifier to create a new item for the collection");
1774 RNA_def_string(func,
1775 "unlink",
1776 nullptr,
1777 0,
1778 "",
1779 "Operator identifier to unlink or delete the active "
1780 "item from the collection");
1782
1783 func = RNA_def_function(srna, "template_search_preview", "rna_uiTemplateSearchPreview");
1786 parm = RNA_def_pointer(
1787 func, "search_data", "AnyType", "", "Data from which to take collection to search in");
1789 parm = RNA_def_string(
1790 func, "search_property", nullptr, 0, "", "Identifier of search collection property");
1793 func, "new", nullptr, 0, "", "Operator identifier to create a new item for the collection");
1794 RNA_def_string(func,
1795 "unlink",
1796 nullptr,
1797 0,
1798 "",
1799 "Operator identifier to unlink or delete the active "
1800 "item from the collection");
1803 func, "rows", 0, 0, INT_MAX, "Number of thumbnail preview rows to display", "", 0, INT_MAX);
1804 RNA_def_int(func,
1805 "cols",
1806 0,
1807 0,
1808 INT_MAX,
1809 "Number of thumbnail preview columns to display",
1810 "",
1811 0,
1812 INT_MAX);
1813
1814 func = RNA_def_function(srna, "template_path_builder", "rna_uiTemplatePathBuilder");
1815 parm = RNA_def_pointer(func, "data", "AnyType", "", "Data from which to take property");
1817 parm = RNA_def_string(func, "property", nullptr, 0, "", "Identifier of property in data");
1819 parm = RNA_def_pointer(func, "root", "ID", "", "ID-block from which path is evaluated from");
1822
1823 func = RNA_def_function(srna, "template_modifiers", "uiTemplateModifiers");
1825 RNA_def_function_ui_description(func, "Generates the UI layout for the modifier stack");
1826
1827 func = RNA_def_function(srna, "template_strip_modifiers", "uiTemplateStripModifiers");
1829 RNA_def_function_ui_description(func, "Generates the UI layout for the strip modifier stack");
1830
1831 func = RNA_def_function(srna, "template_collection_exporters", "uiTemplateCollectionExporters");
1833 RNA_def_function_ui_description(func, "Generates the UI layout for collection exporters");
1834
1835 func = RNA_def_function(srna, "template_constraints", "uiTemplateConstraints");
1837 RNA_def_function_ui_description(func, "Generates the panels for the constraint stack");
1838 RNA_def_boolean(func,
1839 "use_bone_constraints",
1840 true,
1841 "",
1842 "Add panels for bone constraints instead of object constraints");
1843
1844 func = RNA_def_function(srna, "template_shaderfx", "uiTemplateShaderFx");
1846 RNA_def_function_ui_description(func, "Generates the panels for the shader effect stack");
1847
1848 func = RNA_def_function(srna, "template_greasepencil_color", "uiTemplateGpencilColorPreview");
1852 func, "rows", 0, 0, INT_MAX, "Number of thumbnail preview rows to display", "", 0, INT_MAX);
1853 RNA_def_int(func,
1854 "cols",
1855 0,
1856 0,
1857 INT_MAX,
1858 "Number of thumbnail preview columns to display",
1859 "",
1860 0,
1861 INT_MAX);
1862 RNA_def_float(func, "scale", 1.0f, 0.1f, 1.5f, "Scale of the image thumbnails", "", 0.5f, 1.0f);
1863 RNA_def_enum(func,
1864 "filter",
1865 id_template_filter_items,
1867 "",
1868 "Optionally limit the items which can be selected");
1869
1870 func = RNA_def_function(srna, "template_constraint_header", "uiTemplateConstraintHeader");
1871 RNA_def_function_ui_description(func, "Generates the header for constraint panels");
1872 parm = RNA_def_pointer(func, "data", "Constraint", "", "Constraint data");
1874
1875 func = RNA_def_function(srna, "template_preview", "uiTemplatePreview");
1877 func, "Item. A preview window for materials, textures, lights or worlds.");
1879 parm = RNA_def_pointer(func, "id", "ID", "", "ID data-block");
1881 RNA_def_boolean(func, "show_buttons", true, "", "Show preview buttons?");
1882 RNA_def_pointer(func, "parent", "ID", "", "ID data-block");
1883 RNA_def_pointer(func, "slot", "TextureSlot", "", "Texture slot");
1885 func,
1886 "preview_id",
1887 nullptr,
1888 0,
1889 "",
1890 "Identifier of this preview widget, if not set the ID type will be used "
1891 "(i.e. all previews of materials without explicit ID will have the same size...).");
1892
1893 func = RNA_def_function(srna, "template_curve_mapping", "uiTemplateCurveMapping");
1895 func, "Item. A curve mapping widget used for e.g falloff curves for lights.");
1897 RNA_def_enum(func, "type", curve_type_items, 0, "Type", "Type of curves to display");
1898 RNA_def_boolean(func, "levels", false, "", "Show black/white levels");
1899 RNA_def_boolean(func, "brush", false, "", "Show brush options");
1900 RNA_def_boolean(func, "use_negative_slope", false, "", "Use a negative slope by default");
1901 RNA_def_boolean(func, "show_tone", false, "", "Show tone options");
1902 RNA_def_boolean(func, "show_presets", false, "", "Show preset options");
1903
1904 func = RNA_def_function(srna, "template_curveprofile", "uiTemplateCurveProfile");
1905 RNA_def_function_ui_description(func, "A profile path editor used for custom profiles");
1907
1908 func = RNA_def_function(srna, "template_color_ramp", "uiTemplateColorRamp");
1909 RNA_def_function_ui_description(func, "Item. A color ramp widget.");
1911 RNA_def_boolean(func, "expand", false, "", "Expand button to show more detail");
1912
1913 func = RNA_def_function(srna, "template_icon", "uiTemplateIcon");
1914 RNA_def_function_ui_description(func, "Display a large icon");
1915 parm = RNA_def_int(func, "icon_value", 0, 0, INT_MAX, "Icon to display", "", 0, INT_MAX);
1917 RNA_def_float(func,
1918 "scale",
1919 1.0f,
1920 1.0f,
1921 100.0f,
1922 "Scale",
1923 "Scale the icon size (by the button size)",
1924 1.0f,
1925 100.0f);
1926
1927 func = RNA_def_function(srna, "template_icon_view", "uiTemplateIconView");
1928 RNA_def_function_ui_description(func, "Enum. Large widget showing Icon previews.");
1930 RNA_def_boolean(func, "show_labels", false, "", "Show enum label in preview buttons");
1931 RNA_def_float(func,
1932 "scale",
1933 6.0f,
1934 1.0f,
1935 100.0f,
1936 "UI Units",
1937 "Scale the button icon size (by the button size)",
1938 1.0f,
1939 100.0f);
1940 RNA_def_float(func,
1941 "scale_popup",
1942 5.0f,
1943 1.0f,
1944 100.0f,
1945 "Scale",
1946 "Scale the popup icon size (by the button size)",
1947 1.0f,
1948 100.0f);
1949
1950 func = RNA_def_function(srna, "template_histogram", "uiTemplateHistogram");
1951 RNA_def_function_ui_description(func, "Item. A histogramm widget to analyze imaga data.");
1953
1954 func = RNA_def_function(srna, "template_waveform", "uiTemplateWaveform");
1955 RNA_def_function_ui_description(func, "Item. A waveform widget to analyze imaga data.");
1957
1958 func = RNA_def_function(srna, "template_vectorscope", "uiTemplateVectorscope");
1959 RNA_def_function_ui_description(func, "Item. A vectorscope widget to analyze imaga data.");
1961
1962 func = RNA_def_function(srna, "template_layers", "uiTemplateLayers");
1964 parm = RNA_def_pointer(
1965 func, "used_layers_data", "AnyType", "", "Data from which to take property");
1967 parm = RNA_def_string(
1968 func, "used_layers_property", nullptr, 0, "", "Identifier of property in data");
1970 parm = RNA_def_int(func, "active_layer", 0, 0, INT_MAX, "Active Layer", "", 0, INT_MAX);
1972
1973 func = RNA_def_function(srna, "template_color_picker", "uiTemplateColorPicker");
1974 RNA_def_function_ui_description(func, "Item. A color wheel widget to pick colors.");
1977 func, "value_slider", false, "", "Display the value slider to the right of the color wheel");
1978 RNA_def_boolean(func,
1979 "lock",
1980 false,
1981 "",
1982 "Lock the color wheel display to value 1.0 regardless of actual color");
1984 func, "lock_luminosity", false, "", "Keep the color at its original vector length");
1985 RNA_def_boolean(func, "cubic", false, "", "Cubic saturation for picking values close to white");
1986
1987 func = RNA_def_function(srna, "template_palette", "uiTemplatePalette");
1988 RNA_def_function_ui_description(func, "Item. A palette used to pick colors.");
1990 RNA_def_boolean(func, "color", false, "", "Display the colors as colors or values");
1991
1992 func = RNA_def_function(srna, "template_image_layers", "uiTemplateImageLayers");
1994 parm = RNA_def_pointer(func, "image", "Image", "", "");
1996 parm = RNA_def_pointer(func, "image_user", "ImageUser", "", "");
1998
1999 func = RNA_def_function(srna, "template_image", "uiTemplateImage");
2001 func, "Item(s). User interface for selecting images and their source paths.");
2004 parm = RNA_def_pointer(func, "image_user", "ImageUser", "", "");
2006 RNA_def_boolean(func, "compact", false, "", "Use more compact layout");
2007 RNA_def_boolean(func, "multiview", false, "", "Expose Multi-View options");
2008
2009 func = RNA_def_function(srna, "template_image_settings", "uiTemplateImageSettings");
2011 RNA_def_function_ui_description(func, "User interface for setting image format options");
2012 parm = RNA_def_pointer(func, "image_settings", "ImageFormatSettings", "", "");
2014 RNA_def_boolean(func, "color_management", false, "", "Show color management settings");
2015
2016 func = RNA_def_function(srna, "template_image_stereo_3d", "uiTemplateImageStereo3d");
2017 RNA_def_function_ui_description(func, "User interface for setting image stereo 3d options");
2018 parm = RNA_def_pointer(func, "stereo_3d_format", "Stereo3dFormat", "", "");
2020
2021 func = RNA_def_function(srna, "template_image_views", "uiTemplateImageViews");
2022 RNA_def_function_ui_description(func, "User interface for setting image views output options");
2023 parm = RNA_def_pointer(func, "image_settings", "ImageFormatSettings", "", "");
2025
2026 func = RNA_def_function(srna, "template_movieclip", "uiTemplateMovieClip");
2028 func, "Item(s). User interface for selecting movie clips and their source paths.");
2031 RNA_def_boolean(func, "compact", false, "", "Use more compact layout");
2032
2033 func = RNA_def_function(srna, "template_track", "uiTemplateTrack");
2034 RNA_def_function_ui_description(func, "Item. A movie-track widget to preview tracking image.");
2036
2037 func = RNA_def_function(srna, "template_marker", "uiTemplateMarker");
2038 RNA_def_function_ui_description(func, "Item. A widget to control single marker settings.");
2040 parm = RNA_def_pointer(func, "clip_user", "MovieClipUser", "", "");
2042 parm = RNA_def_pointer(func, "track", "MovieTrackingTrack", "", "");
2044 RNA_def_boolean(func, "compact", false, "", "Use more compact layout");
2045
2046 func = RNA_def_function(
2047 srna, "template_movieclip_information", "uiTemplateMovieclipInformation");
2048 RNA_def_function_ui_description(func, "Item. Movie clip information data.");
2050 parm = RNA_def_pointer(func, "clip_user", "MovieClipUser", "", "");
2052
2053 func = RNA_def_function(srna, "template_list", "rna_uiTemplateList");
2054 RNA_def_function_ui_description(func, "Item. A list widget to display data, e.g. vertexgroups.");
2056 parm = RNA_def_string(
2057 func, "listtype_name", nullptr, 0, "", "Identifier of the list type to use");
2059 parm = RNA_def_string(
2060 func,
2061 "list_id",
2062 nullptr,
2063 0,
2064 "",
2065 "Identifier of this list widget. Necessary to tell apart different list widgets. Mandatory "
2066 "when using default \"" UI_UL_DEFAULT_CLASS_NAME
2067 "\" class. "
2068 "If this not an empty string, the uilist gets a custom ID, otherwise it takes the "
2069 "name of the class used to define the uilist (for example, if the "
2070 "class name is \"OBJECT_UL_vgroups\", and list_id is not set by the "
2071 "script, then bl_idname = \"OBJECT_UL_vgroups\")");
2073 parm = RNA_def_pointer(
2074 func, "dataptr", "AnyType", "", "Data from which to take the Collection property");
2076 parm = RNA_def_string(
2077 func, "propname", nullptr, 0, "", "Identifier of the Collection property in data");
2079 parm = RNA_def_pointer(func,
2080 "active_dataptr",
2081 "AnyType",
2082 "",
2083 "Data from which to take the integer property, index of the active item");
2085 parm = RNA_def_string(
2086 func,
2087 "active_propname",
2088 nullptr,
2089 0,
2090 "",
2091 "Identifier of the integer property in active_data, index of the active item");
2093 RNA_def_string(func,
2094 "item_dyntip_propname",
2095 nullptr,
2096 0,
2097 "",
2098 "Identifier of a string property in items, to use as tooltip content");
2099 RNA_def_int(func,
2100 "rows",
2101 5,
2102 0,
2103 INT_MAX,
2104 "",
2105 "Default and minimum number of rows to display",
2106 0,
2107 INT_MAX);
2109 func, "maxrows", 5, 0, INT_MAX, "", "Default maximum number of rows to display", 0, INT_MAX);
2110 RNA_def_enum(func,
2111 "type",
2114 "Type",
2115 "Type of layout to use");
2116 RNA_def_int(func,
2117 "columns",
2118 9,
2119 0,
2120 INT_MAX,
2121 "",
2122 "Number of items to display per row, for GRID layout",
2123 0,
2124 INT_MAX);
2125 RNA_def_boolean(func, "sort_reverse", false, "", "Display items in reverse order by default");
2126 RNA_def_boolean(func, "sort_lock", false, "", "Lock display order to default value");
2127
2128 func = RNA_def_function(srna, "template_running_jobs", "uiTemplateRunningJobs");
2130
2131 RNA_def_function(srna, "template_operator_search", "uiTemplateOperatorSearch");
2132 RNA_def_function(srna, "template_menu_search", "uiTemplateMenuSearch");
2133
2134 func = RNA_def_function(srna, "template_header_3D_mode", "uiTemplateHeader3D_mode");
2137
2138 func = RNA_def_function(srna, "template_edit_mode_selection", "uiTemplateEditModeSelection");
2141 func, "Inserts common 3DView Edit modes header UI (selector for selection mode)");
2142
2143 func = RNA_def_function(srna, "template_reports_banner", "uiTemplateReportsBanner");
2145
2146 func = RNA_def_function(srna, "template_input_status", "uiTemplateInputStatus");
2148
2149 func = RNA_def_function(srna, "template_status_info", "uiTemplateStatusInfo");
2151
2152 func = RNA_def_function(srna, "template_node_link", "uiTemplateNodeLink");
2154 parm = RNA_def_pointer(func, "ntree", "NodeTree", "", "");
2156 parm = RNA_def_pointer(func, "node", "Node", "", "");
2158 parm = RNA_def_pointer(func, "socket", "NodeSocket", "", "");
2160
2161 func = RNA_def_function(srna, "template_node_view", "uiTemplateNodeView");
2163 parm = RNA_def_pointer(func, "ntree", "NodeTree", "", "");
2165 parm = RNA_def_pointer(func, "node", "Node", "", "");
2167 parm = RNA_def_pointer(func, "socket", "NodeSocket", "", "");
2169
2170 func = RNA_def_function(
2171 srna, "template_node_asset_menu_items", "rna_uiLayout_template_node_asset_menu_items");
2173 parm = RNA_def_string(func, "catalog_path", nullptr, 0, "", "");
2174 parm = RNA_def_enum(func,
2175 "operator",
2176 rna_enum_template_node_operator_type,
2178 "Operator",
2179 "The operator the asset menu will use");
2180
2181 func = RNA_def_function(srna,
2182 "template_modifier_asset_menu_items",
2183 "rna_uiLayout_template_modifier_asset_menu_items");
2184 parm = RNA_def_string(func, "catalog_path", nullptr, 0, "", "");
2185 parm = RNA_def_boolean(func, "skip_essentials", false, "", "");
2186
2187 func = RNA_def_function(srna,
2188 "template_node_operator_asset_menu_items",
2189 "rna_uiLayout_template_node_operator_asset_menu_items");
2191 parm = RNA_def_string(func, "catalog_path", nullptr, 0, "", "");
2192
2193 func = RNA_def_function(srna,
2194 "template_node_operator_asset_root_items",
2195 "rna_uiLayout_template_node_operator_root_items");
2197
2198 func = RNA_def_function(srna, "template_texture_user", "uiTemplateTextureUser");
2200
2201 func = RNA_def_function(
2202 srna, "template_keymap_item_properties", "uiTemplateKeymapItemProperties");
2203 parm = RNA_def_pointer(func, "item", "KeyMapItem", "", "");
2205
2206 func = RNA_def_function(srna, "template_component_menu", "uiTemplateComponentMenu");
2207 RNA_def_function_ui_description(func, "Item. Display expanded property in a popup menu");
2208 parm = RNA_def_pointer(func, "data", "AnyType", "", "Data from which to take property");
2210 parm = RNA_def_string(func, "property", nullptr, 0, "", "Identifier of property in data");
2212 RNA_def_string(func, "name", nullptr, 0, "", "");
2213
2214 /* color management templates */
2215 func = RNA_def_function(srna, "template_colorspace_settings", "uiTemplateColorspaceSettings");
2216 RNA_def_function_ui_description(func, "Item. A widget to control input color space settings.");
2218
2219 func = RNA_def_function(
2220 srna, "template_colormanaged_view_settings", "uiTemplateColormanagedViewSettings");
2221 RNA_def_function_ui_description(func, "Item. A widget to control color managed view settings.");
2224# if 0
2225 RNA_def_boolean(func,
2226 "show_global_settings",
2227 false,
2228 "",
2229 "Show widgets to control global color management settings");
2230# endif
2231
2232 /* node socket icon */
2233 func = RNA_def_function(srna, "template_node_socket", "uiTemplateNodeSocket");
2234 RNA_def_function_ui_description(func, "Node Socket Icon");
2237 func, "color", 4, node_socket_color_default, 0.0f, 1.0f, "Color", "", 0.0f, 1.0f);
2238
2239 func = RNA_def_function(srna, "template_cache_file", "rna_uiTemplateCacheFile");
2241 func, "Item(s). User interface for selecting cache files and their source paths");
2244
2245 func = RNA_def_function(srna, "template_cache_file_velocity", "rna_uiTemplateCacheFileVelocity");
2246 RNA_def_function_ui_description(func, "Show cache files velocity properties");
2248
2249 func = RNA_def_function(
2250 srna, "template_cache_file_time_settings", "rna_uiTemplateCacheFileTimeSettings");
2251 RNA_def_function_ui_description(func, "Show cache files time settings");
2253
2254 func = RNA_def_function(srna, "template_cache_file_layers", "rna_uiTemplateCacheFileLayers");
2255 RNA_def_function_ui_description(func, "Show cache files override layers properties");
2258
2259 func = RNA_def_function(srna, "template_recent_files", "uiTemplateRecentFiles");
2260 RNA_def_function_ui_description(func, "Show list of recently saved .blend files");
2261 RNA_def_int(func, "rows", 6, 1, INT_MAX, "", "Maximum number of items to show", 1, INT_MAX);
2262 parm = RNA_def_int(func, "found", 0, 0, INT_MAX, "", "Number of items drawn", 0, INT_MAX);
2263 RNA_def_function_return(func, parm);
2264
2265 func = RNA_def_function(srna, "template_file_select_path", "uiTemplateFileSelectPath");
2267 "Item. A text button to set the active file browser path.");
2268 parm = RNA_def_pointer(func, "params", "FileSelectParams", "", "");
2271
2272 func = RNA_def_function(
2273 srna, "template_event_from_keymap_item", "rna_uiTemplateEventFromKeymapItem");
2274 RNA_def_function_ui_description(func, "Display keymap item as icons/text");
2275 parm = RNA_def_property(func, "item", PROP_POINTER, PROP_NONE);
2276 RNA_def_property_struct_type(parm, "KeyMapItem");
2277 RNA_def_property_ui_text(parm, "Item", "");
2280
2281 func = RNA_def_function(
2282 srna, "template_light_linking_collection", "uiTemplateLightLinkingCollection");
2284 "Visualization of a content of a light linking collection");
2286 parm = RNA_def_pointer(func,
2287 "context_layout",
2288 "UILayout",
2289 "",
2290 "Layout to set active list element as context properties");
2293
2294 func = RNA_def_function(srna, "template_bone_collection_tree", "uiTemplateBoneCollectionTree");
2295 RNA_def_function_ui_description(func, "Show bone collections tree");
2297
2298 func = RNA_def_function(
2299 srna, "template_grease_pencil_layer_tree", "uiTemplateGreasePencilLayerTree");
2300 RNA_def_function_ui_description(func, "View of the active Grease Pencil layer tree");
2302
2303 func = RNA_def_function(srna, "template_node_tree_interface", "uiTemplateNodeTreeInterface");
2304 RNA_def_function_ui_description(func, "Show a node tree interface");
2306 parm = RNA_def_pointer(func,
2307 "interface",
2308 "NodeTreeInterface",
2309 "Node Tree Interface",
2310 "Interface of a node tree to display");
2312
2313 func = RNA_def_function(srna, "template_node_inputs", "uiTemplateNodeInputs");
2314 RNA_def_function_ui_description(func, "Show a node settings and input socket values");
2316 parm = RNA_def_pointer(func, "node", "Node", "Node", "Display inputs of this node");
2318
2319 func = RNA_def_function(srna, "template_asset_shelf_popover", "rna_uiTemplateAssetShelfPopover");
2320 RNA_def_function_ui_description(func, "Create a button to open an asset shelf in a popover");
2322 parm = RNA_def_string(func,
2323 "asset_shelf",
2324 nullptr,
2325 0,
2326 "",
2327 "Identifier of the asset shelf to display (``bl_idname``)");
2329 parm = RNA_def_string(
2330 func, "name", nullptr, 0, "", "Optional name to indicate the active asset");
2332 parm = RNA_def_property(func, "icon", PROP_ENUM, PROP_NONE);
2334 RNA_def_property_ui_text(parm, "Icon", "Override automatic icon of the item");
2335 parm = RNA_def_property(func, "icon_value", PROP_INT, PROP_UNSIGNED);
2336 RNA_def_property_ui_text(parm, "Icon Value", "Override automatic icon of the item");
2337
2338 /* A version of `operator` that defines a [Cancel, Confirm] pair of buttons. */
2339 func = RNA_def_function(srna, "template_popup_confirm", "rna_uiTemplatePopupConfirm");
2341 parm = RNA_def_string(func,
2342 "cancel_text",
2343 nullptr,
2344 0,
2345 "",
2346 "Optional text to use for the cancel, not shown when an empty string");
2347 RNA_def_boolean(func, "cancel_default", false, "", "Cancel button by default");
2349 func, "Add confirm & cancel buttons into a popup which will close the popup when pressed");
2351
2352 parm = RNA_def_pointer(
2353 func, "properties", "OperatorProperties", "", "Operator properties to fill in");
2355 RNA_def_function_return(func, parm);
2356
2357 func = RNA_def_function(
2358 srna, "template_shape_key_tree", "blender::ed::object::shapekey::template_tree");
2359 RNA_def_function_ui_description(func, "Shape Key tree view");
2361}
2362
2363#endif
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
@ RPT_ERROR
Definition BKE_report.hh:39
void BLI_kdtree_nd_ free(KDTree *tree)
#define ELEM(...)
bool BLT_translate_iface()
const char * BLT_pgettext(const char *msgctxt, const char *msgid)
#define BLT_I18NCONTEXT_DEFAULT
@ UILST_LAYOUT_DEFAULT
@ RGN_TYPE_WINDOW
int BIFIconID
Definition ED_asset.hh:28
#define RNA_warning(format,...)
@ PARM_RNAPTR
Definition RNA_types.hh:547
@ PARM_REQUIRED
Definition RNA_types.hh:545
@ FUNC_USE_REPORTS
Definition RNA_types.hh:914
@ FUNC_NO_SELF
Definition RNA_types.hh:907
@ FUNC_USE_CONTEXT
Definition RNA_types.hh:913
@ PROP_BOOLEAN
Definition RNA_types.hh:162
@ PROP_ENUM
Definition RNA_types.hh:166
@ PROP_INT
Definition RNA_types.hh:163
@ PROP_POINTER
Definition RNA_types.hh:167
PropertyFlag
Definition RNA_types.hh:300
@ PROP_NEVER_NULL
Definition RNA_types.hh:377
@ PROP_COLOR
Definition RNA_types.hh:260
@ PROP_NONE
Definition RNA_types.hh:233
@ PROP_COLOR_GAMMA
Definition RNA_types.hh:272
@ PROP_UNSIGNED
Definition RNA_types.hh:249
#define C
Definition RandGen.cpp:29
void uiTemplateCacheFileLayers(uiLayout *layout, const bContext *C, PointerRNA *fileptr)
void uiTemplateAnyID(uiLayout *layout, PointerRNA *ptr, blender::StringRefNull propname, blender::StringRefNull proptypename, std::optional< blender::StringRef > text)
bool uiTemplateCacheFilePointer(PointerRNA *ptr, blender::StringRefNull propname, PointerRNA *r_file_ptr)
@ UI_TEMPLATE_ID_FILTER_AVAILABLE
@ UI_TEMPLATE_ID_FILTER_ALL
#define UI_UL_DEFAULT_CLASS_NAME
bool uiTemplateEventFromKeymapItem(uiLayout *layout, blender::StringRefNull text, const wmKeyMapItem *kmi, bool text_fallback)
void uiTemplateCacheFileVelocity(uiLayout *layout, PointerRNA *fileptr)
void uiTemplateID(uiLayout *layout, const bContext *C, PointerRNA *ptr, blender::StringRefNull propname, const char *newop, const char *openop, const char *unlinkop, int filter=UI_TEMPLATE_ID_FILTER_ALL, bool live_icon=false, std::optional< blender::StringRef > text=std::nullopt)
void uiTemplateSearchPreview(uiLayout *layout, bContext *C, PointerRNA *ptr, blender::StringRefNull propname, PointerRNA *searchptr, const char *searchpropname, const char *newop, const char *unlinkop, int rows, int cols, std::optional< blender::StringRef > text=std::nullopt)
bool UI_popup_block_template_confirm_is_supported(const uiBlock *block)
void uiTemplatePathBuilder(uiLayout *layout, PointerRNA *ptr, blender::StringRefNull propname, PointerRNA *root_ptr, std::optional< blender::StringRefNull > text)
void UI_popup_block_template_confirm_op(uiLayout *layout, wmOperatorType *ot, std::optional< blender::StringRef > confirm_text, std::optional< blender::StringRef > cancel_text, const int icon, bool cancel_default, PointerRNA *r_ptr)
void uiTemplateList(uiLayout *layout, const bContext *C, const char *listtype_name, const char *list_id, PointerRNA *dataptr, blender::StringRefNull propname, PointerRNA *active_dataptr, const char *active_propname, const char *item_dyntip_propname, int rows, int maxrows, int layout_type, int columns, enum uiTemplateListFlags flags)
void uiTemplateAction(uiLayout *layout, const bContext *C, ID *id, const char *newop, const char *unlinkop, std::optional< blender::StringRef > text)
void uiTemplateCacheFileTimeSettings(uiLayout *layout, PointerRNA *fileptr)
void uiTemplateSearch(uiLayout *layout, const bContext *C, PointerRNA *ptr, blender::StringRefNull propname, PointerRNA *searchptr, const char *searchpropname, const char *newop, const char *unlinkop, std::optional< blender::StringRef > text=std::nullopt)
uiTemplateListFlags
@ UI_TEMPLATE_LIST_SORT_LOCK
@ UI_TEMPLATE_LIST_SORT_REVERSE
@ UI_TEMPLATE_LIST_FLAG_NONE
void uiTemplateCacheFile(uiLayout *layout, const bContext *C, PointerRNA *ptr, blender::StringRefNull propname)
int UI_icon_from_rnaptr(const bContext *C, PointerRNA *ptr, int rnaicon, bool big)
@ UI_ITEM_R_EVENT
@ UI_ITEM_R_TOGGLE
@ UI_ITEM_O_DEPRESS
@ UI_ITEM_R_ICON_NEVER
@ UI_ITEM_R_EXPAND
@ UI_ITEM_R_NO_BG
@ UI_ITEM_R_CHECKBOX_INVERT
@ UI_ITEM_R_ICON_ONLY
@ UI_ITEM_R_FULL_EVENT
@ UI_ITEM_R_SLIDER
NodeAssetMenuOperatorType
#define UI_ITEM_NONE
LayoutSeparatorType
#define UI_MAX_NAME_STR
BMesh const char void * data
#define row_major
#define filter
void MEM_freeN(void *vmemh)
Definition mallocn.cc:113
void ui_template_node_operator_asset_menu_items(uiLayout &layout, const bContext &C, const StringRef catalog_path)
void ui_template_node_operator_asset_root_items(uiLayout &layout, const bContext &C)
void ui_template_modifier_asset_menu_items(uiLayout &layout, StringRef catalog_path, bool skip_essentials)
void ui_template_node_asset_menu_items(uiLayout &layout, const bContext &C, StringRef catalog_path, const NodeAssetMenuOperatorType operator_type)
void template_asset_shelf_popover(uiLayout &layout, const bContext &C, StringRefNull asset_shelf_id, StringRef name, int icon)
const char * name
PropertyRNA * RNA_struct_type_find_property(StructRNA *srna, const char *identifier)
bool RNA_property_array_check(PropertyRNA *prop)
StructRNA * RNA_property_pointer_type(PointerRNA *ptr, PropertyRNA *prop)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
int RNA_enum_from_identifier(const EnumPropertyItem *item, const char *identifier)
PropertyType RNA_property_type(PropertyRNA *prop)
const PointerRNA PointerRNA_NULL
const char * RNA_struct_identifier(const StructRNA *type)
void RNA_property_enum_items_gettexted(bContext *C, PointerRNA *ptr, PropertyRNA *prop, const EnumPropertyItem **r_item, int *r_totitem, bool *r_free)
const char * RNA_property_translation_context(const PropertyRNA *prop)
int RNA_struct_ui_icon(const StructRNA *type)
bool RNA_pointer_is_null(const PointerRNA *ptr)
PropertySubType RNA_property_subtype(PropertyRNA *prop)
void RNA_property_enum_items(bContext *C, PointerRNA *ptr, PropertyRNA *prop, const EnumPropertyItem **r_item, int *r_totitem, bool *r_free)
const char * RNA_struct_translation_context(const StructRNA *type)
static const EnumPropertyItem curve_type_items[]
Definition rna_curve.cc:122
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_return(FunctionRNA *func, PropertyRNA *ret)
void RNA_def_property_ui_text(PropertyRNA *prop, const char *name, const char *description)
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)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
void RNA_def_property_enum_items(PropertyRNA *prop, const EnumPropertyItem *item)
FunctionRNA * RNA_def_function(StructRNA *srna, const char *identifier, const char *call)
PropertyRNA * RNA_def_pointer(StructOrFunctionRNA *cont_, const char *identifier, const char *type, const char *ui_name, const char *ui_description)
void RNA_def_property_struct_type(PropertyRNA *prop, const char *type)
void RNA_def_function_ui_description(FunctionRNA *func, const char *description)
PropertyRNA * RNA_def_property(StructOrFunctionRNA *cont_, const char *identifier, int type, int subtype)
void RNA_def_function_flag(FunctionRNA *func, int flag)
void RNA_def_property_clear_flag(PropertyRNA *prop, PropertyFlag flag)
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)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
void RNA_def_function_output(FunctionRNA *, PropertyRNA *ret)
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 RNA_def_parameter_flags(PropertyRNA *prop, PropertyFlag flag_property, ParameterFlag flag_parameter)
std::optional< blender::StringRefNull > rna_translate_ui_text(const char *text, const char *text_ctxt, StructRNA *type, PropertyRNA *prop, bool translate)
const EnumPropertyItem rna_enum_region_type_items[]
Definition rna_screen.cc:21
const EnumPropertyItem rna_enum_space_type_items[]
Definition rna_space.cc:73
const EnumPropertyItem rna_enum_uilist_layout_type_items[]
Definition rna_ui.cc:50
static void api_ui_item_common_text(FunctionRNA *func)
static void api_ui_item_common(FunctionRNA *func)
static void api_ui_item_rna_common(FunctionRNA *func)
static void api_ui_item_op(FunctionRNA *func)
static void api_ui_item_op_common(FunctionRNA *func)
static void api_ui_item_common_heading(FunctionRNA *func)
const EnumPropertyItem rna_enum_icon_items[]
Definition rna_ui_api.cc:26
void RNA_api_ui_layout(StructRNA *srna)
void api_ui_item_common_translation(FunctionRNA *func)
#define FLT_MAX
Definition stdcycles.h:14
const char * name
Definition RNA_types.hh:661
const char * description
Definition RNA_types.hh:663
Definition DNA_ID.h:414
StructRNA * type
Definition RNA_types.hh:52
PointerRNA op_menu_enum(const bContext *C, wmOperatorType *ot, blender::StringRefNull propname, std::optional< blender::StringRefNull > name, int icon)
void prop_enum(PointerRNA *ptr, PropertyRNA *prop, int value, std::optional< blender::StringRefNull > name, int icon)
void decorator(PointerRNA *ptr, PropertyRNA *prop, int index)
PanelLayout panel(const bContext *C, blender::StringRef idname, bool default_closed)
void progress_indicator(const char *text, float factor, blender::ui::ButProgressType progress_type)
void props_enum(PointerRNA *ptr, blender::StringRefNull propname)
void popover(const bContext *C, PanelType *pt, std::optional< blender::StringRef > name_opt, int icon)
uiLayout & column_flow(int number, bool align)
blender::wm::OpCallContext operator_context() const
PanelLayout panel_prop(const bContext *C, PointerRNA *open_prop_owner, blender::StringRefNull open_prop_name)
void op_enum(blender::StringRefNull opname, blender::StringRefNull propname, IDProperty *properties, blender::wm::OpCallContext context, eUI_Item_Flag flag, const int active=-1)
uiBlock * block() const
void separator_spacer()
void popover_group(bContext *C, int space_id, int region_id, const char *context, const char *category)
void label(blender::StringRef name, int icon)
float search_weight() const
uiLayout & column(bool align)
void search_weight_set(float weight)
void prop_search(PointerRNA *ptr, PropertyRNA *prop, PointerRNA *searchptr, PropertyRNA *searchprop, PropertyRNA *item_searchpropname, std::optional< blender::StringRefNull > name, int icon, bool results_are_suggestions)
uiLayout & grid_flow(bool row_major, int columns_len, bool even_columns, bool even_rows, bool align)
void separator(float factor=1.0f, LayoutSeparatorType type=LayoutSeparatorType::Auto)
void context_ptr_set(blender::StringRef name, const PointerRNA *ptr)
uiLayout & row(bool align)
uiLayout & split(float percentage, bool align)
uiLayout & box()
void prop_menu_enum(PointerRNA *ptr, PropertyRNA *prop, std::optional< blender::StringRefNull > name, int icon)
PointerRNA op_menu_hold(wmOperatorType *ot, std::optional< blender::StringRef > name, int icon, blender::wm::OpCallContext context, eUI_Item_Flag flag, const char *menu_id)
void prop_with_menu(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< blender::StringRefNull > name, int icon, const char *menu_type)
uiLayout & menu_pie()
Panel * root_panel() const
PointerRNA op(wmOperatorType *ot, std::optional< blender::StringRef > name, int icon, blender::wm::OpCallContext context, eUI_Item_Flag flag)
void prop_with_popover(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< blender::StringRefNull > name, int icon, const char *panel_type)
void menu(MenuType *mt, std::optional< blender::StringRef > name, int icon)
void menu_contents(blender::StringRef menuname)
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< blender::StringRef > name_opt, int icon, std::optional< blender::StringRef > placeholder=std::nullopt)
void prop_tabs_enum(bContext *C, PointerRNA *ptr, PropertyRNA *prop, PointerRNA *ptr_highlight, PropertyRNA *prop_highlight, bool icon_only)
void context_string_set(blender::StringRef name, blender::StringRef value)
PointerRNA * ptr
Definition wm_files.cc:4238
wmOperatorType * ot
Definition wm_files.cc:4237
wmOperatorType * WM_operatortype_find(const char *idname, bool quiet)
uint8_t flag
Definition wm_window.cc:145