Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Eisel <julian@blender.org>2021-03-08 17:13:35 +0300
committerJulian Eisel <julian@blender.org>2021-03-08 20:38:23 +0300
commit4292bb060d598659889e7448e02142248564fae7 (patch)
treea496d0f95c5e951bf4190dffc55f1827fe8e8cd9 /source/blender/editors/space_outliner/tree
parent8771f015f50ec72c3b0eaac1eb9498d277a4952b (diff)
Outliner: Port scene elements and some related types to new tree-element code design
Continuation of work in 2e221de4ceee, 249e4df110e0 and 3a907e742507. Adds new tree-element classes for the scene-ID, scene collections, scene objects, and the view layers base. There is some more temporary stuff in here, which can be removed once we're further along with the porting. Noted that in comments.
Diffstat (limited to 'source/blender/editors/space_outliner/tree')
-rw-r--r--source/blender/editors/space_outliner/tree/tree_display.h4
-rw-r--r--source/blender/editors/space_outliner/tree/tree_element.cc45
-rw-r--r--source/blender/editors/space_outliner/tree/tree_element.h2
-rw-r--r--source/blender/editors/space_outliner/tree/tree_element.hh19
-rw-r--r--source/blender/editors/space_outliner/tree/tree_element_collection_base.cc44
-rw-r--r--source/blender/editors/space_outliner/tree/tree_element_collection_base.hh36
-rw-r--r--source/blender/editors/space_outliner/tree/tree_element_id.cc156
-rw-r--r--source/blender/editors/space_outliner/tree/tree_element_id.hh37
-rw-r--r--source/blender/editors/space_outliner/tree/tree_element_scene_objects_base.cc50
-rw-r--r--source/blender/editors/space_outliner/tree/tree_element_scene_objects_base.hh36
-rw-r--r--source/blender/editors/space_outliner/tree/tree_element_view_layer_base.cc51
-rw-r--r--source/blender/editors/space_outliner/tree/tree_element_view_layer_base.hh36
12 files changed, 495 insertions, 21 deletions
diff --git a/source/blender/editors/space_outliner/tree/tree_display.h b/source/blender/editors/space_outliner/tree/tree_display.h
index 4ef71ded133..c0a751f2cd5 100644
--- a/source/blender/editors/space_outliner/tree/tree_display.h
+++ b/source/blender/editors/space_outliner/tree/tree_display.h
@@ -56,6 +56,10 @@ struct TreeElement *outliner_add_element(SpaceOutliner *space_outliner,
short type,
short index);
void outliner_make_object_parent_hierarchy(ListBase *lb);
+bool outliner_animdata_test(const struct AnimData *adt);
+TreeElement *outliner_add_collection_recursive(SpaceOutliner *space_outliner,
+ struct Collection *collection,
+ TreeElement *ten);
const char *outliner_idcode_to_plural(short idcode);
diff --git a/source/blender/editors/space_outliner/tree/tree_element.cc b/source/blender/editors/space_outliner/tree/tree_element.cc
index 79c2831475f..75ecfb5584a 100644
--- a/source/blender/editors/space_outliner/tree/tree_element.cc
+++ b/source/blender/editors/space_outliner/tree/tree_element.cc
@@ -21,10 +21,13 @@
#include "DNA_listBase.h"
#include "tree_element_anim_data.hh"
+#include "tree_element_collection_base.hh"
#include "tree_element_driver_base.hh"
#include "tree_element_gpencil_layer.hh"
#include "tree_element_id.hh"
#include "tree_element_nla.hh"
+#include "tree_element_scene_objects_base.hh"
+#include "tree_element_view_layer_base.hh"
#include "tree_element.h"
#include "tree_element.hh"
@@ -52,6 +55,12 @@ static AbstractTreeElement *tree_element_create(int type, TreeElement &legacy_te
return new TreeElementNLAAction(legacy_te);
case TSE_GP_LAYER:
return new TreeElementGPencilLayer(legacy_te, *static_cast<bGPDlayer *>(idv));
+ case TSE_R_LAYER_BASE:
+ return new TreeElementViewLayerBase(legacy_te, *static_cast<Scene *>(idv));
+ case TSE_SCENE_COLLECTION_BASE:
+ return new TreeElementCollectionBase(legacy_te, *static_cast<Scene *>(idv));
+ case TSE_SCENE_OBJECTS_BASE:
+ return new TreeElementSceneObjectsBase(legacy_te, *static_cast<Scene *>(idv));
default:
break;
}
@@ -67,7 +76,33 @@ static void tree_element_free(AbstractTreeElement **tree_element)
static void tree_element_expand(AbstractTreeElement &tree_element, SpaceOutliner &space_outliner)
{
+ /* Most types can just expand. IDs optionally expand (hence the poll) and do additional, common
+ * expanding. Could be done nicer, we could request a small "expander" helper object from the
+ * element type, that the IDs have a more advanced implementation for. */
+ if (!tree_element.expandPoll(space_outliner)) {
+ return;
+ }
tree_element.expand(space_outliner);
+ tree_element.postExpand(space_outliner);
+}
+
+/**
+ * Needed for types that still expand in C, but need to execute the same post-expand logic. Can be
+ * removed once all ID types expand entirely using the new design.
+ */
+static void tree_element_post_expand_only(AbstractTreeElement &tree_element,
+ SpaceOutliner &space_outliner)
+{
+ tree_element.postExpand(space_outliner);
+}
+/**
+ * Needed for types that still expand in C, to poll if they should expand in current context. Can
+ * be removed once all ID types expand entirely using the new design.
+ */
+static bool tree_element_expand_poll(AbstractTreeElement &tree_element,
+ SpaceOutliner &space_outliner)
+{
+ return tree_element.expandPoll(space_outliner);
}
} // namespace blender::ed::outliner
@@ -91,6 +126,16 @@ bool outliner_tree_element_type_is_expand_valid(TreeElementType *type)
*type);
return element.isExpandValid();
}
+bool outliner_tree_element_type_expand_poll(TreeElementType *type, SpaceOutliner *space_outliner)
+{
+ return outliner::tree_element_expand_poll(
+ reinterpret_cast<outliner::AbstractTreeElement &>(*type), *space_outliner);
+}
+void outliner_tree_element_type_post_expand(TreeElementType *type, SpaceOutliner *space_outliner)
+{
+ outliner::tree_element_post_expand_only(reinterpret_cast<outliner::AbstractTreeElement &>(*type),
+ *space_outliner);
+}
void outliner_tree_element_type_free(TreeElementType **type)
{
diff --git a/source/blender/editors/space_outliner/tree/tree_element.h b/source/blender/editors/space_outliner/tree/tree_element.h
index c3dec1bf68a..8e5b02278cc 100644
--- a/source/blender/editors/space_outliner/tree/tree_element.h
+++ b/source/blender/editors/space_outliner/tree/tree_element.h
@@ -40,6 +40,8 @@ void outliner_tree_element_type_free(TreeElementType **type);
void outliner_tree_element_type_expand(TreeElementType *type, SpaceOutliner *space_outliner);
bool outliner_tree_element_type_is_expand_valid(TreeElementType *type);
+bool outliner_tree_element_type_expand_poll(TreeElementType *type, SpaceOutliner *space_outliner);
+void outliner_tree_element_type_post_expand(TreeElementType *type, SpaceOutliner *space_outliner);
#ifdef __cplusplus
}
diff --git a/source/blender/editors/space_outliner/tree/tree_element.hh b/source/blender/editors/space_outliner/tree/tree_element.hh
index 3e61dd25898..4a7e95556db 100644
--- a/source/blender/editors/space_outliner/tree/tree_element.hh
+++ b/source/blender/editors/space_outliner/tree/tree_element.hh
@@ -37,17 +37,24 @@ class AbstractTreeElement {
TreeElement &legacy_te_;
public:
- AbstractTreeElement(TreeElement &legacy_te) : legacy_te_(legacy_te)
- {
- }
virtual ~AbstractTreeElement() = default;
/**
+ * Check if the type is expandible in current context.
+ */
+ virtual bool expandPoll(const SpaceOutliner &) const
+ {
+ return true;
+ }
+ /**
* Let the type add its own children.
*/
virtual void expand(SpaceOutliner &) const
{
}
+ virtual void postExpand(SpaceOutliner &) const
+ {
+ }
/**
* Just while transitioning to the new tree-element design: Some types are only partially ported,
@@ -57,6 +64,12 @@ class AbstractTreeElement {
{
return true;
}
+
+ protected:
+ /* Pseudo-abstract: Only allow creation through derived types. */
+ AbstractTreeElement(TreeElement &legacy_te) : legacy_te_(legacy_te)
+ {
+ }
};
} // namespace blender::ed::outliner
diff --git a/source/blender/editors/space_outliner/tree/tree_element_collection_base.cc b/source/blender/editors/space_outliner/tree/tree_element_collection_base.cc
new file mode 100644
index 00000000000..29e010b100d
--- /dev/null
+++ b/source/blender/editors/space_outliner/tree/tree_element_collection_base.cc
@@ -0,0 +1,44 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/** \file
+ * \ingroup spoutliner
+ */
+
+#include "DNA_listBase.h"
+
+#include "BLT_translation.h"
+
+#include "../outliner_intern.h"
+#include "tree_display.h"
+
+#include "tree_element_collection_base.hh"
+
+namespace blender::ed::outliner {
+
+TreeElementCollectionBase::TreeElementCollectionBase(TreeElement &legacy_te, Scene &scene)
+ : AbstractTreeElement(legacy_te), scene_(scene)
+{
+ BLI_assert(legacy_te.store_elem->type == TSE_SCENE_COLLECTION_BASE);
+ legacy_te.name = IFACE_("Scene Collection");
+}
+
+void TreeElementCollectionBase::expand(SpaceOutliner &space_outliner) const
+{
+ outliner_add_collection_recursive(&space_outliner, scene_.master_collection, &legacy_te_);
+}
+
+} // namespace blender::ed::outliner
diff --git a/source/blender/editors/space_outliner/tree/tree_element_collection_base.hh b/source/blender/editors/space_outliner/tree/tree_element_collection_base.hh
new file mode 100644
index 00000000000..e9584d37dfe
--- /dev/null
+++ b/source/blender/editors/space_outliner/tree/tree_element_collection_base.hh
@@ -0,0 +1,36 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/** \file
+ * \ingroup spoutliner
+ */
+
+#pragma once
+
+#include "tree_element.hh"
+
+namespace blender::ed::outliner {
+
+class TreeElementCollectionBase final : public AbstractTreeElement {
+ Scene &scene_;
+
+ public:
+ TreeElementCollectionBase(TreeElement &legacy_te, Scene &scene);
+
+ void expand(SpaceOutliner &) const override;
+};
+
+} // namespace blender::ed::outliner
diff --git a/source/blender/editors/space_outliner/tree/tree_element_id.cc b/source/blender/editors/space_outliner/tree/tree_element_id.cc
index 26787475635..a061c084027 100644
--- a/source/blender/editors/space_outliner/tree/tree_element_id.cc
+++ b/source/blender/editors/space_outliner/tree/tree_element_id.cc
@@ -20,30 +20,29 @@
#include "DNA_ID.h"
+#include "BLI_listbase_wrapper.hh"
#include "BLI_utildefines.h"
+#include "BKE_lib_override.h"
+
+#include "BLT_translation.h"
+
+#include "RNA_access.h"
+
#include "../outliner_intern.h"
+#include "tree_display.h"
#include "tree_element_id.hh"
namespace blender::ed::outliner {
-TreeElementID::TreeElementID(TreeElement &legacy_te, const ID &id) : AbstractTreeElement(legacy_te)
-{
- BLI_assert(legacy_te_.store_elem->type == TSE_SOME_ID);
- BLI_assert(TSE_IS_REAL_ID(legacy_te_.store_elem));
-
- /* Default, some specific types override this. */
- legacy_te_.name = id.name + 2;
- legacy_te_.idcode = GS(id.name);
-}
-
-TreeElementID *TreeElementID::createFromID(TreeElement &legacy_te, const ID &id)
+TreeElementID *TreeElementID::createFromID(TreeElement &legacy_te, ID &id)
{
switch (ID_Type type = GS(id.name); type) {
case ID_LI:
- return new TreeElementIDLibrary(legacy_te, id);
+ return new TreeElementIDLibrary(legacy_te, (Library &)id);
case ID_SCE:
+ return new TreeElementIDScene(legacy_te, (Scene &)id);
case ID_OB:
case ID_ME:
case ID_CU:
@@ -91,10 +90,137 @@ TreeElementID *TreeElementID::createFromID(TreeElement &legacy_te, const ID &id)
return nullptr;
}
-TreeElementIDLibrary::TreeElementIDLibrary(TreeElement &legacy_te, const ID &id)
- : TreeElementID(legacy_te, id)
+/* -------------------------------------------------------------------- */
+/* ID Tree-Element Base Class (common/default logic) */
+
+TreeElementID::TreeElementID(TreeElement &legacy_te, ID &id)
+ : AbstractTreeElement(legacy_te), id_(id)
+{
+ BLI_assert(legacy_te_.store_elem->type == TSE_SOME_ID);
+ BLI_assert(TSE_IS_REAL_ID(legacy_te_.store_elem));
+
+ /* Default, some specific types override this. */
+ legacy_te_.name = id.name + 2;
+ legacy_te_.idcode = GS(id.name);
+}
+
+void TreeElementID::expand_library_overrides(SpaceOutliner &space_outliner) const
+{
+ if (!id_.override_library) {
+ return;
+ }
+
+ PointerRNA idpoin;
+ RNA_id_pointer_create(&id_, &idpoin);
+
+ PointerRNA override_rna_ptr;
+ PropertyRNA *override_rna_prop;
+ int index = 0;
+
+ for (auto *override_prop :
+ ListBaseWrapper<IDOverrideLibraryProperty>(id_.override_library->properties)) {
+ if (!BKE_lib_override_rna_property_find(
+ &idpoin, override_prop, &override_rna_ptr, &override_rna_prop)) {
+ /* This is fine, override properties list is not always fully up-to-date with current
+ * RNA/IDProps etc., this gets cleaned up when re-generating the overrides rules,
+ * no error here. */
+ continue;
+ }
+
+ TreeElement *ten = outliner_add_element(
+ &space_outliner, &legacy_te_.subtree, &id_, &legacy_te_, TSE_LIBRARY_OVERRIDE, index++);
+ ten->name = RNA_property_ui_name(override_rna_prop);
+ }
+}
+
+void TreeElementID::postExpand(SpaceOutliner &space_outliner) const
+{
+ const bool lib_overrides_visible = !SUPPORT_FILTER_OUTLINER(&space_outliner) ||
+ ((space_outliner.filter & SO_FILTER_NO_LIB_OVERRIDE) == 0);
+
+ if (lib_overrides_visible && ID_IS_OVERRIDE_LIBRARY(&id_)) {
+ TreeElement *ten = outliner_add_element(
+ &space_outliner, &legacy_te_.subtree, &id_, &legacy_te_, TSE_LIBRARY_OVERRIDE_BASE, 0);
+
+ ten->name = IFACE_("Library Overrides");
+ expand_library_overrides(space_outliner);
+ }
+}
+
+bool TreeElementID::expandPoll(const SpaceOutliner &space_outliner) const
+{
+ const TreeStoreElem *tsepar = legacy_te_.parent ? TREESTORE(legacy_te_.parent) : nullptr;
+ return (tsepar == NULL || tsepar->type != TSE_ID_BASE || space_outliner.filter_id_type);
+}
+
+void TreeElementID::expand_animation_data(SpaceOutliner &space_outliner,
+ const AnimData *anim_data) const
+{
+ if (outliner_animdata_test(anim_data)) {
+ outliner_add_element(
+ &space_outliner, &legacy_te_.subtree, &id_, &legacy_te_, TSE_ANIM_DATA, 0);
+ }
+}
+
+/* -------------------------------------------------------------------- */
+/* Library Tree-Element */
+
+TreeElementIDLibrary::TreeElementIDLibrary(TreeElement &legacy_te, Library &library)
+ : TreeElementID(legacy_te, library.id)
+{
+ legacy_te.name = library.filepath;
+}
+
+bool TreeElementIDLibrary::isExpandValid() const
+{
+ return true;
+}
+
+/* -------------------------------------------------------------------- */
+/* Scene Tree-Element */
+
+TreeElementIDScene::TreeElementIDScene(TreeElement &legacy_te, Scene &scene)
+ : TreeElementID(legacy_te, scene.id), scene_(scene)
+{
+}
+
+bool TreeElementIDScene::isExpandValid() const
+{
+ return true;
+}
+
+void TreeElementIDScene::expand(SpaceOutliner &space_outliner) const
+{
+ expandViewLayers(space_outliner);
+ expandWorld(space_outliner);
+ expandCollections(space_outliner);
+ expandObjects(space_outliner);
+
+ expand_animation_data(space_outliner, scene_.adt);
+}
+
+void TreeElementIDScene::expandViewLayers(SpaceOutliner &space_outliner) const
+{
+ outliner_add_element(
+ &space_outliner, &legacy_te_.subtree, &scene_, &legacy_te_, TSE_R_LAYER_BASE, 0);
+}
+
+void TreeElementIDScene::expandWorld(SpaceOutliner &space_outliner) const
+{
+ outliner_add_element(
+ &space_outliner, &legacy_te_.subtree, scene_.world, &legacy_te_, TSE_SOME_ID, 0);
+}
+
+void TreeElementIDScene::expandCollections(SpaceOutliner &space_outliner) const
+{
+ outliner_add_element(
+ &space_outliner, &legacy_te_.subtree, &scene_, &legacy_te_, TSE_SCENE_COLLECTION_BASE, 0);
+}
+
+void TreeElementIDScene::expandObjects(SpaceOutliner &space_outliner) const
{
- legacy_te.name = ((Library &)id).filepath;
+ outliner_add_element(
+ &space_outliner, &legacy_te_.subtree, &scene_, &legacy_te_, TSE_SCENE_OBJECTS_BASE, 0);
}
} // namespace blender::ed::outliner
diff --git a/source/blender/editors/space_outliner/tree/tree_element_id.hh b/source/blender/editors/space_outliner/tree/tree_element_id.hh
index 612c1cd4a6f..21bc25564fd 100644
--- a/source/blender/editors/space_outliner/tree/tree_element_id.hh
+++ b/source/blender/editors/space_outliner/tree/tree_element_id.hh
@@ -25,10 +25,16 @@
namespace blender::ed::outliner {
class TreeElementID : public AbstractTreeElement {
+ protected:
+ ID &id_;
+
public:
- TreeElementID(TreeElement &legacy_te, const ID &id);
+ TreeElementID(TreeElement &legacy_te, ID &id);
+
+ static TreeElementID *createFromID(TreeElement &legacy_te, ID &id);
- static TreeElementID *createFromID(TreeElement &legacy_te, const ID &id);
+ void postExpand(SpaceOutliner &) const override;
+ bool expandPoll(const SpaceOutliner &) const override;
/**
* Expanding not implemented for all types yet. Once it is, this can be set to true or
@@ -38,11 +44,36 @@ class TreeElementID : public AbstractTreeElement {
{
return false;
}
+
+ protected:
+ /* ID types with animation data can use this. */
+ void expand_animation_data(SpaceOutliner &, const AnimData *) const;
+
+ private:
+ void expand_library_overrides(SpaceOutliner &) const;
};
class TreeElementIDLibrary final : public TreeElementID {
public:
- TreeElementIDLibrary(TreeElement &legacy_te, const ID &id);
+ TreeElementIDLibrary(TreeElement &legacy_te, Library &library);
+
+ bool isExpandValid() const override;
+};
+
+class TreeElementIDScene final : public TreeElementID {
+ Scene &scene_;
+
+ public:
+ TreeElementIDScene(TreeElement &legacy_te, Scene &scene);
+
+ void expand(SpaceOutliner &) const override;
+ bool isExpandValid() const override;
+
+ private:
+ void expandViewLayers(SpaceOutliner &) const;
+ void expandWorld(SpaceOutliner &) const;
+ void expandCollections(SpaceOutliner &) const;
+ void expandObjects(SpaceOutliner &) const;
};
} // namespace blender::ed::outliner
diff --git a/source/blender/editors/space_outliner/tree/tree_element_scene_objects_base.cc b/source/blender/editors/space_outliner/tree/tree_element_scene_objects_base.cc
new file mode 100644
index 00000000000..4446b8864e6
--- /dev/null
+++ b/source/blender/editors/space_outliner/tree/tree_element_scene_objects_base.cc
@@ -0,0 +1,50 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/** \file
+ * \ingroup spoutliner
+ */
+
+#include "BKE_collection.h"
+
+#include "BLI_utildefines.h"
+
+#include "BLT_translation.h"
+
+#include "../outliner_intern.h"
+#include "tree_display.h"
+
+#include "tree_element_scene_objects_base.hh"
+
+namespace blender::ed::outliner {
+
+TreeElementSceneObjectsBase::TreeElementSceneObjectsBase(TreeElement &legacy_te, Scene &scene)
+ : AbstractTreeElement(legacy_te), scene_(scene)
+{
+ BLI_assert(legacy_te.store_elem->type == TSE_SCENE_OBJECTS_BASE);
+ legacy_te.name = IFACE_("Objects");
+}
+
+void TreeElementSceneObjectsBase::expand(SpaceOutliner &space_outliner) const
+{
+ FOREACH_SCENE_OBJECT_BEGIN (&scene_, ob) {
+ outliner_add_element(&space_outliner, &legacy_te_.subtree, ob, &legacy_te_, TSE_SOME_ID, 0);
+ }
+ FOREACH_SCENE_OBJECT_END;
+ outliner_make_object_parent_hierarchy(&legacy_te_.subtree);
+}
+
+} // namespace blender::ed::outliner
diff --git a/source/blender/editors/space_outliner/tree/tree_element_scene_objects_base.hh b/source/blender/editors/space_outliner/tree/tree_element_scene_objects_base.hh
new file mode 100644
index 00000000000..a2aa29c4a33
--- /dev/null
+++ b/source/blender/editors/space_outliner/tree/tree_element_scene_objects_base.hh
@@ -0,0 +1,36 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/** \file
+ * \ingroup spoutliner
+ */
+
+#pragma once
+
+#include "tree_element.hh"
+
+namespace blender::ed::outliner {
+
+class TreeElementSceneObjectsBase final : public AbstractTreeElement {
+ Scene &scene_;
+
+ public:
+ TreeElementSceneObjectsBase(TreeElement &legacy_te, Scene &scene);
+
+ void expand(SpaceOutliner &) const override;
+};
+
+} // namespace blender::ed::outliner
diff --git a/source/blender/editors/space_outliner/tree/tree_element_view_layer_base.cc b/source/blender/editors/space_outliner/tree/tree_element_view_layer_base.cc
new file mode 100644
index 00000000000..490086203dc
--- /dev/null
+++ b/source/blender/editors/space_outliner/tree/tree_element_view_layer_base.cc
@@ -0,0 +1,51 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/** \file
+ * \ingroup spoutliner
+ */
+
+#include "DNA_layer_types.h"
+
+#include "BLI_listbase_wrapper.hh"
+
+#include "BLT_translation.h"
+
+#include "../outliner_intern.h"
+#include "tree_display.h"
+
+#include "tree_element_view_layer_base.hh"
+
+namespace blender::ed::outliner {
+
+TreeElementViewLayerBase::TreeElementViewLayerBase(TreeElement &legacy_te, Scene &scene)
+ : AbstractTreeElement(legacy_te), scene_(scene)
+{
+ BLI_assert(legacy_te.store_elem->type == TSE_R_LAYER_BASE);
+ legacy_te_.name = IFACE_("View Layers");
+}
+
+void TreeElementViewLayerBase::expand(SpaceOutliner &space_outliner) const
+{
+ for (auto *view_layer : ListBaseWrapper<ViewLayer>(scene_.view_layers)) {
+ TreeElement *tenlay = outliner_add_element(
+ &space_outliner, &legacy_te_.subtree, &scene_, &legacy_te_, TSE_R_LAYER, 0);
+ tenlay->name = view_layer->name;
+ tenlay->directdata = view_layer;
+ }
+}
+
+} // namespace blender::ed::outliner
diff --git a/source/blender/editors/space_outliner/tree/tree_element_view_layer_base.hh b/source/blender/editors/space_outliner/tree/tree_element_view_layer_base.hh
new file mode 100644
index 00000000000..24e03b265dc
--- /dev/null
+++ b/source/blender/editors/space_outliner/tree/tree_element_view_layer_base.hh
@@ -0,0 +1,36 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+/** \file
+ * \ingroup spoutliner
+ */
+
+#pragma once
+
+#include "tree_element.hh"
+
+namespace blender::ed::outliner {
+
+class TreeElementViewLayerBase final : public AbstractTreeElement {
+ Scene &scene_;
+
+ public:
+ TreeElementViewLayerBase(TreeElement &legacy_te, Scene &scene);
+
+ void expand(SpaceOutliner &) const override;
+};
+
+} // namespace blender::ed::outliner