Blender V5.3
outliner_collections.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include <cstring>
10
11#include "BLI_listbase.hh"
12#include "BLI_set.hh"
13#include "BLI_utildefines.hh"
14
15#include "BLT_translation.hh"
16
17#include "DNA_ID.h"
19#include "DNA_layer_types.h"
20#include "DNA_object_types.h"
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_report.hh"
29
30#include "DEG_depsgraph.hh"
32
33#include "ED_object.hh"
34#include "ED_outliner.hh"
35#include "ED_screen.hh"
36
37#include "WM_api.hh"
38#include "WM_message.hh"
39#include "WM_types.hh"
40
41#include "RNA_access.hh"
42#include "RNA_define.hh"
43#include "RNA_enum_types.hh"
44
45#include "outliner_intern.hh" /* own include */
46
47#include "tree/tree_iterator.hh"
48
49namespace blender {
50
51namespace ed::outliner {
52
53/* -------------------------------------------------------------------- */
56
58{
59 TreeStoreElem *tselem = TREESTORE(te);
60
61 if (!tselem) {
62 return false;
63 }
64
65 if (ELEM(
67 {
68 return true;
69 }
70 if ((tselem->type == TSE_SOME_ID) && te->idcode == ID_GR) {
71 return true;
72 }
73
74 return false;
75}
76
78{
79 TreeStoreElem *tselem = TREESTORE(te);
80
81 if (!tselem) {
82 return nullptr;
83 }
84
85 if (tselem->type == TSE_LAYER_COLLECTION) {
86 LayerCollection *lc = static_cast<LayerCollection *>(te->directdata);
87 return lc->collection;
88 }
90 Scene *scene = id_cast<Scene *>(tselem->id);
91 return scene->master_collection;
92 }
93 if ((tselem->type == TSE_SOME_ID) && (te->idcode == ID_GR)) {
94 return id_cast<Collection *>(tselem->id);
95 }
96
97 return nullptr;
98}
99
101{
102 IDsSelectedData *data = static_cast<IDsSelectedData *>(customdata);
103 TreeStoreElem *tselem = TREESTORE(te);
104
106 BLI_addtail(&data->selected_array, BLI_genericNodeN(te));
107 return TRAVERSE_CONTINUE;
108 }
109
110 if ((tselem->type != TSE_SOME_ID) || (tselem->id && tselem->id->id_type() != ID_GR)) {
112 }
113
114 return TRAVERSE_CONTINUE;
115}
116
118 void *customdata)
119{
120 IDsSelectedData *data = static_cast<IDsSelectedData *>(customdata);
121 /* If collection is already selected, skip iterating their children. */
124 return TRAVERSE_CONTINUE;
125 }
126 BLI_addtail(&data->selected_array, BLI_genericNodeN(te));
128 }
129 return TRAVERSE_CONTINUE;
130}
131
133{
134 IDsSelectedData *data = static_cast<IDsSelectedData *>(customdata);
135 TreeStoreElem *tselem = TREESTORE(te);
136
138 return TRAVERSE_CONTINUE;
139 }
140
141 if ((tselem->type != TSE_SOME_ID) || (tselem->id == nullptr) || (tselem->id->id_type() != ID_OB))
142 {
144 }
145
146 BLI_addtail(&data->selected_array, BLI_genericNodeN(te));
147
148 return TRAVERSE_CONTINUE;
149}
150
151} // namespace ed::outliner
152
153void ED_outliner_selected_objects_get(const bContext *C, ListBaseT<LinkData> *objects)
154{
155 using namespace blender::ed::outliner;
156
157 SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
158 IDsSelectedData data = {{nullptr}};
159 outliner_tree_traverse(space_outliner,
160 &space_outliner->runtime->tree,
161 0,
164 &data);
165 for (LinkData &link : data.selected_array) {
166 TreeElement *ten_selected = static_cast<TreeElement *>(link.data);
167 Object *ob = id_cast<Object *>(TREESTORE(ten_selected)->id);
168 BLI_addtail(objects, BLI_genericNodeN(ob));
169 }
170 data.selected_array.free_no_destruct();
171}
172
173namespace ed::outliner {
174
176
177/* -------------------------------------------------------------------- */
180
181} // namespace ed::outliner
182
184{
185 SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
186 return (space_outliner != nullptr) &&
188}
189
190namespace ed::outliner {
191
193{
194 SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
195 return (space_outliner != nullptr) && (space_outliner->outlinevis == SO_VIEW_LAYER);
196}
197
199{
201 return false;
202 }
203 Scene *scene = CTX_data_scene(C);
204 if (!ID_IS_EDITABLE(scene) || ID_IS_OVERRIDE_LIBRARY(scene)) {
205 return false;
206 }
207 return true;
208}
209
211{
213 return false;
214 }
216 return false;
217 }
218 return true;
219}
220
222
223/* -------------------------------------------------------------------- */
226
228{
229 WorkSpace *workspace = CTX_wm_workspace(C);
230 SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
231 ARegion *region = CTX_wm_region(C);
232 Main *bmain = CTX_data_main(C);
233 Scene *scene = CTX_data_scene(C);
234 ViewLayer *view_layer = CTX_data_view_layer(C);
235
236 Collection *collection = nullptr;
237
238 if (RNA_boolean_get(op->ptr, "nested")) {
239 if (TreeElement *active_te = outliner_find_element_with_flag(&space_outliner->runtime->tree,
240 TSE_ACTIVE))
241 {
242 collection = outliner_collection_from_tree_element(active_te);
243 if (active_te->idcode == ID_OB) {
244 collection = BKE_collection_object_find(
245 bmain, scene, nullptr, reinterpret_cast<Object *>(active_te->store_elem->id));
246 }
247 }
248 if (!collection && view_layer->active_collection) {
249 collection = view_layer->active_collection->collection;
250 }
251 }
252
253 if (collection == nullptr || !ID_IS_EDITABLE(collection) || ID_IS_OVERRIDE_LIBRARY(collection)) {
254 collection = scene->master_collection;
255 }
256
257 if (!ID_IS_EDITABLE(scene) || ID_IS_OVERRIDE_LIBRARY(scene)) {
258 BKE_report(op->reports, RPT_ERROR, "Cannot add a new collection to linked/override scene");
259 return OPERATOR_CANCELLED;
260 }
261
262 Collection *new_collection = BKE_collection_add(bmain, collection, nullptr);
263 new_collection->color_tag = collection->color_tag;
264 BKE_view_layer_synced_ensure(*bmain, scene, view_layer);
266 view_layer, new_collection))
267 {
268 BKE_layer_collection_activate(view_layer, layer_collection);
271 }
272
273 outliner_build_tree(bmain, workspace, scene, view_layer, space_outliner, region);
274 bool is_textbut_set = false;
275 tree_iterator::all(space_outliner->runtime->tree, [&](TreeElement *te) {
276 TreeStoreElem *tselem = TREESTORE(te);
277 if (Collection *collection = outliner_collection_from_tree_element(te)) {
278 if ((new_collection == collection) && !is_textbut_set) {
279 tselem->flag |= TSE_TEXTBUT;
280 is_textbut_set = true;
281 }
282 }
283 });
284
287
288 outliner_cleanup_tree(space_outliner);
290 return OPERATOR_FINISHED;
291}
292
294{
295 /* identifiers */
296 ot->name = "New Collection";
297 ot->idname = "OUTLINER_OT_collection_new";
298 ot->description = "Add a new collection";
299
300 /* API callbacks. */
303
304 /* flags */
306
307 /* properties */
309 ot->srna, "nested", false, "Nested", "Add as child of selected collection");
311}
312
314
315/* -------------------------------------------------------------------- */
318
324
325 /* Whether the processed operation should be allowed on liboverride collections, or not. */
327 /* Whether the processed operation should be allowed on hierarchy roots of liboverride
328 * collections, or not. */
330 /* When true, do not skip the hierarchy of children when a parent collection is selected. This is
331 * useful for deleting selected child collections, see: #126860. */
332 bool is_recursive = false;
333};
334
336{
337 CollectionEditData *data = static_cast<CollectionEditData *>(customdata);
339
340 if (!collection) {
342 }
343
344 if (collection->flag & COLLECTION_IS_MASTER) {
345 /* Skip - showing warning/error message might be misleading
346 * when deleting multiple collections, so just do nothing. */
347 return TRAVERSE_CONTINUE;
348 }
349
350 if (ID_IS_OVERRIDE_LIBRARY_REAL(collection)) {
352 if (!(data->is_liboverride_hierarchy_root_allowed || data->is_liboverride_allowed)) {
354 }
355 }
356 else {
357 if (!data->is_liboverride_allowed) {
359 }
360 }
361 }
362
363 /* Delete, duplicate and link don't edit children, those will come along
364 * with the parents. */
365 data->collections_to_edit.add(collection);
366 return data->is_recursive ? TRAVERSE_CONTINUE : TRAVERSE_SKIP_CHILDS;
367}
368
370 bContext *C, Main *bmain, Scene *scene, ReportList *reports, bool do_hierarchy)
371{
372 SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
373
375 data.scene = scene;
376 data.space_outliner = space_outliner;
377 data.is_liboverride_allowed = false;
378 data.is_liboverride_hierarchy_root_allowed = do_hierarchy;
379 data.is_recursive = !do_hierarchy;
380
381 /* We first walk over and find the Collections we actually want to delete
382 * (ignoring duplicates). */
383 outliner_tree_traverse(space_outliner,
384 &space_outliner->runtime->tree,
385 0,
388 &data);
389
390 /* Effectively delete the collections. */
391 for (Collection *collection : data.collections_to_edit) {
392 /* Test in case collection got deleted as part of another one. */
393 if (BLI_findindex(&bmain->collections, collection) != -1) {
394 /* We cannot allow deleting collections that are indirectly linked,
395 * or that are used by (linked to...) other linked scene/collection. */
396 bool skip = false;
397 if (!ID_IS_EDITABLE(collection)) {
398 if (collection->id.tag & ID_TAG_INDIRECT) {
399 skip = true;
400 }
401 else {
402 for (CollectionParent &cparent : collection->runtime->parents) {
403 Collection *parent = cparent.collection;
404 if (!ID_IS_EDITABLE(parent) || ID_IS_OVERRIDE_LIBRARY(parent)) {
405 skip = true;
406 break;
407 }
408 if (parent->flag & COLLECTION_IS_MASTER) {
410
411 ID *scene_owner = BKE_id_owner_get(&parent->id);
412 BLI_assert(scene_owner != nullptr);
413 BLI_assert(GS(scene_owner->name) == ID_SCE);
414 if (!ID_IS_EDITABLE(scene_owner) || ID_IS_OVERRIDE_LIBRARY(scene_owner)) {
415 skip = true;
416 break;
417 }
418 }
419 }
420 }
421 }
422
423 if (!skip) {
424 BKE_collection_delete(bmain, collection, do_hierarchy);
425 }
426 else {
427 BKE_reportf(reports,
429 "Cannot delete collection '%s', it is either a linked one used by other "
430 "linked scenes/collections, or a library override one",
431 collection->id.name + 2);
432 }
433 }
434 }
435}
436
438{
439 Main *bmain = CTX_data_main(C);
440 Scene *scene = CTX_data_scene(C);
441 ViewLayer *view_layer = CTX_data_view_layer(C);
443 BKE_view_layer_synced_ensure(*bmain, scene, view_layer);
444 const Base *basact_prev = BKE_view_layer_active_base_get(view_layer);
445
446 outliner_collection_delete(C, bmain, scene, op->reports, true);
447
450
452
453 BKE_view_layer_synced_ensure(*bmain, scene, view_layer);
454 if (basact_prev != BKE_view_layer_active_base_get(view_layer)) {
455 WM_msg_publish_rna_prop(mbus, &scene->id, view_layer, LayerObjects, active);
456 }
457
459
460 return OPERATOR_FINISHED;
461}
462
464{
465 /* identifiers */
466 ot->name = "Delete Hierarchy";
467 ot->idname = "OUTLINER_OT_collection_hierarchy_delete";
468 ot->description = "Delete selected collection hierarchies";
469
470 /* API callbacks. */
473
474 /* flags */
476}
477
479
480/* -------------------------------------------------------------------- */
483
488
490 void *customdata)
491{
493 TreeStoreElem *tselem = TREESTORE(te);
494
495 switch (tselem->type) {
497 data->layer_collection = static_cast<LayerCollection *>(te->directdata);
498 return TRAVERSE_BREAK;
499 case TSE_R_LAYER:
502 return TRAVERSE_CONTINUE;
503 default:
505 }
506}
507
509{
510 SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
511
513
514 outliner_tree_traverse(space_outliner,
515 &space_outliner->runtime->tree,
516 0,
519 &data);
520 return data.layer_collection;
521}
522
524{
525 const Main *bmain = CTX_data_main(C);
526 Scene *scene = CTX_data_scene(C);
527 ViewLayer *view_layer = CTX_data_view_layer(C);
528 SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
529 bool deselect = STREQ(op->idname, "OUTLINER_OT_collection_objects_deselect");
530
531 IDsSelectedData selected_collections{};
532 outliner_tree_traverse(space_outliner,
533 &space_outliner->runtime->tree,
534 0,
537 &selected_collections);
538
539 if (selected_collections.selected_array.first_ == nullptr) {
540 return OPERATOR_CANCELLED;
541 }
542
543 for (LinkData &link : selected_collections.selected_array) {
544 TreeElement *te = static_cast<TreeElement *>(link.data);
546 LayerCollection *layer_collection = static_cast<LayerCollection *>(te->directdata);
547 BKE_layer_collection_objects_select(*bmain, scene, view_layer, layer_collection, deselect);
548 }
549 }
550
551 selected_collections.selected_array.free_no_destruct();
555
556 return OPERATOR_FINISHED;
557}
558
560{
561 /* identifiers */
562 ot->name = "Select Objects";
563 ot->idname = "OUTLINER_OT_collection_objects_select";
564 ot->description = "Select objects in collection";
565
566 /* API callbacks. */
569
570 /* flags */
572}
573
575{
576 /* identifiers */
577 ot->name = "Deselect Objects";
578 ot->idname = "OUTLINER_OT_collection_objects_deselect";
579 ot->description = "Deselect objects in collection";
580
581 /* API callbacks. */
584
585 /* flags */
587}
588
590
591/* -------------------------------------------------------------------- */
594
598
600 void *customdata)
601{
602 CollectionDuplicateData *data = static_cast<CollectionDuplicateData *>(customdata);
603 TreeStoreElem *tselem = TREESTORE(te);
604
605 switch (tselem->type) {
607 data->te = te;
608 return TRAVERSE_BREAK;
609 case TSE_R_LAYER:
612 default:
613 return TRAVERSE_CONTINUE;
614 }
615}
616
618{
619 SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
620
622
623 outliner_tree_traverse(space_outliner,
624 &space_outliner->runtime->tree,
625 0,
628 &data);
629 return data.te;
630}
631
633{
634 Main *bmain = CTX_data_main(C);
635 const bool linked = strstr(op->idname, "linked") != nullptr;
636 SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
637
638 IDsSelectedData selected_collections{};
639 outliner_tree_traverse(space_outliner,
640 &space_outliner->runtime->tree,
641 0,
644 &selected_collections);
645
646 /* Can happen when calling from a key binding. */
647 if (selected_collections.selected_array.is_empty()) {
648 BKE_report(op->reports, RPT_ERROR, "No collection selected");
649 return OPERATOR_CANCELLED;
650 }
651
652 int failed_count = 0;
653 for (LinkData &link : selected_collections.selected_array) {
654 TreeElement *te = static_cast<TreeElement *>(link.data);
657 nullptr;
658 if (!parent) {
659 failed_count += 1;
660 continue;
661 }
662 CollectionChild *child = BKE_collection_child_find(parent, collection);
663
664 /* We are allowed to duplicated linked collections (they will become local IDs then),
665 * but we should not allow its parent to be a linked ID, ever.
666 * This can happen when a whole scene is linked e.g. */
667 if (parent != nullptr && (!ID_IS_EDITABLE(parent) || ID_IS_OVERRIDE_LIBRARY(parent))) {
668 Scene *scene = CTX_data_scene(C);
669 parent = (!ID_IS_EDITABLE(scene) || ID_IS_OVERRIDE_LIBRARY(scene)) ?
670 nullptr :
671 scene->master_collection;
672 }
673 else if (parent != nullptr && (parent->flag & COLLECTION_IS_MASTER) != 0) {
675
676 Scene *scene_owner = reinterpret_cast<Scene *>(BKE_id_owner_get(&parent->id));
677 BLI_assert(scene_owner != nullptr);
678 BLI_assert(GS(scene_owner->id.name) == ID_SCE);
679
680 if (!ID_IS_EDITABLE(scene_owner) || ID_IS_OVERRIDE_LIBRARY(scene_owner)) {
681 scene_owner = CTX_data_scene(C);
682 parent = (!ID_IS_EDITABLE(scene_owner) || ID_IS_OVERRIDE_LIBRARY(scene_owner)) ?
683 nullptr :
684 scene_owner->master_collection;
685 }
686 }
687
689 (linked ? 0 : U.dupflag));
691 bmain, parent, child, collection, dupli_flags, LIB_ID_DUPLICATE_IS_ROOT_ID);
692 }
693
694 if (failed_count != 0) {
697 "Unable to duplicate %d of the selected collections. "
698 "Could not find a valid parent collection for the new duplicate, "
699 "they won't be linked to any view layer",
700 failed_count);
701 }
702
703 selected_collections.selected_array.free_no_destruct();
707
708 return OPERATOR_FINISHED;
709}
710
712{
713 /* identifiers */
714 ot->name = "Duplicate Linked Collection";
715 ot->idname = "OUTLINER_OT_collection_duplicate_linked";
716 ot->description =
717 "Recursively duplicate the collection, all its children and objects, with linked object "
718 "data";
719
720 /* API callbacks. */
723
724 /* flags */
726}
727
729{
730 /* identifiers */
731 ot->name = "Duplicate Collection";
732 ot->idname = "OUTLINER_OT_collection_duplicate";
733 ot->description =
734 "Recursively duplicate the collection, all its children, objects and object data";
735
736 /* API callbacks. */
739
740 /* flags */
742}
743
745
746/* -------------------------------------------------------------------- */
749
751{
752 Main *bmain = CTX_data_main(C);
753 Scene *scene = CTX_data_scene(C);
754 Collection *active_collection = CTX_data_layer_collection(C)->collection;
755 SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
756
758 data.scene = scene;
759 data.space_outliner = space_outliner;
760 data.is_liboverride_allowed = false; /* No linking of non-root collections. */
761 data.is_liboverride_hierarchy_root_allowed = true;
762
763 if ((!ID_IS_EDITABLE(active_collection) || ID_IS_OVERRIDE_LIBRARY(active_collection)) ||
764 ((active_collection->flag & COLLECTION_IS_MASTER) &&
765 (!ID_IS_EDITABLE(scene) || ID_IS_OVERRIDE_LIBRARY(scene))))
766 {
768 op->reports, RPT_ERROR, "Cannot add a collection to a linked/override collection/scene");
769 return OPERATOR_CANCELLED;
770 }
771
772 /* We first walk over and find the Collections we actually want to link (ignoring duplicates). */
773 outliner_tree_traverse(space_outliner,
774 &space_outliner->runtime->tree,
775 0,
778 &data);
779
780 /* Effectively link the collections. */
781 for (Collection *collection : data.collections_to_edit) {
782 BKE_collection_child_add(bmain, active_collection, collection);
783 id_fake_user_clear(&collection->id);
784 }
785
786 DEG_id_tag_update(&active_collection->id, ID_RECALC_SYNC_TO_EVAL);
788
790
791 return OPERATOR_FINISHED;
792}
793
795{
796 /* identifiers */
797 ot->name = "Link Collection";
798 ot->idname = "OUTLINER_OT_collection_link";
799 ot->description = "Link selected collections to active scene";
800
801 /* API callbacks. */
804
805 /* flags */
807}
808
810
811/* -------------------------------------------------------------------- */
814
816{
817 Main *bmain = CTX_data_main(C);
818 Scene *scene = CTX_data_scene(C);
819 ViewLayer *view_layer = CTX_data_view_layer(C);
820 SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
822 data.scene = scene;
823 data.space_outliner = space_outliner;
824 data.is_liboverride_allowed = true;
825 data.is_liboverride_hierarchy_root_allowed = true;
826
827 /* We first walk over and find the Collections we actually want to instance
828 * (ignoring duplicates). */
829 outliner_tree_traverse(space_outliner,
830 &space_outliner->runtime->tree,
831 0,
834 &data);
835
836 /* Find an active collection to add to, that doesn't give dependency cycles. */
837 LayerCollection *active_lc = BKE_layer_collection_get_active(view_layer);
838
839 for (Collection *collection : data.collections_to_edit) {
840 while (BKE_collection_cycle_find(active_lc->collection, collection)) {
841 active_lc = BKE_layer_collection_activate_parent(view_layer, active_lc);
842 }
843 }
844
845 /* Effectively instance the collections. */
846 for (Collection *collection : data.collections_to_edit) {
848 C, OB_EMPTY, collection->id.name + 2, scene->cursor.location, nullptr, false, 0);
849 ob->instance_collection = collection;
850 ob->empty_drawsize = U.collection_instance_empty_size;
852 id_us_plus(&collection->id);
853 }
854
856
858
859 return OPERATOR_FINISHED;
860}
861
863{
864 /* identifiers */
865 ot->name = "Instance Collection";
866 ot->idname = "OUTLINER_OT_collection_instance";
867 ot->description = "Instance selected collections to active scene";
868
869 /* API callbacks. */
872
873 /* flags */
875}
876
878
879/* -------------------------------------------------------------------- */
882
884{
885 CollectionEditData *data = static_cast<CollectionEditData *>(customdata);
886 TreeStoreElem *tselem = TREESTORE(te);
887
888 if (!(tselem && tselem->type == TSE_LAYER_COLLECTION)) {
889 return TRAVERSE_CONTINUE;
890 }
891
892 LayerCollection *lc = static_cast<LayerCollection *>(te->directdata);
893
895 /* skip - showing warning/error message might be misleading
896 * when deleting multiple collections, so just do nothing */
897 }
898 else {
899 /* Delete, duplicate and link don't edit children, those will come along
900 * with the parents. */
901 data->layer_collections_to_edit.add(lc);
902 }
903
904 return TRAVERSE_CONTINUE;
905}
906
907static bool collections_view_layer_poll(bContext *C, bool clear, int flag)
908{
909 /* Poll function so the right click menu show current state of selected collections. */
910 SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
911 if (!(space_outliner && space_outliner->outlinevis == SO_VIEW_LAYER)) {
912 return false;
913 }
914
915 Scene *scene = CTX_data_scene(C);
917 data.scene = scene;
918 data.space_outliner = space_outliner;
919 data.is_liboverride_allowed = true;
920 data.is_liboverride_hierarchy_root_allowed = true;
921 bool result = false;
922
923 outliner_tree_traverse(space_outliner,
924 &space_outliner->runtime->tree,
925 0,
928 &data);
929
930 for (LayerCollection *lc : data.layer_collections_to_edit) {
931 if (clear && (lc->flag & flag)) {
932 result = true;
933 }
934 else if (!clear && !(lc->flag & flag)) {
935 result = true;
936 }
937 }
938
939 return result;
940}
941
946
951
956
961
966
971
973{
974 Main *bmain = CTX_data_main(C);
975 Scene *scene = CTX_data_scene(C);
976 ViewLayer *view_layer = CTX_data_view_layer(C);
977 SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
979 data.scene = scene;
980 data.space_outliner = space_outliner;
981 data.is_liboverride_allowed = true;
982 data.is_liboverride_hierarchy_root_allowed = true;
983 bool clear = strstr(op->idname, "clear") != nullptr;
984 eLayerCollection_Flag flag = strstr(op->idname, "holdout") ? LAYER_COLLECTION_HOLDOUT :
985 strstr(op->idname, "indirect_only") ?
988
989 outliner_tree_traverse(space_outliner,
990 &space_outliner->runtime->tree,
991 0,
994 &data);
995
996 for (LayerCollection *lc : data.layer_collections_to_edit) {
997 BKE_layer_collection_set_flag(lc, flag, !clear);
998 }
999
1002
1004
1005 return OPERATOR_FINISHED;
1006}
1007
1009{
1010 /* identifiers */
1011 ot->name = "Disable from View Layer";
1012 ot->idname = "OUTLINER_OT_collection_exclude_set";
1013 ot->description = "Exclude collection from the active view layer";
1014
1015 /* API callbacks. */
1018
1019 /* flags */
1021}
1022
1024{
1025 /* identifiers */
1026 ot->name = "Enable in View Layer";
1027 ot->idname = "OUTLINER_OT_collection_exclude_clear";
1028 ot->description = "Include collection in the active view layer";
1029
1030 /* API callbacks. */
1033
1034 /* flags */
1036}
1037
1039{
1040 /* identifiers */
1041 ot->name = "Set Holdout";
1042 ot->idname = "OUTLINER_OT_collection_holdout_set";
1043 ot->description = "Mask collection in the active view layer";
1044
1045 /* API callbacks. */
1048
1049 /* flags */
1051}
1052
1054{
1055 /* identifiers */
1056 ot->name = "Clear Holdout";
1057 ot->idname = "OUTLINER_OT_collection_holdout_clear";
1058 ot->description = "Clear masking of collection in the active view layer";
1059
1060 /* API callbacks. */
1063
1064 /* flags */
1066}
1067
1069{
1070 /* identifiers */
1071 ot->name = "Set Indirect Only";
1072 ot->idname = "OUTLINER_OT_collection_indirect_only_set";
1073 ot->description =
1074 "Set collection to only contribute indirectly (through shadows and reflections) in the view "
1075 "layer";
1076
1077 /* API callbacks. */
1080
1081 /* flags */
1083}
1084
1086{
1087 /* identifiers */
1088 ot->name = "Clear Indirect Only";
1089 ot->idname = "OUTLINER_OT_collection_indirect_only_clear";
1090 ot->description = "Clear collection contributing only indirectly in the view layer";
1091
1092 /* API callbacks. */
1095
1096 /* flags */
1098}
1099
1101
1102/* -------------------------------------------------------------------- */
1105
1107{
1108 const Main *bmain = CTX_data_main(C);
1109 Scene *scene = CTX_data_scene(C);
1110 ViewLayer *view_layer = CTX_data_view_layer(C);
1111 SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
1112 const bool extend = RNA_boolean_get(op->ptr, "extend");
1114 data.scene = scene;
1115 data.space_outliner = space_outliner;
1116 data.is_liboverride_allowed = true;
1117 data.is_liboverride_hierarchy_root_allowed = true;
1118 outliner_tree_traverse(space_outliner,
1119 &space_outliner->runtime->tree,
1120 0,
1121 extend ? TSE_SELECTED : TSE_ACTIVE,
1123 &data);
1124
1125 for (LayerCollection *layer_collection : data.layer_collections_to_edit) {
1126 if (extend) {
1127 BKE_layer_collection_isolate_global(scene, view_layer, layer_collection, true);
1128 }
1129 else {
1130 PropertyRNA *prop = RNA_struct_type_find_property(RNA_LayerCollection, "hide_viewport");
1132 &scene->id, RNA_LayerCollection, layer_collection);
1133
1134 /* We need to flip the value because the isolate flag routine was designed to work from the
1135 * outliner as a callback. That means the collection visibility was set before the callback
1136 * was called. */
1137 const bool value = !RNA_property_boolean_get(&ptr, prop);
1139 *bmain, scene, view_layer, layer_collection, nullptr, prop, "hide_viewport", value);
1140 break;
1141 }
1142 }
1143
1146
1148 return OPERATOR_FINISHED;
1149}
1150
1152 wmOperator *op,
1153 const wmEvent *event)
1154{
1155 PropertyRNA *prop = RNA_struct_find_property(op->ptr, "extend");
1156 if (!RNA_property_is_set(op->ptr, prop) && (event->modifier & KM_SHIFT)) {
1157 RNA_property_boolean_set(op->ptr, prop, true);
1158 }
1159 return collection_isolate_exec(C, op);
1160}
1161
1163{
1164 /* identifiers */
1165 ot->name = "Isolate Collection";
1166 ot->idname = "OUTLINER_OT_collection_isolate";
1167 ot->description = "Hide all but this collection and its parents";
1168
1169 /* API callbacks. */
1173
1174 /* flags */
1176
1177 /* properties */
1179 ot->srna, "extend", false, "Extend", "Extend current visible collections");
1181}
1182
1187
1192
1194{
1196 return false;
1197 }
1198 return outliner_active_layer_collection(C) != nullptr;
1199}
1200
1202{
1203 const Main *bmain = CTX_data_main(C);
1204 Scene *scene = CTX_data_scene(C);
1205 ViewLayer *view_layer = CTX_data_view_layer(C);
1206 SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
1207 const bool is_inside = strstr(op->idname, "inside") != nullptr;
1208 const bool show = strstr(op->idname, "show") != nullptr;
1210 data.scene = scene;
1211 data.space_outliner = space_outliner;
1212 data.is_liboverride_allowed = true;
1213 data.is_liboverride_hierarchy_root_allowed = true;
1214
1215 outliner_tree_traverse(space_outliner,
1216 &space_outliner->runtime->tree,
1217 0,
1220 &data);
1221
1222 for (LayerCollection *layer_collection : data.layer_collections_to_edit) {
1223 BKE_layer_collection_set_visible(*bmain, scene, view_layer, layer_collection, show, is_inside);
1224 }
1225
1228
1230 return OPERATOR_FINISHED;
1231}
1232
1234{
1235 /* identifiers */
1236 ot->name = "Show Collection";
1237 ot->idname = "OUTLINER_OT_collection_show";
1238 ot->description = "Show the collection in this view layer";
1239
1240 /* API callbacks. */
1243
1244 /* flags */
1246}
1247
1249{
1250 /* identifiers */
1251 ot->name = "Hide Collection";
1252 ot->idname = "OUTLINER_OT_collection_hide";
1253 ot->description = "Hide the collection in this view layer";
1254
1255 /* API callbacks. */
1258
1259 /* flags */
1261}
1262
1264{
1265 /* identifiers */
1266 ot->name = "Show Inside Collection";
1267 ot->idname = "OUTLINER_OT_collection_show_inside";
1268 ot->description = "Show all the objects and collections inside the collection";
1269
1270 /* API callbacks. */
1273
1274 /* flags */
1276}
1277
1279{
1280 /* identifiers */
1281 ot->name = "Hide Inside Collection";
1282 ot->idname = "OUTLINER_OT_collection_hide_inside";
1283 ot->description = "Hide all the objects and collections inside the collection";
1284
1285 /* API callbacks. */
1288
1289 /* flags */
1291}
1292
1294
1295/* -------------------------------------------------------------------- */
1298
1299static bool collection_flag_poll(bContext *C, bool clear, int flag)
1300{
1302 return false;
1303 }
1304
1306 if (te == nullptr) {
1307 return false;
1308 }
1309
1311 if (collection == nullptr) {
1312 return false;
1313 }
1314
1315 if (clear && (collection->flag & flag)) {
1316 return true;
1317 }
1318 if (!clear && !(collection->flag & flag)) {
1319 return true;
1320 }
1321
1322 return false;
1323}
1324
1329
1334
1339
1344
1346{
1347 Main *bmain = CTX_data_main(C);
1348 Scene *scene = CTX_data_scene(C);
1349 ViewLayer *view_layer = CTX_data_view_layer(C);
1350 SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
1351 const bool is_render = strstr(op->idname, "render");
1352 const bool clear = strstr(op->idname, "show") || strstr(op->idname, "enable");
1355 data.scene = scene;
1356 data.space_outliner = space_outliner;
1357 data.is_liboverride_allowed = true;
1358 data.is_liboverride_hierarchy_root_allowed = true;
1359 const bool has_layer_collection = space_outliner->outlinevis == SO_VIEW_LAYER;
1360
1361 if (has_layer_collection) {
1362 outliner_tree_traverse(space_outliner,
1363 &space_outliner->runtime->tree,
1364 0,
1367 &data);
1368 for (LayerCollection *layer_collection : data.layer_collections_to_edit) {
1369 Collection *collection = layer_collection->collection;
1370 if (!BKE_id_is_editable(bmain, &collection->id)) {
1371 continue;
1372 }
1373 if (clear) {
1374 collection->flag &= ~flag;
1375 }
1376 else {
1377 collection->flag |= flag;
1378 }
1379
1380 /* Make sure (at least for this view layer) the collection is visible. */
1381 if (clear && !is_render) {
1382 layer_collection->flag &= ~LAYER_COLLECTION_HIDE;
1383 }
1384 }
1385 }
1386 else {
1387 outliner_tree_traverse(space_outliner,
1388 &space_outliner->runtime->tree,
1389 0,
1392 &data);
1393 for (Collection *collection : data.collections_to_edit) {
1394 if (!BKE_id_is_editable(bmain, &collection->id)) {
1395 continue;
1396 }
1397
1398 if (clear) {
1399 collection->flag &= ~flag;
1400 }
1401 else {
1402 collection->flag |= flag;
1403 }
1404 }
1405 }
1406
1409
1410 if (!is_render) {
1412 }
1413
1415 return OPERATOR_FINISHED;
1416}
1417
1419{
1420 /* identifiers */
1421 ot->name = "Enable Collection";
1422 ot->idname = "OUTLINER_OT_collection_enable";
1423 ot->description = "Enable viewport display in the view layers";
1424
1425 /* API callbacks. */
1428
1429 /* flags */
1431}
1432
1434{
1435 /* identifiers */
1436 ot->name = "Disable Collection";
1437 ot->idname = "OUTLINER_OT_collection_disable";
1438 ot->description = "Disable viewport display in the view layers";
1439
1440 /* API callbacks. */
1443
1444 /* flags */
1446}
1447
1449{
1450 /* identifiers */
1451 ot->name = "Enable Collection in Render";
1452 ot->idname = "OUTLINER_OT_collection_enable_render";
1453 ot->description = "Render the collection";
1454
1455 /* API callbacks. */
1458
1459 /* flags */
1461}
1462
1464{
1465 /* identifiers */
1466 ot->name = "Disable Collection in Render";
1467 ot->idname = "OUTLINER_OT_collection_disable_render";
1468 ot->description = "Do not render this collection";
1469
1470 /* API callbacks. */
1473
1474 /* flags */
1476}
1477
1487
1489
1490/* -------------------------------------------------------------------- */
1493
1495{
1496 OutlinerHideEditData *data = static_cast<OutlinerHideEditData *>(customdata);
1497 TreeStoreElem *tselem = TREESTORE(te);
1498
1499 if (tselem == nullptr) {
1500 return TRAVERSE_CONTINUE;
1501 }
1502
1503 if (tselem->type == TSE_LAYER_COLLECTION) {
1504 LayerCollection *lc = static_cast<LayerCollection *>(te->directdata);
1505
1507 /* Skip - showing warning/error message might be misleading
1508 * when deleting multiple collections, so just do nothing. */
1509 }
1510 else if (!data->hide_unselected && tselem->flag & TSE_SELECTED) {
1511 /* Delete, duplicate and link don't edit children,
1512 * those will come along with the parents. */
1513 data->collections_to_edit.add(lc);
1514 }
1515 }
1516 else if ((tselem->type == TSE_SOME_ID) && (te->idcode == ID_OB)) {
1517 if (data->hide_unselected != bool(tselem->flag & TSE_SELECTED)) {
1518 Object *ob = id_cast<Object *>(tselem->id);
1519 BKE_view_layer_synced_ensure(*data->bmain, data->scene, data->view_layer);
1520 Base *base = BKE_view_layer_base_find(data->view_layer, ob);
1521 data->bases_to_edit.add(base);
1522 }
1523 }
1524
1525 return TRAVERSE_CONTINUE;
1526}
1527
1529{
1530 const Main *bmain = CTX_data_main(C);
1531 Scene *scene = CTX_data_scene(C);
1532 ViewLayer *view_layer = CTX_data_view_layer(C);
1533 SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
1535 data.bmain = bmain;
1536 data.scene = scene;
1537 data.view_layer = view_layer;
1538 data.space_outliner = space_outliner;
1539 data.hide_unselected = RNA_boolean_get(op->ptr, "unselected");
1540
1541 outliner_tree_traverse(space_outliner,
1542 &space_outliner->runtime->tree,
1543 0,
1544 0,
1546 &data);
1547
1548 for (LayerCollection *layer_collection : data.collections_to_edit) {
1549 BKE_layer_collection_set_visible(*bmain, scene, view_layer, layer_collection, false, false);
1550 }
1551
1552 for (Base *base : data.bases_to_edit) {
1553 base->flag |= BASE_HIDDEN;
1554 }
1555
1558
1560 return OPERATOR_FINISHED;
1561}
1562
1564{
1565 /* identifiers */
1566 ot->name = "Hide";
1567 ot->idname = "OUTLINER_OT_hide";
1568 ot->description = "Hide selected objects and collections";
1569
1570 /* API callbacks. */
1573
1574 /* flags */
1576
1577 ot->prop = RNA_def_boolean(
1578 ot->srna, "unselected", false, "Unselected", "Hide unselected objects");
1580}
1581
1583{
1584 const Main *bmain = CTX_data_main(C);
1585 Scene *scene = CTX_data_scene(C);
1586 ViewLayer *view_layer = CTX_data_view_layer(C);
1587
1588 /* Unhide all the collections. */
1589 LayerCollection *lc_master = view_layer->layer_collections.first();
1590 for (LayerCollection &lc_iter : lc_master->layer_collections) {
1592 }
1593
1594 /* Unhide all objects. */
1595 BKE_view_layer_synced_ensure(*bmain, scene, view_layer);
1596 for (Base &base : *BKE_view_layer_object_bases_get(view_layer)) {
1597 base.flag &= ~BASE_HIDDEN;
1598 }
1599
1602
1604 return OPERATOR_FINISHED;
1605}
1606
1608{
1609 /* identifiers */
1610 ot->name = "Unhide All";
1611 ot->idname = "OUTLINER_OT_unhide_all";
1612 ot->description = "Unhide all objects and collections";
1613
1614 /* API callbacks. */
1617
1618 /* flags */
1620}
1621
1623
1624/* -------------------------------------------------------------------- */
1627
1629{
1630 Scene *scene = CTX_data_scene(C);
1631 SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
1632 const CollectionColorTag color_tag = CollectionColorTag(RNA_enum_get(op->ptr, "color"));
1633
1634 IDsSelectedData selected{};
1635
1636 outliner_tree_traverse(space_outliner,
1637 &space_outliner->runtime->tree,
1638 0,
1641 &selected);
1642
1643 for (LinkData &link : selected.selected_array) {
1644 TreeElement *te_selected = static_cast<TreeElement *>(link.data);
1645
1646 Collection *collection = outliner_collection_from_tree_element(te_selected);
1647 if (collection == scene->master_collection) {
1648 continue;
1649 }
1650 if (!BKE_id_is_editable(CTX_data_main(C), &collection->id)) {
1651 BKE_report(op->reports, RPT_WARNING, "Cannot add a color tag to a linked collection");
1652 continue;
1653 }
1654
1655 collection->color_tag = color_tag;
1656 };
1657
1658 selected.selected_array.free_no_destruct();
1659
1661
1662 return OPERATOR_FINISHED;
1663}
1664
1666 PointerRNA *properties)
1667{
1668 const int color = RNA_enum_get(properties, "color");
1670 return TIP_("Remove Color Tag");
1671 }
1672 return CTX_IFACE_(ot->translation_context, ot->name);
1673}
1674
1676 wmOperatorType *ot,
1677 PointerRNA *properties)
1678{
1679 const int color = RNA_enum_get(properties, "color");
1681 return TIP_("Remove color tag from the selected collections");
1682 }
1683 return ot->description ? CTX_IFACE_(ot->translation_context, ot->description) : "";
1684}
1685
1687{
1688 /* identifiers */
1689 ot->name = "Set Color Tag";
1690 ot->idname = "OUTLINER_OT_collection_color_tag_set";
1691 ot->description = "Set a color tag for the selected collections";
1692
1693 /* API callbacks. */
1698
1699 /* flags */
1701
1703 ot->srna, "color", rna_enum_collection_color_items, COLLECTION_COLOR_NONE, "Color Tag", "");
1704}
1705
1707
1708} // namespace ed::outliner
1709} // namespace blender
#define TIP_(msgid)
#define CTX_IFACE_(context, msgid)
ID and Library types, which are fundamental for SDNA.
#define ID_IS_OVERRIDE_LIBRARY_REAL(_id)
Definition DNA_ID.h:729
#define ID_IS_EDITABLE(_id)
Definition DNA_ID.h:708
#define ID_IS_OVERRIDE_LIBRARY(_id)
Definition DNA_ID.h:736
#define ID_IS_OVERRIDE_LIBRARY_HIERARCHY_ROOT(_id)
Definition DNA_ID.h:739
Object groups, one object can be in many groups at once.
Object is a sort of wrapper for general info.
#define C
Definition RandGen.cpp:29
#define ND_OB_SELECT
Definition WM_types.hh:461
#define NC_SCENE
Definition WM_types.hh:391
#define ND_LAYER_CONTENT
Definition WM_types.hh:472
#define ND_LAYER
Definition WM_types.hh:469
#define ELEM(...)
#define STREQ(a, b)
Object * add_type(bContext *C, int type, const char *name, const float loc[3], const float rot[3], bool enter_editmode, unsigned short local_view_bits) ATTR_NONNULL(1) ATTR_RETURNS_NONNULL
void all(const SpaceOutliner &space_outliner, const ConstVisitorFn visitor)
void OUTLINER_OT_collection_duplicate_linked(wmOperatorType *ot)
void OUTLINER_OT_collection_objects_deselect(wmOperatorType *ot)
void OUTLINER_OT_collection_disable_render(wmOperatorType *ot)
static bool collections_exclude_clear_poll(bContext *C)
void OUTLINER_OT_collection_link(wmOperatorType *ot)
void OUTLINER_OT_collection_color_tag_set(wmOperatorType *ot)
void OUTLINER_OT_collection_hierarchy_delete(wmOperatorType *ot)
void OUTLINER_OT_collection_exclude_set(wmOperatorType *ot)
static bool collection_inside_poll(bContext *C)
static TreeTraversalAction collection_collect_data_to_edit(TreeElement *te, void *customdata)
void OUTLINER_OT_collection_show(wmOperatorType *ot)
static wmOperatorStatus collection_isolate_exec(bContext *C, wmOperator *op)
bool outliner_tree_traverse(const SpaceOutliner *space_outliner, ListBaseT< TreeElement > *tree, int filter_te_flag, int filter_tselem_flag, TreeTraversalFunc func, void *customdata)
static bool collections_holdout_clear_poll(bContext *C)
bool outliner_is_collection_tree_element(const TreeElement *te)
static wmOperatorStatus collection_new_exec(bContext *C, wmOperator *op)
static TreeElement * outliner_active_collection(bContext *C)
static std::string outliner_collection_color_tag_set_get_name(wmOperatorType *ot, PointerRNA *properties)
static bool collection_disable_poll(bContext *C)
static wmOperatorStatus collection_objects_select_exec(bContext *C, wmOperator *op)
static TreeTraversalAction outliner_find_first_selected_layer_collection(TreeElement *te, void *customdata)
static wmOperatorStatus collection_visibility_exec(bContext *C, wmOperator *op)
void OUTLINER_OT_collection_indirect_only_clear(wmOperatorType *ot)
void OUTLINER_OT_hide(wmOperatorType *ot)
static bool collections_exclude_set_poll(bContext *C)
void OUTLINER_OT_collection_holdout_set(wmOperatorType *ot)
static bool collection_show_poll(bContext *C)
void OUTLINER_OT_collection_hide(wmOperatorType *ot)
void OUTLINER_OT_collection_exclude_clear(wmOperatorType *ot)
static bool collections_view_layer_poll(bContext *C, bool clear, int flag)
void OUTLINER_OT_collection_objects_select(wmOperatorType *ot)
static TreeTraversalAction layer_collection_collect_data_to_edit(TreeElement *te, void *customdata)
static LayerCollection * outliner_active_layer_collection(bContext *C)
static wmOperatorStatus collection_instance_exec(bContext *C, wmOperator *)
void outliner_collection_delete(bContext *C, Main *bmain, Scene *scene, ReportList *reports, bool do_hierarchy)
static bool collection_enable_poll(bContext *C)
static bool collections_holdout_set_poll(bContext *C)
static wmOperatorStatus collection_hierarchy_delete_exec(bContext *C, wmOperator *op)
void OUTLINER_OT_unhide_all(wmOperatorType *ot)
void OUTLINER_OT_collection_hide_inside(wmOperatorType *ot)
void OUTLINER_OT_collection_enable(wmOperatorType *ot)
static wmOperatorStatus collection_flag_exec(bContext *C, wmOperator *op)
static bool outliner_view_layer_collections_editor_poll(bContext *C)
static wmOperatorStatus collection_link_exec(bContext *C, wmOperator *op)
TreeTraversalAction outliner_collect_selected_objects(TreeElement *te, void *customdata)
Collection * outliner_collection_from_tree_element(const TreeElement *te)
static bool collections_indirect_only_clear_poll(bContext *C)
static wmOperatorStatus outliner_hide_exec(bContext *C, wmOperator *op)
static std::string outliner_collection_color_tag_set_get_description(bContext *, wmOperatorType *ot, PointerRNA *properties)
static wmOperatorStatus outliner_unhide_all_exec(bContext *C, wmOperator *)
static bool collections_indirect_only_set_poll(bContext *C)
static TreeTraversalAction outliner_find_first_selected_collection(TreeElement *te, void *customdata)
static TreeTraversalAction outliner_hide_collect_data_to_edit(TreeElement *te, void *customdata)
static bool collection_disable_render_poll(bContext *C)
void outliner_cleanup_tree(SpaceOutliner *space_outliner)
static bool collection_edit_in_active_scene_poll(bContext *C)
void OUTLINER_OT_collection_holdout_clear(wmOperatorType *ot)
void OUTLINER_OT_collection_duplicate(wmOperatorType *ot)
static bool collection_hide_poll(bContext *C)
void OUTLINER_OT_collection_isolate(wmOperatorType *ot)
void OUTLINER_OT_collection_disable(wmOperatorType *ot)
void OUTLINER_OT_collection_show_inside(wmOperatorType *ot)
void outliner_collection_isolate_flag(const Main &bmain, Scene *scene, ViewLayer *view_layer, LayerCollection *layer_collection, Collection *collection, PropertyRNA *layer_or_collection_prop, const char *propname, const bool value)
static wmOperatorStatus outliner_color_tag_set_exec(bContext *C, wmOperator *op)
static wmOperatorStatus collection_duplicate_exec(bContext *C, wmOperator *op)
static TreeTraversalAction outliner_collect_selected_parent_collections(TreeElement *te, void *customdata)
static bool collection_flag_poll(bContext *C, bool clear, int flag)
void outliner_build_tree(Main *mainvar, WorkSpace *workspace, Scene *scene, ViewLayer *view_layer, SpaceOutliner *space_outliner, ARegion *region)
static bool collection_enable_render_poll(bContext *C)
void OUTLINER_OT_collection_new(wmOperatorType *ot)
static bool collection_new_poll(bContext *C)
void OUTLINER_OT_collection_instance(wmOperatorType *ot)
void OUTLINER_OT_collection_indirect_only_set(wmOperatorType *ot)
TreeTraversalAction outliner_collect_selected_collections(TreeElement *te, void *customdata)
static wmOperatorStatus collection_view_layer_exec(bContext *C, wmOperator *op)
TreeElement * outliner_find_element_with_flag(const ListBaseT< TreeElement > *lb, short flag)
void OUTLINER_OT_collection_enable_render(wmOperatorType *ot)
static wmOperatorStatus collection_isolate_invoke(bContext *C, wmOperator *op, const wmEvent *event)
BMesh Iterators.
void WM_main_add_notifier(uint type, void *reference)
bool BKE_collection_delete(Main *bmain, Collection *collection, bool hierarchy)
UserDef U
Definition blender.cc:58
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
int RNA_enum_get(PointerRNA *ptr, const char *name)
const EnumPropertyItem rna_enum_collection_color_items[]
@ RPT_WARNING
Definition BKE_report.hh:40
Collection * BKE_collection_duplicate(Main *bmain, Collection *parent, CollectionChild *child_old, Collection *collection, eDupli_ID_Flags duplicate_flags, uint duplicate_options)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
bool BKE_layer_collection_activate(ViewLayer *view_layer, LayerCollection *lc)
WorkSpace * CTX_wm_workspace(const bContext *C)
SpaceOutliner * CTX_wm_space_outliner(const bContext *C)
void id_us_plus(ID *id)
Definition lib_id.cc:433
LayerCollection * BKE_layer_collection_get_active(ViewLayer *view_layer)
void ED_outliner_select_sync_from_collection_tag(bContext *C)
bool BKE_collection_child_add(Main *bmain, Collection *parent, Collection *child)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
Base * BKE_view_layer_active_base_get(ViewLayer *view_layer)
void BKE_view_layer_need_resync_tag(ViewLayer *view_layer)
@ TSE_SCENE_COLLECTION_BASE
ViewLayer * CTX_data_view_layer(const bContext *C)
void ED_outliner_select_sync_from_object_tag(bContext *C)
void BKE_layer_collection_set_flag(LayerCollection *lc, eLayerCollection_Flag flag, bool value)
bool RNA_property_boolean_get(PointerRNA *ptr, PropertyRNA *prop)
@ LIB_ID_DUPLICATE_IS_ROOT_ID
Collection * BKE_collection_object_find(Main *bmain, Scene *scene, Collection *collection, Object *ob)
int BLI_findindex(const ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition listbase.cc:593
bool ED_outliner_collections_editor_poll(bContext *C)
void DEG_id_tag_update(ID *id, unsigned int flags)
void BKE_layer_collection_isolate_global(Scene *scene, ViewLayer *view_layer, LayerCollection *lc, bool extend)
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition report.cc:162
BMesh const char void * data
@ LAYER_COLLECTION_INDIRECT_ONLY
@ LAYER_COLLECTION_EXCLUDE
@ LAYER_COLLECTION_HIDE
@ LAYER_COLLECTION_HOLDOUT
CollectionChild * BKE_collection_child_find(Collection *parent, Collection *collection)
bool BKE_view_layer_synced_ensure(const Main &bmain, const Scene *scene, ViewLayer *view_layer)
void ED_outliner_selected_objects_get(const bContext *C, ListBaseT< LinkData > *objects)
LayerCollection * BKE_layer_collection_first_from_scene_collection(const ViewLayer *view_layer, const Collection *collection)
LinkData * BLI_genericNodeN(void *data)
Definition listbase.cc:936
PointerRNA RNA_pointer_create_discrete(ID *id, StructRNA *type, void *data)
PropertyRNA * RNA_struct_type_find_property(StructRNA *srna, const char *identifier)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
wmMsgBus * CTX_wm_message_bus(const bContext *C)
bool BKE_collection_cycle_find(Collection *new_ancestor, Collection *collection)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
Definition report.cc:191
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:118
Main * CTX_data_main(const bContext *C)
void ED_outliner_select_sync_flag_outliners(const bContext *C)
@ ID_RECALC_SELECT
Definition DNA_ID.h:1101
@ ID_RECALC_SYNC_TO_EVAL
Definition DNA_ID.h:1118
@ ID_RECALC_BASE_FLAGS
Definition DNA_ID.h:1104
ID_Type GS(const char *name)
Definition DNA_ID.h:410
@ PROP_SKIP_SAVE
Definition RNA_types.hh:414
Base * BKE_view_layer_base_find(ViewLayer *view_layer, Object *ob)
@ ID_TAG_INDIRECT
Definition DNA_ID.h:851
LayerCollection * BKE_layer_collection_activate_parent(ViewLayer *view_layer, LayerCollection *lc)
bool BKE_layer_collection_objects_select(const Main &bmain, const Scene *scene, ViewLayer *view_layer, LayerCollection *lc, bool deselect)
ID * BKE_id_owner_get(ID *id, const bool debug_relationship_assert=true)
Definition lib_id.cc:2770
void DEG_relations_tag_update(Main *bmain)
void RNA_property_boolean_set(PointerRNA *ptr, PropertyRNA *prop, bool value)
Scene * CTX_data_scene(const bContext *C)
@ ID_FLAG_EMBEDDED_DATA
Definition DNA_ID.h:775
@ OPTYPE_REGISTER
Definition WM_types.hh:188
@ OPTYPE_UNDO
Definition WM_types.hh:190
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
bool ED_operator_region_outliner_active(bContext *C)
bool BKE_id_is_editable(const Main *bmain, const ID *id)
Definition lib_id.cc:2782
void id_fake_user_clear(ID *id)
Definition lib_id.cc:479
ARegion * CTX_wm_region(const bContext *C)
ListBaseT< Base > * BKE_view_layer_object_bases_get(ViewLayer *view_layer)
bool RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop)
LayerCollection * CTX_data_layer_collection(const bContext *C)
void BKE_layer_collection_set_visible(const Main &bmain, const Scene *scene, ViewLayer *view_layer, LayerCollection *lc, bool visible, bool hierarchy)
Collection * BKE_collection_add(Main *bmain, Collection *collection_parent, const char *name_custom)
#define TREESTORE(a)
struct Collection * collection
bke::CollectionRuntime * runtime
CollectionColorTag color_tag
char name[258]
Definition DNA_ID.h:433
short flag
Definition DNA_ID.h:439
eLayerCollection_Flag flag
struct Collection * collection
ListBaseT< LayerCollection > layer_collections
ListBaseT< Collection > collections
Definition BKE_main.hh:406
eObject_TransFlag transflag
struct Collection * instance_collection
struct Collection * master_collection
View3DCursor cursor
eSpaceOutliner_Mode outlinevis
ed::outliner::SpaceOutliner_Runtime * runtime
eTreeStoreElem_Flag flag
ListBaseT< LayerCollection > layer_collections
LayerCollection * active_collection
ListBaseT< CollectionParent > parents
ListBaseT< ed::outliner::TreeElement > tree
wmEventModifierFlag modifier
Definition WM_types.hh:834
wmOperatorStatus(*) exec(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1125
const char * description
Definition WM_types.hh:1115
const char * translation_context
Definition WM_types.hh:1113
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
std::string(*) get_description(bContext *C, wmOperatorType *ot, PointerRNA *ptr)
Definition WM_types.hh:1197
std::string(*) get_name(wmOperatorType *ot, PointerRNA *ptr)
Definition WM_types.hh:1191
struct ReportList * reports
#define WM_msg_publish_rna_prop(mbus, id_, data_, type_, prop_)