82 return scene->master_collection;
135 outliner_tree_traverse(space_outliner,
136 &space_outliner->
tree,
139 outliner_collect_selected_objects,
162 return (space_outliner !=
nullptr) &&
217 if (data->collection !=
nullptr) {
222 data->collection = collection;
240 &space_outliner->
tree,
252 if (data.collection ==
nullptr || !
ID_IS_EDITABLE(data.collection) ||
255 data.collection = scene->master_collection;
276 ot->
name =
"New Collection";
277 ot->
idname =
"OUTLINER_OT_collection_new";
278 ot->
description =
"Add a new collection inside selected collection";
289 ot->
srna,
"nested",
true,
"Nested",
"Add as child of selected collection");
331 if (!(data->is_liboverride_hierarchy_root_allowed || data->is_liboverride_allowed)) {
336 if (!data->is_liboverride_allowed) {
355 data.space_outliner = space_outliner;
356 data.is_liboverride_allowed =
false;
357 data.is_liboverride_hierarchy_root_allowed = do_hierarchy;
358 data.is_recursive = !do_hierarchy;
365 &space_outliner->
tree,
373 GSET_ITER (collections_to_edit_iter, data.collections_to_edit) {
414 "Cannot delete collection '%s', it is either a linked one used by other "
415 "linked scenes/collections, or a library override one",
416 collection->id.name + 2);
453 ot->
name =
"Delete Hierarchy";
454 ot->
idname =
"OUTLINER_OT_collection_hierarchy_delete";
482 switch (tselem->
type) {
502 &space_outliner->
tree,
507 return data.layer_collection;
515 bool deselect =
STREQ(op->
idname,
"OUTLINER_OT_collection_objects_deselect");
519 &space_outliner->
tree,
523 &selected_collections);
525 if (selected_collections.selected_array.first ==
nullptr) {
548 ot->
name =
"Select Objects";
549 ot->
idname =
"OUTLINER_OT_collection_objects_select";
563 ot->
name =
"Deselect Objects";
564 ot->
idname =
"OUTLINER_OT_collection_objects_deselect";
591 switch (tselem->
type) {
610 &space_outliner->
tree,
622 const bool linked = strstr(op->
idname,
"linked") !=
nullptr;
640 scene->master_collection;
662 if (parent ==
nullptr) {
665 "Could not find a valid parent collection for the new duplicate, "
666 "it won't be linked to any view layer");
670 (linked ? 0 :
U.dupflag));
684 ot->
name =
"Duplicate Linked Collection";
685 ot->
idname =
"OUTLINER_OT_collection_duplicate_linked";
687 "Recursively duplicate the collection, all its children and objects, with linked object "
701 ot->
name =
"Duplicate Collection";
702 ot->
idname =
"OUTLINER_OT_collection_duplicate";
704 "Recursively duplicate the collection, all its children, objects and object data";
729 data.space_outliner = space_outliner;
730 data.is_liboverride_allowed =
false;
731 data.is_liboverride_hierarchy_root_allowed =
true;
738 op->
reports,
RPT_ERROR,
"Cannot add a collection to a linked/override collection/scene");
746 &space_outliner->
tree,
754 GSET_ITER (collections_to_edit_iter, data.collections_to_edit) {
774 ot->
name =
"Link Collection";
775 ot->
idname =
"OUTLINER_OT_collection_link";
776 ot->
description =
"Link selected collections to active scene";
800 data.space_outliner = space_outliner;
801 data.is_liboverride_allowed =
true;
802 data.is_liboverride_hierarchy_root_allowed =
true;
809 &space_outliner->
tree,
819 GSET_ITER (collections_to_edit_iter, data.collections_to_edit) {
829 GSET_ITER (collections_to_edit_iter, data.collections_to_edit) {
833 C,
OB_EMPTY, collection->id.name + 2, scene->cursor.location,
nullptr,
false, 0);
851 ot->
name =
"Instance Collection";
852 ot->
idname =
"OUTLINER_OT_collection_instance";
853 ot->
description =
"Instance selected collections to active scene";
904 data.space_outliner = space_outliner;
905 data.is_liboverride_allowed =
true;
906 data.is_liboverride_hierarchy_root_allowed =
true;
911 &space_outliner->
tree,
918 GSET_ITER (collections_to_edit_iter, data.collections_to_edit) {
972 data.space_outliner = space_outliner;
973 data.is_liboverride_allowed =
true;
974 data.is_liboverride_hierarchy_root_allowed =
true;
975 bool clear = strstr(op->
idname,
"clear") !=
nullptr;
983 &space_outliner->
tree,
990 GSET_ITER (collections_to_edit_iter, data.collections_to_edit) {
1009 ot->
name =
"Disable from View Layer";
1010 ot->
idname =
"OUTLINER_OT_collection_exclude_set";
1011 ot->
description =
"Exclude collection from the active view layer";
1024 ot->
name =
"Enable in View Layer";
1025 ot->
idname =
"OUTLINER_OT_collection_exclude_clear";
1026 ot->
description =
"Include collection in the active view layer";
1039 ot->
name =
"Set Holdout";
1040 ot->
idname =
"OUTLINER_OT_collection_holdout_set";
1041 ot->
description =
"Mask collection in the active view layer";
1054 ot->
name =
"Clear Holdout";
1055 ot->
idname =
"OUTLINER_OT_collection_holdout_clear";
1056 ot->
description =
"Clear masking of collection in the active view layer";
1069 ot->
name =
"Set Indirect Only";
1070 ot->
idname =
"OUTLINER_OT_collection_indirect_only_set";
1072 "Set collection to only contribute indirectly (through shadows and reflections) in the view "
1086 ot->
name =
"Clear Indirect Only";
1087 ot->
idname =
"OUTLINER_OT_collection_indirect_only_clear";
1088 ot->
description =
"Clear collection contributing only indirectly in the view layer";
1112 data.space_outliner = space_outliner;
1113 data.is_liboverride_allowed =
true;
1114 data.is_liboverride_hierarchy_root_allowed =
true;
1117 &space_outliner->
tree,
1124 GSET_ITER (collections_to_edit_iter, data.collections_to_edit) {
1140 scene, view_layer, layer_collection,
nullptr, prop,
"hide_viewport", value);
1165 ot->
name =
"Isolate Collection";
1166 ot->
idname =
"OUTLINER_OT_collection_isolate";
1167 ot->
description =
"Hide all but this collection and its parents";
1179 ot->
srna,
"extend",
false,
"Extend",
"Extend current visible collections");
1207 const bool show = strstr(op->
idname,
"show") !=
nullptr;
1210 data.space_outliner = space_outliner;
1211 data.is_liboverride_allowed =
true;
1212 data.is_liboverride_hierarchy_root_allowed =
true;
1216 &space_outliner->
tree,
1223 GSET_ITER (collections_to_edit_iter, data.collections_to_edit) {
1240 ot->
name =
"Show Collection";
1241 ot->
idname =
"OUTLINER_OT_collection_show";
1255 ot->
name =
"Hide Collection";
1256 ot->
idname =
"OUTLINER_OT_collection_hide";
1270 ot->
name =
"Show Inside Collection";
1271 ot->
idname =
"OUTLINER_OT_collection_show_inside";
1272 ot->
description =
"Show all the objects and collections inside the collection";
1285 ot->
name =
"Hide Inside Collection";
1286 ot->
idname =
"OUTLINER_OT_collection_hide_inside";
1287 ot->
description =
"Hide all the objects and collections inside the collection";
1310 if (te ==
nullptr) {
1315 if (collection ==
nullptr) {
1319 if (
clear && (collection->flag &
flag)) {
1322 if (!
clear && !(collection->flag &
flag)) {
1355 const bool is_render = strstr(op->
idname,
"render");
1360 data.space_outliner = space_outliner;
1361 data.is_liboverride_allowed =
true;
1362 data.is_liboverride_hierarchy_root_allowed =
true;
1366 if (has_layer_collection) {
1368 &space_outliner->
tree,
1374 GSET_ITER (collections_to_edit_iter, data.collections_to_edit) {
1382 collection->
flag &= ~flag;
1385 collection->flag |=
flag;
1389 if (
clear && !is_render) {
1390 layer_collection->
flag &= ~LAYER_COLLECTION_HIDE;
1397 &space_outliner->
tree,
1403 GSET_ITER (collections_to_edit_iter, data.collections_to_edit) {
1411 collection->
flag &= ~flag;
1414 collection->flag |=
flag;
1434 ot->
name =
"Enable Collection";
1435 ot->
idname =
"OUTLINER_OT_collection_enable";
1436 ot->
description =
"Enable viewport display in the view layers";
1449 ot->
name =
"Disable Collection";
1450 ot->
idname =
"OUTLINER_OT_collection_disable";
1451 ot->
description =
"Disable viewport display in the view layers";
1464 ot->
name =
"Enable Collection in Render";
1465 ot->
idname =
"OUTLINER_OT_collection_enable_render";
1479 ot->
name =
"Disable Collection in Render";
1480 ot->
idname =
"OUTLINER_OT_collection_disable_render";
1510 if (tselem ==
nullptr) {
1544 data.view_layer = view_layer;
1545 data.space_outliner = space_outliner;
1546 data.collections_to_edit =
BLI_gset_ptr_new(
"outliner_hide_exec__collections_to_edit");
1547 data.bases_to_edit =
BLI_gset_ptr_new(
"outliner_hide_exec__bases_to_edit");
1550 &space_outliner->
tree,
1557 GSET_ITER (collections_to_edit_iter, data.collections_to_edit) {
1565 GSET_ITER (bases_to_edit_iter, data.bases_to_edit) {
1607 base->flag &= ~BASE_HIDDEN;
1621 ot->
idname =
"OUTLINER_OT_unhide_all";
1647 &space_outliner->
tree,
1657 if (collection == scene->master_collection) {
1665 collection->color_tag = color_tag;
1678 ot->
name =
"Set Color Tag";
1679 ot->
idname =
"OUTLINER_OT_collection_color_tag_set";
1680 ot->
description =
"Set a color tag for the selected collections";
CollectionChild * BKE_collection_child_find(Collection *parent, Collection *collection)
Collection * BKE_collection_add(Main *bmain, Collection *collection_parent, const char *name_custom)
bool BKE_collection_child_add(Main *bmain, Collection *parent, Collection *child)
bool BKE_collection_delete(Main *bmain, Collection *collection, bool hierarchy)
bool BKE_collection_cycle_find(Collection *new_ancestor, Collection *collection)
Collection * BKE_collection_duplicate(Main *bmain, Collection *parent, CollectionChild *child_old, Collection *collection, uint duplicate_flags, uint duplicate_options)
LayerCollection * CTX_data_layer_collection(const bContext *C)
SpaceOutliner * CTX_wm_space_outliner(const bContext *C)
Scene * CTX_data_scene(const bContext *C)
Main * CTX_data_main(const bContext *C)
ARegion * CTX_wm_region(const bContext *C)
wmMsgBus * CTX_wm_message_bus(const bContext *C)
ViewLayer * CTX_data_view_layer(const bContext *C)
LayerCollection * BKE_layer_collection_get_active(ViewLayer *view_layer)
void BKE_view_layer_synced_ensure(const Scene *scene, ViewLayer *view_layer)
bool BKE_layer_collection_objects_select(const Scene *scene, ViewLayer *view_layer, LayerCollection *lc, bool deselect)
Base * BKE_view_layer_active_base_get(ViewLayer *view_layer)
void BKE_layer_collection_set_visible(const Scene *scene, ViewLayer *view_layer, LayerCollection *lc, bool visible, bool hierarchy)
void BKE_layer_collection_isolate_global(Scene *scene, ViewLayer *view_layer, LayerCollection *lc, bool extend)
void BKE_view_layer_need_resync_tag(ViewLayer *view_layer)
Base * BKE_view_layer_base_find(ViewLayer *view_layer, Object *ob)
LayerCollection * BKE_layer_collection_activate_parent(ViewLayer *view_layer, LayerCollection *lc)
void BKE_layer_collection_set_flag(LayerCollection *lc, int flag, bool value)
ListBase * BKE_view_layer_object_bases_get(ViewLayer *view_layer)
bool BKE_id_is_editable(const Main *bmain, const ID *id)
ID * BKE_id_owner_get(ID *id, const bool debug_relationship_assert=true)
void id_fake_user_clear(ID *id)
@ LIB_ID_DUPLICATE_IS_ROOT_ID
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
void BKE_report(ReportList *reports, eReportType type, const char *message)
GSet * BLI_gset_ptr_new(const char *info)
BLI_INLINE void * BLI_gsetIterator_getKey(GSetIterator *gsi)
#define GSET_ITER(gs_iter_, gset_)
void BLI_gset_free(GSet *gs, GSetKeyFreeFP keyfreefp)
bool BLI_gset_add(GSet *gs, void *key)
#define LISTBASE_FOREACH(type, var, list)
void void BLI_freelistN(struct ListBase *listbase) ATTR_NONNULL(1)
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
int BLI_findindex(const struct ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
struct LinkData * BLI_genericNodeN(void *data)
void DEG_id_tag_update(ID *id, unsigned int flags)
void DEG_relations_tag_update(Main *bmain)
ID and Library types, which are fundamental for SDNA.
#define ID_IS_OVERRIDE_LIBRARY_REAL(_id)
#define ID_IS_EDITABLE(_id)
#define ID_IS_OVERRIDE_LIBRARY(_id)
#define ID_IS_OVERRIDE_LIBRARY_HIERARCHY_ROOT(_id)
Object groups, one object can be in many groups at once.
@ COLLECTION_HIDE_VIEWPORT
@ LAYER_COLLECTION_EXCLUDE
@ LAYER_COLLECTION_INDIRECT_ONLY
@ LAYER_COLLECTION_HOLDOUT
Object is a sort of wrapper for general info.
@ TSE_VIEW_COLLECTION_BASE
@ TSE_SCENE_COLLECTION_BASE
void ED_outliner_select_sync_from_object_tag(bContext *C)
bool ED_outliner_collections_editor_poll(bContext *C)
bool ED_operator_region_outliner_active(bContext *C)
static bool is_inside(int x, int y, int cols, int rows)
static void clear(Message &msg)
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
static int collection_link_exec(bContext *C, wmOperator *op)
void OUTLINER_OT_collection_duplicate_linked(wmOperatorType *ot)
static int outliner_hide_exec(bContext *C, wmOperator *)
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 bool collections_holdout_clear_poll(bContext *C)
bool outliner_is_collection_tree_element(const TreeElement *te)
static TreeElement * outliner_active_collection(bContext *C)
static bool collection_disable_poll(bContext *C)
static int collection_view_layer_exec(bContext *C, wmOperator *op)
static TreeTraversalAction outliner_find_first_selected_layer_collection(TreeElement *te, void *customdata)
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 int collection_instance_exec(bContext *C, wmOperator *)
static bool collection_show_poll(bContext *C)
void OUTLINER_OT_collection_hide(wmOperatorType *ot)
void outliner_collection_isolate_flag(Scene *scene, ViewLayer *view_layer, LayerCollection *layer_collection, Collection *collection, PropertyRNA *layer_or_collection_prop, const char *propname, const bool value)
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)
void outliner_collection_delete(bContext *C, Main *bmain, Scene *scene, ReportList *reports, bool do_hierarchy)
static bool collection_enable_poll(bContext *C)
static int collection_hierarchy_delete_exec(bContext *C, wmOperator *op)
void outliner_build_tree(Main *mainvar, Scene *scene, ViewLayer *view_layer, SpaceOutliner *space_outliner, ARegion *region)
static int outliner_unhide_all_exec(bContext *C, wmOperator *)
static bool collections_holdout_set_poll(bContext *C)
void OUTLINER_OT_unhide_all(wmOperatorType *ot)
void OUTLINER_OT_collection_hide_inside(wmOperatorType *ot)
static int collection_isolate_invoke(bContext *C, wmOperator *op, const wmEvent *event)
void OUTLINER_OT_collection_enable(wmOperatorType *ot)
static bool outliner_view_layer_collections_editor_poll(bContext *C)
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)
bool outliner_tree_traverse(const SpaceOutliner *space_outliner, ListBase *tree, int filter_te_flag, int filter_tselem_flag, TreeTraversalFunc func, void *customdata)
static bool collections_indirect_only_set_poll(bContext *C)
static TreeTraversalAction outliner_find_first_selected_collection(TreeElement *te, void *customdata)
static int collection_new_exec(bContext *C, wmOperator *op)
static TreeTraversalAction collection_find_selected_to_add(TreeElement *te, void *customdata)
static TreeTraversalAction outliner_hide_collect_data_to_edit(TreeElement *te, void *customdata)
static int collection_isolate_exec(bContext *C, wmOperator *op)
static bool collection_disable_render_poll(bContext *C)
static int outliner_color_tag_set_exec(bContext *C, wmOperator *op)
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)
static int collection_duplicate_exec(bContext *C, wmOperator *op)
static int collection_visibility_exec(bContext *C, wmOperator *op)
static bool collection_flag_poll(bContext *C, bool clear, int flag)
static bool collection_enable_render_poll(bContext *C)
static int collection_flag_exec(bContext *C, wmOperator *op)
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)
void OUTLINER_OT_collection_enable_render(wmOperatorType *ot)
static int collection_objects_select_exec(bContext *C, wmOperator *op)
void ED_outliner_selected_objects_get(const bContext *C, ListBase *objects)
bool ED_outliner_collections_editor_poll(bContext *C)
PropertyRNA * RNA_struct_type_find_property(StructRNA *srna, const char *identifier)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
bool RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop)
bool RNA_property_boolean_get(PointerRNA *ptr, PropertyRNA *prop)
void RNA_property_boolean_set(PointerRNA *ptr, PropertyRNA *prop, bool value)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
PointerRNA RNA_pointer_create(ID *id, StructRNA *type, void *data)
int RNA_enum_get(PointerRNA *ptr, const char *name)
const EnumPropertyItem rna_enum_collection_color_items[]
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
ListBase layer_collections
struct Collection * collection
struct Collection * instance_collection
struct Collection * master_collection
ListBase layer_collections
bool is_liboverride_hierarchy_root_allowed
SpaceOutliner * space_outliner
GSet * collections_to_edit
bool is_liboverride_allowed
LayerCollection * layer_collection
SpaceOutliner * space_outliner
GSet * collections_to_edit
TreeStoreElem * store_elem
bool(* poll)(bContext *C) ATTR_WARN_UNUSED_RESULT
int(* invoke)(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
int(* exec)(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
struct ReportList * reports
void WM_main_add_notifier(uint type, void *reference)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
#define WM_msg_publish_rna_prop(mbus, id_, data_, type_, prop_)