Blender V5.3
interface_ops.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 <cstring>
10
11#include <fmt/format.h>
12
13#include "MEM_guardedalloc.h"
14
15#include "DNA_armature_types.h"
16#include "DNA_key_types.h"
17#include "DNA_material_types.h"
18#include "DNA_modifier_types.h" /* for handling geometry nodes properties */
20#include "DNA_object_types.h" /* for OB_DATA_SUPPORT_ID */
21#include "DNA_screen_types.h"
22
23#include "ANIM_keyframing.hh"
24
25#include "BLI_listbase.hh"
26#include "BLI_math_color_c.hh"
27#include "BLI_rect.hh"
28#include "BLI_string.hh"
29#include "BLI_string_utf8.hh"
30
31#include "BLF_api.hh"
32#include "BLT_lang.hh"
33#include "BLT_translation.hh"
34
35#include "BKE_anim_data.hh"
36#include "BKE_armature.hh"
37#include "BKE_context.hh"
38#include "BKE_fcurve.hh"
39#include "BKE_idtype.hh"
40#include "BKE_layer.hh"
41#include "BKE_lib_id.hh"
42#include "BKE_lib_override.hh"
43#include "BKE_lib_remap.hh"
44#include "BKE_library.hh"
45#include "BKE_material.hh"
46#include "BKE_node.hh"
47#include "BKE_report.hh"
48#include "BKE_screen.hh"
49
51
52#include "DEG_depsgraph.hh"
54
55#include "RNA_access.hh"
56#include "RNA_define.hh"
57#include "RNA_path.hh"
58#include "RNA_prototypes.hh"
59
60#include "UI_abstract_view.hh"
61#include "UI_interface.hh"
63#include "UI_tree_view.hh"
64
65#include "interface_intern.hh"
66
67#include "WM_api.hh"
68#include "WM_types.hh"
69
70#include "ED_object.hh"
71#include "ED_outliner.hh"
72#include "ED_paint.hh"
73#include "ED_undo.hh"
74
75/* for Copy As Driver */
76#include "ED_keyframing.hh"
77
78/* Only for #UI_OT_editsource. */
79#include "ED_screen.hh"
80
81#include "NOD_socket.hh"
82
83namespace blender {
84
85extern void PyC_FileAndNum_Safe(const char **r_filename, int *r_lineno);
86
87namespace ui {
88
89/* -------------------------------------------------------------------- */
103
105{
106 if (region->regiontype == RGN_TYPE_TEMPORARY) {
107 ARegion *old_region = CTX_wm_region_popup(C);
108
110 CTX_wm_region_popup_set(C, region);
111 if (region->runtime->type->layout) {
112 wmViewport(&region->winrct);
113 region->runtime->type->layout(C, region);
114 }
115
116 CTX_wm_region_popup_set(C, old_region);
118 return;
119 }
120 ED_region_do_layout(C, region);
122 ED_region_do_draw(C, region);
124 region->runtime->do_draw = 0;
125}
126
128
129/* -------------------------------------------------------------------- */
132
134{
135 PointerRNA ptr;
136 PropertyRNA *prop;
137 int index;
138
139 context_active_but_prop_get(C, &ptr, &prop, &index);
140
141 if (ptr && ptr.has_owner_id() && prop) {
142 if (const std::optional<std::string> path = RNA_path_from_ID_to_property(&ptr, prop)) {
143 UNUSED_VARS(path);
144 return true;
145 }
146 }
147
148 return false;
149}
150
152{
153 Main *bmain = CTX_data_main(C);
154 PointerRNA ptr;
155 PropertyRNA *prop;
156 int index;
157 ID *id;
158
159 const bool full_path = RNA_boolean_get(op->ptr, "full_path");
160
161 /* try to create driver using property retrieved from UI */
162 context_active_but_prop_get(C, &ptr, &prop, &index);
163
164 std::optional<std::string> path;
165 if (ptr.has_owner_id()) {
166 if (full_path) {
167 if (prop) {
168 path = RNA_path_full_property_py_ex(&ptr, prop, index, true);
169 }
170 else {
171 path = RNA_path_full_struct_py(&ptr);
172 }
173 }
174 else {
175 const int index_dim = (index != -1 && RNA_property_array_check(prop)) ? 1 : 0;
176 path = RNA_path_from_real_ID_to_property_index(bmain, &ptr, prop, index_dim, index, &id);
177
178 if (!path) {
179 path = RNA_path_from_ID_to_property_index(&ptr, prop, index_dim, index);
180 }
181 }
182
183 if (path) {
184 WM_clipboard_text_set(path->c_str(), false);
185 return OPERATOR_FINISHED;
186 }
187 }
188
189 return OPERATOR_CANCELLED;
190}
191
193{
194 PropertyRNA *prop;
195
196 /* identifiers */
197 ot->name = "Copy Data Path";
198 ot->idname = "UI_OT_copy_data_path_button";
199 ot->description = "Copy the RNA data path for this property to the clipboard";
200
201 /* callbacks */
204
205 /* flags */
206 ot->flag = OPTYPE_REGISTER;
207
208 /* properties */
209 prop = RNA_def_boolean(ot->srna, "full_path", false, "full_path", "Copy full data path");
211}
212
214
215/* -------------------------------------------------------------------- */
218
220{
221 PointerRNA ptr;
222 PropertyRNA *prop;
223 int index;
224
225 context_active_but_prop_get(C, &ptr, &prop, &index);
226
227 if (ptr && ptr.has_owner_id() && prop &&
229 (index >= 0 || !RNA_property_array_check(prop)))
230 {
231 if (const std::optional<std::string> path = RNA_path_from_ID_to_property(&ptr, prop)) {
232 UNUSED_VARS(path);
233 return true;
234 }
235 }
236
237 return false;
238}
239
241{
242 Main *bmain = CTX_data_main(C);
243 PointerRNA ptr;
244 PropertyRNA *prop;
245 int index;
246
247 /* try to create driver using property retrieved from UI */
248 context_active_but_prop_get(C, &ptr, &prop, &index);
249
250 if (ptr && ptr.has_owner_id() && prop) {
251 ID *id;
252 const int dim = RNA_property_array_dimension(&ptr, prop, nullptr);
253 if (const std::optional<std::string> path = RNA_path_from_real_ID_to_property_index(
254 bmain, &ptr, prop, dim, index, &id))
255 {
256 ANIM_copy_as_driver(id, path->c_str(), RNA_property_identifier(prop));
257 return OPERATOR_FINISHED;
258 }
259
260 BKE_reportf(op->reports, RPT_ERROR, "Could not compute a valid data path");
261 return OPERATOR_CANCELLED;
262 }
263
264 return OPERATOR_CANCELLED;
265}
266
268{
269 /* identifiers */
270 ot->name = "Copy as New Driver";
271 ot->idname = "UI_OT_copy_as_driver_button";
272 ot->description =
273 "Create a new driver with this property as input, and copy it to the "
274 "internal clipboard. Use Paste Driver to add it to the target property, "
275 "or Paste Driver Variables to extend an existing driver";
276
277 /* callbacks */
280
281 /* flags */
282 ot->flag = OPTYPE_REGISTER;
283}
284
286
287/* -------------------------------------------------------------------- */
290
292{
294
295 if (but && (but->optype != nullptr)) {
296 return true;
297 }
298
299 return false;
300}
301
303{
305
306 if (but && (but->optype != nullptr)) {
307 /* allocated when needed, the button owns it */
309
310 std::string str = WM_operator_pystring_ex(C, nullptr, false, true, but->optype, opptr);
311
312 WM_clipboard_text_set(str.c_str(), false);
313
314 return OPERATOR_FINISHED;
315 }
316
317 return OPERATOR_CANCELLED;
318}
319
321{
322 /* identifiers */
323 ot->name = "Copy Python Command";
324 ot->idname = "UI_OT_copy_python_command_button";
325 ot->description = "Copy the Python command matching this button";
326
327 /* callbacks */
330
331 /* flags */
332 ot->flag = OPTYPE_REGISTER;
333}
334
336
337/* -------------------------------------------------------------------- */
340
342 PointerRNA *ptr,
343 PropertyRNA *prop)
344{
345 /* Assign before executing logic in the unlikely event the ID is freed. */
346 const bool is_undo = ptr->owner_id && ID_CHECK_UNDO(ptr->owner_id);
347
348 /* perform updates required for this property */
349 RNA_property_update(C, ptr, prop);
350
351 /* as if we pressed the button */
353
354 /* Since we don't want to undo _all_ edits to settings, eg window
355 * edits on the screen or on operator settings.
356 * it might be better to move undo's inline - campbell */
357 if (is_undo) {
358 /* do nothing, go ahead with undo */
359 return OPERATOR_FINISHED;
360 }
361 return OPERATOR_CANCELLED;
362}
363
365 PointerRNA *ptr,
366 PropertyRNA *prop)
367{
368 /* Perform updates required for this property. */
369 RNA_property_update(C, ptr, prop);
370
371 /* As if we pressed the button. */
373
374 return OPERATOR_FINISHED;
375}
376
378{
379 PointerRNA ptr;
380 PropertyRNA *prop;
381 int index;
382
383 context_active_but_prop_get(C, &ptr, &prop, &index);
384
385 return (ptr && prop && RNA_property_editable(&ptr, prop));
386}
387
389{
390 Main &bmain = *CTX_data_main(C);
391 PointerRNA ptr;
392 PropertyRNA *prop;
393 int index;
394 const bool all = RNA_boolean_get(op->ptr, "all");
395
396 /* try to reset the nominated setting to its default value */
397 context_active_but_prop_get(C, &ptr, &prop, &index);
398
399 /* if there is a valid property that is editable... */
400 if (ptr && prop && RNA_property_editable(&ptr, prop)) {
401 const int array_index = (all) ? -1 : index;
402 if (RNA_property_reset(&bmain, &ptr, prop, array_index)) {
403
404 /* Apply auto keyframe when property is successfully reset. */
405 Scene *scene = CTX_data_scene(C);
406 animrig::autokeyframe_property(C, scene, &ptr, prop, array_index, scene->r.cfra, true);
407
409 }
410 }
411
412 return OPERATOR_CANCELLED;
413}
414
416{
417 /* identifiers */
418 ot->name = "Reset to Default Value";
419 ot->idname = "UI_OT_reset_default_button";
420 ot->description = "Reset this property's value to its default value";
421
422 /* callbacks */
425
426 /* flags */
427 /* Don't set #OPTYPE_UNDO because #operator_button_property_finish_with_undo
428 * is responsible for the undo push. */
429 ot->flag = OPTYPE_REGISTER;
430
431 /* properties */
433 ot->srna, "all", true, "All", "Reset to default values all elements of the array");
434}
435
437
438/* -------------------------------------------------------------------- */
441
443{
444 PointerRNA ptr;
445 PropertyRNA *prop;
446 int index;
447
448 context_active_but_prop_get(C, &ptr, &prop, &index);
449
450 if (ptr && prop && RNA_property_editable(&ptr, prop)) {
451 const PropertyType type = RNA_property_type(prop);
452
453 return RNA_property_is_idprop(prop) && !RNA_property_array_check(prop) &&
454 ELEM(type, PROP_INT, PROP_FLOAT);
455 }
456
457 return false;
458}
459
461{
462 PointerRNA ptr;
463 PropertyRNA *prop;
464 int index;
465
466 /* try to reset the nominated setting to its default value */
467 context_active_but_prop_get(C, &ptr, &prop, &index);
468
469 /* if there is a valid property that is editable... */
470 if (ptr && prop && RNA_property_editable(&ptr, prop)) {
471 if (RNA_property_assign_default(&ptr, prop)) {
472 return operator_button_property_finish(C, &ptr, prop);
473 }
474 }
475
476 return OPERATOR_CANCELLED;
477}
478
480{
481 /* identifiers */
482 ot->name = "Assign Value as Default";
483 ot->idname = "UI_OT_assign_default_button";
484 ot->description = "Set this property's current value as the new default";
485
486 /* callbacks */
489
490 /* flags */
491 ot->flag = OPTYPE_UNDO;
492}
493
495
496/* -------------------------------------------------------------------- */
499
501{
502 PointerRNA ptr;
503 PropertyRNA *prop;
504 int index;
505
506 /* try to unset the nominated property */
507 context_active_but_prop_get(C, &ptr, &prop, &index);
508
509 /* if there is a valid property that is editable... */
510 if (ptr && prop && RNA_property_editable(&ptr, prop) &&
511 /* RNA_property_is_idprop(prop) && */
512 RNA_property_is_set(&ptr, prop))
513 {
514 RNA_property_unset(&ptr, prop);
515 return operator_button_property_finish(C, &ptr, prop);
516 }
517
518 return OPERATOR_CANCELLED;
519}
520
522{
523 /* identifiers */
524 ot->name = "Unset Property";
525 ot->idname = "UI_OT_unset_property_button";
526 ot->description = "Clear the property and use default or generated value in operators";
527
528 /* callbacks */
531
532 /* flags */
533 ot->flag = OPTYPE_UNDO;
534}
535
537
538/* -------------------------------------------------------------------- */
541
543{
544 PointerRNA ptr;
545 PropertyRNA *prop;
546 int index;
547
548 context_active_but_prop_get(C, &ptr, &prop, &index);
549
551 CTX_data_main(C), &ptr, prop, index);
552
553 return (ptr && prop && flag_is_set(override_status, eRNAOverrideStatus::LibOverridable));
554}
555
557{
558 PointerRNA ptr;
559 PropertyRNA *prop;
560 int index;
561 bool created;
562 const bool all = RNA_boolean_get(op->ptr, "all");
563
565
566 /* try to reset the nominated setting to its default value */
567 context_active_but_prop_get(C, &ptr, &prop, &index);
568
570
571 if (all) {
572 index = -1;
573 }
574
576 CTX_data_main(C), &ptr, prop, operation, index, true, nullptr, &created);
577
578 if (opop == nullptr) {
579 /* Sometimes e.g. RNA cannot generate a path to the given property. */
580 BKE_reportf(op->reports, RPT_WARNING, "Failed to create the override operation");
581 return OPERATOR_CANCELLED;
582 }
583
584 if (!created) {
585 opop->operation = operation;
586 }
587
588 /* Outliner e.g. has to be aware of this change. */
590
591 return operator_button_property_finish(C, &ptr, prop);
592}
593
595{
596 /* identifiers */
597 ot->name = "Add Override";
598 ot->idname = "UI_OT_override_add_button";
599 ot->description = "Create an override operation";
600
601 /* callbacks */
604
605 /* flags */
606 ot->flag = OPTYPE_UNDO;
607
608 /* properties */
609 RNA_def_boolean(ot->srna, "all", true, "All", "Add overrides for all elements of the array");
610}
611
613{
614 PointerRNA ptr;
615 PropertyRNA *prop;
616 int index;
617
618 context_active_but_prop_get(C, &ptr, &prop, &index);
619
621 CTX_data_main(C), &ptr, prop, index);
622
623 return (ptr && ptr.has_owner_id() && prop &&
624 flag_is_set(override_status, eRNAOverrideStatus::LibOverridden));
625}
626
628{
629 Main *bmain = CTX_data_main(C);
630 PointerRNA ptr, src;
631 PropertyRNA *prop;
632 int index;
633 const bool all = RNA_boolean_get(op->ptr, "all");
634
635 /* try to reset the nominated setting to its default value */
636 context_active_but_prop_get(C, &ptr, &prop, &index);
637
638 ID *id = ptr.owner_id;
639 IDOverrideLibraryProperty *oprop = RNA_property_override_property_find(bmain, &ptr, prop, &id);
640 BLI_assert(oprop != nullptr);
641 BLI_assert(id != nullptr && id->override_library != nullptr);
642
643 /* The source (i.e. linked data) is required to restore values of deleted overrides. */
644 PropertyRNA *src_prop;
645 PointerRNA id_refptr = RNA_id_pointer_create(id->override_library->reference);
646 if (!RNA_path_resolve_property(&id_refptr, oprop->rna_path, &src, &src_prop)) {
647 BLI_assert_msg(0, "Failed to create matching source (linked data) RNA pointer");
648 }
649
650 if (!all && index != -1) {
651 bool is_strict_find;
652 /* Remove override operation for given item,
653 * add singular operations for the other items as needed. */
655 oprop, nullptr, nullptr, {}, {}, index, index, false, &is_strict_find);
656 BLI_assert(opop != nullptr);
657 if (!is_strict_find) {
658 /* No specific override operation, we have to get generic one,
659 * and create item-specific override operations for all but given index,
660 * before removing generic one. */
661 for (int idx = RNA_property_array_length(&ptr, prop); idx--;) {
662 if (idx != index) {
664 oprop, opop->operation, nullptr, nullptr, {}, {}, idx, idx, true, nullptr, nullptr);
665 }
666 }
667 }
668 RNA_property_copy(bmain, &ptr, &src, prop, index, oprop, opop);
670 if (oprop->operations.is_empty()) {
671 BKE_lib_override_library_property_delete(id->override_library, oprop);
672 }
673 }
674 else {
675 /* Just remove whole generic override operation of this property. */
676 RNA_property_copy(bmain, &ptr, &src, prop, -1, oprop);
677 BKE_lib_override_library_property_delete(id->override_library, oprop);
678 }
679
680 /* Outliner e.g. has to be aware of this change. */
682
683 return operator_button_property_finish(C, &ptr, prop);
684}
685
687{
688 /* identifiers */
689 ot->name = "Remove Override";
690 ot->idname = "UI_OT_override_remove_button";
691 ot->description = "Remove an override operation";
692
693 /* callbacks */
696
697 /* flags */
698 ot->flag = OPTYPE_UNDO;
699
700 /* properties */
702 ot->srna, "all", true, "All", "Reset to default values all elements of the array");
703}
704
706 bContext *C, ID **r_owner_id, ID **r_id, PointerRNA *r_owner_ptr, PropertyRNA **r_prop)
707{
708 PointerRNA owner_ptr;
709 PropertyRNA *prop;
710 context_active_but_prop_get_templateID(C, &owner_ptr, &prop);
711
712 if (!owner_ptr || prop == nullptr) {
713 *r_owner_id = *r_id = nullptr;
714 if (r_owner_ptr != nullptr) {
715 *r_owner_ptr = {};
716 }
717 if (r_prop != nullptr) {
718 *r_prop = nullptr;
719 }
720 return;
721 }
722
723 *r_owner_id = owner_ptr.owner_id;
724 PointerRNA idptr = RNA_property_pointer_get(&owner_ptr, prop);
725 *r_id = static_cast<ID *>(idptr.data);
726 if (r_owner_ptr != nullptr) {
727 *r_owner_ptr = owner_ptr;
728 }
729 if (r_prop != nullptr) {
730 *r_prop = prop;
731 }
732}
733
734static bool override_idtemplate_poll(bContext *C, const bool is_create_op)
735{
736 ID *owner_id, *id;
737 override_idtemplate_ids_get(C, &owner_id, &id, nullptr, nullptr);
738
739 if (owner_id == nullptr || id == nullptr) {
740 return false;
741 }
742
743 if (ID_IS_PACKED(id)) {
744 return false;
745 }
746
747 if (is_create_op) {
748 if (!ID_IS_LINKED(id) && !ID_IS_OVERRIDE_LIBRARY_REAL(id)) {
749 return false;
750 }
751 return true;
752 }
753
754 /* Reset/Clear operations. */
756 return false;
757 }
758 return true;
759}
760
762{
763 return override_idtemplate_poll(C, true);
764}
765
767{
768 ID *owner_id, *id;
769 PointerRNA owner_ptr;
770 PropertyRNA *prop;
771 override_idtemplate_ids_get(C, &owner_id, &id, &owner_ptr, &prop);
772 if (ELEM(nullptr, owner_id, id)) {
773 return OPERATOR_CANCELLED;
774 }
775
777 C, CTX_data_main(C), owner_id, id, nullptr);
778
779 if (id_override == nullptr) {
780 return OPERATOR_CANCELLED;
781 }
782
783 /* `idptr` is re-assigned to owner property to ensure proper updates etc. Here we also use it
784 * to ensure remapping of the owner property from the linked data to the newly created
785 * liboverride (note that in theory this remapping has already been done by code above), but
786 * only in case owner ID was already local ID (override or pure local data).
787 *
788 * Otherwise, owner ID will also have been overridden, and remapped already to use it's
789 * override of the data too. */
790 if (!ID_IS_LINKED(owner_id)) {
791 PointerRNA idptr = RNA_id_pointer_create(id_override);
792 RNA_property_pointer_set(&owner_ptr, prop, idptr, nullptr);
793 }
794 RNA_property_update(C, &owner_ptr, prop);
795
796 /* 'Security' extra tagging, since this process may also affect the owner ID and not only the
797 * used ID, relying on the property update code only is not always enough. */
802
803 return OPERATOR_FINISHED;
804}
805
807{
808 /* identifiers */
809 ot->name = "Make Library Override";
810 ot->idname = "UI_OT_override_idtemplate_make";
811 ot->description =
812 "Create a local override of the selected linked data-block, and its hierarchy of "
813 "dependencies";
814
815 /* callbacks */
818
819 /* flags */
820 ot->flag = OPTYPE_UNDO;
821}
822
824{
825 return override_idtemplate_poll(C, false);
826}
827
829{
830 ID *owner_id, *id;
831 PointerRNA owner_ptr;
832 PropertyRNA *prop;
833 override_idtemplate_ids_get(C, &owner_id, &id, &owner_ptr, &prop);
834 if (ELEM(nullptr, owner_id, id)) {
835 return OPERATOR_CANCELLED;
836 }
837
839 return OPERATOR_CANCELLED;
840 }
841
843
844 /* `idptr` is re-assigned to owner property to ensure proper updates etc. */
846 RNA_property_pointer_set(&owner_ptr, prop, idptr, nullptr);
847 RNA_property_update(C, &owner_ptr, prop);
848
849 /* No need for 'security' extra tagging here, since this process will never affect the owner ID.
850 */
851
852 return OPERATOR_FINISHED;
853}
854
856{
857 /* identifiers */
858 ot->name = "Reset Library Override";
859 ot->idname = "UI_OT_override_idtemplate_reset";
860 ot->description = "Reset the selected local override to its linked reference values";
861
862 /* callbacks */
865
866 /* flags */
867 ot->flag = OPTYPE_UNDO;
868}
869
871{
872 return override_idtemplate_poll(C, false);
873}
874
876{
877 ID *owner_id, *id;
878 PointerRNA owner_ptr;
879 PropertyRNA *prop;
880 override_idtemplate_ids_get(C, &owner_id, &id, &owner_ptr, &prop);
881 if (ELEM(nullptr, owner_id, id)) {
882 return OPERATOR_CANCELLED;
883 }
884
885 if (ID_IS_LINKED(id)) {
886 return OPERATOR_CANCELLED;
887 }
888
889 Main *bmain = CTX_data_main(C);
890 ViewLayer *view_layer = CTX_data_view_layer(C);
891 Scene *scene = CTX_data_scene(C);
892 ID *id_new = id;
893
895 id_new = id->override_library->reference;
896 bool do_remap_active = false;
897 BKE_view_layer_synced_ensure(*bmain, scene, view_layer);
898 if (BKE_view_layer_active_object_get(view_layer) == id_cast<Object *>(id)) {
899 BLI_assert(GS(id->name) == ID_OB);
900 BLI_assert(GS(id_new->name) == ID_OB);
901 do_remap_active = true;
902 }
904 if (do_remap_active) {
905 Object *ref_object = id_cast<Object *>(id_new);
906 Base *basact = BKE_view_layer_base_find(view_layer, ref_object);
907 if (basact != nullptr) {
908 view_layer->basact = basact;
909 }
911 }
912 BKE_id_delete(bmain, id);
913 }
914 else {
915 BKE_lib_override_library_id_reset(bmain, id, true);
916 }
917
918 /* Here the affected ID may remain the same, or be replaced by its linked reference. In either
919 * case, the owner ID remains unchanged, and remapping is already handled by internal code, so
920 * calling `RNA_property_update` on it is enough to ensure proper notifiers are sent. */
921 RNA_property_update(C, &owner_ptr, prop);
922
923 /* 'Security' extra tagging, since this process may also affect the owner ID and not only the
924 * used ID, relying on the property update code only is not always enough. */
929
930 return OPERATOR_FINISHED;
931}
932
934{
935 /* identifiers */
936 ot->name = "Clear Library Override";
937 ot->idname = "UI_OT_override_idtemplate_clear";
938 ot->description =
939 "Delete the selected local override and relink its usages to the linked data-block if "
940 "possible, else reset it and mark it as non editable";
941
942 /* callbacks */
945
946 /* flags */
947 ot->flag = OPTYPE_UNDO;
948}
949
950static bool override_idtemplate_menu_poll(const bContext *C_const, MenuType * /*mt*/)
951{
952 bContext *C = const_cast<bContext *>(C_const);
953 ID *owner_id, *id;
954 override_idtemplate_ids_get(C, &owner_id, &id, nullptr, nullptr);
955
956 if (owner_id == nullptr || id == nullptr) {
957 return false;
958 }
959
960 if (!(ID_IS_LINKED(id) || ID_IS_OVERRIDE_LIBRARY_REAL(id))) {
961 return false;
962 }
963 return true;
964}
965
966static void override_idtemplate_menu_draw(const bContext * /*C*/, Menu *menu)
967{
968 Layout &layout = *menu->layout;
969 layout.op("UI_OT_override_idtemplate_make", IFACE_("Make"), ICON_NONE);
970 layout.op("UI_OT_override_idtemplate_reset", IFACE_("Reset"), ICON_NONE);
971 layout.op("UI_OT_override_idtemplate_clear", IFACE_("Clear"), ICON_NONE);
972}
973
975{
976 MenuType *mt;
977
978 mt = MEM_new_zeroed<MenuType>(__func__);
979 STRNCPY_UTF8(mt->idname, "UI_MT_idtemplate_liboverride");
980 STRNCPY_UTF8(mt->label, N_("Library Override"));
983 WM_menutype_add(mt);
984}
985
987
988/* -------------------------------------------------------------------- */
991
999{
1000 bPoseChannel *pchan = static_cast<bPoseChannel *>(pchan_ptr.data);
1001
1002 BLI_assert(GS(pchan_ptr.owner_id->name) == ID_OB);
1003 Object *object = reinterpret_cast<Object *>(pchan_ptr.owner_id);
1005
1006 BLI_assert(GS(object->data->name) == ID_AR);
1007 bArmature *armature = id_cast<bArmature *>(object->data);
1008
1009 return RNA_pointer_create_discrete(&armature->id, RNA_Bone, pchan->bone_get(*object));
1010}
1011
1013{
1014 Vector<PointerRNA> lb = CTX_data_collection_get(C, "selected_pose_bones");
1015
1016 for (PointerRNA &ptr : lb) {
1017 ptr = rnapointer_pchan_to_bone(ptr);
1018 }
1019
1020 *r_lb = std::move(lb);
1021}
1022
1024 Vector<PointerRNA> *r_lb,
1025 FModifier *source)
1026{
1027 Vector<PointerRNA> fcurve_links;
1028 fcurve_links = CTX_data_collection_get(C, "selected_editable_fcurves");
1029 if (fcurve_links.is_empty()) {
1030 return;
1031 }
1032 r_lb->clear();
1033 for (const PointerRNA &ptr : fcurve_links) {
1034 const FCurve *fcu = static_cast<const FCurve *>(ptr.data);
1035 for (FModifier &mod : fcu->modifiers) {
1036 if (STREQ(mod.name, source->name) && mod.type == source->type) {
1037 r_lb->append(RNA_pointer_create_discrete(ptr.owner_id, RNA_FModifier, &mod));
1038 /* Since names are unique it is safe to break here. */
1039 break;
1040 }
1041 }
1042 }
1043}
1044
1045static void context_selected_key_blocks(ID *owner_id_key, Vector<PointerRNA> *r_lb)
1046{
1047 /* This function chooses to return the selected keyblocks of the owning Key ID.
1048 * The other option would be to return identically named keyblocks from selected objects. I
1049 * (christoph) think that the first case is more useful which is why the function works as it
1050 * does. */
1051 Key *containing_key = reinterpret_cast<Key *>(owner_id_key);
1052 for (KeyBlock &key_block : containing_key->block) {
1053 /* This does not use the function `shape_key_is_selected` since that would include the active
1054 * shapekey which is not required for this function to work. */
1055 if (key_block.flag & KEYBLOCK_SEL) {
1056 r_lb->append(RNA_pointer_create_discrete(owner_id_key, RNA_ShapeKey, &key_block));
1057 }
1058 }
1059}
1060
1062 const bNodeTreeInterfaceItem &active_item,
1063 PropertyRNA *prop)
1064{
1065 if (active_item.item_type != item.item_type) {
1066 return false;
1067 }
1068 const char *prop_id = RNA_property_identifier(prop);
1069 const bool is_generic_prop = STR_ELEM(
1070 prop_id, "socket_type", "description", "optional_label", "hide_value", "hide_in_modifier");
1071
1072 switch (item.item_type) {
1074 const auto &sock = reinterpret_cast<const bNodeTreeInterfaceSocket &>(item);
1075 if ((sock.flag & NODE_INTERFACE_SOCKET_SELECT) == 0) {
1076 return false;
1077 }
1078 /* Switch logic based on the property being edited. */
1079 if (is_generic_prop) {
1080 if (sock.flag & NODE_INTERFACE_SOCKET_PANEL_TOGGLE) {
1081 /* Disallow changing socket type for panel toggle. */
1082 return !STREQ(prop_id, "socket_type");
1083 }
1084 return true;
1085 }
1086 if (STREQ(prop_id, "structure_type")) {
1087 return sock.flag & NODE_INTERFACE_SOCKET_INPUT;
1088 }
1089 if (STREQ(prop_id, "attribute_domain") && sock.flag & NODE_INTERFACE_SOCKET_OUTPUT) {
1090 return nodes::socket_type_supports_attributes(sock.socket_typeinfo()->type);
1091 }
1092 /* Other properties only support batch setting for selected items of the same type. */
1093 const auto &active_sock = reinterpret_cast<const bNodeTreeInterfaceSocket &>(active_item);
1094 return sock.socket_typeinfo()->type == active_sock.socket_typeinfo()->type;
1095 }
1097 const auto &panel = reinterpret_cast<const bNodeTreeInterfacePanel &>(item);
1098 return panel.flag & NODE_INTERFACE_PANEL_SELECT;
1099 }
1100 }
1101 return false;
1102}
1103
1105 PropertyRNA *prop,
1106 Vector<PointerRNA> *r_lb)
1107{
1108 bNodeTree *ntree = id_cast<bNodeTree *>(ptr->owner_id);
1109 bNodeTreeInterfaceItem *active_item = static_cast<bNodeTreeInterfaceItem *>(ptr->data);
1110 if (!active_item) {
1111 return;
1112 }
1113 ntree->tree_interface.foreach_item([&](bNodeTreeInterfaceItem &item) {
1114 if (tree_interface_item_can_set_prop(item, *active_item, prop)) {
1115 r_lb->append(RNA_pointer_create_discrete(&ntree->id, RNA_NodeTreeInterfaceItem, &item));
1116 }
1117 return true;
1118 });
1119}
1120
1122 PointerRNA *ptr,
1123 PropertyRNA *prop,
1124 Vector<PointerRNA> *r_lb,
1125 bool *r_use_path_from_id,
1126 std::optional<std::string> *r_path)
1127{
1128 *r_use_path_from_id = false;
1129 *r_path = std::nullopt;
1130 /* special case for bone constraints */
1131 const bool is_rna = !RNA_property_is_idprop(prop);
1132 /* Remove links from the collection list which don't contain 'prop'. */
1133 bool ensure_list_items_contain_prop = false;
1134
1135 /* PropertyGroup objects don't have a reference to the struct that actually owns
1136 * them, so it is normally necessary to do a brute force search to find it. This
1137 * handles the search for non-ID owners by using the 'active' reference as a hint
1138 * to preserve efficiency. Only properties defined through RNA are handled, as
1139 * custom properties cannot be assumed to be valid for all instances.
1140 *
1141 * Properties owned by the ID are handled by the 'if (ptr->owner_id)' case below.
1142 */
1143 if (is_rna && RNA_struct_is_a(ptr->type, RNA_PropertyGroup)) {
1144 PointerRNA owner_ptr;
1145 std::optional<std::string> idpath;
1146
1147 /* First, check the active PoseBone and PoseBone->Bone. */
1148 owner_ptr = CTX_data_pointer_get_type(C, "active_pose_bone", RNA_PoseBone);
1149 if (owner_ptr) {
1150 idpath = RNA_path_from_struct_to_idproperty(&owner_ptr,
1151 static_cast<const IDProperty *>(ptr->data));
1152 if (idpath) {
1153 *r_lb = CTX_data_collection_get(C, "selected_pose_bones");
1154 }
1155 else {
1156 PointerRNA bone_ptr = rnapointer_pchan_to_bone(owner_ptr);
1157 idpath = RNA_path_from_struct_to_idproperty(&bone_ptr,
1158 static_cast<const IDProperty *>(ptr->data));
1159 if (idpath) {
1161 }
1162 }
1163 }
1164
1165 if (!idpath) {
1166 /* Check the active EditBone if in edit mode. */
1167 owner_ptr = CTX_data_pointer_get_type_silent(C, "active_bone", RNA_EditBone);
1168 if (owner_ptr) {
1169 idpath = RNA_path_from_struct_to_idproperty(&owner_ptr,
1170 static_cast<const IDProperty *>(ptr->data));
1171 if (idpath) {
1172 *r_lb = CTX_data_collection_get(C, "selected_editable_bones");
1173 }
1174 }
1175
1176 /* Add other simple cases here (Node, NodeSocket, Sequence, ViewLayer etc). */
1177 }
1178
1179 if (idpath) {
1180 *r_path = fmt::format("{}.{}", *idpath, RNA_property_identifier(prop));
1181 return true;
1182 }
1183 }
1184
1185 if (RNA_struct_is_a(ptr->type, RNA_EditBone)) {
1186 /* Special case when we do this for #edit_bone.lock.
1187 * (if the edit_bone is locked, it is not included in "selected_editable_bones"). */
1188 const char *prop_id = RNA_property_identifier(prop);
1189 if (STREQ(prop_id, "lock")) {
1190 *r_lb = CTX_data_collection_get(C, "selected_bones");
1191 }
1192 else {
1193 *r_lb = CTX_data_collection_get(C, "selected_editable_bones");
1194 }
1195 }
1196 else if (RNA_struct_is_a(ptr->type, RNA_PoseBone)) {
1197 *r_lb = CTX_data_collection_get(C, "selected_pose_bones");
1198 }
1199 else if (RNA_struct_is_a(ptr->type, RNA_Bone)) {
1200 /* "selected_bones" or "selected_editable_bones" will only yield anything in Armature Edit
1201 * mode. In other modes, it'll be empty, and the only way to get the selected bones is via
1202 * "selected_pose_bones". */
1204 }
1205 else if (RNA_struct_is_a(ptr->type, RNA_BoneColor)) {
1206 /* Get the things that own the bone color (bones, pose bones, or edit bones). */
1207 /* First this will be bones, then gets remapped to colors. */
1208 Vector<PointerRNA> list_of_things = {};
1209 switch (GS(ptr->owner_id->name)) {
1210 case ID_OB:
1211 list_of_things = CTX_data_collection_get(C, "selected_pose_bones");
1212 break;
1213 case ID_AR: {
1214 /* Armature-owned bones can be accessed from both edit mode and pose mode.
1215 * - Edit mode: visit selected edit bones.
1216 * - Pose mode: visit the armature bones of selected pose bones.
1217 */
1218 const bArmature *arm = reinterpret_cast<bArmature *>(ptr->owner_id);
1219 if (arm->edbo) {
1220 list_of_things = CTX_data_collection_get(C, "selected_editable_bones");
1221 }
1222 else {
1223 list_of_things = CTX_data_collection_get(C, "selected_pose_bones");
1224 CTX_data_collection_remap_property(list_of_things, "bone");
1225 }
1226 break;
1227 }
1228 default:
1229 printf("BoneColor is unexpectedly owned by %s '%s'\n",
1231 ptr->owner_id->name + 2);
1232 BLI_assert_msg(false,
1233 "expected BoneColor to be owned by the Armature "
1234 "(bone & edit bone) or the Object (pose bone)");
1235 return false;
1236 }
1237
1238 /* Remap from some bone to its color, to ensure the items of r_lb are of
1239 * type ptr->type. Since all three structs `bPoseChan`, `Bone`, and
1240 * `EditBone` have the same name for their embedded `BoneColor` struct, this
1241 * code is suitable for all of them. */
1242 CTX_data_collection_remap_property(list_of_things, "color");
1243
1244 *r_lb = list_of_things;
1245 }
1246 else if (RNA_struct_is_a(ptr->type, RNA_Strip)) {
1247 /* Special case when we do this for 'Strip.lock'.
1248 * (if the strip is locked, it won't be in "selected_editable_strips"). */
1249 const char *prop_id = RNA_property_identifier(prop);
1250 if (STREQ(prop_id, "lock")) {
1251 *r_lb = CTX_data_collection_get(C, "selected_strips");
1252 }
1253 else {
1254 *r_lb = CTX_data_collection_get(C, "selected_editable_strips");
1255 }
1256
1257 if (is_rna) {
1258 /* Account for properties only being available for some sequence types. */
1259 ensure_list_items_contain_prop = true;
1260 }
1261 }
1262 else if (RNA_struct_is_a(ptr->type, RNA_FCurve)) {
1263 *r_lb = CTX_data_collection_get(C, "selected_editable_fcurves");
1264 }
1265 else if (RNA_struct_is_a(ptr->type, RNA_FModifier)) {
1266 FModifier *mod = static_cast<FModifier *>(ptr->data);
1268 }
1269 else if (RNA_struct_is_a(ptr->type, RNA_Keyframe)) {
1270 *r_lb = CTX_data_collection_get(C, "selected_editable_keyframes");
1271 }
1272 else if (RNA_struct_is_a(ptr->type, RNA_Action)) {
1273 *r_lb = CTX_data_collection_get(C, "selected_editable_actions");
1274 }
1275 else if (RNA_struct_is_a(ptr->type, RNA_NlaStrip)) {
1276 *r_lb = CTX_data_collection_get(C, "selected_nla_strips");
1277 }
1278 else if (RNA_struct_is_a(ptr->type, RNA_MovieTrackingTrack)) {
1279 *r_lb = CTX_data_collection_get(C, "selected_movieclip_tracks");
1280 }
1281 else if (RNA_struct_is_a(ptr->type, RNA_ShapeKey)) {
1283 }
1284 else if (const std::optional<std::string> path_from_bone =
1285 RNA_path_resolve_from_type_to_property(ptr, prop, RNA_PoseBone);
1286 RNA_struct_is_a(ptr->type, RNA_Constraint) && path_from_bone)
1287 {
1288 *r_lb = CTX_data_collection_get(C, "selected_pose_bones");
1289 *r_path = path_from_bone;
1290 }
1291 else if (RNA_struct_is_a(ptr->type, RNA_Node) || RNA_struct_is_a(ptr->type, RNA_NodeSocket)) {
1293 std::optional<std::string> path;
1294 bNode *node = nullptr;
1295
1296 /* Get the node we're editing */
1297 if (RNA_struct_is_a(ptr->type, RNA_NodeSocket)) {
1298 bNodeTree *ntree = id_cast<bNodeTree *>(ptr->owner_id);
1299 bNodeSocket *sock = static_cast<bNodeSocket *>(ptr->data);
1300 node = &bke::node_find_node(*ntree, *sock);
1301 path = RNA_path_resolve_from_type_to_property(ptr, prop, RNA_Node);
1302 if (path) {
1303 /* we're good! */
1304 }
1305 else {
1306 node = nullptr;
1307 }
1308 }
1309 else {
1310 node = static_cast<bNode *>(ptr->data);
1311 }
1312
1313 /* Now filter out non-matching nodes (by idname). */
1314 if (node) {
1315 const StringRef node_idname = node->idname;
1316 lb = CTX_data_collection_get(C, "selected_nodes");
1317 lb.remove_if([&](const PointerRNA &link) {
1318 bNode *node_data = static_cast<bNode *>(link.data);
1319 if (node_data->idname != node_idname) {
1320 return true;
1321 }
1322 return false;
1323 });
1324 }
1325
1326 *r_lb = lb;
1327 *r_path = path;
1328 }
1329 else if (RNA_struct_is_a(ptr->type, RNA_NodeTreeInterfaceItem)) {
1331 }
1332 else if (RNA_struct_is_a(ptr->type, RNA_AssetMetaData)) {
1333 /* Remap from #AssetRepresentation to #AssetMetaData. */
1334 Vector<PointerRNA> list_of_things = CTX_data_collection_get(C, "selected_assets");
1335 CTX_data_collection_remap_property(list_of_things, "metadata");
1336 *r_lb = list_of_things;
1337 }
1338 else if (CTX_wm_space_outliner(C)) {
1339 const ID *id = ptr->owner_id;
1340 if (!(id && (GS(id->name) == ID_OB))) {
1341 return false;
1342 }
1343
1344 ListBaseT<LinkData> selected_objects = {nullptr};
1345 ED_outliner_selected_objects_get(C, &selected_objects);
1346 for (LinkData &link : selected_objects) {
1347 Object *ob = static_cast<Object *>(link.data);
1348 r_lb->append(RNA_id_pointer_create(&ob->id));
1349 }
1350 }
1351 else if (ptr->owner_id) {
1352 ID *id = ptr->owner_id;
1353
1354 if (GS(id->name) == ID_OB) {
1355 *r_lb = CTX_data_collection_get(C, "selected_editable_objects");
1356 *r_use_path_from_id = true;
1357 *r_path = RNA_path_from_ID_to_property(ptr, prop);
1358 }
1359 else if (OB_DATA_SUPPORT_ID(GS(id->name))) {
1360 /* check we're using the active object */
1361 const short id_code = GS(id->name);
1362 Vector<PointerRNA> lb = CTX_data_collection_get(C, "selected_editable_objects");
1363 const std::optional<std::string> path = RNA_path_from_ID_to_property(ptr, prop);
1364
1365 /* de-duplicate obdata */
1366 if (!lb.is_empty()) {
1367 for (const PointerRNA &ob_ptr : lb) {
1368 Object *ob = id_cast<Object *>(ob_ptr.owner_id);
1369 if (ID *id_data = ob->data) {
1370 id_data->tag |= ID_TAG_DOIT;
1371 }
1372 }
1373
1374 Vector<PointerRNA> new_lb;
1375 for (const PointerRNA &link : lb) {
1376 Object *ob = id_cast<Object *>(link.owner_id);
1377 ID *id_data = ob->data;
1378 if ((id_data == nullptr) || (id_data->tag & ID_TAG_DOIT) == 0 ||
1379 !ID_IS_EDITABLE(id_data) || (GS(id_data->name) != id_code))
1380 {
1381 continue;
1382 }
1383 /* Avoid prepending 'data' to the path. */
1384 new_lb.append(RNA_id_pointer_create(id_data));
1385
1386 if (id_data) {
1387 id_data->tag &= ~ID_TAG_DOIT;
1388 }
1389 }
1390
1391 lb = std::move(new_lb);
1392 }
1393
1394 *r_lb = lb;
1395 *r_path = path;
1396 }
1397 else if (GS(id->name) == ID_SCE) {
1398 /* Sequencer's ID is scene :/ */
1399 /* Try to recursively find an RNA_Strip ancestor,
1400 * to handle situations like #41062... */
1401 *r_path = RNA_path_resolve_from_type_to_property(ptr, prop, RNA_Strip);
1402 if (r_path->has_value()) {
1403 /* Special case when we do this for 'Strip.lock'.
1404 * (if the strip is locked, it won't be in "selected_editable_strips"). */
1405 const char *prop_id = RNA_property_identifier(prop);
1406 if (is_rna && STREQ(prop_id, "lock")) {
1407 *r_lb = CTX_data_collection_get(C, "selected_strips");
1408 }
1409 else {
1410 *r_lb = CTX_data_collection_get(C, "selected_editable_strips");
1411 }
1412
1413 if (is_rna) {
1414 /* Account for properties only being available for some sequence types. */
1415 ensure_list_items_contain_prop = true;
1416 }
1417 }
1418 }
1419 return r_path->has_value();
1420 }
1421 else {
1422 return false;
1423 }
1424
1425 if (RNA_property_is_idprop(prop)) {
1426 if (!r_path->has_value()) {
1427 *r_path = RNA_path_from_ptr_to_property_index(ptr, prop, 0, -1);
1428 BLI_assert(*r_path);
1429 }
1430 /* Always resolve custom-properties because they can always exist per-item. */
1431 ensure_list_items_contain_prop = true;
1432 }
1433
1434 if (ensure_list_items_contain_prop) {
1435 if (is_rna) {
1436 const char *prop_id = RNA_property_identifier(prop);
1437 r_lb->remove_if([&](const PointerRNA &link) {
1438 if ((ptr->type != link.type) &&
1439 (RNA_struct_type_find_property(link.type, prop_id) != prop))
1440 {
1441 return true;
1442 }
1443 return false;
1444 });
1445 }
1446 else {
1447 const bool prop_is_array = RNA_property_array_check(prop);
1448 const int prop_array_len = prop_is_array ? RNA_property_array_length(ptr, prop) : -1;
1449 const PropertyType prop_type = RNA_property_type(prop);
1450 r_lb->remove_if([&](PointerRNA &link) {
1451 PointerRNA lptr;
1452 PropertyRNA *lprop = nullptr;
1454 &link, r_path->has_value() ? r_path->value().c_str() : nullptr, &lptr, &lprop);
1455
1456 if (lprop == nullptr) {
1457 return true;
1458 }
1459 if (!RNA_property_is_idprop(lprop)) {
1460 return true;
1461 }
1462 if (prop_type != RNA_property_type(lprop)) {
1463 return true;
1464 }
1465 if (prop_is_array != RNA_property_array_check(lprop)) {
1466 return true;
1467 }
1468 if (prop_is_array && (prop_array_len != RNA_property_array_length(&link, lprop))) {
1469 return true;
1470 }
1471 return false;
1472 });
1473 }
1474 }
1475
1476 return true;
1477}
1478
1480 PointerRNA *ptr_link,
1481 PropertyRNA *prop,
1482 const char *path,
1483 bool use_path_from_id,
1484 PointerRNA *r_ptr,
1485 PropertyRNA **r_prop)
1486{
1487 PropertyRNA *lprop;
1488 PointerRNA lptr;
1489
1490 if (ptr_link->data == ptr->data) {
1491 return false;
1492 }
1493
1494 if (use_path_from_id) {
1495 /* Path relative to ID. */
1496 lprop = nullptr;
1497 PointerRNA idptr = RNA_id_pointer_create(ptr_link->owner_id);
1498 RNA_path_resolve_property(&idptr, path, &lptr, &lprop);
1499 }
1500 else if (path) {
1501 /* Path relative to elements from list. */
1502 lprop = nullptr;
1503 RNA_path_resolve_property(ptr_link, path, &lptr, &lprop);
1504 }
1505 else {
1507 lptr = *ptr_link;
1508 lprop = prop;
1509 }
1510
1511 if (lptr.data == ptr->data) {
1512 /* The source & destination are the same, so there is nothing to copy. */
1513 return false;
1514 }
1515
1516 /* Skip non-existing properties on link. This was previously covered with the `lprop != prop`
1517 * check but we are now more permissive when it comes to ID properties, see below. */
1518 if (lprop == nullptr) {
1519 return false;
1520 }
1521
1522 if (RNA_property_type(lprop) != RNA_property_type(prop)) {
1523 return false;
1524 }
1525
1526 /* Check property pointers matching.
1527 * For ID properties, these pointers match:
1528 * - If the property is API defined on an existing class (and they are equally named).
1529 * - Never for ID properties on specific ID (even if they are equally named).
1530 * - Never for NodesModifierSettings properties (even if they are equally named).
1531 *
1532 * Be permissive on ID properties in the following cases:
1533 * - #NodesModifierSettings properties
1534 * - (special check: only if the node-group matches, since the 'Input_n' properties are name
1535 * based and similar on potentially very different node-groups).
1536 * - ID properties on specific ID
1537 * - (no special check, copying seems OK [even if type does not match -- does not do anything
1538 * then])
1539 */
1540 bool ignore_prop_eq = RNA_property_is_idprop(lprop) && RNA_property_is_idprop(prop);
1541 if (RNA_struct_is_a(lptr.type, RNA_NodesModifier) &&
1542 RNA_struct_is_a(ptr->type, RNA_NodesModifier))
1543 {
1544 ignore_prop_eq = false;
1545
1546 NodesModifierData *nmd_link = static_cast<NodesModifierData *>(lptr.data);
1547 NodesModifierData *nmd_src = static_cast<NodesModifierData *>(ptr->data);
1548 if (nmd_link->node_group == nmd_src->node_group) {
1549 ignore_prop_eq = true;
1550 }
1551 }
1552
1553 if ((lprop != prop) && !ignore_prop_eq) {
1554 return false;
1555 }
1556
1557 if (!RNA_property_editable(&lptr, lprop)) {
1558 return false;
1559 }
1560
1561 if (r_ptr) {
1562 *r_ptr = lptr;
1563 }
1564 if (r_prop) {
1565 *r_prop = lprop;
1566 }
1567
1568 return true;
1569}
1570
1578static bool copy_to_selected_button(bContext *C, bool all, bool poll)
1579{
1580 Main *bmain = CTX_data_main(C);
1581 PointerRNA ptr, lptr;
1582 PropertyRNA *prop, *lprop;
1583 int index;
1584
1585 /* try to reset the nominated setting to its default value */
1586 context_active_but_prop_get(C, &ptr, &prop, &index);
1587
1588 /* if there is a valid property that is editable... */
1589 if (!ptr || prop == nullptr) {
1590 return false;
1591 }
1592
1593 bool success = false;
1594 std::optional<std::string> path;
1595 bool use_path_from_id;
1597
1598 if (context_copy_to_selected_list(C, &ptr, prop, &lb, &use_path_from_id, &path)) {
1599 for (PointerRNA &link : lb) {
1600 if (link.data == ptr.data) {
1601 continue;
1602 }
1603
1605 &link,
1606 prop,
1607 path.has_value() ? path->c_str() : nullptr,
1608 use_path_from_id,
1609 &lptr,
1610 &lprop))
1611 {
1612 continue;
1613 }
1614
1615 if (poll) {
1616 success = true;
1617 break;
1618 }
1619 if (RNA_property_copy(bmain, &lptr, &ptr, prop, (all) ? -1 : index)) {
1620 RNA_property_update(C, &lptr, prop);
1621 success = true;
1622 }
1623 }
1624 }
1625
1626 return success;
1627}
1628
1630{
1631 return copy_to_selected_button(C, false, true);
1632}
1633
1635{
1636 bool success;
1637
1638 const bool all = RNA_boolean_get(op->ptr, "all");
1639
1640 success = copy_to_selected_button(C, all, false);
1641
1642 return (success) ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
1643}
1644
1646{
1647 /* identifiers */
1648 ot->name = "Copy to Selected";
1649 ot->idname = "UI_OT_copy_to_selected_button";
1650 ot->description =
1651 "Copy the property's value from the active item to the same property of all selected items "
1652 "if the same property exists";
1653
1654 /* callbacks */
1657
1658 /* flags */
1660
1661 /* properties */
1662 RNA_def_boolean(ot->srna, "all", true, "All", "Copy to selected all elements of the array");
1663}
1664
1666
1667/* -------------------------------------------------------------------- */
1670
1671/* Name-spaced for unit testing. Conceptually these functions should be static
1672 * and not be used outside this source file. But they need to be externally
1673 * accessible to add unit tests for them. */
1674namespace internal {
1675
1677 PointerRNA *ptr, PropertyRNA *prop, const bool get_all, const int index, bool *r_is_array_prop)
1678{
1679 BLI_assert(ptr && prop);
1680
1681 const std::optional<std::string> path = RNA_path_from_ID_to_property(ptr, prop);
1682 if (!path.has_value()) {
1683 return {};
1684 }
1685
1687 if (!adt) {
1688 return {};
1689 }
1690
1691 Vector<FCurve *> drivers = {};
1692 const bool is_array_prop = RNA_property_array_check(prop);
1693 if (!is_array_prop) {
1694 /* NOTE: by convention Blender assigns 0 as the index for drivers of
1695 * non-array properties, which is why we search for it here. Values > 0 are
1696 * not recognized by Blender's driver system in that case. Values < 0 are
1697 * recognized for driver evaluation, but `BKE_fcurve_find()` unconditionally
1698 * returns nullptr in that case so it wouldn't matter here anyway. */
1699 drivers.append(BKE_fcurve_find(&adt->drivers, path->c_str(), 0));
1700 }
1701 else {
1702 /* For array properties, we always allocate space for all elements of an
1703 * array property, and the unused ones just remain null. */
1704 drivers.resize(RNA_property_array_length(ptr, prop), nullptr);
1705 for (int i = 0; i < drivers.size(); i++) {
1706 if (get_all || i == index) {
1707 drivers[i] = BKE_fcurve_find(&adt->drivers, path->c_str(), i);
1708 }
1709 }
1710 }
1711
1712 /* If we didn't get any drivers to copy, instead of returning a vector of all
1713 * nullptr, return an empty vector for clarity. That way the caller gets
1714 * either a useful result or an empty one. */
1715 bool fetched_at_least_one = false;
1716 for (const FCurve *driver : drivers) {
1717 fetched_at_least_one |= driver != nullptr;
1718 }
1719 if (!fetched_at_least_one) {
1720 return {};
1721 }
1722
1723 if (r_is_array_prop) {
1724 *r_is_array_prop = is_array_prop;
1725 }
1726
1727 return drivers;
1728}
1729
1731 const bool is_array_prop,
1732 PointerRNA *dst_ptr,
1733 PropertyRNA *dst_prop)
1734{
1735 BLI_assert(src_drivers.size() > 0);
1736 BLI_assert(is_array_prop || src_drivers.size() == 1);
1737
1738 /* Get the RNA path and relevant animdata for the property we're copying to. */
1739 const std::optional<std::string> dst_path = RNA_path_from_ID_to_property(dst_ptr, dst_prop);
1740 if (!dst_path.has_value()) {
1741 return 0;
1742 }
1743 AnimData *dst_adt = BKE_animdata_ensure_id(dst_ptr->owner_id);
1744 if (!dst_adt) {
1745 return 0;
1746 }
1747
1748 /* Do the copying. */
1749 int paste_count = 0;
1750 for (int i = 0; i < src_drivers.size(); i++) {
1751 if (!src_drivers[i]) {
1752 continue;
1753 }
1754 const int dst_index = is_array_prop ? i : 0;
1755
1756 /* If it's already animated by something other than a driver, skip. This is
1757 * because Blender's UI assumes that properties are either animated *or*
1758 * driven, and things can get confusing for users otherwise. Additionally,
1759 * no other parts of Blender's UI allow users to (at least easily) add
1760 * drivers on already-animated properties, so this keeps things consistent
1761 * across driver-related operators. */
1762 bool driven;
1763 {
1764 const FCurve *fcu = BKE_fcurve_find_by_rna(
1765 dst_ptr, dst_prop, dst_index, nullptr, nullptr, &driven, nullptr);
1766 if (fcu && !driven) {
1767 continue;
1768 }
1769 }
1770
1771 /* If there's an existing matching driver, remove it first.
1772 *
1773 * TODO: in the context of `copy_driver_to_selected_button()` this has
1774 * quadratic complexity when the drivers are within the same ID, due to this
1775 * being inside of a loop and doing a linear scan of the drivers to find one
1776 * that matches. We should be able to make this more efficient with a
1777 * little cleverness. */
1778 if (driven) {
1779 FCurve *old_driver = BKE_fcurve_find(&dst_adt->drivers, dst_path->c_str(), dst_index);
1780 if (old_driver) {
1781 BLI_remlink(&dst_adt->drivers, old_driver);
1782 BKE_fcurve_free(old_driver);
1783 }
1784 }
1785
1786 /* Create the new driver. */
1787 FCurve *new_driver = BKE_fcurve_copy(src_drivers[i]);
1788 new_driver->rna_path_set(dst_path.value());
1789 BLI_addtail(&dst_adt->drivers, new_driver);
1790
1791 paste_count++;
1792 }
1793
1794 return paste_count;
1795}
1796
1797} // namespace internal
1798
1820static bool copy_driver_to_selected_button(bContext *C, bool copy_entire_array, const bool poll)
1821{
1822 using namespace blender::ui::internal;
1823
1824 PropertyRNA *prop;
1825 PointerRNA ptr;
1826 int index;
1827
1828 /* Get the property of the clicked button. */
1829 context_active_but_prop_get(C, &ptr, &prop, &index);
1830 if (!ptr.has_owner_id() || !ptr || !prop) {
1831 return false;
1832 }
1833 copy_entire_array |= index == -1; /* -1 implies `copy_entire_array` for array properties. */
1834
1835 /* Get the property's driver(s). */
1836 bool is_array_prop = false;
1837 const Vector<FCurve *> src_drivers = get_property_drivers(
1838 &ptr, prop, copy_entire_array, index, &is_array_prop);
1839 if (src_drivers.is_empty()) {
1840 return false;
1841 }
1842
1843 /* Build the list of properties to copy the driver(s) to, along with relevant
1844 * side data. */
1845 std::optional<std::string> path;
1846 bool use_path_from_id;
1847 Vector<PointerRNA> target_properties;
1848 if (!context_copy_to_selected_list(C, &ptr, prop, &target_properties, &use_path_from_id, &path))
1849 {
1850 return false;
1851 }
1852
1853 /* Copy the driver(s) to the list of target properties. */
1854 int total_copy_count = 0;
1855 for (PointerRNA &target_prop : target_properties) {
1856 if (target_prop.data == ptr.data) {
1857 continue;
1858 }
1859
1860 /* Get the target property and ensure that it's appropriate for adding
1861 * drivers. */
1862 PropertyRNA *dst_prop;
1863 PointerRNA dst_ptr;
1865 &target_prop,
1866 prop,
1867 path.has_value() ? path->c_str() : nullptr,
1868 use_path_from_id,
1869 &dst_ptr,
1870 &dst_prop))
1871 {
1872 continue;
1873 }
1874 if (!RNA_property_driver_editable(&dst_ptr, dst_prop)) {
1875 continue;
1876 }
1877
1878 /* If we're just polling, then we early-out on the first property we would
1879 * be able to copy to. */
1880 if (poll) {
1881 return true;
1882 }
1883
1884 const int paste_count = paste_property_drivers(
1885 src_drivers.as_span(), is_array_prop, &dst_ptr, dst_prop);
1886 if (paste_count == 0) {
1887 continue;
1888 }
1889
1890 RNA_property_update(C, &dst_ptr, dst_prop);
1891 total_copy_count += paste_count;
1892 }
1893
1894 return total_copy_count > 0;
1895}
1896
1898{
1899 return copy_driver_to_selected_button(C, false, true);
1900}
1901
1903{
1904 const bool all = RNA_boolean_get(op->ptr, "all");
1905
1906 if (!copy_driver_to_selected_button(C, all, false)) {
1907 return OPERATOR_CANCELLED;
1908 }
1909
1912 return OPERATOR_FINISHED;
1913}
1914
1916{
1917 /* Identifiers. */
1918 ot->name = "Copy Driver to Selected";
1919 ot->idname = "UI_OT_copy_driver_to_selected_button";
1920 ot->description =
1921 "Copy the property's driver from the active item to the same property "
1922 "of all selected items, if the same property exists";
1923
1924 /* Callbacks. */
1927
1928 /* Flags. */
1930
1931 /* Properties. */
1933 ot->srna, "all", false, "All", "Copy to selected the drivers of all elements of the array");
1934}
1935
1937
1938/* -------------------------------------------------------------------- */
1941
1943static bool jump_to_target_ptr(bContext *C, PointerRNA ptr, const bool poll)
1944{
1945 if (!ptr) {
1946 return false;
1947 }
1948
1949 /* Verify pointer type. */
1950 char bone_name[MAXBONENAME];
1951 const StructRNA *target_type = nullptr;
1952
1953 if (ELEM(ptr.type, RNA_EditBone, RNA_PoseBone, RNA_Bone)) {
1954 RNA_string_get(&ptr, "name", bone_name);
1955 if (bone_name[0] != '\0') {
1956 target_type = RNA_Bone;
1957 }
1958 }
1959 else if (RNA_struct_is_a(ptr.type, RNA_Object)) {
1960 target_type = RNA_Object;
1961 }
1962
1963 if (target_type == nullptr) {
1964 return false;
1965 }
1966
1967 /* Find the containing Object. */
1968 const Main *bmain = CTX_data_main(C);
1969 const Scene *scene = CTX_data_scene(C);
1970 ViewLayer *view_layer = CTX_data_view_layer(C);
1971 Base *base = nullptr;
1972 const short id_type = GS(ptr.owner_id->name);
1973 if (id_type == ID_OB) {
1974 BKE_view_layer_synced_ensure(*bmain, scene, view_layer);
1975 base = BKE_view_layer_base_find(view_layer, id_cast<Object *>(ptr.owner_id));
1976 }
1977 else if (OB_DATA_SUPPORT_ID(id_type)) {
1978 base = ed::object::find_first_by_data_id(*bmain, scene, view_layer, ptr.owner_id);
1979 }
1980
1981 bool ok = false;
1982 if ((base == nullptr) || ((target_type == RNA_Bone) && (base->object->type != OB_ARMATURE))) {
1983 /* pass */
1984 }
1985 else if (poll) {
1986 ok = true;
1987 }
1988 else {
1989 /* Make optional. */
1990 const bool reveal_hidden = true;
1991 /* Select and activate the target. */
1992 if (target_type == RNA_Bone) {
1993 ok = ed::object::jump_to_bone(C, base->object, bone_name, reveal_hidden);
1994 }
1995 else if (target_type == RNA_Object) {
1996 ok = ed::object::jump_to_object(C, base->object, reveal_hidden);
1997 }
1998 else {
1999 BLI_assert(0);
2000 }
2001 }
2002 return ok;
2003}
2004
2012static bool jump_to_target_button(bContext *C, bool poll)
2013{
2014 PointerRNA ptr, target_ptr;
2015 PropertyRNA *prop;
2016 int index;
2017
2018 const Button *but = context_active_but_prop_get(C, &ptr, &prop, &index);
2019
2020 /* If there is a valid property... */
2021 if (ptr && prop) {
2022 const PropertyType type = RNA_property_type(prop);
2023
2024 /* For pointer properties, use their value directly. */
2025 if (type == PROP_POINTER) {
2026 target_ptr = RNA_property_pointer_get(&ptr, prop);
2027
2028 return jump_to_target_ptr(C, target_ptr, poll);
2029 }
2030 /* For string properties with prop_search, look up the search collection item. */
2031 if (type == PROP_STRING) {
2032 const ButtonSearch *search_but = (but->type == ButtonType::SearchMenu) ?
2033 static_cast<ButtonSearch *>(const_cast<Button *>(but)) :
2034 nullptr;
2035
2036 if (search_but && search_but->items_update_fn == rna_collection_search_update_fn) {
2037 auto *coll_search = static_cast<RNACollectionSearch *>(search_but->arg.get());
2038
2039 char str_buf[MAXBONENAME];
2040 char *str_ptr = RNA_property_string_get_alloc(
2041 &ptr, prop, str_buf, sizeof(str_buf), nullptr);
2042
2043 bool found = false;
2044 /* Jump to target only works with search properties currently, not search callbacks yet.
2045 * See #button_configure_search. */
2046 if (coll_search->search_prop != nullptr) {
2048 &coll_search->search_ptr, coll_search->search_prop, str_ptr, &target_ptr);
2049 }
2050
2051 if (str_ptr != str_buf) {
2052 MEM_delete(str_ptr);
2053 }
2054
2055 if (found) {
2056 return jump_to_target_ptr(C, target_ptr, poll);
2057 }
2058 }
2059 }
2060 }
2061
2062 return false;
2063}
2064
2066{
2067 return jump_to_target_button(C, true);
2068}
2069
2071{
2072 const bool success = jump_to_target_button(C, false);
2073
2074 return (success) ? OPERATOR_FINISHED : OPERATOR_CANCELLED;
2075}
2076
2078{
2079 /* identifiers */
2080 ot->name = "Jump to Target";
2081 ot->idname = "UI_OT_jump_to_target_button";
2082 ot->description = "Switch to the target object or bone";
2083
2084 /* callbacks */
2087
2088 /* flags */
2090}
2091
2093
2094/* -------------------------------------------------------------------- */
2097
2098#ifdef WITH_PYTHON
2099
2100/* ------------------------------------------------------------------------- */
2101/* EditSource Utility functions and operator,
2102 * NOTE: this includes utility functions and button matching checks. */
2103
2104struct EditSourceButStore {
2105 char py_dbg_fn[FILE_MAX] = {};
2106 int py_dbg_line_number = 0;
2107};
2108
2109struct EditSourceStore {
2110 Button but_orig;
2111 Map<const Button *, std::unique_ptr<EditSourceButStore>> hash;
2112
2113 EditSourceStore(const Button &but) : but_orig{but} {};
2114};
2115
2116/* should only ever be set while the edit source operator is running */
2117static EditSourceStore *editsource_info = nullptr;
2118
2120{
2121 return (editsource_info != nullptr);
2122}
2123
2124static void editsource_active_but_set(Button *but)
2125{
2126 BLI_assert(editsource_info == nullptr);
2127
2128 editsource_info = MEM_new<EditSourceStore>(__func__, *but);
2129}
2130
2131static void editsource_active_but_clear()
2132{
2133 MEM_delete(editsource_info);
2134 editsource_info = nullptr;
2135}
2136
2137static bool editsource_uibut_match(const Button *but_a, const Button *but_b)
2138{
2139# if 0
2140 printf("matching buttons: '%s' == '%s'\n", but_a->drawstr, but_b->drawstr);
2141# endif
2142
2143 /* this just needs to be a 'good-enough' comparison so we can know beyond
2144 * reasonable doubt that these buttons are the same between redraws.
2145 * if this fails it only means edit-source fails - campbell */
2146 if (BLI_rctf_compare(&but_a->rect, &but_b->rect, FLT_EPSILON) && (but_a->type == but_b->type) &&
2147 (but_a->rnaprop == but_b->rnaprop) && (but_a->optype == but_b->optype) &&
2148 (but_a->unit_type == but_b->unit_type) && but_a->drawstr == but_b->drawstr)
2149 {
2150 return true;
2151 }
2152 return false;
2153}
2154
2156{
2157 auto but_store = std::make_unique<EditSourceButStore>();
2158
2159 const char *fn;
2160 int line_number = -1;
2161
2162# if 0
2163 printf("comparing buttons: '%s' == '%s'\n", but->drawstr, editsource_info->but_orig.drawstr);
2164# endif
2165
2167
2168 if (line_number != -1) {
2169 STRNCPY(but_store->py_dbg_fn, fn);
2170 but_store->py_dbg_line_number = line_number;
2171 }
2172 else {
2173 but_store->py_dbg_fn[0] = '\0';
2174 but_store->py_dbg_line_number = -1;
2175 }
2176
2177 editsource_info->hash.add(but, std::move(but_store));
2178}
2179
2180static wmOperatorStatus editsource_text_edit(bContext *C,
2181 wmOperator * /*op*/,
2182 const char filepath[FILE_MAX],
2183 const int line)
2184{
2185 wmOperatorType *ot = WM_operatortype_find("TEXT_OT_jump_to_file_at_point", true);
2186
2187 PointerRNA op_props = WM_operator_properties_create_ptr(ot);
2188 RNA_string_set(&op_props, "filepath", filepath);
2189 RNA_int_set(&op_props, "line", line - 1);
2190 RNA_int_set(&op_props, "column", 0);
2191
2193 C, ot, wm::OpCallContext::ExecDefault, &op_props, nullptr);
2194 WM_operator_properties_free(&op_props);
2195 return result;
2196}
2197
2198static wmOperatorStatus editsource_exec(bContext *C, wmOperator *op)
2199{
2200
2201 ARegion *region = nullptr;
2202 Button *but = nullptr;
2203
2204 {
2205 const bContextStore *ctx_store = CTX_store_get(C);
2206 const PointerRNA *region_ptr = ctx_store ? CTX_store_ptr_lookup(
2207 ctx_store, "popup_region", RNA_Region) :
2208 nullptr;
2209 if (region_ptr && region_ptr->has_data()) {
2210 region = region_ptr->data_as<ARegion>();
2211 but = region_find_active_but(region);
2212 if (region->regiontype == RGN_TYPE_TEMPORARY && !but->block->handle->can_refresh) {
2213 BKE_report(op->reports,
2214 RPT_ERROR,
2215 "Cannot edit source in popup regions that does not support refresh.");
2216 return OPERATOR_CANCELLED;
2217 }
2218 }
2219 else {
2221 region = CTX_wm_region(C);
2222 }
2223 }
2224
2225 if (but) {
2227
2228 // printf("%s: begin\n", __func__);
2229
2230 /* take care not to return before calling editsource_active_but_clear */
2231 editsource_active_but_set(but);
2232
2233 /* Needed so the active button does not get updated. */
2234 button_active_free(C, but);
2235
2236 /* redraw and get active button python info */
2238
2239 /* It's possible the key button referenced in `editsource_info` has been freed.
2240 * This typically happens with popovers but could happen in other situations, see: #140439. */
2241 Set<const Button *> valid_buttons_in_region;
2242 for (Block &block_base : region->runtime->uiblocks) {
2243 Block *block_pair[2] = {&block_base, block_base.oldblock};
2244 for (Block *block : Span(block_pair, block_pair[1] ? 2 : 1)) {
2245 for (Button &but : block->buttons()) {
2246 valid_buttons_in_region.add(&but);
2247 }
2248 }
2249 }
2250
2251 EditSourceButStore *but_store = nullptr;
2252 for (const auto &item : editsource_info->hash.items()) {
2253 const Button *but_key = item.key;
2254 if (but_key == nullptr) {
2255 continue;
2256 }
2257
2258 if (!valid_buttons_in_region.contains(but_key)) {
2259 continue;
2260 }
2261
2262 if (editsource_uibut_match(&editsource_info->but_orig, but_key)) {
2263 but_store = item.value.get();
2264 break;
2265 }
2266 }
2267
2268 if (but_store) {
2269 if (but_store->py_dbg_line_number != -1) {
2270 ret = editsource_text_edit(C, op, but_store->py_dbg_fn, but_store->py_dbg_line_number);
2271 }
2272 else {
2273 BKE_report(
2274 op->reports, RPT_ERROR, "Active button is not from a script, cannot edit source");
2276 }
2277 }
2278 else {
2279 BKE_report(op->reports, RPT_ERROR, "Active button match cannot be found");
2281 }
2282
2283 editsource_active_but_clear();
2284
2285 // printf("%s: end\n", __func__);
2286
2287 return ret;
2288 }
2289
2290 BKE_report(op->reports, RPT_ERROR, "Active button not found");
2291 return OPERATOR_CANCELLED;
2292}
2293
2294static void UI_OT_editsource(wmOperatorType *ot)
2295{
2296 /* identifiers */
2297 ot->name = "Edit Source";
2298 ot->idname = "UI_OT_editsource";
2299 ot->description = "Edit UI source code of the active button";
2300
2301 /* callbacks */
2302 ot->exec = editsource_exec;
2303}
2304
2306
2307#endif /* WITH_PYTHON */
2308
2309/* -------------------------------------------------------------------- */
2312
2314{
2315 BLT_lang_init();
2317 BLT_lang_set(nullptr);
2318 reinit_font();
2319 return OPERATOR_FINISHED;
2320}
2321
2323{
2324 /* identifiers */
2325 ot->name = "Reload Translation";
2326 ot->idname = "UI_OT_reloadtranslation";
2327 ot->description = "Force a full reload of UI translation";
2328
2329 /* callbacks */
2331}
2332
2334
2335/* -------------------------------------------------------------------- */
2338
2340{
2341 bScreen *screen = CTX_wm_screen(C);
2342 const bool skip_depressed = RNA_boolean_get(op->ptr, "skip_depressed");
2343 ARegion *region_prev = CTX_wm_region(C);
2344 ARegion *region = screen ? BKE_screen_find_region_xy(screen, RGN_TYPE_ANY, event->xy) : nullptr;
2345
2346 if (region == nullptr) {
2347 region = region_prev;
2348 }
2349
2350 if (region == nullptr) {
2351 return OPERATOR_PASS_THROUGH;
2352 }
2353
2354 CTX_wm_region_set(C, region);
2356 CTX_wm_region_set(C, region_prev);
2357
2358 if (but == nullptr) {
2359 return OPERATOR_PASS_THROUGH;
2360 }
2361 if (skip_depressed && (but->flag & (UI_SELECT | UI_SELECT_DRAW))) {
2362 return OPERATOR_PASS_THROUGH;
2363 }
2364
2365 /* Weak, this is a workaround for 'but_is_tool', which checks the operator type,
2366 * having this avoids a minor drawing glitch. */
2367 void *but_optype = but->optype;
2368
2369 button_execute(C, region, but);
2370
2371 but->optype = static_cast<wmOperatorType *>(but_optype);
2372
2374
2375 return OPERATOR_FINISHED;
2376}
2377
2379{
2380 ot->name = "Press Button";
2381 ot->idname = "UI_OT_button_execute";
2382 ot->description = "Presses active button";
2383
2385 ot->flag = OPTYPE_INTERNAL;
2386
2387 RNA_def_boolean(ot->srna, "skip_depressed", false, "Skip Depressed", "");
2388}
2389
2391
2392/* -------------------------------------------------------------------- */
2395
2397{
2399
2400 if (but) {
2402 }
2403
2404 return OPERATOR_FINISHED;
2405}
2406
2408{
2409 ot->name = "Clear Button String";
2410 ot->idname = "UI_OT_button_string_clear";
2411 ot->description = "Unsets the text of the active button";
2412
2415 ot->flag = OPTYPE_INTERNAL;
2416}
2417
2419
2420/* -------------------------------------------------------------------- */
2423
2424bool drop_color_poll(bContext *C, wmDrag *drag, const wmEvent * /*event*/)
2425{
2426 /* should only return true for regions that include buttons, for now
2427 * return true always */
2428 if (drag->type == WM_DRAG_COLOR) {
2430 ARegion *region = CTX_wm_region(C);
2431
2433 return true;
2434 }
2435
2436 if (sima && (sima->mode == SI_MODE_PAINT) && sima->image &&
2437 (region && region->regiontype == RGN_TYPE_WINDOW))
2438 {
2439 return true;
2440 }
2441 }
2442
2443 return false;
2444}
2445
2446void drop_color_copy(bContext * /*C*/, wmDrag *drag, wmDropBox *drop)
2447{
2448 DragColorHandle *drag_info = static_cast<DragColorHandle *>(drag->poin);
2449
2450 RNA_float_set_array(drop->ptr, "color", drag_info->color);
2451 RNA_boolean_set(drop->ptr, "gamma", drag_info->gamma_corrected);
2452 RNA_boolean_set(drop->ptr, "has_alpha", drag_info->has_alpha);
2453}
2454
2456{
2457 ARegion *region = CTX_wm_region(C);
2458 Button *but = nullptr;
2459
2460 float color[4];
2461 RNA_float_get_array(op->ptr, "color", color);
2462
2463 const bool gamma = RNA_boolean_get(op->ptr, "gamma");
2464 const bool has_alpha = RNA_boolean_get(op->ptr, "has_alpha");
2465
2466 /* find button under mouse, check if it has RNA color property and
2467 * if it does copy the data */
2468 but = region_find_active_but(region);
2469
2470 if (but && but->type == ButtonType::Color && but->rnaprop) {
2471 if (!has_alpha) {
2472 color[3] = 1.0f;
2473 }
2474
2476 if (!gamma) {
2478 }
2480 RNA_property_update(C, &but->rnapoin, but->rnaprop);
2481 }
2482 else if (RNA_property_subtype(but->rnaprop) == PROP_COLOR) {
2483 if (gamma) {
2485 }
2487 RNA_property_update(C, &but->rnapoin, but->rnaprop);
2488 }
2489
2490 if (button_flag_is_set(but, BUT_UNDO)) {
2492 }
2493 }
2494 else {
2495 if (gamma) {
2497 }
2498
2499 ED_imapaint_bucket_fill(C, color, op, event->mval);
2500 }
2501
2502 ED_region_tag_redraw(region);
2503
2504 return OPERATOR_FINISHED;
2505}
2506
2508{
2509 ot->name = "Drop Color";
2510 ot->idname = "UI_OT_drop_color";
2511 ot->description = "Drop colors to buttons";
2512
2515
2516 ot->flag = OPTYPE_INTERNAL;
2517
2519 ot->srna, "color", 4, nullptr, 0.0, FLT_MAX, "Color", "Source color", 0.0, 1.0);
2521 ot->srna, "gamma", false, "Gamma Corrected", "The source color is gamma corrected");
2523 ot->srna, "has_alpha", false, "Has Alpha", "The source color contains an Alpha component");
2524}
2525
2527
2528/* -------------------------------------------------------------------- */
2531
2533{
2535 return false;
2536 }
2537
2539 if (!but) {
2540 return false;
2541 }
2542
2543 if (but->flag & BUT_DISABLED) {
2544 return false;
2545 }
2546
2547 return true;
2548}
2549
2551{
2553 std::string str = RNA_string_get(op->ptr, "string");
2554
2555 button_set_string_interactive(C, but, str.c_str());
2556
2557 return OPERATOR_FINISHED;
2558}
2559
2561{
2562 ot->name = "Drop Name";
2563 ot->idname = "UI_OT_drop_name";
2564 ot->description = "Drop name to button";
2565
2566 ot->poll = drop_name_poll;
2569
2571 ot->srna, "string", nullptr, 0, "String", "The string value to drop into the button");
2572}
2573
2575
2576/* -------------------------------------------------------------------- */
2579
2581{
2582 const ARegion *region = CTX_wm_region(C);
2583 if (!region) {
2584 return false;
2585 }
2586 const wmWindow *win = CTX_wm_window(C);
2587 const uiList *list = uilist_find_mouse_over(region, win->runtime->eventstate);
2588
2589 return list != nullptr;
2590}
2591
2597{
2598 if (list->filter_flag & UILST_FLT_SHOW) {
2599 /* Nothing to be done. */
2600 return false;
2601 }
2602
2603 list->filter_flag |= UILST_FLT_SHOW;
2604 return true;
2605}
2606
2608 wmOperator * /*op*/,
2609 const wmEvent *event)
2610{
2611 ARegion *region = CTX_wm_region(C);
2612 uiList *list = uilist_find_mouse_over(region, event);
2613 /* Poll should check. */
2614 BLI_assert(list != nullptr);
2615
2617 ED_region_tag_redraw(region);
2618 }
2619 ED_region_activate_rna_prop(C, region, list, "filter_name");
2620
2621 return OPERATOR_FINISHED;
2622}
2623
2625{
2626 ot->name = "List Filter";
2627 ot->idname = "UI_OT_list_start_filter";
2628 ot->description = "Start entering filter text for the list in focus";
2629
2632}
2633
2635
2636/* -------------------------------------------------------------------- */
2639
2641{
2642 const wmWindow *win = CTX_wm_window(C);
2643 if (!(win && win->runtime->eventstate)) {
2644 return nullptr;
2645 }
2646
2647 const ARegion *region_popup = CTX_wm_region_popup(C);
2648 const ARegion *region = region_popup ? region_popup : CTX_wm_region(C);
2649 if (!region) {
2650 return nullptr;
2651 }
2652 return region_view_find_at(region, win->runtime->eventstate->xy, 0);
2653}
2654
2656{
2657 const AbstractView *view = get_view_focused(C);
2658 return view != nullptr;
2659}
2660
2662 wmOperator * /*op*/,
2663 const wmEvent *event)
2664{
2665 const ARegion *region = CTX_wm_region(C);
2666 const AbstractView *hovered_view = region_view_find_at(region, event->xy, 0);
2667
2668 if (!hovered_view->begin_filtering(*C)) {
2670 }
2671
2672 return OPERATOR_FINISHED;
2673}
2674
2676{
2677 ot->name = "View Filter";
2678 ot->idname = "UI_OT_view_start_filter";
2679 ot->description = "Start entering filter text for the data-set in focus";
2680
2682 ot->poll = view_focused_poll;
2683
2684 ot->flag = OPTYPE_INTERNAL;
2685}
2686
2688
2689/* -------------------------------------------------------------------- */
2692
2694{
2695 const wmWindow *win = CTX_wm_window(C);
2696 if (!(win && win->runtime->eventstate)) {
2697 return false;
2698 }
2699 const ARegion *region = CTX_wm_region(C);
2700 if (region == nullptr) {
2701 return false;
2702 }
2703 return region_views_find_drop_target_at(region, win->runtime->eventstate->xy) != nullptr;
2704}
2705
2707{
2708 if (event->custom != EVT_DATA_DRAGDROP) {
2710 }
2711
2712 ARegion *region = CTX_wm_region(C);
2713 std::unique_ptr<DropTargetInterface> drop_target = region_views_find_drop_target_at(region,
2714 event->xy);
2715
2717 *region,
2718 *event,
2719 *drop_target,
2720 *static_cast<const ListBaseT<wmDrag> *>(event->customdata)))
2721 {
2723 }
2724
2725 ED_region_tag_redraw(region);
2726 return OPERATOR_FINISHED;
2727}
2728
2730{
2731 ot->name = "View Drop";
2732 ot->idname = "UI_OT_view_drop";
2733 ot->description = "Drag and drop onto a data-set or item within the data-set";
2734
2736 ot->poll = view_drop_poll;
2737
2738 ot->flag = OPTYPE_INTERNAL;
2739}
2740
2742
2743/* -------------------------------------------------------------------- */
2746
2748{
2749 const AbstractView *view = get_view_focused(C);
2750 if (!view) {
2751 return false;
2752 }
2753
2754 return view->supports_scrolling();
2755}
2756
2758{
2759 ARegion *region = CTX_wm_region(C);
2760 int type = event->type;
2761 bool invert_direction = false;
2762
2763 if (type == MOUSEPAN) {
2764 int dummy_val;
2765 pan_to_scroll(event, &type, &dummy_val);
2766
2767 /* 'pan_to_scroll' gives the absolute direction. */
2768 if (event->flag & WM_EVENT_SCROLL_INVERT) {
2769 invert_direction = true;
2770 }
2771 }
2772
2774 std::optional<ViewScrollDirection> direction =
2775 [type, invert_direction]() -> std::optional<ViewScrollDirection> {
2776 switch (type) {
2777 case WHEELUPMOUSE:
2778 return invert_direction ? ViewScrollDirection::DOWN : ViewScrollDirection::UP;
2779 case WHEELDOWNMOUSE:
2780 return invert_direction ? ViewScrollDirection::UP : ViewScrollDirection::DOWN;
2781 default:
2782 return std::nullopt;
2783 }
2784 }();
2785 if (!direction) {
2786 return OPERATOR_CANCELLED;
2787 }
2788
2790 if (view->is_fully_visible()) {
2791 /* The view does not need scrolling currently, so pass the event through. This allows scrolling
2792 * e.g. the entire region even when hovering a tree-view that supports scrolling generally. */
2793 return OPERATOR_PASS_THROUGH;
2794 }
2795 view->scroll(*direction);
2796
2797 ED_region_tag_redraw(region);
2798 return OPERATOR_FINISHED;
2799}
2800
2802{
2803 ot->name = "View Scroll";
2804 ot->idname = "UI_OT_view_scroll";
2805
2807 ot->poll = view_scroll_poll;
2808
2809 ot->flag = OPTYPE_INTERNAL;
2810}
2811
2813
2814/* -------------------------------------------------------------------- */
2822
2824{
2825 const AbstractView *view = get_view_focused(C);
2826 if (!view) {
2827 return nullptr;
2828 }
2829 AbstractViewItem *active_item = nullptr;
2830 view->foreach_view_item([&](AbstractViewItem &item) {
2831 if (item.is_active()) {
2832 active_item = &item;
2833 }
2834 });
2835 return active_item;
2836}
2837
2839{
2840 const AbstractView *view = get_view_focused(C);
2841 if (view == nullptr) {
2842 return false;
2843 }
2844 const AbstractViewItem *active_item = find_active_view_item(C);
2845 return active_item != nullptr && view_item_can_rename(*active_item);
2846}
2847
2849{
2850 ARegion *region = CTX_wm_region(C);
2852
2853 if (AbstractTreeView *tree_view = dynamic_cast<AbstractTreeView *>(&active_item->get_view())) {
2854 /* In tree views, ensure the active item is visible when renaming starts. */
2855 tree_view->scroll_active_into_view(C, true);
2856 }
2857
2858 view_item_begin_rename(*active_item);
2859 ED_region_tag_redraw(region);
2860
2861 return OPERATOR_FINISHED;
2862}
2863
2865{
2866 ot->name = "Rename View Item";
2867 ot->idname = "UI_OT_view_item_rename";
2868 ot->description = "Rename the active item in the data-set view";
2869
2872 /* Could get a custom tooltip via the `get_description()` callback and another overridable
2873 * function of the view. */
2874
2875 ot->flag = OPTYPE_INTERNAL;
2876}
2877
2878
2879/* -------------------------------------------------------------------- */
2885
2887 AbstractViewItem *clicked_item,
2888 const AbstractView &view,
2889 const bool extend,
2890 const bool range_select,
2891 bool wait_to_deselect_others)
2892{
2893 const bool already_selected = clicked_item && clicked_item->is_selected();
2894
2895 if (extend || range_select) {
2896 wait_to_deselect_others = false;
2897 }
2898
2899 if (clicked_item && already_selected && wait_to_deselect_others) {
2901 }
2902
2903 if (!extend) {
2904 view.foreach_view_item([](AbstractViewItem &item) { item.set_selected(false); });
2905 }
2906
2907 if (clicked_item == nullptr) {
2908 /* Only clear selection (if needed). */
2909 return OPERATOR_FINISHED;
2910 }
2911
2912 if (range_select) {
2913 bool is_inside_range = false;
2914 view.foreach_view_item([&](AbstractViewItem &item) {
2915 if (item.is_active() ^ (&item == clicked_item)) {
2916 is_inside_range = !is_inside_range;
2917 /* Select end items from the range. */
2918 item.set_selected(true);
2919 }
2920
2921 if (!item.is_filtered_visible()) {
2922 /* Skip selection of elements that are not visible with the search string. */
2923 return;
2924 }
2925
2926 if (is_inside_range) {
2927 /* Select items within the range. */
2928 item.set_selected(true);
2929 }
2930 });
2931 return OPERATOR_FINISHED;
2932 }
2933
2934 clicked_item->activate(C);
2935
2936 return OPERATOR_FINISHED;
2937}
2938
2939static std::pair<AbstractView *, AbstractViewItem *> select_operator_view_and_item_find_xy(
2940 const ARegion &region, const wmOperator &op)
2941{
2942 /* Mouse coordinates in window space. */
2943 int window_xy[2];
2944 {
2945 /* Mouse coordinates in region space. */
2946 int region_xy[2];
2947 region_xy[0] = RNA_int_get(op.ptr, "mouse_x");
2948 region_xy[1] = RNA_int_get(op.ptr, "mouse_y");
2949 region_to_window(&region, region_xy[0], region_xy[1], &window_xy[0], &window_xy[1]);
2950 }
2951
2952 AbstractView *view = region_view_find_at(&region, window_xy, 0);
2953 AbstractViewItem *item = region_views_find_item_at(region, window_xy);
2954 BLI_assert(!item || &item->get_view() == view);
2955
2956 return std::make_pair(view, item);
2957}
2958
2960{
2961 ARegion &region = *CTX_wm_region(C);
2962 auto [view, clicked_item] = select_operator_view_and_item_find_xy(region, *op);
2963
2964 if (!view) {
2965 return OPERATOR_CANCELLED;
2966 }
2967
2968 const bool is_multiselect = view->is_multiselect_supported();
2969 const bool extend = RNA_boolean_get(op->ptr, "extend") && is_multiselect;
2970 const bool range_select = RNA_boolean_get(op->ptr, "range_select") && is_multiselect;
2971 const bool wait_to_deselect_others = RNA_boolean_get(op->ptr, "wait_to_deselect_others");
2972
2974 *C, clicked_item, *view, extend, range_select, wait_to_deselect_others);
2975
2976 ED_region_tag_redraw(&region);
2977
2978 return status;
2979}
2980
2982{
2983 const ARegion &region = *CTX_wm_region(C);
2984 const AbstractViewItem *clicked_item = region_views_find_item_at(region, event->xy);
2985
2986 /* Wait with selecting to see if there's a click or drag event, if requested by the view item. */
2987 if (clicked_item && clicked_item->is_select_on_click()) {
2988 RNA_boolean_set(op->ptr, "use_select_on_click", true);
2989 }
2990
2991 return WM_generic_select_invoke(C, op, event);
2992}
2993
2995{
2996 ot->name = "Select View Item";
2997 ot->idname = "UI_OT_view_item_select";
2998 ot->description = "Activate selected view item";
2999
3003 ot->poll = view_focused_poll;
3004
3005 ot->flag = OPTYPE_INTERNAL;
3006
3008 PropertyRNA *prop = RNA_def_boolean(ot->srna, "extend", false, "extend", "Extend Selection");
3010 prop = RNA_def_boolean(ot->srna,
3011 "range_select",
3012 false,
3013 "Range Select",
3014 "Select all between clicked and active items");
3016}
3017
3018
3019/* -------------------------------------------------------------------- */
3024
3026 wmOperator * /*op*/,
3027 const wmEvent * /*event*/)
3028{
3030
3031 view->foreach_view_item([&](AbstractViewItem &item) {
3032 if (!item.is_filtered_visible()) {
3033 return;
3034 }
3035 if (item.is_active() || item.is_selected()) {
3036 item.delete_item(C);
3037 }
3038 });
3039
3040 return OPERATOR_FINISHED;
3041}
3042
3044{
3045 ot->name = "Delete";
3046 ot->idname = "UI_OT_view_item_delete";
3047 ot->description = "Delete selected list item";
3048
3050 ot->poll = view_focused_poll;
3051
3052 ot->flag = OPTYPE_INTERNAL;
3053}
3054
3055
3056/* -------------------------------------------------------------------- */
3062
3069
3071 wmOperator *op,
3072 const wmEvent * /*event*/)
3073{
3074 ARegion &region = *CTX_wm_region(C);
3075 const Direction direction = Direction(RNA_enum_get(op->ptr, "direction"));
3077
3079 AbstractViewItem *next_item = nullptr;
3080 switch (direction) {
3081 case Direction::UP: {
3082 next_item = view->navigate_up(from);
3083 break;
3084 }
3085 case Direction::Down: {
3086 next_item = view->navigate_down(from);
3087 break;
3088 }
3089 case Direction::LEFT: {
3090 next_item = view->navigate_left(from);
3091 break;
3092 }
3093 case Direction::RIGHT: {
3094 next_item = view->navigate_right(from);
3095 break;
3096 }
3097 }
3098
3099 if (next_item) {
3100 view_item_click_select(*C, next_item, *view, false, false, false);
3102 }
3103
3104 ED_region_tag_redraw(&region);
3105 return OPERATOR_FINISHED;
3106}
3107
3109{
3110 ot->name = "View Navigate";
3111 ot->idname = "UI_OT_view_item_navigate";
3112 ot->description = "Walk and select view items in given direction";
3113
3115 ot->poll = view_focused_poll;
3116
3117 ot->flag = OPTYPE_INTERNAL;
3118
3119 static const EnumPropertyItem direction_enum_items[] = {
3120 {int(Direction::UP), "UP", 0, "Up", "Select item above the active"},
3121 {int(Direction::Down), "DOWN", 0, "Down", "Select item below the active"},
3122 {int(Direction::LEFT),
3123 "LEFT",
3124 0,
3125 "Left",
3126 "Collapse or walk towards left of the active item"},
3127 {int(Direction::RIGHT),
3128 "RIGHT",
3129 0,
3130 "Right",
3131 "Uncollapse or walk towards right of the active item"},
3132 {0, nullptr, 0, nullptr, nullptr},
3133 };
3134
3135 RNA_def_enum(ot->srna,
3136 "direction",
3137 direction_enum_items,
3138 0,
3139 "Navigation Direction",
3140 "Direction in which to navigate and select next element.");
3141}
3142
3143
3144/* -------------------------------------------------------------------- */
3150
3152 wmOperator * /*op*/,
3153 const wmEvent * /*event*/)
3154{
3155 ARegion *region = CTX_wm_region(C);
3157
3158 view->scroll_active_into_view(C, true);
3159 ED_region_tag_redraw(region);
3160
3161 return OPERATOR_FINISHED;
3162}
3163
3165{
3166 ot->name = "Focus Active Item";
3167 ot->idname = "UI_OT_view_item_focus";
3168 ot->description = "Bring active item into focus by scrolling the view";
3169
3171 ot->poll = view_focused_poll;
3172
3173 ot->flag = OPTYPE_INTERNAL;
3174}
3175
3176
3177/* -------------------------------------------------------------------- */
3183
3185 wmOperator *op,
3186 const wmEvent * /*event*/)
3187{
3188 ARegion &region = *CTX_wm_region(C);
3190 const PageScrollDirection direction = PageScrollDirection(
3191 RNA_enum_get(op->ptr, "scroll_direction"));
3192
3193 view->page_scroll(C, direction);
3194
3195 ED_region_tag_redraw(&region);
3196 return OPERATOR_FINISHED;
3197}
3198
3200{
3201 ot->name = "Scroll page";
3202 ot->idname = "UI_OT_view_item_page_scroll";
3203 ot->description = "Scroll the list to the next/previous page";
3204
3206 ot->poll = view_focused_poll;
3207
3208 static const EnumPropertyItem direction_enum_items[] = {
3209 {int(PageScrollDirection::Up), "UP", 0, "Up", "Scroll one page up"},
3210 {int(PageScrollDirection::Down), "DOWN", 0, "Down", "Scroll one page down"},
3211 {int(PageScrollDirection::Top), "TOP", 0, "Top", "Scroll to the top"},
3212 {int(PageScrollDirection::Bottom), "BOTTOM", 0, "Bottom", "Scroll to the bottom"},
3213 {0, nullptr, 0, nullptr, nullptr},
3214 };
3215
3216 RNA_def_enum(ot->srna,
3217 "scroll_direction",
3218 direction_enum_items,
3219 0,
3220 "Scroll Direction",
3221 "Scroll to next/previous page in the list.");
3222}
3223
3224
3225/* -------------------------------------------------------------------- */
3229
3231{
3232 PointerRNA ptr = CTX_data_pointer_get_type(C, "object", RNA_Object);
3233 const Object *ob = static_cast<const Object *>(ptr.data);
3234 if (ob == nullptr) {
3235 return false;
3236 }
3237
3238 PointerRNA mat_slot = CTX_data_pointer_get_type(C, "material_slot", RNA_MaterialSlot);
3239 if (!mat_slot) {
3240 return false;
3241 }
3242
3243 return true;
3244}
3245
3247{
3248 Main *bmain = CTX_data_main(C);
3249
3250 Material *ma = id_cast<Material *>(
3252 if (ma == nullptr) {
3253 return OPERATOR_CANCELLED;
3254 }
3255
3256 PointerRNA ptr = CTX_data_pointer_get_type(C, "object", RNA_Object);
3257 Object *ob = static_cast<Object *>(ptr.data);
3258 BLI_assert(ob);
3259
3260 PointerRNA mat_slot = CTX_data_pointer_get_type(C, "material_slot", RNA_MaterialSlot);
3261 BLI_assert(mat_slot);
3262 const int target_slot = RNA_int_get(&mat_slot, "slot_index") + 1;
3263
3264 /* only drop grease pencil material on grease pencil objects */
3265 if ((ma->gp_style != nullptr) && (ob->type != OB_GREASE_PENCIL)) {
3266 return OPERATOR_CANCELLED;
3267 }
3268
3269 BKE_object_material_assign(bmain, ob, ma, target_slot, BKE_MAT_ASSIGN_USERPREF);
3270
3275
3276 return OPERATOR_FINISHED;
3277}
3278
3280{
3281 ot->name = "Drop Material in Material slots";
3282 ot->description = "Drag material to Material slots in Properties";
3283 ot->idname = "UI_OT_drop_material";
3284
3288
3290}
3291
3293
3294/* -------------------------------------------------------------------- */
3298
3300{
3301 ARegion *region = CTX_wm_region(C);
3302 if (!(region->flag & RGN_FLAG_SEARCH_FILTER_SHOW)) {
3305 }
3308 }
3309 ED_region_activate_rna_prop(C, region, region, "search_filter");
3310 return OPERATOR_FINISHED;
3311}
3312
3314{
3315 ARegion *region = CTX_wm_region(C);
3316 return region && BKE_regiontype_uses_panel_categories_search(region->runtime->type);
3317}
3318
3320{
3321 ot->name = "Show Filter";
3322 ot->description = "Shows and starts entering region filter text";
3323 ot->idname = "UI_OT_region_start_filter";
3326}
3327
3339
3341{
3342 ARegion *region = CTX_wm_region(C);
3344}
3345
3347{
3348 ot->name = "Clear and Hide Filter";
3349 ot->description = "Clear and hide the region search filter";
3350 ot->idname = "UI_OT_region_clear_filter";
3353}
3354
3356
3357/* -------------------------------------------------------------------- */
3360
3362{
3375#ifdef WITH_PYTHON
3376 WM_operatortype_append(UI_OT_editsource);
3377#endif
3381
3383
3393
3400
3401 /* external */
3412
3414}
3415
3417{
3418 WM_keymap_ensure(keyconf, "User Interface", SPACE_EMPTY, RGN_TYPE_WINDOW);
3419
3420 eyedropper_modal_keymap(keyconf);
3422}
3423
3425
3426} // namespace ui
3427} // namespace blender
Functions to insert, delete or modify keyframes.
General operations, lookup, etc. for materials.
#define FILE_MAX
#define STR_ELEM(...)
#define STRNCPY_UTF8(dst, src)
#define IFACE_(msgid)
#define ID_IS_PACKED(_id)
Definition DNA_ID.h:703
#define ID_IS_OVERRIDE_LIBRARY_REAL(_id)
Definition DNA_ID.h:729
#define ID_CHECK_UNDO(id)
Definition DNA_ID.h:686
#define ID_IS_LINKED(_id)
Definition DNA_ID.h:697
#define ID_IS_EDITABLE(_id)
Definition DNA_ID.h:708
#define MAXBONENAME
Object is a sort of wrapper for general info.
#define OB_DATA_SUPPORT_ID(_id_type)
#define RGN_TYPE_ANY
Read Blender memory allocation and freeing.
#define C
Definition RandGen.cpp:29
#define NC_WINDOW
Definition WM_types.hh:388
#define NC_WM
Definition WM_types.hh:387
#define NC_ANIMATION
Definition WM_types.hh:401
#define NC_SCREEN
Definition WM_types.hh:390
#define ND_LIB_OVERRIDE_CHANGED
Definition WM_types.hh:435
#define NA_EDITED
Definition WM_types.hh:634
#define ND_KEYFRAME_PROP
Definition WM_types.hh:538
#define NC_MATERIAL
Definition WM_types.hh:393
#define ND_OB_SHADING
Definition WM_types.hh:476
#define ND_SPACE_VIEW3D
Definition WM_types.hh:571
#define NC_OBJECT
Definition WM_types.hh:392
#define ND_SHADING_LINKS
Definition WM_types.hh:522
#define NC_SPACE
Definition WM_types.hh:405
#define UNUSED_VARS(...)
#define BLI_assert(a)
#define ELEM(...)
#define BLI_assert_msg(a, msg)
#define STREQ(a, b)
bool contains(const Key &key) const
Definition BLI_set.hh:310
bool add(const Key &key)
Definition BLI_set.hh:248
void clear()
Definition BLI_set.hh:570
constexpr Span()=default
constexpr int64_t size() const
Definition BLI_span.hh:256
void append(const T &value)
void resize(const int64_t new_size)
int64_t remove_if(Predicate &&predicate)
Span< T > as_span() const
virtual void delete_item(bContext *C)
virtual void set_selected(const bool select)
virtual bool supports_scrolling() const
virtual AbstractViewItem * navigate_left(AbstractViewItem *from)=0
virtual bool is_fully_visible() const
virtual void foreach_view_item(FunctionRef< void(AbstractViewItem &)> iter_fn) const =0
virtual void page_scroll(bContext *C, PageScrollDirection direction)=0
virtual void scroll_active_into_view(bContext *C, bool scroll_active_to_center=false)=0
virtual bool begin_filtering(const bContext &C) const
virtual void scroll(ViewScrollDirection direction)
virtual AbstractViewItem * navigate_down(AbstractViewItem *from)=0
virtual AbstractViewItem * navigate_right(AbstractViewItem *from)=0
virtual AbstractViewItem * navigate_up(AbstractViewItem *from)=0
virtual AbstractViewItem * find_active_or_visible_item() const =0
#define str(s)
#define FLT_MAX
#define FLT_EPSILON
VecBase< float, D > constexpr mod(VecOp< float, D >, VecOp< float, D >) RET
bool all(VecOp< bool, D >) RET
bool autokeyframe_property(bContext *C, Scene *scene, PointerRNA *ptr, PropertyRNA *prop, int rnaindex, float cfra, bool only_if_property_keyed)
bNode & node_find_node(bNodeTree &ntree, bNodeSocket &socket)
Definition node.cc:4053
bool jump_to_object(bContext *C, Object *ob, bool reveal_hidden)
Base * find_first_by_data_id(const Main &bmain, const Scene *scene, ViewLayer *view_layer, ID *id)
bool jump_to_bone(bContext *C, Object *ob, const char *bone_name, bool reveal_hidden)
size_t line_number(const std::string_view &str, size_t pos)
bool socket_type_supports_attributes(const eNodeSocketDatatype socket_type)
int paste_property_drivers(Span< FCurve * > src_drivers, bool is_array_prop, PointerRNA *dst_ptr, PropertyRNA *dst_prop)
Vector< FCurve * > get_property_drivers(PointerRNA *ptr, PropertyRNA *prop, bool get_all, int index, bool *r_is_array_prop)
bool button_active_drop_color(bContext *C)
static void UI_OT_view_item_rename(wmOperatorType *ot)
static void context_selected_key_blocks(ID *owner_id_key, Vector< PointerRNA > *r_lb)
void drop_color_copy(bContext *C, wmDrag *drag, wmDropBox *drop)
Button * button_active_drop_name_button(const bContext *C)
void button_active_free(const bContext *C, Button *but)
void button_active_string_clear_and_exit(bContext *C, Button *but)
void UI_OT_eyedropper_id(wmOperatorType *ot)
static bool copy_to_selected_button_poll(bContext *C)
static void UI_OT_region_start_filter(wmOperatorType *ot)
AbstractViewItem * region_views_find_item_at(const ARegion &region, const int xy[2])
static bool copy_driver_to_selected_button(bContext *C, bool copy_entire_array, const bool poll)
static void UI_OT_unset_property_button(wmOperatorType *ot)
static bool override_idtemplate_reset_poll(bContext *C)
static bool uilist_focused_poll(bContext *C)
static void UI_OT_reset_default_button(wmOperatorType *ot)
static void region_redraw_immediately(bContext *C, ARegion *region)
bool panel_region_visible_width_ensure(ARegion *region)
static bool uilist_unhide_filter_options(uiList *list)
static bool reset_default_button_poll(bContext *C)
static wmOperatorStatus view_drop_invoke(bContext *C, wmOperator *, const wmEvent *event)
static wmOperatorStatus override_add_button_exec(bContext *C, wmOperator *op)
bool context_copy_to_selected_list(bContext *C, PointerRNA *ptr, PropertyRNA *prop, Vector< PointerRNA > *r_lb, bool *r_use_path_from_id, std::optional< std::string > *r_path)
Button * context_active_but_get_respect_popup(const bContext *C)
static void UI_OT_view_item_focus(wmOperatorType *ot)
bool drop_target_apply_drop(bContext &C, const ARegion &region, const wmEvent &event, const DropTargetInterface &drop_target, const ListBaseT< wmDrag > &drags)
static void UI_OT_button_execute(wmOperatorType *ot)
static wmOperatorStatus copy_driver_to_selected_button_exec(bContext *C, wmOperator *op)
static wmOperatorStatus assign_default_button_exec(bContext *C, wmOperator *)
static bool tree_interface_item_can_set_prop(const bNodeTreeInterfaceItem &item, const bNodeTreeInterfaceItem &active_item, PropertyRNA *prop)
static void UI_OT_drop_color(wmOperatorType *ot)
static void override_idtemplate_menu_draw(const bContext *, Menu *menu)
void UI_OT_eyedropper_colorramp(wmOperatorType *ot)
static wmOperatorStatus unset_property_button_exec(bContext *C, wmOperator *)
void operatortypes_ui()
static wmOperatorStatus view_start_filter_invoke(bContext *C, wmOperator *, const wmEvent *event)
static bool assign_default_button_poll(bContext *C)
static void UI_OT_override_idtemplate_clear(wmOperatorType *ot)
uiList * uilist_find_mouse_over(const ARegion *region, const wmEvent *event)
static wmOperatorStatus copy_to_selected_button_exec(bContext *C, wmOperator *op)
static wmOperatorStatus drop_name_invoke(bContext *C, wmOperator *op, const wmEvent *)
static wmOperatorStatus override_idtemplate_reset_exec(bContext *C, wmOperator *)
bool drop_color_poll(bContext *C, wmDrag *drag, const wmEvent *event)
static wmOperatorStatus operator_button_property_finish(bContext *C, PointerRNA *ptr, PropertyRNA *prop)
bool view_item_can_rename(const AbstractViewItem &item)
static wmOperatorStatus drop_material_exec(bContext *C, wmOperator *op)
static wmOperatorStatus button_press_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static wmOperatorStatus uilist_start_filter_invoke(bContext *C, wmOperator *, const wmEvent *event)
static bool override_add_button_poll(bContext *C)
PointerRNA * button_operator_ptr_ensure(Button *but)
void UI_OT_eyedropper_colorramp_point(wmOperatorType *ot)
static bool view_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
static wmOperatorStatus ui_view_item_navigate_invoke(bContext *C, wmOperator *op, const wmEvent *)
static bool copy_data_path_button_poll(bContext *C)
static wmOperatorStatus view_item_select_exec(bContext *C, wmOperator *op)
static void UI_OT_view_item_delete(wmOperatorType *ot)
static PointerRNA rnapointer_pchan_to_bone(const PointerRNA &pchan_ptr)
static AbstractViewItem * find_active_view_item(bContext *C)
bool jump_to_target_button_poll(bContext *C)
static bool view_item_rename_poll(bContext *C)
static wmOperatorStatus reloadtranslation_exec(bContext *, wmOperator *)
static void UI_OT_view_drop(wmOperatorType *ot)
void keymap_ui(wmKeyConfig *keyconf)
User Interface Keymap.
void region_panels_sort_for_search_filter_visibility_change(bContext *C, const ARegion *region)
Button * region_find_active_but(ARegion *region) ATTR_WARN_UNUSED_RESULT
void view_item_begin_rename(AbstractViewItem &item)
static bool jump_to_target_button(bContext *C, bool poll)
static void ui_context_matched_tree_interface_items(PointerRNA *ptr, PropertyRNA *prop, Vector< PointerRNA > *r_lb)
static bool jump_to_target_ptr(bContext *C, PointerRNA ptr, const bool poll)
static wmOperatorStatus override_idtemplate_clear_exec(bContext *C, wmOperator *)
static wmOperatorStatus operator_button_property_finish_with_undo(bContext *C, PointerRNA *ptr, PropertyRNA *prop)
static void context_selected_bones_via_pose(bContext *C, Vector< PointerRNA > *r_lb)
static wmOperatorStatus reset_default_button_exec(bContext *C, wmOperator *op)
static bool view_focused_poll(bContext *C)
void UI_OT_eyedropper_grease_pencil_color(wmOperatorType *ot)
ID * template_id_liboverride_hierarchy_make(bContext *C, Main *bmain, ID *owner_id, ID *id, const char **r_undo_push_label)
static void UI_OT_drop_name(wmOperatorType *ot)
void region_to_window(const ARegion *region, int *x, int *y)
Definition interface.cc:263
static wmOperatorStatus drop_color_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static bool drop_name_poll(bContext *C, wmDrag *drag, const wmEvent *)
static void UI_OT_override_idtemplate_reset(wmOperatorType *ot)
bool button_flag_is_set(Button *but, int64_t flag)
static wmOperatorStatus ui_view_item_scroll_page_invoke(bContext *C, wmOperator *op, const wmEvent *)
static void UI_OT_copy_data_path_button(wmOperatorType *ot)
static void UI_OT_copy_driver_to_selected_button(wmOperatorType *ot)
static wmOperatorStatus button_string_clear_exec(bContext *C, wmOperator *)
bool editsource_enable_check()
static AbstractView * get_view_focused(bContext *C)
void button_set_string_interactive(bContext *C, Button *but, const char *value)
static void UI_OT_override_idtemplate_make(wmOperatorType *ot)
void context_active_but_prop_get_templateID(const bContext *C, PointerRNA *r_ptr, PropertyRNA **r_prop)
static wmOperatorStatus view_item_delete_invoke(bContext *C, wmOperator *, const wmEvent *)
static wmOperatorStatus jump_to_target_button_exec(bContext *C, wmOperator *)
static bool override_remove_button_poll(bContext *C)
static bool copy_python_command_button_poll(bContext *C)
static void UI_OT_copy_as_driver_button(wmOperatorType *ot)
static void context_fcurve_modifiers_via_fcurve(bContext *C, Vector< PointerRNA > *r_lb, FModifier *source)
static bool copy_driver_to_selected_button_poll(bContext *C)
static bool override_idtemplate_poll(bContext *C, const bool is_create_op)
static bool override_idtemplate_clear_poll(bContext *C)
static void override_idtemplate_menu()
static void UI_OT_list_start_filter(wmOperatorType *ot)
static bool region_clear_filter_poll(blender::bContext *C)
wmKeyMap * eyedropper_modal_keymap(wmKeyConfig *keyconf)
static void UI_OT_drop_material(wmOperatorType *ot)
MenuType * UI_MT_color_space_select()
static void UI_OT_copy_python_command_button(wmOperatorType *ot)
static bool view_scroll_poll(bContext *C)
static void override_idtemplate_ids_get(bContext *C, ID **r_owner_id, ID **r_id, PointerRNA *r_owner_ptr, PropertyRNA **r_prop)
static void UI_OT_copy_to_selected_button(wmOperatorType *ot)
static void UI_OT_view_item_page_scroll(wmOperatorType *ot)
static wmOperatorStatus copy_as_driver_button_exec(bContext *C, wmOperator *op)
static wmOperatorStatus override_idtemplate_make_exec(bContext *C, wmOperator *)
static bool copy_to_selected_button(bContext *C, bool all, bool poll)
static void UI_OT_assign_default_button(wmOperatorType *ot)
static wmOperatorStatus ui_view_item_focus_invoke(bContext *C, wmOperator *, const wmEvent *)
static void UI_OT_view_item_navigate(wmOperatorType *ot)
static wmOperatorStatus region_start_filter_exec(bContext *C, wmOperator *)
static bool override_idtemplate_menu_poll(const bContext *C_const, MenuType *)
static void UI_OT_view_scroll(wmOperatorType *ot)
void context_active_but_prop_handle(bContext *C, bool handle_undo)
static void UI_OT_region_clear_filter(wmOperatorType *ot)
void rna_collection_search_update_fn(const bContext *C, void *arg, const char *str, SearchItems *items, bool is_first)
static void UI_OT_override_remove_button(wmOperatorType *ot)
static void UI_OT_view_start_filter(wmOperatorType *ot)
static wmOperatorStatus view_item_click_select(bContext &C, AbstractViewItem *clicked_item, const AbstractView &view, const bool extend, const bool range_select, bool wait_to_deselect_others)
void reinit_font()
void editsource_active_but_test(Button *but)
static wmOperatorStatus copy_python_command_button_exec(bContext *C, wmOperator *)
static void UI_OT_view_item_select(wmOperatorType *ot)
void UI_OT_eyedropper_bone(wmOperatorType *ot)
wmKeyMap * eyedropper_colorband_modal_keymap(wmKeyConfig *keyconf)
void pan_to_scroll(const wmEvent *event, int *type, int *val)
std::unique_ptr< DropTargetInterface > region_views_find_drop_target_at(const ARegion *region, const int xy[2])
static wmOperatorStatus view_item_rename_exec(bContext *C, wmOperator *)
static void UI_OT_reloadtranslation(wmOperatorType *ot)
static bool override_idtemplate_make_poll(bContext *C)
static void UI_OT_override_add_button(wmOperatorType *ot)
static wmOperatorStatus view_scroll_invoke(bContext *C, wmOperator *, const wmEvent *event)
static std::pair< AbstractView *, AbstractViewItem * > select_operator_view_and_item_find_xy(const ARegion &region, const wmOperator &op)
static wmOperatorStatus override_remove_button_exec(bContext *C, wmOperator *op)
Button * context_active_but_prop_get(const bContext *C, PointerRNA *r_ptr, PropertyRNA **r_prop, int *r_index)
void UI_OT_eyedropper_driver(wmOperatorType *ot)
static bool copy_as_driver_button_poll(bContext *C)
void UI_OT_eyedropper_depth(wmOperatorType *ot)
Button * context_active_but_get(const bContext *C)
void UI_OT_eyedropper_color(wmOperatorType *ot)
static bool drop_material_poll(bContext *C, wmDrag *drag, const wmEvent *)
static wmOperatorStatus region_clear_filter_exec(bContext *C, wmOperator *)
static wmOperatorStatus copy_data_path_button_exec(bContext *C, wmOperator *op)
static void UI_OT_button_string_clear(wmOperatorType *ot)
bool context_copy_to_selected_check(PointerRNA *ptr, PointerRNA *ptr_link, PropertyRNA *prop, const char *path, bool use_path_from_id, PointerRNA *r_ptr, PropertyRNA **r_prop)
static bool region_start_filter_poll(blender::bContext *C)
void button_execute(const bContext *C, ARegion *region, Button *but)
static void UI_OT_jump_to_target_button(wmOperatorType *ot)
static wmOperatorStatus view_item_select_invoke(bContext *C, wmOperator *op, const wmEvent *event)
AbstractView * region_view_find_at(const ARegion *region, const int xy[2], int pad, Block **r_block=nullptr)
BMesh Iterators.
void WM_main_add_notifier(uint type, void *reference)
char * RNA_property_string_get_alloc(PointerRNA *ptr, PropertyRNA *prop, char *fixedbuf, int fixedlen, int *r_len)
const char * BKE_idtype_idcode_to_name(short idcode)
Definition idtype.cc:261
bool RNA_property_assign_default(PointerRNA *ptr, PropertyRNA *prop)
int RNA_property_array_length(PointerRNA *ptr, PropertyRNA *prop)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void WM_operatortype_append(void(*opfunc)(wmOperatorType *))
void RNA_float_set_array(PointerRNA *ptr, const char *name, const float *values)
Vector< PointerRNA > CTX_data_collection_get(const bContext *C, const char *member)
PointerRNA RNA_property_pointer_get(PointerRNA *ptr, PropertyRNA *prop)
ScrArea * CTX_wm_area(const bContext *C)
bool BKE_regiontype_uses_panel_categories_search(const ARegionType *region_type)
Definition screen.cc:417
char * STRNCPY(char(&dst)[N], const char *src)
int RNA_enum_get(PointerRNA *ptr, const char *name)
void wmViewport(const rcti *winrct)
Object * BKE_view_layer_active_object_get(const ViewLayer *view_layer)
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
@ RPT_WARNING
Definition BKE_report.hh:40
IDOverrideLibraryPropertyOperation * BKE_lib_override_library_property_operation_find(IDOverrideLibraryProperty *liboverride_property, const char *subitem_refname, const char *subitem_locname, const std::optional< const ID * > &subitem_refid, const std::optional< const ID * > &subitem_locid, int subitem_refindex, int subitem_locindex, bool strict, bool *r_strict)
const PointerRNA * CTX_store_ptr_lookup(const bContextStore *store, StringRef name, const StructRNA *type=nullptr)
void BKE_id_delete(Main *bmain, void *idv, const BKEIDDeleteOptions &options={}) ATTR_NONNULL()
void RNA_property_update(bContext *C, PointerRNA *ptr, PropertyRNA *prop)
void RNA_property_pointer_set(PointerRNA *ptr, PropertyRNA *prop, PointerRNA ptr_value, ReportList *reports)
bool RNA_struct_is_a(const StructRNA *type, const StructRNA *srna)
void WM_operator_properties_id_lookup(wmOperatorType *ot, const bool add_name_prop)
void BLT_lang_set(const char *)
Definition blt_lang.cc:253
SpaceOutliner * CTX_wm_space_outliner(const bContext *C)
bool RNA_property_reset(Main *bmain, PointerRNA *ptr, PropertyRNA *prop, int index)
void wmWindowViewport(const wmWindow *win)
void ED_region_do_layout(bContext *C, ARegion *region)
Definition area.cc:495
PointerRNA RNA_id_pointer_create(ID *id)
std::optional< std::string > RNA_path_from_ID_to_property(const PointerRNA *ptr, PropertyRNA *prop)
Definition rna_path.cc:1237
PropertyRNA * RNA_def_float_color(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)
std::optional< std::string > RNA_path_full_struct_py(const PointerRNA *ptr)
Definition rna_path.cc:1325
void WM_operator_properties_free(PointerRNA *ptr)
ID * WM_operator_properties_id_lookup_from_name_or_session_uid(Main *bmain, PointerRNA *ptr, const ID_Type type)
const char * RNA_property_identifier(const PropertyRNA *prop)
void RNA_string_set(PointerRNA *ptr, const char *name, const char *value)
void srgb_to_linearrgb_v3_v3(float linear[3], const float srgb[3])
void RNA_int_set(PointerRNA *ptr, const char *name, int value)
void void BKE_libblock_remap(Main *bmain, void *old_idv, void *new_idv, int remap_flags) ATTR_NONNULL(1
Definition lib_remap.cc:701
IDOverrideLibraryPropertyOperation * RNA_property_override_property_operation_get(Main *bmain, PointerRNA *ptr, PropertyRNA *prop, const eID_OverrideLib_Op operation, const int index, const bool strict, bool *r_strict, bool *r_created)
FCurve * BKE_fcurve_find_by_rna(PointerRNA *ptr, PropertyRNA *prop, int rnaindex, AnimData **r_adt, bAction **r_action, bool *r_driven, bool *r_special)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
PointerRNA WM_operator_properties_create_ptr(wmOperatorType *ot)
@ WM_DRAG_COLOR
Definition WM_types.hh:1312
bool RNA_property_driver_editable(const PointerRNA *ptr, PropertyRNA *prop)
int RNA_int_get(PointerRNA *ptr, const char *name)
wmWindow * CTX_wm_window(const bContext *C)
@ ID_REMAP_SKIP_INDIRECT_USAGE
void BKE_object_material_assign(Main *bmain, Object *ob, Material *ma, short act, int assign_type)
std::optional< std::string > RNA_path_from_real_ID_to_property_index(Main *bmain, const PointerRNA *ptr, PropertyRNA *prop, int index_dim, int index, ID **r_real_id)
Definition rna_path.cc:1242
void ED_region_search_filter_update(const ScrArea *area, ARegion *region)
Definition area.cc:957
wmOperatorStatus WM_generic_select_invoke(bContext *C, wmOperator *op, const wmEvent *event)
void ED_region_tag_redraw(ARegion *region)
Definition area.cc:681
eID_OverrideLib_Op
Definition DNA_ID.h:182
@ LIBOVERRIDE_OP_REPLACE
Definition DNA_ID.h:188
void ED_region_do_draw(bContext *C, ARegion *region)
Definition area.cc:515
void BKE_pose_ensure_bone_indices(const Object &pose_object)
void PyC_FileAndNum_Safe(const char **r_filename, int *r_lineno)
StructRNA RNA_PropertyGroup
ViewLayer * CTX_data_view_layer(const bContext *C)
void WM_draw_region_viewport_bind(ARegion *region)
Definition wm_draw.cc:1837
AnimData * BKE_animdata_ensure_id(ID *id)
Definition anim_data.cc:107
bool RNA_property_array_check(PropertyRNA *prop)
const bContextStore * CTX_store_get(const bContext *C)
PropertyType RNA_property_type(PropertyRNA *prop)
AnimData * BKE_animdata_from_id(const ID *id)
Definition anim_data.cc:93
std::string WM_operator_pystring_ex(bContext *C, wmOperator *op, const bool all_args, const bool macro_args, wmOperatorType *ot, PointerRNA *opptr)
@ WM_EVENT_SCROLL_INVERT
Definition WM_types.hh:737
void * MEM_new_zeroed(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
void ED_region_tag_refresh_ui(ARegion *region)
Definition area.cc:738
@ PROP_BOOLEAN
Definition RNA_types.hh:210
@ PROP_POINTER
Definition RNA_types.hh:215
@ PROP_STRING
Definition RNA_types.hh:213
bool BLI_rctf_compare(const struct rctf *rect_a, const struct rctf *rect_b, float limit)
void BLI_remlink(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:138
void DEG_id_tag_update(ID *id, unsigned int flags)
std::string RNA_path_from_ptr_to_property_index(const PointerRNA *ptr, PropertyRNA *prop, int index_dim, int index)
Definition rna_path.cc:1212
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition report.cc:162
void ED_undo_push(bContext *C, const char *str, UndoEncodeHints hints=UndoEncodeHints(0))
Definition ed_undo.cc:103
ARegion * BKE_screen_find_region_xy(const bScreen *screen, int regiontype, const int xy[2]) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1
Definition screen.cc:1079
BLI_INLINE void IMB_colormanagement_srgb_to_scene_linear_v3(float scene_linear[3], const float srgb[3])
std::optional< std::string > RNA_path_resolve_from_type_to_property(const PointerRNA *ptr, PropertyRNA *prop, const StructRNA *type)
Definition rna_path.cc:1260
@ BKE_MAT_ASSIGN_USERPREF
void RNA_property_unset(PointerRNA *ptr, PropertyRNA *prop)
FCurve * BKE_fcurve_copy(const FCurve *fcu)
bool RNA_property_collection_lookup_string(PointerRNA *ptr, PropertyRNA *prop, const char *key, PointerRNA *r_ptr)
constexpr size_t ARRAY_SIZE(const T(&arg)[N]) noexcept
PointerRNA CTX_data_pointer_get_type_silent(const bContext *C, const char *member, StructRNA *type)
bool BKE_view_layer_synced_ensure(const Main &bmain, const Scene *scene, ViewLayer *view_layer)
void ED_outliner_selected_objects_get(const bContext *C, ListBaseT< LinkData > *objects)
void BLT_lang_init()
Definition blt_lang.cc:195
wmKeyMap * WM_keymap_ensure(wmKeyConfig *keyconf, const char *idname, int spaceid, int regionid)
Definition wm_keymap.cc:935
bool ED_operator_regionactive(bContext *C)
IDOverrideLibraryProperty * RNA_property_override_property_find(Main *bmain, PointerRNA *ptr, PropertyRNA *prop, ID **r_owner_id)
bool RNA_property_is_idprop(const PropertyRNA *prop)
PointerRNA RNA_pointer_create_discrete(ID *id, StructRNA *type, void *data)
PropertyRNA * RNA_struct_type_find_property(StructRNA *srna, const char *identifier)
void BKE_lib_override_library_property_operation_delete(IDOverrideLibraryProperty *liboverride_property, IDOverrideLibraryPropertyOperation *liboverride_property_operation)
void BKE_lib_override_library_id_reset(Main *bmain, ID *id_root, bool do_reset_system_override)
void RNA_property_float_set_array_at_most(PointerRNA *ptr, PropertyRNA *prop, const float *values, int values_num)
eRNAOverrideStatus RNA_property_override_library_status(Main *bmain, PointerRNA *ptr, PropertyRNA *prop, const int index)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
void CTX_wm_region_popup_set(bContext *C, ARegion *region_popup)
wmOperatorStatus WM_generic_select_modal(bContext *C, wmOperator *op, const wmEvent *event)
void ED_imapaint_bucket_fill(bContext *C, const float color[3], wmOperator *op, const int mouse[2])
int RNA_property_array_dimension(const PointerRNA *ptr, PropertyRNA *prop, int length[])
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
void RNA_boolean_set(PointerRNA *ptr, const char *name, bool value)
SpaceImage * CTX_wm_space_image(const bContext *C)
PropertySubType RNA_property_subtype(PropertyRNA *prop)
wmOperatorType * WM_operatortype_find(const char *idname, bool quiet)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
void BKE_fcurve_free(FCurve *fcu)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
Definition report.cc:191
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:118
Main * CTX_data_main(const bContext *C)
bool BKE_lib_override_library_is_hierarchy_leaf(Main *bmain, ID *id)
bool WM_menutype_add(MenuType *mt)
std::optional< std::string > RNA_path_from_ID_to_property_index(const PointerRNA *ptr, PropertyRNA *prop, int index_dim, int index)
Definition rna_path.cc:1220
void BLF_cache_clear()
Definition blf.cc:100
std::optional< std::string > RNA_path_full_property_py_ex(const PointerRNA *ptr, PropertyRNA *prop, int index, bool use_fallback)
Definition rna_path.cc:1341
void WM_clipboard_text_set(const char *buf, bool selection)
void CTX_data_collection_remap_property(MutableSpan< PointerRNA > collection_pointers, const char *propname)
@ ID_RECALC_SELECT
Definition DNA_ID.h:1101
@ ID_RECALC_TRANSFORM
Definition DNA_ID.h:1054
@ ID_RECALC_SYNC_TO_EVAL
Definition DNA_ID.h:1118
@ ID_RECALC_BASE_FLAGS
Definition DNA_ID.h:1104
wmOperatorStatus WM_operator_name_call_ptr(bContext *C, wmOperatorType *ot, wm::OpCallContext context, PointerRNA *properties, const wmEvent *event)
ID_Type GS(const char *name)
Definition DNA_ID.h:410
@ PROP_SKIP_SAVE
Definition RNA_types.hh:414
ARegion * CTX_wm_region_popup(const bContext *C)
Base * BKE_view_layer_base_find(ViewLayer *view_layer, Object *ob)
@ ID_TAG_DOIT
Definition DNA_ID.h:1029
bool RNA_property_editable(const PointerRNA *ptr, PropertyRNA *prop)
void DEG_relations_tag_update(Main *bmain)
Scene * CTX_data_scene(const bContext *C)
bool BKE_region_panel_categories_search_filter_visible(const ARegion *region)
Definition screen.cc:422
bScreen * CTX_wm_screen(const bContext *C)
void CTX_wm_region_set(bContext *C, ARegion *region)
@ OPTYPE_REGISTER
Definition WM_types.hh:188
@ OPTYPE_UNDO
Definition WM_types.hh:190
@ OPTYPE_INTERNAL
Definition WM_types.hh:210
@ RGN_FLAG_SEARCH_FILTER_SHOW
std::string RNA_string_get(PointerRNA *ptr, const char *name)
void ANIM_copy_as_driver(ID *target_id, const char *target_path, const char *var_name)
Definition drivers.cc:761
BLI_INLINE void IMB_colormanagement_scene_linear_to_srgb_v3(float srgb[3], const float scene_linear[3])
FCurve * BKE_fcurve_find(ListBaseT< FCurve > *list, const char rna_path[], int array_index)
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
void ED_region_activate_rna_prop(bContext *C, ARegion *region, const void *data, StringRefNull prop_name)
Definition area.cc:696
void WM_event_add_mousemove(wmWindow *win)
void BKE_lib_override_library_property_delete(IDOverrideLibrary *liboverride, IDOverrideLibraryProperty *liboverride_property)
bool RNA_path_resolve_property(const PointerRNA *ptr, const char *path, PointerRNA *r_ptr, PropertyRNA **r_prop)
Definition rna_path.cc:578
std::optional< std::string > RNA_path_from_struct_to_idproperty(PointerRNA *ptr, const IDProperty *needle)
Definition rna_path.cc:984
ARegion * CTX_wm_region(const bContext *C)
IDOverrideLibraryPropertyOperation * BKE_lib_override_library_property_operation_get(IDOverrideLibraryProperty *liboverride_property, eID_OverrideLib_Op operation, const char *subitem_refname, const char *subitem_locname, const std::optional< ID * > &subitem_refid, const std::optional< ID * > &subitem_locid, int subitem_refindex, int subitem_locindex, bool strict, bool *r_strict, bool *r_created)
void WM_operator_properties_generic_select(wmOperatorType *ot)
void WM_draw_region_viewport_unbind(ARegion *region)
Definition wm_draw.cc:1842
PointerRNA CTX_data_pointer_get_type(const bContext *C, const char *member, StructRNA *type)
bool RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop)
const char * RNA_property_ui_name(const PropertyRNA *prop, const PointerRNA *ptr)
void RNA_float_get_array(PointerRNA *ptr, const char *name, float *values)
bool RNA_property_copy(Main *bmain, PointerRNA *ptr, PointerRNA *fromptr, PropertyRNA *prop, int index, IDOverrideLibraryProperty *removed_oprop, IDOverrideLibraryPropertyOperation *removed_opop)
#define hash
Definition noise_c.cc:156
void(*) layout(const bContext *C, ARegion *region)
bke::ARegionRuntime * runtime
eRegion_Type regiontype
ListBaseT< FCurve > drivers
struct Object * object
ListBaseT< FModifier > modifiers
eFModifier_Types type
ListBaseT< IDOverrideLibraryPropertyOperation > operations
Definition DNA_ID.h:326
char name[258]
Definition DNA_ID.h:433
IDOverrideLibrary * override_library
Definition DNA_ID.h:495
KeyBlockFlag flag
ListBaseT< KeyBlock > block
char idname[BKE_ST_MAXNAME]
bool(*) poll(const bContext *C, MenuType *mt)
char label[BKE_ST_MAXNAME]
void(*) draw(const bContext *C, Menu *menu)
ui::Layout * layout
T * data_as() const
Definition RNA_types.hh:139
StructRNA * type
Definition RNA_types.hh:63
bool has_data() const
Definition RNA_types.hh:169
bool has_owner_id() const
Definition RNA_types.hh:186
struct RenderData r
eSpaceImage_Mode mode
ListBaseT< EditBone > * edbo
bNodeTreeInterface tree_interface
ListBaseT< ui::Block > uiblocks
struct ARegionType * type
Set< std::string > categories_search_match
std::shared_ptr< void > arg
ButtonSearchUpdateFn items_update_fn
wmOperatorType * optype
PointerRNA op(wmOperatorType *ot, std::optional< StringRef > name, int icon, wm::OpCallContext context, eUI_Item_Flag flag)
eWM_DragDataType type
Definition WM_types.hh:1424
PointerRNA * ptr
Definition WM_types.hh:1524
eWM_EventFlag flag
Definition WM_types.hh:848
wmOperatorStatus(*) exec(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1125
const char * description
Definition WM_types.hh:1115
bool(*) poll(bContext *C) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1165
wmOperatorStatus(*) invoke(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1141
wmOperatorStatus(*) modal(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1157
struct ReportList * reports
bke::WindowRuntime * runtime
#define N_(msgid)