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:
-rw-r--r--source/blender/editors/space_outliner/CMakeLists.txt6
-rw-r--r--source/blender/editors/space_outliner/outliner_tree.c113
-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
14 files changed, 517 insertions, 118 deletions
diff --git a/source/blender/editors/space_outliner/CMakeLists.txt b/source/blender/editors/space_outliner/CMakeLists.txt
index 7b9bc44f986..82c87a7b199 100644
--- a/source/blender/editors/space_outliner/CMakeLists.txt
+++ b/source/blender/editors/space_outliner/CMakeLists.txt
@@ -56,10 +56,13 @@ set(SRC
tree/tree_display_view_layer.cc
tree/tree_element.cc
tree/tree_element_anim_data.cc
+ tree/tree_element_collection_base.cc
tree/tree_element_driver_base.cc
tree/tree_element_gpencil_layer.cc
tree/tree_element_id.cc
tree/tree_element_nla.cc
+ tree/tree_element_scene_objects_base.cc
+ tree/tree_element_view_layer_base.cc
outliner_intern.h
tree/tree_display.h
@@ -67,10 +70,13 @@ set(SRC
tree/tree_element.h
tree/tree_element.hh
tree/tree_element_anim_data.hh
+ tree/tree_element_collection_base.hh
tree/tree_element_driver_base.hh
tree/tree_element_gpencil_layer.hh
tree/tree_element_id.hh
tree/tree_element_nla.hh
+ tree/tree_element_scene_objects_base.hh
+ tree/tree_element_view_layer_base.hh
)
set(LIB
diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c
index 6ca986660c1..6319b890b3b 100644
--- a/source/blender/editors/space_outliner/outliner_tree.c
+++ b/source/blender/editors/space_outliner/outliner_tree.c
@@ -1,4 +1,4 @@
-/*
+/*
* 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
@@ -92,9 +92,6 @@
#endif
/* prototypes */
-static TreeElement *outliner_add_collection_recursive(SpaceOutliner *space_outliner,
- Collection *collection,
- TreeElement *ten);
static int outliner_exclude_filter_get(const SpaceOutliner *space_outliner);
/* ********************************************************* */
@@ -274,7 +271,7 @@ static void outliner_add_bone(SpaceOutliner *space_outliner,
}
}
-static bool outliner_animdata_test(AnimData *adt)
+bool outliner_animdata_test(const AnimData *adt)
{
if (adt) {
return (adt->action || adt->drivers.first || adt->nla_tracks.first);
@@ -314,46 +311,6 @@ static void outliner_add_line_styles(SpaceOutliner *space_outliner,
}
#endif
-static void outliner_add_scene_contents(SpaceOutliner *space_outliner,
- ListBase *lb,
- Scene *sce,
- TreeElement *te)
-{
- /* View layers */
- TreeElement *ten = outliner_add_element(space_outliner, lb, sce, te, TSE_R_LAYER_BASE, 0);
- ten->name = IFACE_("View Layers");
-
- ViewLayer *view_layer;
- for (view_layer = sce->view_layers.first; view_layer; view_layer = view_layer->next) {
- TreeElement *tenlay = outliner_add_element(
- space_outliner, &ten->subtree, sce, ten, TSE_R_LAYER, 0);
- tenlay->name = view_layer->name;
- tenlay->directdata = view_layer;
- }
-
- /* World */
- outliner_add_element(space_outliner, lb, sce->world, te, TSE_SOME_ID, 0);
-
- /* Collections */
- ten = outliner_add_element(space_outliner, lb, &sce->id, te, TSE_SCENE_COLLECTION_BASE, 0);
- ten->name = IFACE_("Scene Collection");
- outliner_add_collection_recursive(space_outliner, sce->master_collection, ten);
-
- /* Objects */
- ten = outliner_add_element(space_outliner, lb, sce, te, TSE_SCENE_OBJECTS_BASE, 0);
- ten->name = IFACE_("Objects");
- FOREACH_SCENE_OBJECT_BEGIN (sce, ob) {
- outliner_add_element(space_outliner, &ten->subtree, ob, ten, TSE_SOME_ID, 0);
- }
- FOREACH_SCENE_OBJECT_END;
- outliner_make_object_parent_hierarchy(&ten->subtree);
-
- /* Animation Data */
- if (outliner_animdata_test(sce->adt)) {
- outliner_add_element(space_outliner, lb, sce, te, TSE_ANIM_DATA, 0);
- }
-}
-
/* Can be inlined if necessary. */
static void outliner_add_object_contents(SpaceOutliner *space_outliner,
TreeElement *te,
@@ -629,32 +586,6 @@ static void outliner_add_object_contents(SpaceOutliner *space_outliner,
}
}
-static void outliner_add_library_override_contents(SpaceOutliner *soops, TreeElement *te, ID *id)
-{
- if (!id->override_library) {
- return;
- }
-
- PointerRNA idpoin;
- RNA_id_pointer_create(id, &idpoin);
-
- PointerRNA override_ptr;
- PropertyRNA *override_prop;
- int index = 0;
- LISTBASE_FOREACH (IDOverrideLibraryProperty *, op, &id->override_library->properties) {
- if (!BKE_lib_override_rna_property_find(&idpoin, op, &override_ptr, &override_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(
- soops, &te->subtree, id, te, TSE_LIBRARY_OVERRIDE, index++);
- ten->name = RNA_property_ui_name(override_prop);
- }
-}
-
/* Can be inlined if necessary. */
static void outliner_add_id_contents(SpaceOutliner *space_outliner,
TreeElement *te,
@@ -668,14 +599,10 @@ static void outliner_add_id_contents(SpaceOutliner *space_outliner,
/* expand specific data always */
switch (GS(id->name)) {
- case ID_LI: {
- te->name = ((Library *)id)->filepath;
- break;
- }
- case ID_SCE: {
- outliner_add_scene_contents(space_outliner, &te->subtree, (Scene *)id, te);
+ case ID_LI:
+ case ID_SCE:
+ BLI_assert(!"ID type expected to be expanded through new tree-element design");
break;
- }
case ID_OB: {
outliner_add_object_contents(space_outliner, te, tselem, (Object *)id);
break;
@@ -902,17 +829,6 @@ static void outliner_add_id_contents(SpaceOutliner *space_outliner,
default:
break;
}
-
- 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, &te->subtree, id, te, TSE_LIBRARY_OVERRIDE_BASE, 0);
-
- ten->name = IFACE_("Library Overrides");
- outliner_add_library_override_contents(space_outliner, ten, id);
- }
}
/**
@@ -1001,7 +917,11 @@ TreeElement *outliner_add_element(SpaceOutliner *space_outliner,
/* Other cases must be caught above. */
BLI_assert(TSE_IS_REAL_ID(tselem));
- te->name = id->name + 2; /* Default, can be overridden by Library or non-ID data. */
+ /* The new type design sets the name already, don't override that here. We need to figure out
+ * how to deal with the idcode for non-TSE_SOME_ID types still. Some rely on it... */
+ if (!te->type) {
+ te->name = id->name + 2; /* Default, can be overridden by Library or non-ID data. */
+ }
te->idcode = GS(id->name);
}
@@ -1009,11 +929,10 @@ TreeElement *outliner_add_element(SpaceOutliner *space_outliner,
outliner_tree_element_type_expand(te->type, space_outliner);
}
else if (type == TSE_SOME_ID) {
- TreeStoreElem *tsepar = parent ? TREESTORE(parent) : NULL;
-
- /* ID data-block. */
- if (tsepar == NULL || tsepar->type != TSE_ID_BASE || space_outliner->filter_id_type) {
+ /* ID types not (fully) ported to new design yet. */
+ if (outliner_tree_element_type_expand_poll(te->type, space_outliner)) {
outliner_add_id_contents(space_outliner, te, tselem, id);
+ outliner_tree_element_type_post_expand(te->type, space_outliner);
}
}
else if (ELEM(type,
@@ -1233,9 +1152,9 @@ BLI_INLINE void outliner_add_collection_objects(SpaceOutliner *space_outliner,
}
}
-static TreeElement *outliner_add_collection_recursive(SpaceOutliner *space_outliner,
- Collection *collection,
- TreeElement *ten)
+TreeElement *outliner_add_collection_recursive(SpaceOutliner *space_outliner,
+ Collection *collection,
+ TreeElement *ten)
{
outliner_add_collection_init(ten, collection);
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