Outliner: Port collection elements to new tree-element code design

No user visible changes expected.

Part of #96713, continuation of work started in 249e4df110 and 2e221de4ce.
Refer to these for a motivation and design overview.

Adds a new tree-element class for collection IDs.

Pull Request: https://projects.blender.org/blender/blender/pulls/108943
This commit is contained in:
Almaz Shinbay
2023-06-13 18:22:04 +02:00
committed by Julian Eisel
parent 256146a454
commit 864798b4c7
5 changed files with 68 additions and 9 deletions

View File

@@ -57,6 +57,7 @@ set(SRC
tree/tree_element_driver.cc
tree/tree_element_gpencil_layer.cc
tree/tree_element_id.cc
tree/tree_element_id_collection.cc
tree/tree_element_id_curve.cc
tree/tree_element_id_gpencil_legacy.cc
tree/tree_element_id_library.cc
@@ -83,6 +84,7 @@ set(SRC
tree/tree_element_driver.hh
tree/tree_element_gpencil_layer.hh
tree/tree_element_id.hh
tree/tree_element_id_collection.hh
tree/tree_element_id_curve.hh
tree/tree_element_id_gpencil_legacy.hh
tree/tree_element_id_library.hh

View File

@@ -557,6 +557,7 @@ static void outliner_add_id_contents(SpaceOutliner *space_outliner,
case ID_TE:
case ID_LS:
case ID_GD_LEGACY:
case ID_GR:
BLI_assert_msg(0, "ID type expected to be expanded through new tree-element design");
break;
case ID_OB: {
@@ -674,14 +675,6 @@ static void outliner_add_id_contents(SpaceOutliner *space_outliner,
}
break;
}
case ID_GR: {
/* Don't expand for instances, creates too many elements. */
if (!(te->parent && te->parent->idcode == ID_OB)) {
Collection *collection = (Collection *)id;
outliner_add_collection_recursive(space_outliner, collection, te);
}
break;
}
case ID_CV: {
Curves *curves = (Curves *)id;
if (outliner_animdata_test(curves->adt)) {

View File

@@ -20,6 +20,7 @@
#include "../outliner_intern.hh"
#include "common.hh"
#include "tree_element_id_collection.hh"
#include "tree_element_id_curve.hh"
#include "tree_element_id_gpencil_legacy.hh"
#include "tree_element_id_library.hh"
@@ -57,6 +58,8 @@ std::unique_ptr<TreeElementID> TreeElementID::createFromID(TreeElement &legacy_t
return std::make_unique<TreeElementIDLineStyle>(legacy_te, (FreestyleLineStyle &)id);
case ID_GD_LEGACY:
return std::make_unique<TreeElementIDGPLegacy>(legacy_te, (bGPdata &)id);
case ID_GR:
return std::make_unique<TreeElementIDCollection>(legacy_te, (Collection &)id);
case ID_OB:
case ID_MA:
case ID_LT:
@@ -66,7 +69,6 @@ std::unique_ptr<TreeElementID> TreeElementID::createFromID(TreeElement &legacy_t
case ID_SCR:
case ID_WO:
case ID_SPK:
case ID_GR:
case ID_NT:
case ID_BR:
case ID_PA:

View File

@@ -0,0 +1,37 @@
/* SPDX-FileCopyrightText: 2023 Blender Foundation
*
* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
* \ingroup spoutliner
*/
#include "DNA_ID.h"
#include "DNA_collection_types.h"
#include "DNA_listBase.h"
#include "../outliner_intern.hh"
#include "tree_element_id_collection.hh"
namespace blender::ed::outliner {
TreeElementIDCollection::TreeElementIDCollection(TreeElement &legacy_te, Collection &collection)
: TreeElementID(legacy_te, collection.id), collection_(collection)
{
}
bool TreeElementIDCollection::isExpandValid() const
{
return true;
}
void TreeElementIDCollection::expand(SpaceOutliner &space_outliner) const
{
/* Don't expand for instances, creates too many elements. */
if (!(legacy_te_.parent && legacy_te_.parent->idcode == ID_OB)) {
outliner_add_collection_recursive(&space_outliner, &collection_, &legacy_te_);
}
}
} // namespace blender::ed::outliner

View File

@@ -0,0 +1,25 @@
/* SPDX-FileCopyrightText: 2023 Blender Foundation
*
* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
* \ingroup spoutliner
*/
#pragma once
#include "tree_element_id.hh"
namespace blender::ed::outliner {
class TreeElementIDCollection final : public TreeElementID {
Collection &collection_;
public:
TreeElementIDCollection(TreeElement &legacy_te, Collection &collection);
void expand(SpaceOutliner &) const override;
bool isExpandValid() const override;
};
} // namespace blender::ed::outliner