Blender V5.3
outliner_dragdrop.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2004 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include <climits>
10#include <cstring>
11#include <variant>
12
13#include "MEM_guardedalloc.h"
14
16#include "DNA_material_types.h"
17#include "DNA_object_types.h"
18#include "DNA_space_types.h"
19
20#include "BLI_listbase.hh"
21
22#include "BLT_translation.hh"
23
24#include "BKE_collection.hh"
25#include "BKE_context.hh"
26#include "BKE_layer.hh"
27#include "BKE_lib_id.hh"
28#include "BKE_library.hh"
29#include "BKE_main.hh"
30#include "BKE_material.hh"
31#include "BKE_object.hh"
32#include "BKE_report.hh"
33
34#include "DEG_depsgraph.hh"
36
37#include "ED_object.hh"
38#include "ED_outliner.hh"
39#include "ED_screen.hh"
40
41#include "UI_interface.hh"
42#include "UI_view2d.hh"
43
44#include "RNA_access.hh"
45
46#include "WM_api.hh"
47#include "WM_types.hh"
48
49#include "outliner_intern.hh"
50
51namespace blender::ed::outliner {
52
54
55/* -------------------------------------------------------------------- */
58
60 const float fmval[2],
61 const bool children)
62{
63 if ((fmval[1] > te->ys) && (fmval[1] < (te->ys + UI_UNIT_Y))) {
64 /* name and first icon */
65 if ((fmval[0] > te->xs + UI_UNIT_X) && (fmval[0] < te->xend)) {
66 return te;
67 }
68 }
69 /* Not it. Let's look at its children. */
70 if (children && (TREESTORE(te)->flag & TSE_CLOSED) == 0 && (te->subtree.first())) {
71 for (TreeElement &te_sub : te->subtree) {
72 TreeElement *te_valid = outliner_dropzone_element(&te_sub, fmval, children);
73 if (te_valid) {
74 return te_valid;
75 }
76 }
77 }
78 return nullptr;
79}
80
81/* Find tree element to drop into. */
82static TreeElement *outliner_dropzone_find(const SpaceOutliner *space_outliner,
83 const float fmval[2],
84 const bool children)
85{
86 for (TreeElement &te : space_outliner->runtime->tree) {
87 TreeElement *te_valid = outliner_dropzone_element(&te, fmval, children);
88 if (te_valid) {
89 return te_valid;
90 }
91 }
92 return nullptr;
93}
94
96{
97 ARegion *region = CTX_wm_region(C);
98 SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
99 float fmval[2];
100 ui::view2d_region_to_view(&region->v2d, event->mval[0], event->mval[1], &fmval[0], &fmval[1]);
101
102 return outliner_dropzone_find(space_outliner, fmval, true);
103}
104
105static ID *outliner_ID_drop_find(bContext *C, const wmEvent *event, short idcode)
106{
107 TreeElement *te = outliner_drop_find(C, event);
108 TreeStoreElem *tselem = (te) ? TREESTORE(te) : nullptr;
109
110 if (te && (te->idcode == idcode) && (tselem->type == TSE_SOME_ID)) {
111 return tselem->id;
112 }
113 return nullptr;
114}
115
116/* Find tree element to drop into, with additional before and after reorder support. */
118 const int xy[2],
119 TreeElementInsertType *r_insert_type)
120{
121 SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
122 ARegion *region = CTX_wm_region(C);
123 TreeElement *te_hovered;
124 float view_mval[2];
125
126 /* Empty tree, e.g. while filtered. */
127 if (space_outliner->runtime->tree.is_empty()) {
128 return nullptr;
129 }
130
131 int mval[2];
132 mval[0] = xy[0] - region->winrct.xmin;
133 mval[1] = xy[1] - region->winrct.ymin;
134
135 ui::view2d_region_to_view(&region->v2d, mval[0], mval[1], &view_mval[0], &view_mval[1]);
136 te_hovered = outliner_find_item_at_y(
137 space_outliner, &space_outliner->runtime->tree, view_mval[1]);
138
139 if (te_hovered) {
140 /* Mouse hovers an element (ignoring x-axis),
141 * now find out how to insert the dragged item exactly. */
142 const float margin = UI_UNIT_Y * (1.0f / 4);
143
144 if (view_mval[1] < (te_hovered->ys + margin)) {
145 if (TSELEM_OPEN(TREESTORE(te_hovered), space_outliner) && !te_hovered->subtree.is_empty()) {
146 /* inserting after a open item means we insert into it, but as first child */
147 if (te_hovered->subtree.is_empty()) {
148 *r_insert_type = TE_INSERT_INTO;
149 return te_hovered;
150 }
151 *r_insert_type = TE_INSERT_BEFORE;
152 return te_hovered->subtree.first();
153 }
154 *r_insert_type = TE_INSERT_AFTER;
155 return te_hovered;
156 }
157 if (view_mval[1] > (te_hovered->ys + (3 * margin))) {
158 *r_insert_type = TE_INSERT_BEFORE;
159 return te_hovered;
160 }
161 *r_insert_type = TE_INSERT_INTO;
162 return te_hovered;
163 }
164
165 /* Mouse doesn't hover any item (ignoring x-axis),
166 * so it's either above list bounds or below. */
167 TreeElement *first = space_outliner->runtime->tree.first();
168 TreeElement *last = space_outliner->runtime->tree.last();
169
170 if (view_mval[1] < last->ys) {
171 *r_insert_type = TE_INSERT_AFTER;
172 return last;
173 }
174 if (view_mval[1] > (first->ys + UI_UNIT_Y)) {
175 *r_insert_type = TE_INSERT_BEFORE;
176 return first;
177 }
178
180 return nullptr;
181}
182
183using CheckTypeFn = bool (*)(TreeElement *te);
184
186 TreeElement *te)
187{
188 while (te != nullptr) {
189 if (check_type(te)) {
190 return te;
191 }
192 te = te->parent;
193 }
194 return nullptr;
195}
196
201
202/* Check if a collection is being dragged inside its own hierarchy. */
203static bool outliner_is_collection_dragged_into_itself(TreeElement *drop_target_te, ID *dragged_id)
204{
205 if (!(drop_target_te && dragged_id && GS(dragged_id->name) == ID_GR)) {
206 return false;
207 }
208
209 /* The drop_target_te could be anything. So, traverse up to get the
210 * parent tree_element that represents a collection. */
212 drop_target_te);
213
214 while (coll_te && coll_te->parent != nullptr) {
215 /* Get the actual collection type. */
216 Collection *te_parent_coll = outliner_collection_from_tree_element(coll_te->parent);
217
218 if (&te_parent_coll->id == dragged_id) {
219 /* The destination te is inside the dragged collection's hierarchy. */
220 return true;
221 }
222
223 /* Keep going up the hierarchy */
224 coll_te = coll_te->parent;
225 }
226 return false;
227}
228
230{
231 TreeStoreElem *tselem = TREESTORE(te);
232 return (tselem->type == TSE_SOME_ID) && te->idcode == ID_OB;
233}
234
236{
237 TreeStoreElem *tselem = TREESTORE(te);
238 return tselem->type == TSE_POSE_CHANNEL;
239}
240
242 const int xy[2],
243 TreeElementInsertType *r_insert_type)
244{
245 TreeElement *te = outliner_drop_insert_find(C, xy, r_insert_type);
246 if (!te) {
247 return nullptr;
248 }
249
251 te);
252 if (!collection_te) {
253 return nullptr;
254 }
255
256 /* We can't insert before/after/into a collection that itself is selected/dragged. */
257 TreeStoreElem *collection_tselem = TREESTORE(collection_te);
258 if ((collection_tselem->flag & TSE_SELECTED) != 0) {
259 return nullptr;
260 }
261
262 Collection *collection = outliner_collection_from_tree_element(collection_te);
263
264 /* We can't insert before/after master collection. */
265 if (collection->flag & COLLECTION_IS_MASTER) {
266 const bool is_object_row = is_object_element(te);
267
268 if (!is_object_row) {
269 *r_insert_type = TE_INSERT_INTO;
270 }
271 }
272
273 return te;
274}
275
276template<typename T>
278 TreeElement *drop_te,
279 TreeElementInsertType insert_type,
280 ListBaseT<T> *listbase)
281{
282 /* Find the element to insert after. Null is the start of the list. */
283 if (drag_te->index < drop_te->index) {
284 if (insert_type == TE_INSERT_BEFORE) {
285 drop_te = drop_te->prev;
286 }
287 }
288 else {
289 if (insert_type == TE_INSERT_AFTER) {
290 drop_te = drop_te->next;
291 }
292 }
293
294 if (drop_te == nullptr) {
295 return 0;
296 }
297
298 return BLI_findindex(listbase, drop_te->directdata);
299}
300
302
303/* -------------------------------------------------------------------- */
306
307static bool parent_drop_allowed(const Main &bmain, TreeElement *te, Object *potential_child)
308{
309 TreeStoreElem *tselem = TREESTORE(te);
310 if ((te->idcode != ID_OB) || (tselem->type != TSE_SOME_ID)) {
311 return false;
312 }
313
314 Object *potential_parent = id_cast<Object *>(tselem->id);
315
316 if (potential_parent == potential_child) {
317 return false;
318 }
319 if (BKE_object_is_child_recursive(potential_child, potential_parent)) {
320 return false;
321 }
322 if (potential_parent == potential_child->parent) {
323 return false;
324 }
325
326 /* check that parent/child are both in the same scene */
327 Scene *scene = id_cast<Scene *>(outliner_search_back(te, ID_SCE));
328
329 /* currently outliner organized in a way that if there's no parent scene
330 * element for object it means that all displayed objects belong to
331 * active scene and parenting them is allowed (sergey) */
332 if (scene) {
333 for (ViewLayer &view_layer : scene->view_layers) {
334 BKE_view_layer_synced_ensure(bmain, scene, &view_layer);
335 if (BKE_view_layer_base_find(&view_layer, potential_child)) {
336 return true;
337 }
338 }
339 return false;
340 }
341 return true;
342}
343
345{
346 switch (space_outliner->outlinevis) {
347 case SO_VIEW_LAYER:
348 return space_outliner->filter & SO_FILTER_NO_COLLECTION;
349 case SO_SCENES:
350 return true;
351 default:
352 return false;
353 }
354}
355
356static bool drag_ids_are_all_objects(const wmDrag *drag)
357{
358 for (const wmDragID &drag_id : drag->ids) {
359 if (GS(drag_id.id->name) != ID_OB) {
360 return false;
361 }
362 }
363 return true;
364}
365
366static bool parent_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
367{
368 SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
369
370 bool changed = outliner_flag_set(*space_outliner, TSE_DRAG_ANY, false);
371 if (changed) {
373 }
374
375 Object *potential_child = id_cast<Object *>(WM_drag_get_local_ID(drag, ID_OB));
376 if (!potential_child) {
377 return false;
378 }
379
380 if (!drag_ids_are_all_objects(drag)) {
381 return false;
382 }
383
384 if (!allow_parenting_without_modifier_key(space_outliner)) {
385 if ((event->modifier & (KM_SHIFT | KM_CTRL)) != KM_SHIFT) {
386 return false;
387 }
388 }
389
390 TreeElement *te = outliner_drop_find(C, event);
391 if (!te) {
392 return false;
393 }
394
395 const Main *bmain = CTX_data_main(C);
396
397 if (parent_drop_allowed(*bmain, te, potential_child)) {
398 TREESTORE(te)->flag |= TSE_DRAG_INTO;
400 return true;
401 }
402
403 return false;
404}
405
407 ReportList *reports,
408 wmDragID *drag,
409 Object *parent,
410 short parent_type,
411 const bool keep_transform)
412{
413 Main *bmain = CTX_data_main(C);
414 SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
415
417 space_outliner, &space_outliner->runtime->tree, &parent->id, TreeElementFlag(0));
418 Scene *scene = id_cast<Scene *>(outliner_search_back(te, ID_SCE));
419
420 if (scene == nullptr) {
421 /* currently outliner organized in a way, that if there's no parent scene
422 * element for object it means that all displayed objects belong to
423 * active scene and parenting them is allowed (sergey)
424 */
425
426 scene = CTX_data_scene(C);
427 }
428
429 bool parent_set = false;
430 bool linked_objects = false;
431
432 for (wmDragID *drag_id = drag; drag_id; drag_id = drag_id->next) {
433 if (GS(drag_id->id->name) == ID_OB) {
434 Object *object = id_cast<Object *>(drag_id->id);
435
436 /* Do nothing to linked data */
437 if (!BKE_id_is_editable(bmain, &object->id)) {
438 linked_objects = true;
439 continue;
440 }
441
443 reports, C, scene, object, parent, parent_type, false, keep_transform, nullptr))
444 {
445 parent_set = true;
446 }
447 }
448 }
449
450 if (linked_objects) {
451 BKE_report(reports, RPT_INFO, "Cannot edit library linked or non-editable override object(s)");
452 }
453
454 if (parent_set) {
458 }
459}
460
462{
463 TreeElement *te = outliner_drop_find(C, event);
464 TreeStoreElem *tselem = te ? TREESTORE(te) : nullptr;
465
466 if (!(te && (te->idcode == ID_OB) && (tselem->type == TSE_SOME_ID))) {
467 return OPERATOR_CANCELLED;
468 }
469
470 Object *par = id_cast<Object *>(tselem->id);
471 Object *ob = id_cast<Object *>(WM_drag_get_local_ID_from_event(event, ID_OB));
472
473 if (ELEM(nullptr, ob, par)) {
474 return OPERATOR_CANCELLED;
475 }
476 if (ob == par) {
477 return OPERATOR_CANCELLED;
478 }
479
480 if (event->custom != EVT_DATA_DRAGDROP) {
481 return OPERATOR_CANCELLED;
482 }
483
484 ListBaseT<wmDrag> *lb = static_cast<ListBaseT<wmDrag> *>(event->customdata);
485 wmDrag *drag = lb->first();
486
488 C, op->reports, drag->ids.first(), par, object::PAR_OBJECT, !(event->modifier & KM_ALT));
489
490 return OPERATOR_FINISHED;
491}
492
494{
495 /* identifiers */
496 ot->name = "Drop to Set Parent (hold Alt to not keep transforms)";
497 ot->description = "Drag to parent in Outliner";
498 ot->idname = "OUTLINER_OT_parent_drop";
499
500 /* API callbacks. */
502
504
505 /* flags */
507}
508
510
511/* -------------------------------------------------------------------- */
514
515static bool parent_clear_poll(bContext *C, wmDrag *drag, const wmEvent *event)
516{
517 SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
518
519 if (!allow_parenting_without_modifier_key(space_outliner)) {
520 if ((event->modifier & KM_SHIFT) == 0) {
521 return false;
522 }
523 }
524
525 Object *ob = id_cast<Object *>(WM_drag_get_local_ID(drag, ID_OB));
526 if (!ob) {
527 return false;
528 }
529 if (!ob->parent) {
530 return false;
531 }
532
533 TreeElement *te = outliner_drop_find(C, event);
534 if (te) {
535 TreeStoreElem *tselem = TREESTORE(te);
536 ID *id = tselem->id;
537 if (!id) {
538 return true;
539 }
540
541 switch (GS(id->name)) {
542 case ID_OB:
544 case ID_GR:
545 return (event->modifier & KM_SHIFT) || ELEM(tselem->type, TSE_LIBRARY_OVERRIDE_BASE);
546 default:
547 return true;
548 }
549 }
550 else {
551 return true;
552 }
553}
554
556{
557 Main *bmain = CTX_data_main(C);
558
559 if (event->custom != EVT_DATA_DRAGDROP) {
560 return OPERATOR_CANCELLED;
561 }
562
563 ListBaseT<wmDrag> *lb = static_cast<ListBaseT<wmDrag> *>(event->customdata);
564 wmDrag *drag = lb->first();
565
566 for (wmDragID &drag_id : drag->ids) {
567 if (GS(drag_id.id->name) == ID_OB) {
568 Object *object = id_cast<Object *>(drag_id.id);
569
571 object,
574 }
575 }
576
580 return OPERATOR_FINISHED;
581}
582
584{
585 /* identifiers */
586 ot->name = "Drop to Clear Parent (hold Alt to not keep transforms)";
587 ot->description = "Drag to clear parent in Outliner";
588 ot->idname = "OUTLINER_OT_parent_clear";
589
590 /* API callbacks. */
592
594
595 /* flags */
597}
598
600
601/* -------------------------------------------------------------------- */
604
605static bool scene_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
606{
607 /* Ensure item under cursor is valid drop target */
608 Object *ob = id_cast<Object *>(WM_drag_get_local_ID(drag, ID_OB));
609 return (ob && (outliner_ID_drop_find(C, event, ID_SCE) != nullptr));
610}
611
613{
614 Main *bmain = CTX_data_main(C);
615 Scene *scene = id_cast<Scene *>(outliner_ID_drop_find(C, event, ID_SCE));
616 Object *ob = id_cast<Object *>(WM_drag_get_local_ID_from_event(event, ID_OB));
617
618 if (ELEM(nullptr, ob, scene) || !BKE_id_is_editable(bmain, &scene->id)) {
619 return OPERATOR_CANCELLED;
620 }
621
622 if (BKE_scene_has_object(*bmain, scene, ob)) {
623 return OPERATOR_CANCELLED;
624 }
625
626 Collection *collection;
627 if (scene != CTX_data_scene(C)) {
628 /* when linking to an inactive scene link to the master collection */
629 collection = scene->master_collection;
630 }
631 else {
632 collection = CTX_data_collection(C);
633 }
634
635 BKE_collection_object_add(bmain, collection, ob);
636
637 for (ViewLayer &view_layer : scene->view_layers) {
638 BKE_view_layer_synced_ensure(*bmain, scene, &view_layer);
639 Base *base = BKE_view_layer_base_find(&view_layer, ob);
640 if (base) {
642 }
643 }
644
647
650
651 return OPERATOR_FINISHED;
652}
653
655{
656 /* identifiers */
657 ot->name = "Drop Object to Scene";
658 ot->description = "Drag object to scene in Outliner";
659 ot->idname = "OUTLINER_OT_scene_drop";
660
661 /* API callbacks. */
663
665
666 /* flags */
668}
669
671
672/* -------------------------------------------------------------------- */
675
676static bool material_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
677{
678 /* Ensure item under cursor is valid drop target */
679 Material *ma = id_cast<Material *>(WM_drag_get_local_ID(drag, ID_MA));
680 Object *ob = reinterpret_cast<Object *>(outliner_ID_drop_find(C, event, ID_OB));
681
682 return (!ELEM(nullptr, ob, ma) && ID_IS_EDITABLE(&ob->id) && !ID_IS_OVERRIDE_LIBRARY(&ob->id));
683}
684
686 wmOperator * /*op*/,
687 const wmEvent *event)
688{
689 Main *bmain = CTX_data_main(C);
690 Object *ob = id_cast<Object *>(outliner_ID_drop_find(C, event, ID_OB));
691 Material *ma = id_cast<Material *>(WM_drag_get_local_ID_from_event(event, ID_MA));
692
693 if (ELEM(nullptr, ob, ma) || !BKE_id_is_editable(bmain, &ob->id)) {
694 return OPERATOR_CANCELLED;
695 }
696
697 /* only drop grease pencil material on grease pencil objects */
698 if ((ma->gp_style != nullptr) && (ob->type != OB_GREASE_PENCIL)) {
699 return OPERATOR_CANCELLED;
700 }
701
703
707
708 return OPERATOR_FINISHED;
709}
710
712{
713 /* identifiers */
714 ot->name = "Drop Material on Object";
715 ot->description = "Drag material to object in Outliner";
716 ot->idname = "OUTLINER_OT_material_drop";
717
718 /* API callbacks. */
720
722
723 /* flags */
725}
726
728
729/* -------------------------------------------------------------------- */
740
746
758
760 Object *ob,
761 bPoseChannel *pchan,
762 TreeElement *te,
763 TreeStoreElem *tselem,
764 void *directdata)
765{
766 StackDropData *drop_data = MEM_new_zeroed<StackDropData>("datastack drop data");
767
768 drop_data->ob_parent = ob;
769 drop_data->pchan_parent = pchan;
770 drop_data->drag_tselem = tselem;
771 drop_data->drag_directdata = directdata;
772 drop_data->drag_index = te->index;
773
774 drag->poin = drop_data;
775 drag->flags |= WM_DRAG_FREE_DATA;
776}
777
778static bool datastack_drop_init(bContext *C, const wmEvent *event, StackDropData *drop_data)
779{
780 if (!ELEM(drop_data->drag_tselem->type,
787 {
788 return false;
789 }
790
791 TreeElement *te_target = outliner_drop_insert_find(C, event->xy, &drop_data->insert_type);
792 if (!te_target) {
793 return false;
794 }
795 TreeStoreElem *tselem_target = TREESTORE(te_target);
796
797 if (drop_data->drag_tselem == tselem_target) {
798 return false;
799 }
800
801 Object *ob = nullptr;
803 te_target);
804 if (object_te) {
805 ob = id_cast<Object *>(TREESTORE(object_te)->id);
806 }
807
808 bPoseChannel *pchan = nullptr;
810 if (pchan_te) {
811 pchan = static_cast<bPoseChannel *>(pchan_te->directdata);
812 }
813 if (pchan) {
814 ob = nullptr;
815 }
816
817 if (ob && !BKE_id_is_editable(CTX_data_main(C), &ob->id)) {
818 return false;
819 }
820
821 /* Drag a base for linking. */
822 if (ELEM(drop_data->drag_tselem->type,
826 {
827 drop_data->insert_type = TE_INSERT_INTO;
829
830 if (pchan && pchan != drop_data->pchan_parent) {
831 drop_data->drop_te = pchan_te;
832 tselem_target = TREESTORE(pchan_te);
833 }
834 else if (ob && ob != drop_data->ob_parent) {
835 drop_data->drop_te = object_te;
836 tselem_target = TREESTORE(object_te);
837 }
838 else {
839 return false;
840 }
841 }
842 else if (ob || pchan) {
843 /* Drag a single item. */
844 if (pchan && pchan != drop_data->pchan_parent) {
845 drop_data->insert_type = TE_INSERT_INTO;
847 drop_data->drop_te = pchan_te;
848 tselem_target = TREESTORE(pchan_te);
849 }
850 else if (ob && ob != drop_data->ob_parent) {
851 drop_data->insert_type = TE_INSERT_INTO;
853 drop_data->drop_te = object_te;
854 tselem_target = TREESTORE(object_te);
855 }
856 else if (tselem_target->type == drop_data->drag_tselem->type) {
857 if (drop_data->insert_type == TE_INSERT_INTO) {
858 return false;
859 }
861 drop_data->drop_te = te_target;
862 }
863 else {
864 return false;
865 }
866 }
867 else {
868 return false;
869 }
870
871 return true;
872}
873
874/* Ensure that grease pencil and object data remain separate. */
876{
877 TreeStoreElem *tselem = TREESTORE(drop_data->drop_te);
878 Object *ob_parent = drop_data->ob_parent;
879 Object *ob_dst = id_cast<Object *>(tselem->id);
880
881 /* Don't allow data to be moved between objects and bones. */
882 if (tselem->type == TSE_CONSTRAINT) {
883 }
884 else if ((drop_data->pchan_parent && tselem->type != TSE_POSE_CHANNEL) ||
885 (!drop_data->pchan_parent && tselem->type == TSE_POSE_CHANNEL))
886 {
887 return false;
888 }
889
890 switch (drop_data->drag_tselem->type) {
892 case TSE_MODIFIER:
893 return (ob_parent->type == OB_GREASE_PENCIL) == (ob_dst->type == OB_GREASE_PENCIL);
894 break;
896 case TSE_CONSTRAINT:
897
898 break;
901 return ob_parent->type == OB_GREASE_PENCIL && ob_dst->type == OB_GREASE_PENCIL;
902 break;
903 default:
904 break;
905 }
906
907 return true;
908}
909
910static bool datastack_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
911{
912 if (drag->type != WM_DRAG_DATASTACK) {
913 return false;
914 }
915
916 SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
917 ARegion *region = CTX_wm_region(C);
918 bool changed = outliner_flag_set(*space_outliner, TSE_HIGHLIGHTED_ANY | TSE_DRAG_ANY, false);
919
920 StackDropData *drop_data = static_cast<StackDropData *>(drag->poin);
921 if (!drop_data) {
922 return false;
923 }
924
925 if (!datastack_drop_init(C, event, drop_data)) {
926 return false;
927 }
928
929 if (!datastack_drop_are_types_valid(drop_data)) {
930 return false;
931 }
932
933 TreeStoreElem *tselem_target = TREESTORE(drop_data->drop_te);
934 switch (drop_data->insert_type) {
935 case TE_INSERT_BEFORE:
936 tselem_target->flag |= TSE_DRAG_BEFORE;
937 break;
938 case TE_INSERT_AFTER:
939 tselem_target->flag |= TSE_DRAG_AFTER;
940 break;
941 case TE_INSERT_INTO:
942 tselem_target->flag |= TSE_DRAG_INTO;
943 break;
944 }
945
946 if (changed) {
948 }
949
950 return true;
951}
952
953static std::string datastack_drop_tooltip(bContext * /*C*/,
954 wmDrag *drag,
955 const int /*xy*/[2],
956 wmDropBox * /*drop*/)
957{
958 StackDropData *drop_data = static_cast<StackDropData *>(drag->poin);
959 switch (drop_data->drop_action) {
961 return TIP_("Reorder");
963 if (drop_data->pchan_parent) {
964 return TIP_("Copy to bone");
965 }
966 return TIP_("Copy to object");
967
969 if (drop_data->pchan_parent) {
970 return TIP_("Link all to bone");
971 }
972 return TIP_("Link all to object");
973 }
974 return {};
975}
976
978{
979 Main *bmain = CTX_data_main(C);
980 TreeStoreElem *tselem = TREESTORE(drop_data->drop_te);
981 Object *ob_dst = id_cast<Object *>(tselem->id);
982
983 switch (drop_data->drag_tselem->type) {
985 object::modifier_link(C, ob_dst, drop_data->ob_parent);
986 break;
987 case TSE_CONSTRAINT_BASE: {
988 ListBaseT<bConstraint> *src;
989
990 if (drop_data->pchan_parent) {
991 src = &drop_data->pchan_parent->constraints;
992 }
993 else {
994 src = &drop_data->ob_parent->constraints;
995 }
996
997 ListBaseT<bConstraint> *dst;
998 if (tselem->type == TSE_POSE_CHANNEL) {
999 bPoseChannel *pchan = static_cast<bPoseChannel *>(drop_data->drop_te->directdata);
1000 dst = &pchan->constraints;
1001 }
1002 else {
1003 dst = &ob_dst->constraints;
1004 }
1005
1006 object::constraint_link(bmain, ob_dst, dst, src);
1007 break;
1008 }
1010 if (ob_dst->type != OB_GREASE_PENCIL) {
1011 return;
1012 }
1013
1014 object::shaderfx_link(ob_dst, drop_data->ob_parent);
1015 break;
1016 default:
1017 break;
1018 }
1019}
1020
1022{
1023 Main *bmain = CTX_data_main(C);
1024
1025 TreeStoreElem *tselem = TREESTORE(drop_data->drop_te);
1026 Object *ob_dst = id_cast<Object *>(tselem->id);
1027
1028 switch (drop_data->drag_tselem->type) {
1029 case TSE_MODIFIER: {
1031 bmain,
1033 drop_data->ob_parent,
1034 static_cast<const ModifierData *>(drop_data->drag_directdata),
1035 ob_dst,
1036 CTX_wm_reports(C));
1037 BKE_object_modifier_set_active(ob_dst, md_dst);
1038 break;
1039 }
1040 case TSE_CONSTRAINT:
1041 if (tselem->type == TSE_POSE_CHANNEL) {
1043 bmain,
1044 ob_dst,
1045 static_cast<bPoseChannel *>(drop_data->drop_te->directdata),
1046 static_cast<bConstraint *>(drop_data->drag_directdata));
1047 }
1048 else {
1050 bmain, ob_dst, static_cast<bConstraint *>(drop_data->drag_directdata));
1051 }
1052 break;
1053 case TSE_GPENCIL_EFFECT: {
1054 if (ob_dst->type != OB_GREASE_PENCIL) {
1055 return;
1056 }
1057
1058 object::shaderfx_copy(ob_dst, static_cast<ShaderFxData *>(drop_data->drag_directdata));
1059 break;
1060 }
1061 default:
1062 break;
1063 }
1064}
1065
1066static void datastack_drop_reorder(bContext *C, ReportList *reports, StackDropData *drop_data)
1067{
1068 SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
1069
1070 TreeElement *drag_te = outliner_find_tree_element(&space_outliner->runtime->tree,
1071 drop_data->drag_tselem);
1072 if (!drag_te) {
1073 return;
1074 }
1075
1076 TreeElement *drop_te = drop_data->drop_te;
1077 TreeElementInsertType insert_type = drop_data->insert_type;
1078
1079 Object *ob = drop_data->ob_parent;
1080
1081 int index = 0;
1082 switch (drop_data->drag_tselem->type) {
1083 case TSE_MODIFIER:
1084 index = outliner_get_insert_index(drag_te, drop_te, insert_type, &ob->modifiers);
1087 ob,
1088 static_cast<ModifierData *>(drop_data->drag_directdata),
1089 index,
1090 true);
1091 break;
1092 case TSE_CONSTRAINT:
1093 if (drop_data->pchan_parent) {
1095 drag_te, drop_te, insert_type, &drop_data->pchan_parent->constraints);
1096 }
1097 else {
1098 index = outliner_get_insert_index(drag_te, drop_te, insert_type, &ob->constraints);
1099 }
1101 ob, static_cast<bConstraint *>(drop_data->drag_directdata), index);
1102
1103 break;
1104 case TSE_GPENCIL_EFFECT:
1105 index = outliner_get_insert_index(drag_te, drop_te, insert_type, &ob->shader_fx);
1107 reports, ob, static_cast<ShaderFxData *>(drop_data->drag_directdata), index);
1108 break;
1109 default:
1110 break;
1111 }
1112}
1113
1115{
1116 if (event->custom != EVT_DATA_DRAGDROP) {
1117 return OPERATOR_CANCELLED;
1118 }
1119
1120 ListBaseT<wmDrag> *lb = static_cast<ListBaseT<wmDrag> *>(event->customdata);
1121 wmDrag *drag = lb->first();
1122 StackDropData *drop_data = static_cast<StackDropData *>(drag->poin);
1123
1124 switch (drop_data->drop_action) {
1126 datastack_drop_link(C, drop_data);
1127 break;
1129 datastack_drop_copy(C, drop_data);
1130 break;
1132 datastack_drop_reorder(C, op->reports, drop_data);
1133 break;
1134 }
1135
1136 return OPERATOR_FINISHED;
1137}
1138
1140{
1141 /* identifiers */
1142 ot->name = "Data Stack Drop";
1143 ot->description = "Copy or reorder modifiers, constraints, and effects";
1144 ot->idname = "OUTLINER_OT_datastack_drop";
1145
1146 /* API callbacks. */
1148
1150
1151 /* flags */
1153}
1154
1156
1157/* -------------------------------------------------------------------- */
1160
1168
1170{
1171 /* Can't change linked or override parent collections. */
1172 if (!id || !ID_IS_EDITABLE(id) || ID_IS_OVERRIDE_LIBRARY(id)) {
1173 return nullptr;
1174 }
1175
1176 /* Also support dropping into/from scene collection. */
1177 if (GS(id->name) == ID_SCE) {
1178 return (id_cast<Scene *>(id))->master_collection;
1179 }
1180 if (GS(id->name) == ID_GR) {
1181 return id_cast<Collection *>(id);
1182 }
1183
1184 return nullptr;
1185}
1186
1187static bool collection_drop_init(bContext *C, wmDrag *drag, const int xy[2], CollectionDrop *data)
1188{
1189 /* Get collection to drop into. */
1190 TreeElementInsertType insert_type;
1191 TreeElement *te = outliner_drop_insert_collection_find(C, xy, &insert_type);
1192 if (!te) {
1193 return false;
1194 }
1195
1198 Collection *to_collection = outliner_collection_from_tree_element(collection_te);
1199
1200 if (!ID_IS_EDITABLE(to_collection) || ID_IS_OVERRIDE_LIBRARY(to_collection)) {
1201 if (insert_type == TE_INSERT_INTO) {
1202 return false;
1203 }
1204 }
1205
1206 /* Get drag datablocks. */
1207 if (drag->type != WM_DRAG_ID) {
1208 return false;
1209 }
1210
1211 wmDragID *drag_id = drag->ids.first();
1212 if (drag_id == nullptr) {
1213 return false;
1214 }
1215
1216 ID *id = drag_id->id;
1217 if (!(id && ELEM(GS(id->name), ID_GR, ID_OB))) {
1218 return false;
1219 }
1220
1222 return false;
1223 }
1224
1225 SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
1226 /* Get collection to drag out of. */
1227 ID *parent = drag_id->from_parent;
1228 Collection *from_collection = collection_parent_from_ID(parent);
1229
1230 /* Currently this should not be allowed, cannot edit items in an override of a Collection. */
1231 if (from_collection != nullptr && ID_IS_OVERRIDE_LIBRARY(from_collection)) {
1232 return false;
1233 }
1234
1235 /* If dragging an object and custom sort is off, only allow dropping INTO the collection.
1236 * If dragging a collection, block dropping it onto itself. */
1237 if (GS(id->name) == ID_OB) {
1238 if (space_outliner->sort_method != SO_SORT_CUSTOM) {
1239 insert_type = TE_INSERT_INTO;
1240 }
1241 else if (te && is_object_element(te)) {
1242 if (insert_type == TE_INSERT_INTO) {
1243 insert_type = TE_INSERT_BEFORE;
1244 }
1245 }
1246
1247 if (te == collection_te && space_outliner->sort_method != SO_SORT_CUSTOM) {
1248 insert_type = TE_INSERT_INTO;
1249 }
1250 }
1251 else if (GS(id->name) == ID_GR) {
1252 if (id == &to_collection->id) {
1253 return false;
1254 }
1255 }
1256
1257 /* Currently this should not be allowed, cannot edit items in an override of a Collection. */
1258 if (ID_IS_OVERRIDE_LIBRARY(to_collection) &&
1259 !ELEM(insert_type, TE_INSERT_AFTER, TE_INSERT_BEFORE))
1260 {
1261 return false;
1262 }
1263
1264 if (ELEM(insert_type, TE_INSERT_BEFORE, TE_INSERT_AFTER)) {
1265 const TreeElement *parent_te = outliner_find_parent_element(
1266 &space_outliner->runtime->tree, nullptr, te);
1267 if (parent_te != nullptr && parent_te->idcode == ID_OB) {
1268 const Object *parent_ob = id_cast<Object *>(TREESTORE(parent_te)->id);
1269 for (const wmDragID &drag_id : drag->ids) {
1270 if (GS(drag_id.id->name) == ID_OB) {
1271 const Object *object = id_cast<const Object *>(drag_id.id);
1272 if (object->parent != parent_ob) {
1273 return false;
1274 }
1275 }
1276 else {
1277 return false;
1278 }
1279 }
1280 }
1281 }
1282
1283 const Collection *target_collection = to_collection;
1284 if (ELEM(insert_type, TE_INSERT_BEFORE, TE_INSERT_AFTER)) {
1285 target_collection = nullptr;
1286 for (const TreeElement *te_parent =
1287 outliner_find_parent_element(&space_outliner->runtime->tree, nullptr, te);
1288 te_parent != nullptr;
1289 te_parent = te_parent->parent)
1290 {
1291 target_collection = outliner_collection_from_tree_element(te_parent);
1292 if (target_collection != nullptr) {
1293 break;
1294 }
1295 }
1296 }
1297
1298 if (target_collection != nullptr &&
1299 (!ID_IS_EDITABLE(target_collection) || ID_IS_OVERRIDE_LIBRARY(target_collection)))
1300 {
1301 return false;
1302 }
1303
1304 data->from = from_collection;
1305 data->to = to_collection;
1306 data->te = te;
1307 data->insert_type = insert_type;
1308
1309 return true;
1310}
1311
1312static bool collection_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
1313{
1314 SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
1315 ARegion *region = CTX_wm_region(C);
1316 bool changed = outliner_flag_set(*space_outliner, TSE_HIGHLIGHTED_ANY | TSE_DRAG_ANY, false);
1317
1319 if (((event->modifier != KM_SHIFT)) && collection_drop_init(C, drag, event->xy, &data)) {
1320 TreeElement *te = data.te;
1321 TreeStoreElem *tselem = TREESTORE(te);
1322 switch (data.insert_type) {
1323 case TE_INSERT_BEFORE:
1324 tselem->flag |= TSE_DRAG_BEFORE;
1325 changed = true;
1326 break;
1327 case TE_INSERT_AFTER:
1328 tselem->flag |= TSE_DRAG_AFTER;
1329 changed = true;
1330 break;
1331 case TE_INSERT_INTO: {
1332 tselem->flag |= TSE_DRAG_INTO;
1333 changed = true;
1334 break;
1335 }
1336 }
1337 if (changed) {
1339 }
1340 return true;
1341 }
1342 if (changed) {
1344 }
1345 return false;
1346}
1347
1349 wmDrag *drag,
1350 const int xy[2],
1351 wmDropBox * /*drop*/)
1352{
1353 wmWindow *win = CTX_wm_window(C);
1354 const wmEvent *event = win ? win->runtime->eventstate : nullptr;
1355
1357 if (event && collection_drop_init(C, drag, xy, &data)) {
1358 const bool is_link = !data.from || ((event->modifier & (KM_SHIFT | KM_CTRL)) == KM_CTRL);
1359
1360 /* Test if we are moving within same parent collection. */
1361 bool same_level = false;
1362 for (CollectionParent &parent : data.to->runtime->parents) {
1363 if (data.from == parent.collection) {
1364 same_level = true;
1365 }
1366 }
1367
1368 TreeElement *te = data.te;
1369
1370 const bool target_is_object_row = is_object_element(te);
1371 const bool target_is_collection_row = is_collection_element(te);
1372
1373 if (!target_is_object_row && !target_is_collection_row) {
1374 return "";
1375 }
1376 const bool tooltip_link = (is_link && !same_level);
1377
1378 /* Adapt the tooltip based on whether the hovered row is an object or collection. */
1379 const char *tooltip_before = tooltip_link ?
1380 (target_is_object_row ? TIP_("Link before object") :
1381 TIP_("Link before collection")) :
1382 (target_is_object_row ? TIP_("Move before object") :
1383 TIP_("Move before collection"));
1384
1385 const char *tooltip_between = tooltip_link ?
1386 (target_is_object_row ? TIP_("Link between objects") :
1387 TIP_("Link between collections")) :
1388 (target_is_object_row ? TIP_("Move between objects") :
1389 TIP_("Move between collections"));
1390
1391 const char *tooltip_after = tooltip_link ?
1392 (target_is_object_row ? TIP_("Link after object") :
1393 TIP_("Link after collection")) :
1394 (target_is_object_row ? TIP_("Move after object") :
1395 TIP_("Move after collection"));
1396
1397 /* Choose the tooltip text based on where the drop will go. */
1398 switch (data.insert_type) {
1399 case TE_INSERT_BEFORE:
1400 if (te->prev && (target_is_object_row ? is_object_element(te->prev) :
1402 {
1403 return tooltip_between;
1404 }
1405 return tooltip_before;
1406 case TE_INSERT_AFTER:
1407 if (te->next && (target_is_object_row ? is_object_element(te->next) :
1409 {
1410 return tooltip_between;
1411 }
1412 return tooltip_after;
1413 case TE_INSERT_INTO: {
1414 if (is_link) {
1415 return TIP_("Link inside collection");
1416 }
1417
1418 /* Check the type of the drag IDs to avoid the incorrect "Shift to parent"
1419 * for collections. Checking the type of the first ID works fine here since
1420 * all drag IDs are the same type. */
1421 wmDragID *drag_id = drag->ids.first();
1422 const bool is_object = (GS(drag_id->id->name) == ID_OB);
1423 if (is_object) {
1424 if (event->modifier & (KM_SHIFT | KM_CTRL)) {
1425 return TIP_("Move parent object inside collection");
1426 }
1427 return TIP_(
1428 "Move inside collection (Ctrl to link, Shift to parent, "
1429 "Ctrl + Shift to move only parent)");
1430 }
1431 return TIP_("Move inside collection (Ctrl to link)");
1432 }
1433 }
1434 }
1435 return {};
1436}
1437
1439 Object *ob,
1440 Vector<Object *> &child_objects)
1441{
1442 for (CollectionObject &cob : from->gobject) {
1443 if (cob.ob->parent == ob) {
1444 child_objects.append(cob.ob);
1445 find_child_objects_recursive(from, cob.ob, child_objects);
1446 }
1447 }
1448}
1449
1451 wmOperator * /*op*/,
1452 const wmEvent *event)
1453{
1454 Main *bmain = CTX_data_main(C);
1455 Scene *scene = CTX_data_scene(C);
1456 SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
1457
1458 if (event->custom != EVT_DATA_DRAGDROP) {
1459 return OPERATOR_CANCELLED;
1460 }
1461
1462 ListBaseT<wmDrag> *lb = static_cast<ListBaseT<wmDrag> *>(event->customdata);
1463 wmDrag *drag = lb->first();
1464
1466 if (!collection_drop_init(C, drag, event->xy, &data)) {
1467 return OPERATOR_CANCELLED;
1468 }
1469
1470 Collection *relative = nullptr;
1471 bool relative_after = false;
1472
1473 bool is_parented_object = false;
1474 TreeElement *parent_te = nullptr;
1475
1476 if (ELEM(data.insert_type, TE_INSERT_BEFORE, TE_INSERT_AFTER)) {
1477
1478 relative = data.to;
1479 relative_after = (data.insert_type == TE_INSERT_AFTER);
1480
1481 parent_te = outliner_find_parent_element(&space_outliner->runtime->tree, nullptr, data.te);
1482 data.to = nullptr;
1483 for (TreeElement *te_parent = parent_te; te_parent != nullptr; te_parent = te_parent->parent) {
1485 if (data.to != nullptr) {
1486 break;
1487 }
1488 }
1489 if (parent_te && parent_te->idcode == ID_OB) {
1490 is_parented_object = true;
1491 }
1492 }
1493
1494 if (!data.to) {
1495 return OPERATOR_CANCELLED;
1496 }
1497
1498 if (BKE_collection_is_empty(data.to)) {
1499 TREESTORE(data.te)->flag &= ~TSE_CLOSED;
1500 }
1501
1504 const bool is_custom_sort_move = space_outliner->sort_method == SO_SORT_CUSTOM;
1505
1506 /* Use custom sort for both objects and collections. */
1507 if (is_custom_sort_move) {
1508 if (is_parented_object) {
1509 for (TreeElement &te : parent_te->subtree) {
1510 if (te.idcode == ID_OB) {
1511 Object *ob = id_cast<Object *>(TREESTORE(&te)->id);
1512 items.append(ob);
1513 }
1514 }
1515 }
1516 else {
1517 for (CollectionObject &cob : data.to->gobject) {
1518 items.append(cob.ob);
1519 }
1520 for (CollectionChild &child : data.to->children) {
1521 items.append(child.collection);
1522 }
1523 }
1524 auto get_sort_index = [&](const std::variant<Object *, Collection *> &item) -> int {
1525 int sort_index = -1;
1526 if (std::holds_alternative<Object *>(item)) {
1527 Object *ob = std::get<Object *>(item);
1529 if (cob == nullptr) {
1530 Collection *other_col = BKE_collection_object_find(bmain, scene, nullptr, ob);
1531 if (other_col != nullptr) {
1532 cob = BKE_collection_object_find_in(*other_col, *ob);
1533 }
1534 }
1535 if (cob) {
1536 sort_index = is_parented_object ? cob->parented_sort_index : cob->sort_index;
1537 }
1538 }
1539 else {
1540 CollectionChild *child = BKE_collection_child_find(data.to, std::get<Collection *>(item));
1541 if (child) {
1542 sort_index = child->sort_index;
1543 }
1544 }
1545 return (sort_index >= 0) ? sort_index : INT_MAX;
1546 };
1547 auto items_sort = [&](const std::variant<Object *, Collection *> &a,
1548 const std::variant<Object *, Collection *> &b) {
1549 const int a_index = get_sort_index(a);
1550 const int b_index = get_sort_index(b);
1551 if (a_index != b_index) {
1552 return a_index < b_index;
1553 }
1554 const bool a_is_ob = std::holds_alternative<Object *>(a);
1555 const bool b_is_ob = std::holds_alternative<Object *>(b);
1556 return outliner_treesort_tiebreak(a_is_ob,
1557 a_is_ob ? std::get<Object *>(a)->id.name + 2 : nullptr,
1558 b_is_ob,
1559 b_is_ob ? std::get<Object *>(b)->id.name + 2 : nullptr);
1560 };
1561 std::ranges::stable_sort(items, items_sort);
1562 }
1563
1564 if (relative_after && !is_custom_sort_move) {
1565 BLI_listbase_reverse(&drag->ids);
1566 }
1567
1568 int insert_index = items.size();
1569 if (space_outliner->sort_method == SO_SORT_CUSTOM) {
1570 auto is_relative = [&](const std::variant<Object *, Collection *> &item) {
1571 if (is_object_element(data.te)) {
1572 return std::holds_alternative<Object *>(item) &&
1573 std::get<Object *>(item) == reinterpret_cast<Object *>(TREESTORE(data.te)->id);
1574 }
1575 if (is_collection_element(data.te)) {
1576 return std::holds_alternative<Collection *>(item) &&
1577 std::get<Collection *>(item) ==
1578 reinterpret_cast<Collection *>(TREESTORE(data.te)->id);
1579 }
1580 return false;
1581 };
1582 for (const int i : items.index_range()) {
1583 if (is_relative(items[i])) {
1584 insert_index = (data.insert_type == TE_INSERT_AFTER) ? i + 1 : i;
1585 break;
1586 }
1587 }
1588 }
1589
1590 for (wmDragID &drag_id : drag->ids) {
1591 /* Ctrl enables linking, so we don't need a from collection then. */
1592 Collection *from = ((event->modifier & (KM_SHIFT | KM_CTRL)) == KM_CTRL) ?
1593 nullptr :
1595
1596 if (GS(drag_id.id->name) == ID_OB) {
1597 /* Move/link object into collection. */
1598 Object *object = id_cast<Object *>(drag_id.id);
1599
1600 if (from) {
1601 BKE_collection_object_move(bmain, scene, data.to, from, object);
1602 if ((event->modifier & (KM_CTRL | KM_SHIFT)) == 0) {
1603 Vector<Object *> child_objects;
1604
1605 find_child_objects_recursive(from, object, child_objects);
1606 for (Object *child_ob : child_objects) {
1607 BKE_collection_object_move(bmain, scene, data.to, from, child_ob);
1608 }
1609 }
1610 }
1611 else {
1612 BKE_collection_object_add(bmain, data.to, object);
1613 }
1614
1615 if (is_custom_sort_move) {
1616 const int64_t index = items.first_index_of_try(
1617 std::variant<Object *, Collection *>(object));
1618 if (index != -1) {
1619 if (index < insert_index) {
1620 insert_index--;
1621 }
1622 items.remove(index);
1623 }
1624 dragged_items.append(object);
1625 }
1626 }
1627 else if (GS(drag_id.id->name) == ID_GR) {
1628 /* Move/link collection into collection. */
1629 Collection *collection = id_cast<Collection *>(drag_id.id);
1630
1631 if (collection != from) {
1632 BKE_collection_move(bmain, data.to, from, relative, relative_after, collection);
1633 }
1634
1635 if (is_custom_sort_move) {
1636 const int64_t index = items.first_index_of_try(
1637 std::variant<Object *, Collection *>(collection));
1638 if (index != -1) {
1639 if (index < insert_index) {
1640 insert_index--;
1641 }
1642 items.remove(index);
1643 }
1644 dragged_items.append(collection);
1645 }
1646 }
1647
1648 if (from) {
1649 DEG_id_tag_update(&from->id,
1651 }
1652 }
1653
1654 if (is_custom_sort_move) {
1655 items.insert(insert_index, dragged_items.as_span());
1656
1657 for (const int i : items.index_range()) {
1658 std::visit(
1659 [&](auto &&item) {
1660 using T = std::decay_t<decltype(item)>;
1661 if constexpr (std::is_same_v<T, Object *>) {
1663 if (cob == nullptr) {
1664 Collection *other_col = BKE_collection_object_find(bmain, scene, nullptr, item);
1665 if (other_col != nullptr) {
1666 cob = BKE_collection_object_find_in(*other_col, *item);
1667 }
1668 }
1669 if (cob != nullptr) {
1670 if (is_parented_object) {
1671 cob->parented_sort_index = i;
1672 }
1673 else {
1674 cob->sort_index = i;
1675 }
1676 }
1677 }
1678 else if constexpr (std::is_same_v<T, Collection *>) {
1680 if (child != nullptr) {
1681 child->sort_index = i;
1682 }
1683 }
1684 },
1685 items[i]);
1686 }
1687 }
1688 /* Update dependency graph. */
1691 /* NOTE: It is possible to drag-and-drop between different windows, which means that the source
1692 * window/Outliner may also need to be updated. So do not pass the current window in this
1693 * notifier (unless there is a way to get the drag source window as well?). */
1695
1696 return OPERATOR_FINISHED;
1697}
1698
1700{
1701 /* identifiers */
1702 ot->name = "Move to Collection";
1703 ot->description = "Drag to move to collection in Outliner";
1704 ot->idname = "OUTLINER_OT_collection_drop";
1705
1706 /* API callbacks. */
1709
1710 /* flags */
1712}
1713
1715
1716/* -------------------------------------------------------------------- */
1719
1720#define OUTLINER_DRAG_SCOLL_OUTSIDE_PAD 7 /* In UI units */
1721
1726
1727/* Gathers selected objects and collections together in tree order. */
1729 void *customdata)
1730{
1731 IDsSelectedData *data = static_cast<IDsSelectedData *>(customdata);
1732 TreeStoreElem *tselem = TREESTORE(te);
1733
1736 return TRAVERSE_CONTINUE;
1737 }
1738 BLI_addtail(&data->selected_array, BLI_genericNodeN(te));
1739 return TRAVERSE_SKIP_CHILDS;
1740 }
1741
1742 if ((tselem->type != TSE_SOME_ID) || (tselem->id == nullptr) || (tselem->id->id_type() != ID_OB))
1743 {
1744 return TRAVERSE_SKIP_CHILDS;
1745 }
1746
1747 BLI_addtail(&data->selected_array, BLI_genericNodeN(te));
1748
1749 return TRAVERSE_CONTINUE;
1750}
1751
1753 ARegion *region,
1754 const wmEvent *event)
1755{
1756 /* NOTE: using click-drag events to trigger dragging is fine,
1757 * it sends coordinates from where dragging was started */
1758 int mval[2];
1759 WM_event_drag_start_mval(event, region, mval);
1760
1761 const float my = ui::view2d_region_to_view_y(&region->v2d, mval[1]);
1762 return outliner_find_item_at_y(space_outliner, &space_outliner->runtime->tree, my);
1763}
1764
1766 wmOperator * /*op*/,
1767 const wmEvent *event)
1768{
1769 ARegion *region = CTX_wm_region(C);
1770 SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
1771 TreeElement *te = outliner_item_drag_element_find(space_outliner, region, event);
1772
1773 int mval[2];
1774 WM_event_drag_start_mval(event, region, mval);
1775
1776 if (!te) {
1778 }
1779
1780 TreeStoreElem *tselem = TREESTORE(te);
1782 if (!data.drag_id) {
1784 }
1785
1786 float view_mval[2];
1787 ui::view2d_region_to_view(&region->v2d, mval[0], mval[1], &view_mval[0], &view_mval[1]);
1788 if (outliner_item_is_co_within_close_toggle(te, view_mval[0])) {
1790 }
1791 if (outliner_is_co_within_mode_column(space_outliner, view_mval)) {
1793 }
1794
1795 /* Scroll the view when dragging near edges, but not
1796 * when the drag goes too far outside the region. */
1797 {
1798 wmOperatorType *ot = WM_operatortype_find("VIEW2D_OT_edge_pan", true);
1800 RNA_float_set(&op_ptr, "outside_padding", OUTLINER_DRAG_SCOLL_OUTSIDE_PAD);
1803 }
1804
1805 const bool use_datastack_drag = ELEM(tselem->type,
1812
1813 const eWM_DragDataType wm_drag_type = use_datastack_drag ? WM_DRAG_DATASTACK : WM_DRAG_ID;
1814 wmDrag *drag = WM_drag_data_create(C, data.icon, wm_drag_type, nullptr, WM_DRAG_NOP);
1815
1816 if (use_datastack_drag) {
1817 TreeElement *te_bone = nullptr;
1818 bPoseChannel *pchan = outliner_find_parent_bone(te, &te_bone);
1820 drag, id_cast<Object *>(tselem->id), pchan, te, tselem, te->directdata);
1821 }
1822 else if (ELEM(GS(data.drag_id->name), ID_OB, ID_GR)) {
1823 /* For collections and objects we cheat and drag all selected. */
1824
1825 /* Only drag element under mouse if it was not selected before. */
1826 if ((tselem->flag & TSE_SELECTED) == 0) {
1827 outliner_flag_set(*space_outliner, TSE_SELECTED, 0);
1828 tselem->flag |= TSE_SELECTED;
1829 }
1830
1831 /* Gather all selected elements. Objects and collections are dragged together, preserving
1832 * their on-screen order. */
1833 IDsSelectedData selected{};
1834 outliner_tree_traverse(space_outliner,
1835 &space_outliner->runtime->tree,
1836 0,
1839 &selected);
1840
1841 for (LinkData &link : selected.selected_array) {
1842 TreeElement *te_selected = static_cast<TreeElement *>(link.data);
1843 ID *id;
1844
1845 if (outliner_is_collection_tree_element(te_selected)) {
1846 id = &outliner_collection_from_tree_element(te_selected)->id;
1847 }
1848 else {
1849 id = TREESTORE(te_selected)->id;
1850 }
1851
1852 /* Find parent collection. */
1853 Collection *parent = nullptr;
1854
1855 if (te_selected->parent) {
1856 for (TreeElement *te_parent = te_selected->parent; te_parent;
1857 te_parent = te_parent->parent)
1858 {
1859 if (outliner_is_collection_tree_element(te_parent)) {
1860 parent = outliner_collection_from_tree_element(te_parent);
1861 break;
1862 }
1863 }
1864 }
1865 else {
1866 Scene *scene = CTX_data_scene(C);
1867 parent = scene->master_collection;
1868 }
1869
1870 if ((te_selected->flag & TE_CHILD_NOT_IN_COLLECTION) == 0) {
1871 for (wmDragID &drag_id : drag->ids) {
1872 if (drag_id.id == id) {
1873 drag_id.from_parent = &parent->id;
1874 break;
1875 }
1876 }
1877 }
1878 WM_drag_add_local_ID(drag, id, &parent->id);
1879 }
1880
1881 selected.selected_array.free_no_destruct();
1882 }
1883 else {
1884 /* Add single ID. */
1885 WM_drag_add_local_ID(drag, data.drag_id, data.drag_parent);
1886 }
1887
1889
1891
1893}
1894
1895/* Outliner drag and drop. This operator mostly exists to support dragging
1896 * from outliner text instead of only from the icon, and also to show a
1897 * hint in the status-bar key-map. */
1898
1900{
1901 ot->name = "Drag and Drop";
1902 ot->idname = "OUTLINER_OT_item_drag_drop";
1903 ot->description = "Drag and drop element to another place";
1904
1907}
1908
1909#undef OUTLINER_DRAG_SCOLL_OUTSIDE_PAD
1910
1912
1913/* -------------------------------------------------------------------- */
1916
1918{
1919 ListBaseT<wmDropBox> *lb = WM_dropboxmap_find("Outliner", SPACE_OUTLINER, RGN_TYPE_WINDOW);
1920
1921 WM_dropbox_add(lb, "OUTLINER_OT_parent_drop", parent_drop_poll, nullptr, nullptr, nullptr);
1922 WM_dropbox_add(lb, "OUTLINER_OT_parent_clear", parent_clear_poll, nullptr, nullptr, nullptr);
1923 WM_dropbox_add(lb, "OUTLINER_OT_scene_drop", scene_drop_poll, nullptr, nullptr, nullptr);
1924 WM_dropbox_add(lb, "OUTLINER_OT_material_drop", material_drop_poll, nullptr, nullptr, nullptr);
1925 WM_dropbox_add(lb,
1926 "OUTLINER_OT_datastack_drop",
1928 nullptr,
1929 nullptr,
1931 WM_dropbox_add(lb,
1932 "OUTLINER_OT_collection_drop",
1934 nullptr,
1935 nullptr,
1937}
1938
1940
1941} // namespace blender::ed::outliner
General operations, lookup, etc. for materials.
General operations, lookup, etc. for blender objects.
#define TIP_(msgid)
#define ID_IS_EDITABLE(_id)
Definition DNA_ID.h:708
#define ID_IS_OVERRIDE_LIBRARY(_id)
Definition DNA_ID.h:736
Object groups, one object can be in many groups at once.
Object is a sort of wrapper for general info.
Read Blender memory allocation and freeing.
#define C
Definition RandGen.cpp:29
#define UI_UNIT_Y
#define UI_UNIT_X
#define ND_OB_SELECT
Definition WM_types.hh:461
#define NC_SCENE
Definition WM_types.hh:391
#define ND_PARENT
Definition WM_types.hh:508
#define NC_MATERIAL
Definition WM_types.hh:393
#define ND_TRANSFORM
Definition WM_types.hh:475
#define ND_LAYER
Definition WM_types.hh:469
#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 BLI_assert_unreachable()
#define ELEM(...)
int64_t size() const
void append(const T &value)
void insert(const int64_t insert_index, const T &value)
void remove(const int64_t index)
IndexRange index_range() const
Span< T > as_span() const
int64_t first_index_of_try(const T &value) const
#define INT_MAX
#define T
void constraint_copy_for_object(Main *bmain, Object *ob_dst, bConstraint *con)
void constraint_link(Main *bmain, Object *ob_dst, ListBaseT< bConstraint > *dst, ListBaseT< bConstraint > *src)
void constraint_copy_for_pose(Main *bmain, Object *ob_dst, bPoseChannel *pchan, bConstraint *con)
void base_select(Base *base, eObjectSelect_Mode mode)
ModifierData * modifier_copy_to_object(Main *bmain, const Scene *scene, const Object *ob_src, const ModifierData *md, Object *ob_dst, ReportList *reports)
bool parent_set(ReportList *reports, const bContext *C, Scene *scene, Object *const ob, Object *const par, int partype, bool xmirror, bool keep_transform, const int vert_par[3])
void shaderfx_copy(Object *dst, ShaderFxData *fx)
bool constraint_move_to_index(Object *ob, bConstraint *con, int index)
void parent_clear(Main *bmain, Object *ob, int type)
bool modifier_move_to_index(ReportList *reports, eReportType error_type, Object *ob, ModifierData *md, int index, bool allow_partial)
bool shaderfx_move_to_index(ReportList *reports, Object *ob, ShaderFxData *fx, int index)
void modifier_link(bContext *C, Object *ob_dst, Object *ob_src)
void shaderfx_link(Object *dst, Object *src)
static bool scene_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
bool outliner_item_is_co_within_close_toggle(const TreeElement *te, float view_co_x)
static bool collection_drop_init(bContext *C, wmDrag *drag, const int xy[2], CollectionDrop *data)
static bool is_pchan_element(TreeElement *te)
TreeElement * outliner_find_item_at_y(const SpaceOutliner *space_outliner, const ListBaseT< TreeElement > *tree, float view_co_y)
static void datastack_drop_link(bContext *C, StackDropData *drop_data)
bool(*)(TreeElement *te) CheckTypeFn
static wmOperatorStatus outliner_item_drag_drop_invoke(bContext *C, wmOperator *, const wmEvent *event)
static TreeElement * outliner_drop_find(bContext *C, const wmEvent *event)
static bool parent_drop_allowed(const Main &bmain, TreeElement *te, Object *potential_child)
bool outliner_tree_traverse(const SpaceOutliner *space_outliner, ListBaseT< TreeElement > *tree, int filter_te_flag, int filter_tselem_flag, TreeTraversalFunc func, void *customdata)
static std::string datastack_drop_tooltip(bContext *, wmDrag *drag, const int[2], wmDropBox *)
bool outliner_is_collection_tree_element(const TreeElement *te)
static std::string collection_drop_tooltip(bContext *C, wmDrag *drag, const int xy[2], wmDropBox *)
static ID * outliner_ID_drop_find(bContext *C, const wmEvent *event, short idcode)
static bool collection_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
static wmOperatorStatus scene_drop_invoke(bContext *C, wmOperator *, const wmEvent *event)
static bool datastack_drop_are_types_valid(StackDropData *drop_data)
static void datastack_drop_reorder(bContext *C, ReportList *reports, StackDropData *drop_data)
static wmOperatorStatus datastack_drop_invoke(bContext *C, wmOperator *op, const wmEvent *event)
TreeElement * outliner_find_parent_element(ListBaseT< TreeElement > *lb, TreeElement *parent_te, const TreeElement *child_te)
static TreeTraversalAction outliner_collect_selected_objects_and_collections(TreeElement *te, void *customdata)
static bool datastack_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
void OUTLINER_OT_collection_drop(wmOperatorType *ot)
TreeElementIcon tree_element_get_icon(TreeStoreElem *tselem, TreeElement *te)
static TreeElement * outliner_drop_insert_collection_find(bContext *C, const int xy[2], TreeElementInsertType *r_insert_type)
TreeElement * outliner_find_id(SpaceOutliner *space_outliner, ListBaseT< TreeElement > *lb, const ID *id, TreeElementFlag exclude_flags)
bPoseChannel * outliner_find_parent_bone(TreeElement *te, TreeElement **r_bone_te)
bool outliner_flag_set(SpaceOutliner &space_outliner, const eTreeStoreElem_Flag flag, const short set)
void OUTLINER_OT_datastack_drop(wmOperatorType *ot)
static TreeElement * outliner_drop_insert_find(bContext *C, const int xy[2], TreeElementInsertType *r_insert_type)
static void find_child_objects_recursive(Collection *from, Object *ob, Vector< Object * > &child_objects)
static void datastack_drop_data_init(wmDrag *drag, Object *ob, bPoseChannel *pchan, TreeElement *te, TreeStoreElem *tselem, void *directdata)
Collection * outliner_collection_from_tree_element(const TreeElement *te)
static bool parent_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
bool outliner_is_co_within_mode_column(SpaceOutliner *space_outliner, const float view_mval[2])
void OUTLINER_OT_material_drop(wmOperatorType *ot)
void OUTLINER_OT_scene_drop(wmOperatorType *ot)
static TreeElement * outliner_dropzone_find(const SpaceOutliner *space_outliner, const float fmval[2], const bool children)
static wmOperatorStatus material_drop_invoke(bContext *C, wmOperator *, const wmEvent *event)
static TreeElement * outliner_item_drag_element_find(SpaceOutliner *space_outliner, ARegion *region, const wmEvent *event)
void OUTLINER_OT_parent_drop(wmOperatorType *ot)
ID * outliner_search_back(TreeElement *te, short idcode)
static bool datastack_drop_init(bContext *C, const wmEvent *event, StackDropData *drop_data)
static bool allow_parenting_without_modifier_key(SpaceOutliner *space_outliner)
static void parent_drop_set_parents(bContext *C, ReportList *reports, wmDragID *drag, Object *parent, short parent_type, const bool keep_transform)
bool outliner_treesort_tiebreak(bool a_is_object, const char *a_name, bool b_is_object, const char *b_name)
static wmOperatorStatus parent_drop_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static bool is_object_element(TreeElement *te)
TreeElement * outliner_find_tree_element(ListBaseT< TreeElement > *lb, const TreeStoreElem *store_elem)
static void datastack_drop_copy(bContext *C, StackDropData *drop_data)
static wmOperatorStatus collection_drop_invoke(bContext *C, wmOperator *, const wmEvent *event)
static bool is_collection_element(TreeElement *te)
static TreeElement * outliner_data_from_tree_element_and_parents(CheckTypeFn check_type, TreeElement *te)
static Collection * collection_parent_from_ID(ID *id)
static bool outliner_is_scene_collection_tree_element(const TreeElement *te)
void OUTLINER_OT_parent_clear(wmOperatorType *ot)
static bool outliner_is_collection_dragged_into_itself(TreeElement *drop_target_te, ID *dragged_id)
static TreeElement * outliner_dropzone_element(TreeElement *te, const float fmval[2], const bool children)
static int outliner_get_insert_index(TreeElement *drag_te, TreeElement *drop_te, TreeElementInsertType insert_type, ListBaseT< T > *listbase)
static wmOperatorStatus parent_clear_invoke(bContext *C, wmOperator *, const wmEvent *event)
static bool material_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
void OUTLINER_OT_item_drag_drop(wmOperatorType *ot)
static bool parent_clear_poll(bContext *C, wmDrag *drag, const wmEvent *event)
static bool drag_ids_are_all_objects(const wmDrag *drag)
void view2d_region_to_view(const View2D *v2d, float x, float y, float *r_view_x, float *r_view_y) ATTR_NONNULL()
Definition view2d.cc:1651
float view2d_region_to_view_y(const View2D *v2d, float y)
Definition view2d.cc:1645
void WM_main_add_notifier(uint type, void *reference)
ID * WM_drag_get_local_ID_from_event(const wmEvent *event, short idcode)
@ SO_FILTER_NO_COLLECTION
__int64 int64_t
Definition BKE_text.h:90
wmDropBox * WM_dropbox_add(ListBaseT< wmDropBox > *lb, const char *idname, bool(*poll)(bContext *C, wmDrag *drag, const wmEvent *event), void(*copy)(bContext *C, wmDrag *drag, wmDropBox *drop), void(*cancel)(Main *bmain, wmDrag *drag, wmDropBox *drop), WMDropboxTooltipFunc tooltip)
void WM_event_add_notifier_ex(wmWindowManager *wm, const wmWindow *win, uint type, void *reference)
@ RPT_WARNING
Definition BKE_report.hh:40
SpaceOutliner * CTX_wm_space_outliner(const bContext *C)
void WM_operator_properties_free(PointerRNA *ptr)
void ED_outliner_select_sync_from_outliner(bContext *C, SpaceOutliner *space_outliner)
CollectionObject * BKE_collection_object_find_in(const Collection &collection, const Object &ob)
PointerRNA WM_operator_properties_create_ptr(wmOperatorType *ot)
@ WM_DRAG_DATASTACK
Definition WM_types.hh:1313
wmWindow * CTX_wm_window(const bContext *C)
bool ED_operator_outliner_active(bContext *C)
void BKE_object_material_assign(Main *bmain, Object *ob, Material *ma, short act, int assign_type)
void ED_region_tag_redraw(ARegion *region)
Definition area.cc:681
@ TSE_LIBRARY_OVERRIDE_BASE
@ TSE_SCENE_COLLECTION_BASE
Collection * BKE_collection_object_find(Main *bmain, Scene *scene, Collection *collection, Object *ob)
bool BKE_scene_has_object(const Main &bmain, Scene *scene, Object *ob)
int BLI_findindex(const ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition listbase.cc:593
void * MEM_new_zeroed(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
void DEG_id_tag_update(ID *id, unsigned int flags)
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition report.cc:162
BMesh const char void * data
wmWindowManager * CTX_wm_manager(const bContext *C)
bool BKE_collection_move(Main *bmain, Collection *to_parent, Collection *from_parent, Collection *relative, bool relative_after, Collection *collection)
bool BKE_collection_is_empty(const Collection *collection)
@ BKE_MAT_ASSIGN_USERPREF
CollectionChild * BKE_collection_child_find(Collection *parent, Collection *collection)
bool BKE_view_layer_synced_ensure(const Main &bmain, const Scene *scene, ViewLayer *view_layer)
LinkData * BLI_genericNodeN(void *data)
Definition listbase.cc:936
void BKE_collection_object_move(Main *bmain, Scene *scene, Collection *collection_dst, Collection *collection_src, Object *ob)
bool BKE_collection_object_add(Main *bmain, Collection *collection, Object *ob)
wmDrag * WM_drag_data_create(bContext *C, int icon, eWM_DragDataType type, void *poin, uint flags)
void void void void void void void BLI_listbase_reverse(ListBase *lb) ATTR_NONNULL(1)
Definition listbase.cc:850
@ WM_DRAG_FREE_DATA
Definition WM_types.hh:1324
@ WM_DRAG_NOP
Definition WM_types.hh:1323
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
void WM_event_drag_start_mval(const wmEvent *event, const ARegion *region, int r_mval[2])
void RNA_float_set(PointerRNA *ptr, const char *name, float value)
wmOperatorType * WM_operatortype_find(const char *idname, bool quiet)
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:118
Main * CTX_data_main(const bContext *C)
@ ID_RECALC_SELECT
Definition DNA_ID.h:1101
@ ID_RECALC_HIERARCHY
Definition DNA_ID.h:1158
@ ID_RECALC_SYNC_TO_EVAL
Definition DNA_ID.h:1118
@ ID_RECALC_GEOMETRY
Definition DNA_ID.h:1074
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
Base * BKE_view_layer_base_find(ViewLayer *view_layer, Object *ob)
bool BKE_object_is_child_recursive(const Object *ob_parent, const Object *ob_child)
Definition object.cc:4922
void DEG_relations_tag_update(Main *bmain)
Scene * CTX_data_scene(const bContext *C)
void WM_drag_add_local_ID(wmDrag *drag, ID *id, ID *from_parent)
@ OPTYPE_REGISTER
Definition WM_types.hh:188
@ OPTYPE_UNDO
Definition WM_types.hh:190
@ OPTYPE_INTERNAL
Definition WM_types.hh:210
void WM_event_start_prepared_drag(bContext *C, wmDrag *drag)
ID * WM_drag_get_local_ID(const wmDrag *drag, short idcode)
void BKE_object_modifier_set_active(Object *ob, ModifierData *md)
Definition object.cc:1415
ListBaseT< wmDropBox > * WM_dropboxmap_find(const char *idname, int spaceid, int regionid)
ReportList * CTX_wm_reports(const bContext *C)
bool ED_operator_region_outliner_active(bContext *C)
bool BKE_id_is_editable(const Main *bmain, const ID *id)
Definition lib_id.cc:2782
ARegion * CTX_wm_region(const bContext *C)
void ED_region_tag_redraw_no_rebuild(ARegion *region)
Definition area.cc:727
Collection * CTX_data_collection(const bContext *C)
#define OUTLINER_DRAG_SCOLL_OUTSIDE_PAD
#define TREESTORE(a)
#define TSELEM_OPEN(telm, sv)
struct Collection * collection
ListBaseT< CollectionObject > gobject
char name[258]
Definition DNA_ID.h:433
struct Object * parent
ListBaseT< ModifierData > modifiers
ListBaseT< ShaderFxData > shader_fx
ListBaseT< bConstraint > constraints
ListBaseT< ViewLayer > view_layers
struct Collection * master_collection
eSpaceOutliner_Mode outlinevis
eSpaceOutliner_SortMethod sort_method
ed::outliner::SpaceOutliner_Runtime * runtime
eSpaceOutliner_Filter filter
eTreeStoreElem_Flag flag
ListBaseT< struct bConstraint > constraints
ListBaseT< ed::outliner::TreeElement > tree
wmDragID * next
Definition WM_types.hh:1331
eWM_DragFlags flags
Definition WM_types.hh:1435
eWM_DragDataType type
Definition WM_types.hh:1424
ListBaseT< wmDragID > ids
Definition WM_types.hh:1438
wmEventModifierFlag modifier
Definition WM_types.hh:834
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
struct ReportList * reports
bke::WindowRuntime * runtime