From 70867fa5dd4d0eaed4d119404b7a15b16ed68802 Mon Sep 17 00:00:00 2001 From: Almaz Shinbay Date: Thu, 17 Aug 2023 17:35:10 +0600 Subject: [PATCH] Outliner: Port view collection base elements to new tree-element code design --- .../editors/space_outliner/CMakeLists.txt | 2 ++ .../editors/space_outliner/outliner_tree.cc | 3 ++- .../tree/tree_display_view_layer.cc | 1 - .../space_outliner/tree/tree_element.cc | 4 +++ .../tree/tree_element_view_collection.cc | 27 +++++++++++++++++++ .../tree/tree_element_view_collection.hh | 22 +++++++++++++++ 6 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 source/blender/editors/space_outliner/tree/tree_element_view_collection.cc create mode 100644 source/blender/editors/space_outliner/tree/tree_element_view_collection.hh diff --git a/source/blender/editors/space_outliner/CMakeLists.txt b/source/blender/editors/space_outliner/CMakeLists.txt index d562395bc1d..df6fc0d89b7 100644 --- a/source/blender/editors/space_outliner/CMakeLists.txt +++ b/source/blender/editors/space_outliner/CMakeLists.txt @@ -80,6 +80,7 @@ set(SRC tree/tree_element_rna.cc tree/tree_element_scene_objects.cc tree/tree_element_seq.cc + tree/tree_element_view_collection.cc tree/tree_element_view_layer.cc tree/tree_iterator.cc @@ -120,6 +121,7 @@ set(SRC tree/tree_element_rna.hh tree/tree_element_scene_objects.hh tree/tree_element_seq.hh + tree/tree_element_view_collection.hh tree/tree_element_view_layer.hh tree/tree_iterator.hh ) diff --git a/source/blender/editors/space_outliner/outliner_tree.cc b/source/blender/editors/space_outliner/outliner_tree.cc index 5bcb7222b72..8fd20c9460d 100644 --- a/source/blender/editors/space_outliner/outliner_tree.cc +++ b/source/blender/editors/space_outliner/outliner_tree.cc @@ -416,7 +416,8 @@ TreeElement *outliner_add_element(SpaceOutliner *space_outliner, TSE_R_LAYER, TSE_R_LAYER_BASE, TSE_GREASE_PENCIL_NODE, - TSE_LINKED_OB)) + TSE_LINKED_OB, + TSE_VIEW_COLLECTION_BASE)) { BLI_assert_msg(false, "Element type should already use new AbstractTreeElement design"); } diff --git a/source/blender/editors/space_outliner/tree/tree_display_view_layer.cc b/source/blender/editors/space_outliner/tree/tree_display_view_layer.cc index 8949fc85940..a1af96d48d8 100644 --- a/source/blender/editors/space_outliner/tree/tree_display_view_layer.cc +++ b/source/blender/editors/space_outliner/tree/tree_display_view_layer.cc @@ -120,7 +120,6 @@ void TreeDisplayViewLayer::add_view_layer(Scene &scene, ListBase &tree, TreeElem /* Show collections in the view layer. */ TreeElement &ten = *outliner_add_element( &space_outliner_, &tree, &scene, parent, TSE_VIEW_COLLECTION_BASE, 0); - ten.name = IFACE_("Scene Collection"); TREESTORE(&ten)->flag &= ~TSE_CLOSED; /* First layer collection is for master collection, don't show it. */ diff --git a/source/blender/editors/space_outliner/tree/tree_element.cc b/source/blender/editors/space_outliner/tree/tree_element.cc index 922c0f38890..3d3ac7b5621 100644 --- a/source/blender/editors/space_outliner/tree/tree_element.cc +++ b/source/blender/editors/space_outliner/tree/tree_element.cc @@ -39,6 +39,7 @@ #include "tree_element_rna.hh" #include "tree_element_scene_objects.hh" #include "tree_element_seq.hh" +#include "tree_element_view_collection.hh" #include "tree_element_view_layer.hh" #include "../outliner_intern.hh" @@ -171,6 +172,9 @@ std::unique_ptr AbstractTreeElement::createFromType(const i } case TSE_LINKED_OB: return std::make_unique(legacy_te, *static_cast(idv)); + case TSE_VIEW_COLLECTION_BASE: + return std::make_unique(legacy_te, + *static_cast(idv)); default: break; } diff --git a/source/blender/editors/space_outliner/tree/tree_element_view_collection.cc b/source/blender/editors/space_outliner/tree/tree_element_view_collection.cc new file mode 100644 index 00000000000..de6852c8f53 --- /dev/null +++ b/source/blender/editors/space_outliner/tree/tree_element_view_collection.cc @@ -0,0 +1,27 @@ +/* SPDX-FileCopyrightText: 2023 Blender Authors + * + * SPDX-License-Identifier: GPL-2.0-or-later */ + +/** \file + * \ingroup spoutliner + */ + +#include "DNA_outliner_types.h" +#include "DNA_scene_types.h" + +#include "BLT_translation.h" + +#include "../outliner_intern.hh" + +#include "tree_element_view_collection.hh" + +namespace blender::ed::outliner { + +TreeElementViewCollectionBase::TreeElementViewCollectionBase(TreeElement &legacy_te, Scene &scene) + : AbstractTreeElement(legacy_te), scene_(scene) +{ + BLI_assert(legacy_te.store_elem->type == TSE_VIEW_COLLECTION_BASE); + legacy_te.name = IFACE_("Scene Collection"); +} + +} // namespace blender::ed::outliner diff --git a/source/blender/editors/space_outliner/tree/tree_element_view_collection.hh b/source/blender/editors/space_outliner/tree/tree_element_view_collection.hh new file mode 100644 index 00000000000..5e4d1601a22 --- /dev/null +++ b/source/blender/editors/space_outliner/tree/tree_element_view_collection.hh @@ -0,0 +1,22 @@ +/* SPDX-FileCopyrightText: 2023 Blender Authors + * + * SPDX-License-Identifier: GPL-2.0-or-later */ + +/** \file + * \ingroup spoutliner + */ + +#pragma once + +#include "tree_element.hh" + +namespace blender::ed::outliner { + +class TreeElementViewCollectionBase final : public AbstractTreeElement { + Scene &scene_; + + public: + TreeElementViewCollectionBase(TreeElement &legacy_te, Scene &scene); +}; + +} // namespace blender::ed::outliner -- 2.30.2