Blender V4.5
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 <cstring>
10
11#include "MEM_guardedalloc.h"
12
14#include "DNA_material_types.h"
15#include "DNA_object_types.h"
16#include "DNA_space_types.h"
17
18#include "BLI_listbase.h"
19
20#include "BLT_translation.hh"
21
22#include "BKE_collection.hh"
23#include "BKE_context.hh"
24#include "BKE_layer.hh"
25#include "BKE_lib_id.hh"
26#include "BKE_library.hh"
27#include "BKE_main.hh"
28#include "BKE_material.hh"
29#include "BKE_object.hh"
30#include "BKE_report.hh"
31
32#include "DEG_depsgraph.hh"
34
35#include "ED_object.hh"
36#include "ED_outliner.hh"
37#include "ED_screen.hh"
38
39#include "UI_interface.hh"
40#include "UI_view2d.hh"
41
42#include "RNA_access.hh"
43
44#include "WM_api.hh"
45#include "WM_types.hh"
46
47#include "outliner_intern.hh"
48
49namespace blender::ed::outliner {
50
52
53/* -------------------------------------------------------------------- */
56
58 const float fmval[2],
59 const bool children)
60{
61 if ((fmval[1] > te->ys) && (fmval[1] < (te->ys + UI_UNIT_Y))) {
62 /* name and first icon */
63 if ((fmval[0] > te->xs + UI_UNIT_X) && (fmval[0] < te->xend)) {
64 return te;
65 }
66 }
67 /* Not it. Let's look at its children. */
68 if (children && (TREESTORE(te)->flag & TSE_CLOSED) == 0 && (te->subtree.first)) {
69 LISTBASE_FOREACH (TreeElement *, te_sub, &te->subtree) {
70 TreeElement *te_valid = outliner_dropzone_element(te_sub, fmval, children);
71 if (te_valid) {
72 return te_valid;
73 }
74 }
75 }
76 return nullptr;
77}
78
79/* Find tree element to drop into. */
80static TreeElement *outliner_dropzone_find(const SpaceOutliner *space_outliner,
81 const float fmval[2],
82 const bool children)
83{
84 LISTBASE_FOREACH (TreeElement *, te, &space_outliner->tree) {
85 TreeElement *te_valid = outliner_dropzone_element(te, fmval, children);
86 if (te_valid) {
87 return te_valid;
88 }
89 }
90 return nullptr;
91}
92
94{
95 ARegion *region = CTX_wm_region(C);
96 SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
97 float fmval[2];
98 UI_view2d_region_to_view(&region->v2d, event->mval[0], event->mval[1], &fmval[0], &fmval[1]);
99
100 return outliner_dropzone_find(space_outliner, fmval, true);
101}
102
103static ID *outliner_ID_drop_find(bContext *C, const wmEvent *event, short idcode)
104{
105 TreeElement *te = outliner_drop_find(C, event);
106 TreeStoreElem *tselem = (te) ? TREESTORE(te) : nullptr;
107
108 if (te && (te->idcode == idcode) && (tselem->type == TSE_SOME_ID)) {
109 return tselem->id;
110 }
111 return nullptr;
112}
113
114/* Find tree element to drop into, with additional before and after reorder support. */
116 const int xy[2],
117 TreeElementInsertType *r_insert_type)
118{
119 SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
120 ARegion *region = CTX_wm_region(C);
121 TreeElement *te_hovered;
122 float view_mval[2];
123
124 /* Empty tree, e.g. while filtered. */
125 if (BLI_listbase_is_empty(&space_outliner->tree)) {
126 return nullptr;
127 }
128
129 int mval[2];
130 mval[0] = xy[0] - region->winrct.xmin;
131 mval[1] = xy[1] - region->winrct.ymin;
132
133 UI_view2d_region_to_view(&region->v2d, mval[0], mval[1], &view_mval[0], &view_mval[1]);
134 te_hovered = outliner_find_item_at_y(space_outliner, &space_outliner->tree, view_mval[1]);
135
136 if (te_hovered) {
137 /* Mouse hovers an element (ignoring x-axis),
138 * now find out how to insert the dragged item exactly. */
139 const float margin = UI_UNIT_Y * (1.0f / 4);
140
141 if (view_mval[1] < (te_hovered->ys + margin)) {
142 if (TSELEM_OPEN(TREESTORE(te_hovered), space_outliner) &&
143 !BLI_listbase_is_empty(&te_hovered->subtree))
144 {
145 /* inserting after a open item means we insert into it, but as first child */
146 if (BLI_listbase_is_empty(&te_hovered->subtree)) {
147 *r_insert_type = TE_INSERT_INTO;
148 return te_hovered;
149 }
150 *r_insert_type = TE_INSERT_BEFORE;
151 return static_cast<TreeElement *>(te_hovered->subtree.first);
152 }
153 *r_insert_type = TE_INSERT_AFTER;
154 return te_hovered;
155 }
156 if (view_mval[1] > (te_hovered->ys + (3 * margin))) {
157 *r_insert_type = TE_INSERT_BEFORE;
158 return te_hovered;
159 }
160 *r_insert_type = TE_INSERT_INTO;
161 return te_hovered;
162 }
163
164 /* Mouse doesn't hover any item (ignoring x-axis),
165 * so it's either above list bounds or below. */
166 TreeElement *first = static_cast<TreeElement *>(space_outliner->tree.first);
167 TreeElement *last = static_cast<TreeElement *>(space_outliner->tree.last);
168
169 if (view_mval[1] < last->ys) {
170 *r_insert_type = TE_INSERT_AFTER;
171 return last;
172 }
173 if (view_mval[1] > (first->ys + UI_UNIT_Y)) {
174 *r_insert_type = TE_INSERT_BEFORE;
175 return first;
176 }
177
179 return nullptr;
180}
181
182using CheckTypeFn = bool (*)(TreeElement *te);
183
185 TreeElement *te)
186{
187 while (te != nullptr) {
188 if (check_type(te)) {
189 return te;
190 }
191 te = te->parent;
192 }
193 return nullptr;
194}
195
200
202{
203 TreeStoreElem *tselem = TREESTORE(te);
204 return (tselem->type == TSE_SOME_ID) && te->idcode == ID_OB;
205}
206
208{
209 TreeStoreElem *tselem = TREESTORE(te);
210 return tselem->type == TSE_POSE_CHANNEL;
211}
212
214 const int xy[2],
215 TreeElementInsertType *r_insert_type)
216{
217 TreeElement *te = outliner_drop_insert_find(C, xy, r_insert_type);
218 if (!te) {
219 return nullptr;
220 }
221
223 te);
224 if (!collection_te) {
225 return nullptr;
226 }
227
228 /* We can't insert before/after/into a collection that itself is selected/dragged. */
229 TreeStoreElem *collection_tselem = TREESTORE(collection_te);
230 if ((collection_tselem->flag & TSE_SELECTED) != 0) {
231 return nullptr;
232 }
233
234 Collection *collection = outliner_collection_from_tree_element(collection_te);
235
236 if (collection_te != te) {
237 *r_insert_type = TE_INSERT_INTO;
238 }
239
240 /* We can't insert before/after master collection. */
241 if (collection->flag & COLLECTION_IS_MASTER) {
242 *r_insert_type = TE_INSERT_INTO;
243 }
244
245 return collection_te;
246}
247
249 TreeElement *drop_te,
250 TreeElementInsertType insert_type,
251 ListBase *listbase)
252{
253 /* Find the element to insert after. Null is the start of the list. */
254 if (drag_te->index < drop_te->index) {
255 if (insert_type == TE_INSERT_BEFORE) {
256 drop_te = drop_te->prev;
257 }
258 }
259 else {
260 if (insert_type == TE_INSERT_AFTER) {
261 drop_te = drop_te->next;
262 }
263 }
264
265 if (drop_te == nullptr) {
266 return 0;
267 }
268
269 return BLI_findindex(listbase, drop_te->directdata);
270}
271
273
274/* -------------------------------------------------------------------- */
277
278static bool parent_drop_allowed(TreeElement *te, Object *potential_child)
279{
280 TreeStoreElem *tselem = TREESTORE(te);
281 if ((te->idcode != ID_OB) || (tselem->type != TSE_SOME_ID)) {
282 return false;
283 }
284
285 Object *potential_parent = (Object *)tselem->id;
286
287 if (potential_parent == potential_child) {
288 return false;
289 }
290 if (BKE_object_is_child_recursive(potential_child, potential_parent)) {
291 return false;
292 }
293 if (potential_parent == potential_child->parent) {
294 return false;
295 }
296
297 /* check that parent/child are both in the same scene */
298 Scene *scene = (Scene *)outliner_search_back(te, ID_SCE);
299
300 /* currently outliner organized in a way that if there's no parent scene
301 * element for object it means that all displayed objects belong to
302 * active scene and parenting them is allowed (sergey) */
303 if (scene) {
304 LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) {
305 BKE_view_layer_synced_ensure(scene, view_layer);
306 if (BKE_view_layer_base_find(view_layer, potential_child)) {
307 return true;
308 }
309 }
310 return false;
311 }
312 return true;
313}
314
316{
317 switch (space_outliner->outlinevis) {
318 case SO_VIEW_LAYER:
319 return space_outliner->filter & SO_FILTER_NO_COLLECTION;
320 case SO_SCENES:
321 return true;
322 default:
323 return false;
324 }
325}
326
327static bool parent_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
328{
329 SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
330
331 bool changed = outliner_flag_set(*space_outliner, TSE_DRAG_ANY, false);
332 if (changed) {
334 }
335
336 Object *potential_child = (Object *)WM_drag_get_local_ID(drag, ID_OB);
337 if (!potential_child) {
338 return false;
339 }
340
341 if (!allow_parenting_without_modifier_key(space_outliner)) {
342 if ((event->modifier & KM_SHIFT) == 0) {
343 return false;
344 }
345 }
346
347 TreeElement *te = outliner_drop_find(C, event);
348 if (!te) {
349 return false;
350 }
351
352 if (parent_drop_allowed(te, potential_child)) {
353 TREESTORE(te)->flag |= TSE_DRAG_INTO;
355 return true;
356 }
357
358 return false;
359}
360
363 wmDragID *drag,
364 Object *parent,
365 short parent_type,
366 const bool keep_transform)
367{
368 Main *bmain = CTX_data_main(C);
369 SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
370
371 TreeElement *te = outliner_find_id(space_outliner, &space_outliner->tree, &parent->id);
372 Scene *scene = (Scene *)outliner_search_back(te, ID_SCE);
373
374 if (scene == nullptr) {
375 /* currently outliner organized in a way, that if there's no parent scene
376 * element for object it means that all displayed objects belong to
377 * active scene and parenting them is allowed (sergey)
378 */
379
380 scene = CTX_data_scene(C);
381 }
382
383 bool parent_set = false;
384 bool linked_objects = false;
385
386 for (wmDragID *drag_id = drag; drag_id; drag_id = drag_id->next) {
387 if (GS(drag_id->id->name) == ID_OB) {
388 Object *object = (Object *)drag_id->id;
389
390 /* Do nothing to linked data */
391 if (!BKE_id_is_editable(bmain, &object->id)) {
392 linked_objects = true;
393 continue;
394 }
395
397 reports, C, scene, object, parent, parent_type, false, keep_transform, nullptr))
398 {
399 parent_set = true;
400 }
401 }
402 }
403
404 if (linked_objects) {
405 BKE_report(reports, RPT_INFO, "Can't edit library linked or non-editable override object(s)");
406 }
407
408 if (parent_set) {
412 }
413}
414
416{
417 TreeElement *te = outliner_drop_find(C, event);
418 TreeStoreElem *tselem = te ? TREESTORE(te) : nullptr;
419
420 if (!(te && (te->idcode == ID_OB) && (tselem->type == TSE_SOME_ID))) {
421 return OPERATOR_CANCELLED;
422 }
423
424 Object *par = (Object *)tselem->id;
426
427 if (ELEM(nullptr, ob, par)) {
428 return OPERATOR_CANCELLED;
429 }
430 if (ob == par) {
431 return OPERATOR_CANCELLED;
432 }
433
434 if (event->custom != EVT_DATA_DRAGDROP) {
435 return OPERATOR_CANCELLED;
436 }
437
438 ListBase *lb = static_cast<ListBase *>(event->customdata);
439 wmDrag *drag = static_cast<wmDrag *>(lb->first);
440
442 op->reports,
443 static_cast<wmDragID *>(drag->ids.first),
444 par,
446 event->modifier & KM_ALT);
447
448 return OPERATOR_FINISHED;
449}
450
452{
453 /* identifiers */
454 ot->name = "Drop to Set Parent (hold Alt to keep transforms)";
455 ot->description = "Drag to parent in Outliner";
456 ot->idname = "OUTLINER_OT_parent_drop";
457
458 /* API callbacks. */
459 ot->invoke = parent_drop_invoke;
460
462
463 /* flags */
465}
466
468
469/* -------------------------------------------------------------------- */
472
473static bool parent_clear_poll(bContext *C, wmDrag *drag, const wmEvent *event)
474{
475 SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
476
477 if (!allow_parenting_without_modifier_key(space_outliner)) {
478 if ((event->modifier & KM_SHIFT) == 0) {
479 return false;
480 }
481 }
482
483 Object *ob = (Object *)WM_drag_get_local_ID(drag, ID_OB);
484 if (!ob) {
485 return false;
486 }
487 if (!ob->parent) {
488 return false;
489 }
490
491 TreeElement *te = outliner_drop_find(C, event);
492 if (te) {
493 TreeStoreElem *tselem = TREESTORE(te);
494 ID *id = tselem->id;
495 if (!id) {
496 return true;
497 }
498
499 switch (GS(id->name)) {
500 case ID_OB:
502 case ID_GR:
503 return (event->modifier & KM_SHIFT) || ELEM(tselem->type, TSE_LIBRARY_OVERRIDE_BASE);
504 default:
505 return true;
506 }
507 }
508 else {
509 return true;
510 }
511}
512
514{
515 Main *bmain = CTX_data_main(C);
516
517 if (event->custom != EVT_DATA_DRAGDROP) {
518 return OPERATOR_CANCELLED;
519 }
520
521 ListBase *lb = static_cast<ListBase *>(event->customdata);
522 wmDrag *drag = static_cast<wmDrag *>(lb->first);
523
524 LISTBASE_FOREACH (wmDragID *, drag_id, &drag->ids) {
525 if (GS(drag_id->id->name) == ID_OB) {
526 Object *object = (Object *)drag_id->id;
527
531 }
532 }
533
537 return OPERATOR_FINISHED;
538}
539
541{
542 /* identifiers */
543 ot->name = "Drop to Clear Parent (hold Alt to keep transforms)";
544 ot->description = "Drag to clear parent in Outliner";
545 ot->idname = "OUTLINER_OT_parent_clear";
546
547 /* API callbacks. */
548 ot->invoke = parent_clear_invoke;
549
551
552 /* flags */
554}
555
557
558/* -------------------------------------------------------------------- */
561
562static bool scene_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
563{
564 /* Ensure item under cursor is valid drop target */
565 Object *ob = (Object *)WM_drag_get_local_ID(drag, ID_OB);
566 return (ob && (outliner_ID_drop_find(C, event, ID_SCE) != nullptr));
567}
568
570{
571 Main *bmain = CTX_data_main(C);
572 Scene *scene = (Scene *)outliner_ID_drop_find(C, event, ID_SCE);
574
575 if (ELEM(nullptr, ob, scene) || !BKE_id_is_editable(bmain, &scene->id)) {
576 return OPERATOR_CANCELLED;
577 }
578
579 if (BKE_scene_has_object(scene, ob)) {
580 return OPERATOR_CANCELLED;
581 }
582
583 Collection *collection;
584 if (scene != CTX_data_scene(C)) {
585 /* when linking to an inactive scene link to the master collection */
586 collection = scene->master_collection;
587 }
588 else {
589 collection = CTX_data_collection(C);
590 }
591
592 BKE_collection_object_add(bmain, collection, ob);
593
594 LISTBASE_FOREACH (ViewLayer *, view_layer, &scene->view_layers) {
595 BKE_view_layer_synced_ensure(scene, view_layer);
596 Base *base = BKE_view_layer_base_find(view_layer, ob);
597 if (base) {
599 }
600 }
601
604
607
608 return OPERATOR_FINISHED;
609}
610
612{
613 /* identifiers */
614 ot->name = "Drop Object to Scene";
615 ot->description = "Drag object to scene in Outliner";
616 ot->idname = "OUTLINER_OT_scene_drop";
617
618 /* API callbacks. */
619 ot->invoke = scene_drop_invoke;
620
622
623 /* flags */
625}
626
628
629/* -------------------------------------------------------------------- */
632
633static bool material_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
634{
635 /* Ensure item under cursor is valid drop target */
637 Object *ob = reinterpret_cast<Object *>(outliner_ID_drop_find(C, event, ID_OB));
638
639 return (!ELEM(nullptr, ob, ma) && ID_IS_EDITABLE(&ob->id) && !ID_IS_OVERRIDE_LIBRARY(&ob->id));
640}
641
643 wmOperator * /*op*/,
644 const wmEvent *event)
645{
646 Main *bmain = CTX_data_main(C);
647 Object *ob = (Object *)outliner_ID_drop_find(C, event, ID_OB);
649
650 if (ELEM(nullptr, ob, ma) || !BKE_id_is_editable(bmain, &ob->id)) {
651 return OPERATOR_CANCELLED;
652 }
653
654 /* only drop grease pencil material on grease pencil objects */
655 if ((ma->gp_style != nullptr) && (ob->type != OB_GREASE_PENCIL)) {
656 return OPERATOR_CANCELLED;
657 }
658
660
664
665 return OPERATOR_FINISHED;
666}
667
669{
670 /* identifiers */
671 ot->name = "Drop Material on Object";
672 ot->description = "Drag material to object in Outliner";
673 ot->idname = "OUTLINER_OT_material_drop";
674
675 /* API callbacks. */
676 ot->invoke = material_drop_invoke;
677
679
680 /* flags */
682}
683
685
686/* -------------------------------------------------------------------- */
697
703
715
717 Object *ob,
718 bPoseChannel *pchan,
719 TreeElement *te,
720 TreeStoreElem *tselem,
721 void *directdata)
722{
723 StackDropData *drop_data = MEM_callocN<StackDropData>("datastack drop data");
724
725 drop_data->ob_parent = ob;
726 drop_data->pchan_parent = pchan;
727 drop_data->drag_tselem = tselem;
728 drop_data->drag_directdata = directdata;
729 drop_data->drag_index = te->index;
730
731 drag->poin = drop_data;
732 drag->flags |= WM_DRAG_FREE_DATA;
733}
734
735static bool datastack_drop_init(bContext *C, const wmEvent *event, StackDropData *drop_data)
736{
737 if (!ELEM(drop_data->drag_tselem->type,
744 {
745 return false;
746 }
747
748 TreeElement *te_target = outliner_drop_insert_find(C, event->xy, &drop_data->insert_type);
749 if (!te_target) {
750 return false;
751 }
752 TreeStoreElem *tselem_target = TREESTORE(te_target);
753
754 if (drop_data->drag_tselem == tselem_target) {
755 return false;
756 }
757
758 Object *ob = nullptr;
760 te_target);
761 if (object_te) {
762 ob = (Object *)TREESTORE(object_te)->id;
763 }
764
765 bPoseChannel *pchan = nullptr;
767 if (pchan_te) {
768 pchan = (bPoseChannel *)pchan_te->directdata;
769 }
770 if (pchan) {
771 ob = nullptr;
772 }
773
774 if (ob && !BKE_id_is_editable(CTX_data_main(C), &ob->id)) {
775 return false;
776 }
777
778 /* Drag a base for linking. */
779 if (ELEM(drop_data->drag_tselem->type,
783 {
784 drop_data->insert_type = TE_INSERT_INTO;
786
787 if (pchan && pchan != drop_data->pchan_parent) {
788 drop_data->drop_te = pchan_te;
789 tselem_target = TREESTORE(pchan_te);
790 }
791 else if (ob && ob != drop_data->ob_parent) {
792 drop_data->drop_te = object_te;
793 tselem_target = TREESTORE(object_te);
794 }
795 else {
796 return false;
797 }
798 }
799 else if (ob || pchan) {
800 /* Drag a single item. */
801 if (pchan && pchan != drop_data->pchan_parent) {
802 drop_data->insert_type = TE_INSERT_INTO;
804 drop_data->drop_te = pchan_te;
805 tselem_target = TREESTORE(pchan_te);
806 }
807 else if (ob && ob != drop_data->ob_parent) {
808 drop_data->insert_type = TE_INSERT_INTO;
810 drop_data->drop_te = object_te;
811 tselem_target = TREESTORE(object_te);
812 }
813 else if (tselem_target->type == drop_data->drag_tselem->type) {
814 if (drop_data->insert_type == TE_INSERT_INTO) {
815 return false;
816 }
818 drop_data->drop_te = te_target;
819 }
820 else {
821 return false;
822 }
823 }
824 else {
825 return false;
826 }
827
828 return true;
829}
830
831/* Ensure that grease pencil and object data remain separate. */
833{
834 TreeStoreElem *tselem = TREESTORE(drop_data->drop_te);
835 Object *ob_parent = drop_data->ob_parent;
836 Object *ob_dst = (Object *)tselem->id;
837
838 /* Don't allow data to be moved between objects and bones. */
839 if (tselem->type == TSE_CONSTRAINT) {
840 }
841 else if ((drop_data->pchan_parent && tselem->type != TSE_POSE_CHANNEL) ||
842 (!drop_data->pchan_parent && tselem->type == TSE_POSE_CHANNEL))
843 {
844 return false;
845 }
846
847 switch (drop_data->drag_tselem->type) {
849 case TSE_MODIFIER:
850 return (ob_parent->type == OB_GREASE_PENCIL) == (ob_dst->type == OB_GREASE_PENCIL);
851 break;
853 case TSE_CONSTRAINT:
854
855 break;
858 return ob_parent->type == OB_GREASE_PENCIL && ob_dst->type == OB_GREASE_PENCIL;
859 break;
860 }
861
862 return true;
863}
864
865static bool datastack_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
866{
867 if (drag->type != WM_DRAG_DATASTACK) {
868 return false;
869 }
870
871 SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
872 ARegion *region = CTX_wm_region(C);
873 bool changed = outliner_flag_set(*space_outliner, TSE_HIGHLIGHTED_ANY | TSE_DRAG_ANY, false);
874
875 StackDropData *drop_data = static_cast<StackDropData *>(drag->poin);
876 if (!drop_data) {
877 return false;
878 }
879
880 if (!datastack_drop_init(C, event, drop_data)) {
881 return false;
882 }
883
884 if (!datastack_drop_are_types_valid(drop_data)) {
885 return false;
886 }
887
888 TreeStoreElem *tselem_target = TREESTORE(drop_data->drop_te);
889 switch (drop_data->insert_type) {
890 case TE_INSERT_BEFORE:
891 tselem_target->flag |= TSE_DRAG_BEFORE;
892 break;
893 case TE_INSERT_AFTER:
894 tselem_target->flag |= TSE_DRAG_AFTER;
895 break;
896 case TE_INSERT_INTO:
897 tselem_target->flag |= TSE_DRAG_INTO;
898 break;
899 }
900
901 if (changed) {
903 }
904
905 return true;
906}
907
908static std::string datastack_drop_tooltip(bContext * /*C*/,
909 wmDrag *drag,
910 const int /*xy*/[2],
911 wmDropBox * /*drop*/)
912{
913 StackDropData *drop_data = static_cast<StackDropData *>(drag->poin);
914 switch (drop_data->drop_action) {
916 return TIP_("Reorder");
918 if (drop_data->pchan_parent) {
919 return TIP_("Copy to bone");
920 }
921 return TIP_("Copy to object");
922
924 if (drop_data->pchan_parent) {
925 return TIP_("Link all to bone");
926 }
927 return TIP_("Link all to object");
928 }
929 return {};
930}
931
933{
934 Main *bmain = CTX_data_main(C);
935 TreeStoreElem *tselem = TREESTORE(drop_data->drop_te);
936 Object *ob_dst = (Object *)tselem->id;
937
938 switch (drop_data->drag_tselem->type) {
940 object::modifier_link(C, ob_dst, drop_data->ob_parent);
941 break;
942 case TSE_CONSTRAINT_BASE: {
943 ListBase *src;
944
945 if (drop_data->pchan_parent) {
946 src = &drop_data->pchan_parent->constraints;
947 }
948 else {
949 src = &drop_data->ob_parent->constraints;
950 }
951
952 ListBase *dst;
953 if (tselem->type == TSE_POSE_CHANNEL) {
954 bPoseChannel *pchan = (bPoseChannel *)drop_data->drop_te->directdata;
955 dst = &pchan->constraints;
956 }
957 else {
958 dst = &ob_dst->constraints;
959 }
960
961 object::constraint_link(bmain, ob_dst, dst, src);
962 break;
963 }
965 if (ob_dst->type != OB_GREASE_PENCIL) {
966 return;
967 }
968
969 object::shaderfx_link(ob_dst, drop_data->ob_parent);
970 break;
971 }
972}
973
975{
976 Main *bmain = CTX_data_main(C);
977
978 TreeStoreElem *tselem = TREESTORE(drop_data->drop_te);
979 Object *ob_dst = (Object *)tselem->id;
980
981 switch (drop_data->drag_tselem->type) {
982 case TSE_MODIFIER:
984 bmain,
986 drop_data->ob_parent,
987 static_cast<const ModifierData *>(drop_data->drag_directdata),
988 ob_dst,
990 break;
991 case TSE_CONSTRAINT:
992 if (tselem->type == TSE_POSE_CHANNEL) {
994 bmain,
995 ob_dst,
996 static_cast<bPoseChannel *>(drop_data->drop_te->directdata),
997 static_cast<bConstraint *>(drop_data->drag_directdata));
998 }
999 else {
1001 bmain, ob_dst, static_cast<bConstraint *>(drop_data->drag_directdata));
1002 }
1003 break;
1004 case TSE_GPENCIL_EFFECT: {
1005 if (ob_dst->type != OB_GREASE_PENCIL) {
1006 return;
1007 }
1008
1009 object::shaderfx_copy(ob_dst, static_cast<ShaderFxData *>(drop_data->drag_directdata));
1010 break;
1011 }
1012 }
1013}
1014
1016{
1017 SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
1018
1019 TreeElement *drag_te = outliner_find_tree_element(&space_outliner->tree, drop_data->drag_tselem);
1020 if (!drag_te) {
1021 return;
1022 }
1023
1024 TreeElement *drop_te = drop_data->drop_te;
1025 TreeElementInsertType insert_type = drop_data->insert_type;
1026
1027 Object *ob = drop_data->ob_parent;
1028
1029 int index = 0;
1030 switch (drop_data->drag_tselem->type) {
1031 case TSE_MODIFIER:
1032 index = outliner_get_insert_index(drag_te, drop_te, insert_type, &ob->modifiers);
1035 ob,
1036 static_cast<ModifierData *>(drop_data->drag_directdata),
1037 index,
1038 true);
1039 break;
1040 case TSE_CONSTRAINT:
1041 if (drop_data->pchan_parent) {
1043 drag_te, drop_te, insert_type, &drop_data->pchan_parent->constraints);
1044 }
1045 else {
1046 index = outliner_get_insert_index(drag_te, drop_te, insert_type, &ob->constraints);
1047 }
1049 ob, static_cast<bConstraint *>(drop_data->drag_directdata), index);
1050
1051 break;
1052 case TSE_GPENCIL_EFFECT:
1053 index = outliner_get_insert_index(drag_te, drop_te, insert_type, &ob->shader_fx);
1055 reports, ob, static_cast<ShaderFxData *>(drop_data->drag_directdata), index);
1056 }
1057}
1058
1060{
1061 if (event->custom != EVT_DATA_DRAGDROP) {
1062 return OPERATOR_CANCELLED;
1063 }
1064
1065 ListBase *lb = static_cast<ListBase *>(event->customdata);
1066 wmDrag *drag = static_cast<wmDrag *>(lb->first);
1067 StackDropData *drop_data = static_cast<StackDropData *>(drag->poin);
1068
1069 switch (drop_data->drop_action) {
1071 datastack_drop_link(C, drop_data);
1072 break;
1074 datastack_drop_copy(C, drop_data);
1075 break;
1077 datastack_drop_reorder(C, op->reports, drop_data);
1078 break;
1079 }
1080
1081 return OPERATOR_FINISHED;
1082}
1083
1085{
1086 /* identifiers */
1087 ot->name = "Data Stack Drop";
1088 ot->description = "Copy or reorder modifiers, constraints, and effects";
1089 ot->idname = "OUTLINER_OT_datastack_drop";
1090
1091 /* API callbacks. */
1092 ot->invoke = datastack_drop_invoke;
1093
1095
1096 /* flags */
1098}
1099
1101
1102/* -------------------------------------------------------------------- */
1105
1113
1115{
1116 /* Can't change linked or override parent collections. */
1117 if (!id || !ID_IS_EDITABLE(id) || ID_IS_OVERRIDE_LIBRARY(id)) {
1118 return nullptr;
1119 }
1120
1121 /* Also support dropping into/from scene collection. */
1122 if (GS(id->name) == ID_SCE) {
1123 return ((Scene *)id)->master_collection;
1124 }
1125 if (GS(id->name) == ID_GR) {
1126 return (Collection *)id;
1127 }
1128
1129 return nullptr;
1130}
1131
1132static bool collection_drop_init(bContext *C, wmDrag *drag, const int xy[2], CollectionDrop *data)
1133{
1134 /* Get collection to drop into. */
1135 TreeElementInsertType insert_type;
1137 if (!te) {
1138 return false;
1139 }
1140
1142 if (!ID_IS_EDITABLE(to_collection) || ID_IS_OVERRIDE_LIBRARY(to_collection)) {
1143 if (insert_type == TE_INSERT_INTO) {
1144 return false;
1145 }
1146 }
1147
1148 /* Get drag datablocks. */
1149 if (drag->type != WM_DRAG_ID) {
1150 return false;
1151 }
1152
1153 wmDragID *drag_id = static_cast<wmDragID *>(drag->ids.first);
1154 if (drag_id == nullptr) {
1155 return false;
1156 }
1157
1158 ID *id = drag_id->id;
1159 if (!(id && ELEM(GS(id->name), ID_GR, ID_OB))) {
1160 return false;
1161 }
1162
1163 /* Get collection to drag out of. */
1164 ID *parent = drag_id->from_parent;
1165 Collection *from_collection = collection_parent_from_ID(parent);
1166
1167 /* Currently this should not be allowed, cannot edit items in an override of a Collection. */
1168 if (from_collection != nullptr && ID_IS_OVERRIDE_LIBRARY(from_collection)) {
1169 return false;
1170 }
1171
1172 /* Get collections. */
1173 if (GS(id->name) == ID_GR) {
1174 if (id == &to_collection->id) {
1175 return false;
1176 }
1177 }
1178 else {
1179 insert_type = TE_INSERT_INTO;
1180 }
1181
1182 /* Currently this should not be allowed, cannot edit items in an override of a Collection. */
1183 if (ID_IS_OVERRIDE_LIBRARY(to_collection) &&
1184 !ELEM(insert_type, TE_INSERT_AFTER, TE_INSERT_BEFORE))
1185 {
1186 return false;
1187 }
1188
1189 data->from = from_collection;
1190 data->to = to_collection;
1191 data->te = te;
1192 data->insert_type = insert_type;
1193
1194 return true;
1195}
1196
1197static bool collection_drop_poll(bContext *C, wmDrag *drag, const wmEvent *event)
1198{
1199 SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
1200 ARegion *region = CTX_wm_region(C);
1201 bool changed = outliner_flag_set(*space_outliner, TSE_HIGHLIGHTED_ANY | TSE_DRAG_ANY, false);
1202
1204 if (((event->modifier & KM_SHIFT) == 0) && collection_drop_init(C, drag, event->xy, &data)) {
1205 TreeElement *te = data.te;
1206 TreeStoreElem *tselem = TREESTORE(te);
1207 switch (data.insert_type) {
1208 case TE_INSERT_BEFORE:
1209 tselem->flag |= TSE_DRAG_BEFORE;
1210 changed = true;
1211 break;
1212 case TE_INSERT_AFTER:
1213 tselem->flag |= TSE_DRAG_AFTER;
1214 changed = true;
1215 break;
1216 case TE_INSERT_INTO: {
1217 tselem->flag |= TSE_DRAG_INTO;
1218 changed = true;
1219 break;
1220 }
1221 }
1222 if (changed) {
1224 }
1225 return true;
1226 }
1227 if (changed) {
1229 }
1230 return false;
1231}
1232
1234 wmDrag *drag,
1235 const int xy[2],
1236 wmDropBox * /*drop*/)
1237{
1238 wmWindow *win = CTX_wm_window(C);
1239 const wmEvent *event = win ? win->eventstate : nullptr;
1240
1242 if (event && ((event->modifier & KM_SHIFT) == 0) && collection_drop_init(C, drag, xy, &data)) {
1243 const bool is_link = !data.from || (event->modifier & KM_CTRL);
1244
1245 /* Test if we are moving within same parent collection. */
1246 bool same_level = false;
1247 LISTBASE_FOREACH (CollectionParent *, parent, &data.to->runtime.parents) {
1248 if (data.from == parent->collection) {
1249 same_level = true;
1250 }
1251 }
1252
1253 /* Tooltips when not moving directly into another collection i.e. mouse on border of
1254 * collections. Later we will decide which tooltip to return. */
1255 const bool tooltip_link = (is_link && !same_level);
1256 const char *tooltip_before = tooltip_link ? TIP_("Link before collection") :
1257 TIP_("Move before collection");
1258 const char *tooltip_between = tooltip_link ? TIP_("Link between collections") :
1259 TIP_("Move between collections");
1260 const char *tooltip_after = tooltip_link ? TIP_("Link after collection") :
1261 TIP_("Move after collection");
1262
1263 TreeElement *te = data.te;
1264 switch (data.insert_type) {
1265 case TE_INSERT_BEFORE:
1267 return tooltip_between;
1268 }
1269 return tooltip_before;
1270 case TE_INSERT_AFTER:
1272 return tooltip_between;
1273 }
1274 return tooltip_after;
1275 case TE_INSERT_INTO: {
1276 if (is_link) {
1277 return TIP_("Link inside collection");
1278 }
1279
1280 /* Check the type of the drag IDs to avoid the incorrect "Shift to parent"
1281 * for collections. Checking the type of the first ID works fine here since
1282 * all drag IDs are the same type. */
1283 wmDragID *drag_id = (wmDragID *)drag->ids.first;
1284 const bool is_object = (GS(drag_id->id->name) == ID_OB);
1285 if (is_object) {
1286 return TIP_("Move inside collection (Ctrl to link, Shift to parent)");
1287 }
1288 return TIP_("Move inside collection (Ctrl to link)");
1289 }
1290 }
1291 }
1292 return {};
1293}
1294
1296 wmOperator * /*op*/,
1297 const wmEvent *event)
1298{
1299 Main *bmain = CTX_data_main(C);
1300 Scene *scene = CTX_data_scene(C);
1301
1302 if (event->custom != EVT_DATA_DRAGDROP) {
1303 return OPERATOR_CANCELLED;
1304 }
1305
1306 ListBase *lb = static_cast<ListBase *>(event->customdata);
1307 wmDrag *drag = static_cast<wmDrag *>(lb->first);
1308
1310 if (!collection_drop_init(C, drag, event->xy, &data)) {
1311 return OPERATOR_CANCELLED;
1312 }
1313
1314 /* Before/after insert handling. */
1315 Collection *relative = nullptr;
1316 bool relative_after = false;
1317
1318 if (ELEM(data.insert_type, TE_INSERT_BEFORE, TE_INSERT_AFTER)) {
1319 SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
1320
1321 relative = data.to;
1322 relative_after = (data.insert_type == TE_INSERT_AFTER);
1323
1324 TreeElement *parent_te = outliner_find_parent_element(&space_outliner->tree, nullptr, data.te);
1325 data.to = (parent_te) ? outliner_collection_from_tree_element(parent_te) : nullptr;
1326 }
1327
1328 if (!data.to) {
1329 return OPERATOR_CANCELLED;
1330 }
1331
1332 if (BKE_collection_is_empty(data.to)) {
1333 TREESTORE(data.te)->flag &= ~TSE_CLOSED;
1334 }
1335
1336 if (relative_after) {
1337 BLI_listbase_reverse(&drag->ids);
1338 }
1339
1340 LISTBASE_FOREACH (wmDragID *, drag_id, &drag->ids) {
1341 /* Ctrl enables linking, so we don't need a from collection then. */
1342 Collection *from = (event->modifier & KM_CTRL) ?
1343 nullptr :
1344 collection_parent_from_ID(drag_id->from_parent);
1345
1346 if (GS(drag_id->id->name) == ID_OB) {
1347 /* Move/link object into collection. */
1348 Object *object = (Object *)drag_id->id;
1349
1350 if (from) {
1351 BKE_collection_object_move(bmain, scene, data.to, from, object);
1352 }
1353 else {
1354 BKE_collection_object_add(bmain, data.to, object);
1355 }
1356 }
1357 else if (GS(drag_id->id->name) == ID_GR) {
1358 /* Move/link collection into collection. */
1359 Collection *collection = (Collection *)drag_id->id;
1360
1361 if (collection != from) {
1362 BKE_collection_move(bmain, data.to, from, relative, relative_after, collection);
1363 }
1364 }
1365
1366 if (from) {
1367 DEG_id_tag_update(&from->id,
1369 }
1370 }
1371
1372 /* Update dependency graph. */
1376
1377 return OPERATOR_FINISHED;
1378}
1379
1381{
1382 /* identifiers */
1383 ot->name = "Move to Collection";
1384 ot->description = "Drag to move to collection in Outliner";
1385 ot->idname = "OUTLINER_OT_collection_drop";
1386
1387 /* API callbacks. */
1388 ot->invoke = collection_drop_invoke;
1390
1391 /* flags */
1393}
1394
1396
1397/* -------------------------------------------------------------------- */
1400
1401#define OUTLINER_DRAG_SCOLL_OUTSIDE_PAD 7 /* In UI units */
1402
1404 ARegion *region,
1405 const wmEvent *event)
1406{
1407 /* NOTE: using click-drag events to trigger dragging is fine,
1408 * it sends coordinates from where dragging was started */
1409 int mval[2];
1410 WM_event_drag_start_mval(event, region, mval);
1411
1412 const float my = UI_view2d_region_to_view_y(&region->v2d, mval[1]);
1413 return outliner_find_item_at_y(space_outliner, &space_outliner->tree, my);
1414}
1415
1417 wmOperator * /*op*/,
1418 const wmEvent *event)
1419{
1420 ARegion *region = CTX_wm_region(C);
1421 SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
1422 TreeElement *te = outliner_item_drag_element_find(space_outliner, region, event);
1423
1424 int mval[2];
1425 WM_event_drag_start_mval(event, region, mval);
1426
1427 if (!te) {
1429 }
1430
1431 TreeStoreElem *tselem = TREESTORE(te);
1433 if (!data.drag_id) {
1435 }
1436
1437 float view_mval[2];
1438 UI_view2d_region_to_view(&region->v2d, mval[0], mval[1], &view_mval[0], &view_mval[1]);
1439 if (outliner_item_is_co_within_close_toggle(te, view_mval[0])) {
1441 }
1442 if (outliner_is_co_within_mode_column(space_outliner, view_mval)) {
1444 }
1445
1446 /* Scroll the view when dragging near edges, but not
1447 * when the drag goes too far outside the region. */
1448 {
1449 wmOperatorType *ot = WM_operatortype_find("VIEW2D_OT_edge_pan", true);
1450 PointerRNA op_ptr;
1452 RNA_float_set(&op_ptr, "outside_padding", OUTLINER_DRAG_SCOLL_OUTSIDE_PAD);
1455 }
1456
1457 const bool use_datastack_drag = ELEM(tselem->type,
1464
1465 const eWM_DragDataType wm_drag_type = use_datastack_drag ? WM_DRAG_DATASTACK : WM_DRAG_ID;
1466 wmDrag *drag = WM_drag_data_create(C, data.icon, wm_drag_type, nullptr, WM_DRAG_NOP);
1467
1468 if (use_datastack_drag) {
1469 TreeElement *te_bone = nullptr;
1470 bPoseChannel *pchan = outliner_find_parent_bone(te, &te_bone);
1471 datastack_drop_data_init(drag, (Object *)tselem->id, pchan, te, tselem, te->directdata);
1472 }
1473 else if (ELEM(GS(data.drag_id->name), ID_OB, ID_GR)) {
1474 /* For collections and objects we cheat and drag all selected. */
1475
1476 /* Only drag element under mouse if it was not selected before. */
1477 if ((tselem->flag & TSE_SELECTED) == 0) {
1478 outliner_flag_set(*space_outliner, TSE_SELECTED, 0);
1479 tselem->flag |= TSE_SELECTED;
1480 }
1481
1482 /* Gather all selected elements. */
1483 IDsSelectedData selected{};
1484
1485 if (GS(data.drag_id->name) == ID_OB) {
1486 outliner_tree_traverse(space_outliner,
1487 &space_outliner->tree,
1488 0,
1491 &selected);
1492 }
1493 else {
1494 outliner_tree_traverse(space_outliner,
1495 &space_outliner->tree,
1496 0,
1499 &selected);
1500 }
1501
1502 LISTBASE_FOREACH (LinkData *, link, &selected.selected_array) {
1503 TreeElement *te_selected = (TreeElement *)link->data;
1504 ID *id;
1505
1506 if (GS(data.drag_id->name) == ID_OB) {
1507 id = TREESTORE(te_selected)->id;
1508 }
1509 else {
1510 /* Keep collection hierarchies intact when dragging. */
1511 bool parent_selected = false;
1512 for (TreeElement *te_parent = te_selected->parent; te_parent;
1513 te_parent = te_parent->parent)
1514 {
1515 if (outliner_is_collection_tree_element(te_parent)) {
1516 if (TREESTORE(te_parent)->flag & TSE_SELECTED) {
1517 parent_selected = true;
1518 break;
1519 }
1520 }
1521 }
1522
1523 if (parent_selected) {
1524 continue;
1525 }
1526
1527 id = &outliner_collection_from_tree_element(te_selected)->id;
1528 }
1529
1530 /* Find parent collection. */
1531 Collection *parent = nullptr;
1532
1533 if (te_selected->parent) {
1534 for (TreeElement *te_parent = te_selected->parent; te_parent;
1535 te_parent = te_parent->parent)
1536 {
1537 if (outliner_is_collection_tree_element(te_parent)) {
1538 parent = outliner_collection_from_tree_element(te_parent);
1539 break;
1540 }
1541 }
1542 }
1543 else {
1544 Scene *scene = CTX_data_scene(C);
1545 parent = scene->master_collection;
1546 }
1547
1548 WM_drag_add_local_ID(drag, id, &parent->id);
1549 }
1550
1551 BLI_freelistN(&selected.selected_array);
1552 }
1553 else {
1554 /* Add single ID. */
1555 WM_drag_add_local_ID(drag, data.drag_id, data.drag_parent);
1556 }
1557
1559
1561
1563}
1564
1565/* Outliner drag and drop. This operator mostly exists to support dragging
1566 * from outliner text instead of only from the icon, and also to show a
1567 * hint in the status-bar key-map. */
1568
1570{
1571 ot->name = "Drag and Drop";
1572 ot->idname = "OUTLINER_OT_item_drag_drop";
1573 ot->description = "Drag and drop element to another place";
1574
1577}
1578
1579#undef OUTLINER_DRAG_SCOLL_OUTSIDE_PAD
1580
1582
1583/* -------------------------------------------------------------------- */
1586
1588{
1590
1591 WM_dropbox_add(lb, "OUTLINER_OT_parent_drop", parent_drop_poll, nullptr, nullptr, nullptr);
1592 WM_dropbox_add(lb, "OUTLINER_OT_parent_clear", parent_clear_poll, nullptr, nullptr, nullptr);
1593 WM_dropbox_add(lb, "OUTLINER_OT_scene_drop", scene_drop_poll, nullptr, nullptr, nullptr);
1594 WM_dropbox_add(lb, "OUTLINER_OT_material_drop", material_drop_poll, nullptr, nullptr, nullptr);
1595 WM_dropbox_add(lb,
1596 "OUTLINER_OT_datastack_drop",
1598 nullptr,
1599 nullptr,
1601 WM_dropbox_add(lb,
1602 "OUTLINER_OT_collection_drop",
1604 nullptr,
1605 nullptr,
1607}
1608
1610
1611} // namespace blender::ed::outliner
bool BKE_collection_is_empty(const Collection *collection)
bool BKE_collection_move(Main *bmain, Collection *to_parent, Collection *from_parent, Collection *relative, bool relative_after, Collection *collection)
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)
ReportList * CTX_wm_reports(const bContext *C)
SpaceOutliner * CTX_wm_space_outliner(const bContext *C)
wmWindow * CTX_wm_window(const bContext *C)
Scene * CTX_data_scene(const bContext *C)
Main * CTX_data_main(const bContext *C)
ARegion * CTX_wm_region(const bContext *C)
Collection * CTX_data_collection(const bContext *C)
void BKE_view_layer_synced_ensure(const Scene *scene, ViewLayer *view_layer)
bool BKE_scene_has_object(Scene *scene, Object *ob)
Base * BKE_view_layer_base_find(ViewLayer *view_layer, Object *ob)
bool BKE_id_is_editable(const Main *bmain, const ID *id)
Definition lib_id.cc:2503
General operations, lookup, etc. for materials.
void BKE_object_material_assign(Main *bmain, Object *ob, Material *ma, short act, int assign_type)
@ BKE_MAT_ASSIGN_USERPREF
General operations, lookup, etc. for blender objects.
bool BKE_object_is_child_recursive(const Object *ob_parent, const Object *ob_child)
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition report.cc:126
#define BLI_assert_unreachable()
Definition BLI_assert.h:93
int BLI_findindex(const ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition listbase.cc:586
#define LISTBASE_FOREACH(type, var, list)
BLI_INLINE bool BLI_listbase_is_empty(const ListBase *lb)
void void BLI_freelistN(ListBase *listbase) ATTR_NONNULL(1)
Definition listbase.cc:497
void void void void void void void BLI_listbase_reverse(ListBase *lb) ATTR_NONNULL(1)
Definition listbase.cc:836
#define ELEM(...)
#define TIP_(msgid)
void DEG_id_tag_update(ID *id, unsigned int flags)
void DEG_relations_tag_update(Main *bmain)
@ ID_RECALC_SELECT
Definition DNA_ID.h:1009
@ ID_RECALC_HIERARCHY
Definition DNA_ID.h:1066
@ ID_RECALC_SYNC_TO_EVAL
Definition DNA_ID.h:1026
@ ID_RECALC_GEOMETRY
Definition DNA_ID.h:982
struct ID ID
@ ID_SCE
@ ID_MA
@ ID_GR
@ ID_OB
Object groups, one object can be in many groups at once.
@ COLLECTION_IS_MASTER
struct Collection Collection
Object is a sort of wrapper for general info.
@ OB_GREASE_PENCIL
@ TSE_POSE_CHANNEL
@ TSE_CONSTRAINT_BASE
@ TSE_MODIFIER_BASE
@ TSE_GPENCIL_EFFECT
@ TSE_LIBRARY_OVERRIDE_BASE
@ TSE_CONSTRAINT
@ TSE_GPENCIL_EFFECT_BASE
@ TSE_SOME_ID
@ TSE_MODIFIER
@ TSE_DRAG_AFTER
@ TSE_HIGHLIGHTED_ANY
@ TSE_SELECTED
@ TSE_DRAG_INTO
@ TSE_CLOSED
@ TSE_DRAG_BEFORE
@ TSE_DRAG_ANY
@ RGN_TYPE_WINDOW
@ SPACE_OUTLINER
@ SO_FILTER_NO_COLLECTION
@ SO_VIEW_LAYER
@ SO_SCENES
@ OPERATOR_CANCELLED
@ OPERATOR_FINISHED
@ OPERATOR_PASS_THROUGH
void ED_outliner_select_sync_from_outliner(bContext *C, SpaceOutliner *space_outliner)
bool ED_operator_region_outliner_active(bContext *C)
void ED_region_tag_redraw_no_rebuild(ARegion *region)
Definition area.cc:659
void ED_region_tag_redraw(ARegion *region)
Definition area.cc:639
bool ED_operator_outliner_active(bContext *C)
Read Guarded memory(de)allocation.
#define C
Definition RandGen.cpp:29
#define UI_UNIT_Y
#define UI_UNIT_X
float UI_view2d_region_to_view_y(const View2D *v2d, float y)
Definition view2d.cc:1661
void UI_view2d_region_to_view(const View2D *v2d, float x, float y, float *r_view_x, float *r_view_y) ATTR_NONNULL()
Definition view2d.cc:1667
@ KM_CTRL
Definition WM_types.hh:276
@ KM_ALT
Definition WM_types.hh:277
@ KM_SHIFT
Definition WM_types.hh:275
@ WM_DRAG_NOP
Definition WM_types.hh:1225
@ WM_DRAG_FREE_DATA
Definition WM_types.hh:1226
#define ND_OB_SELECT
Definition WM_types.hh:439
#define NC_SCENE
Definition WM_types.hh:375
#define ND_PARENT
Definition WM_types.hh:464
ReportList * reports
Definition WM_types.hh:1025
#define NC_MATERIAL
Definition WM_types.hh:377
#define ND_TRANSFORM
Definition WM_types.hh:453
#define ND_LAYER
Definition WM_types.hh:447
@ WM_OP_INVOKE_DEFAULT
Definition WM_types.hh:238
eWM_DragDataType
Definition WM_types.hh:1197
@ WM_DRAG_DATASTACK
Definition WM_types.hh:1216
@ WM_DRAG_ID
Definition WM_types.hh:1198
#define ND_OB_SHADING
Definition WM_types.hh:454
#define ND_SPACE_VIEW3D
Definition WM_types.hh:525
#define NC_OBJECT
Definition WM_types.hh:376
#define ND_SHADING_LINKS
Definition WM_types.hh:476
@ OPTYPE_INTERNAL
Definition WM_types.hh:202
@ OPTYPE_UNDO
Definition WM_types.hh:182
@ OPTYPE_REGISTER
Definition WM_types.hh:180
#define NC_SPACE
Definition WM_types.hh:389
BMesh const char void * data
#define ID_IS_EDITABLE(_id)
#define ID_IS_OVERRIDE_LIBRARY(_id)
#define GS(a)
void * MEM_callocN(size_t len, const char *str)
Definition mallocn.cc:118
void constraint_link(Main *bmain, Object *ob_dst, ListBase *dst, ListBase *src)
void constraint_copy_for_object(Main *bmain, Object *ob_dst, bConstraint *con)
bool modifier_copy_to_object(Main *bmain, const Scene *scene, const Object *ob_src, const ModifierData *md, Object *ob_dst, ReportList *reports)
void constraint_copy_for_pose(Main *bmain, Object *ob_dst, bPoseChannel *pchan, bConstraint *con)
void base_select(Base *base, eObjectSelect_Mode mode)
void parent_clear(Object *ob, int type)
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)
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)
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(TreeElement *te, Object *potential_child)
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)
TreeElement * outliner_find_id(SpaceOutliner *space_outliner, ListBase *lb, const ID *id)
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)
bool outliner_flag_set(const SpaceOutliner &space_outliner, const short flag, const short set)
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)
TreeElement * outliner_find_item_at_y(const SpaceOutliner *space_outliner, const ListBase *tree, float view_co_y)
static TreeElement * outliner_drop_insert_collection_find(bContext *C, const int xy[2], TreeElementInsertType *r_insert_type)
bPoseChannel * outliner_find_parent_bone(TreeElement *te, TreeElement **r_bone_te)
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 datastack_drop_data_init(wmDrag *drag, Object *ob, bPoseChannel *pchan, TreeElement *te, TreeStoreElem *tselem, void *directdata)
static int outliner_get_insert_index(TreeElement *drag_te, TreeElement *drop_te, TreeElementInsertType insert_type, ListBase *listbase)
TreeTraversalAction outliner_collect_selected_objects(TreeElement *te, void *customdata)
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)
bool outliner_tree_traverse(const SpaceOutliner *space_outliner, ListBase *tree, int filter_te_flag, int filter_tselem_flag, TreeTraversalFunc func, void *customdata)
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)
TreeElement * outliner_find_tree_element(ListBase *lb, const TreeStoreElem *store_elem)
TreeElement * outliner_find_parent_element(ListBase *lb, TreeElement *parent_te, const TreeElement *child_te)
static wmOperatorStatus parent_drop_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static bool is_object_element(TreeElement *te)
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)
void OUTLINER_OT_parent_clear(wmOperatorType *ot)
static TreeElement * outliner_dropzone_element(TreeElement *te, const float fmval[2], const bool children)
static wmOperatorStatus parent_clear_invoke(bContext *C, wmOperator *, const wmEvent *event)
TreeTraversalAction outliner_collect_selected_collections(TreeElement *te, void *customdata)
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)
#define OUTLINER_DRAG_SCOLL_OUTSIDE_PAD
#define TREESTORE(a)
#define TSELEM_OPEN(telm, sv)
void RNA_float_set(PointerRNA *ptr, const char *name, float value)
Definition DNA_ID.h:404
char name[66]
Definition DNA_ID.h:415
void * last
void * first
struct MaterialGPencilStyle * gp_style
ListBase constraints
ListBase modifiers
ListBase shader_fx
struct Object * parent
struct Collection * master_collection
ListBase view_layers
int ymin
int xmin
wmDragID * next
Definition WM_types.hh:1233
ID * from_parent
Definition WM_types.hh:1235
eWM_DragDataType type
Definition WM_types.hh:1327
void * poin
Definition WM_types.hh:1328
ListBase ids
Definition WM_types.hh:1341
eWM_DragFlags flags
Definition WM_types.hh:1338
wmEventModifierFlag modifier
Definition WM_types.hh:771
short custom
Definition WM_types.hh:790
int xy[2]
Definition WM_types.hh:758
int mval[2]
Definition WM_types.hh:760
struct ReportList * reports
struct wmEvent * eventstate
wmDropBox * WM_dropbox_add(ListBase *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_start_prepared_drag(bContext *C, wmDrag *drag)
wmDrag * WM_drag_data_create(bContext *C, int icon, eWM_DragDataType type, void *poin, uint flags)
ID * WM_drag_get_local_ID_from_event(const wmEvent *event, short idcode)
ListBase * WM_dropboxmap_find(const char *idname, int spaceid, int regionid)
void WM_drag_add_local_ID(wmDrag *drag, ID *id, ID *from_parent)
ID * WM_drag_get_local_ID(const wmDrag *drag, short idcode)
int xy[2]
Definition wm_draw.cc:174
void WM_event_drag_start_mval(const wmEvent *event, const ARegion *region, int r_mval[2])
void WM_main_add_notifier(uint type, void *reference)
wmOperatorStatus WM_operator_name_call_ptr(bContext *C, wmOperatorType *ot, wmOperatorCallContext context, PointerRNA *properties, const wmEvent *event)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
@ EVT_DATA_DRAGDROP
wmOperatorType * ot
Definition wm_files.cc:4226
wmOperatorType * WM_operatortype_find(const char *idname, bool quiet)
void WM_operator_properties_create_ptr(PointerRNA *ptr, wmOperatorType *ot)
void WM_operator_properties_free(PointerRNA *ptr)
uint8_t flag
Definition wm_window.cc:139