diff --git a/source/blender/editors/space_outliner/CMakeLists.txt b/source/blender/editors/space_outliner/CMakeLists.txt index a091de5c26e..652272b0ea0 100644 --- a/source/blender/editors/space_outliner/CMakeLists.txt +++ b/source/blender/editors/space_outliner/CMakeLists.txt @@ -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_curve.cc tree/tree_element_id_library.cc tree/tree_element_id_mesh.cc tree/tree_element_id_scene.cc @@ -78,6 +79,7 @@ set(SRC tree/tree_element_driver.hh tree/tree_element_gpencil_layer.hh tree/tree_element_id.hh + tree/tree_element_id_curve.hh tree/tree_element_id_library.hh tree/tree_element_id_mesh.hh tree/tree_element_id_scene.hh diff --git a/source/blender/editors/space_outliner/outliner_tree.cc b/source/blender/editors/space_outliner/outliner_tree.cc index 351fc037abc..1d41b8cbfff 100644 --- a/source/blender/editors/space_outliner/outliner_tree.cc +++ b/source/blender/editors/space_outliner/outliner_tree.cc @@ -552,24 +552,13 @@ static void outliner_add_id_contents(SpaceOutliner *space_outliner, case ID_LI: case ID_SCE: case ID_ME: + case ID_CU_LEGACY: BLI_assert_msg(0, "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; } - case ID_CU_LEGACY: { - Curve *cu = (Curve *)id; - - if (outliner_animdata_test(cu->adt)) { - outliner_add_element(space_outliner, &te->subtree, cu, te, TSE_ANIM_DATA, 0); - } - - for (int a = 0; a < cu->totcol; a++) { - outliner_add_element(space_outliner, &te->subtree, cu->mat[a], te, TSE_SOME_ID, a); - } - break; - } case ID_MB: { MetaBall *mb = (MetaBall *)id; 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 8483839763d..831a7ff372e 100644 --- a/source/blender/editors/space_outliner/tree/tree_element_id.cc +++ b/source/blender/editors/space_outliner/tree/tree_element_id.cc @@ -20,6 +20,7 @@ #include "../outliner_intern.hh" #include "common.hh" +#include "tree_element_id_curve.hh" #include "tree_element_id_library.hh" #include "tree_element_id_mesh.hh" #include "tree_element_id_scene.hh" @@ -42,8 +43,9 @@ std::unique_ptr TreeElementID::createFromID(TreeElement &legacy_t return std::make_unique(legacy_te, (Scene &)id); case ID_ME: return std::make_unique(legacy_te, (Mesh &)id); - case ID_OB: case ID_CU_LEGACY: + return std::make_unique(legacy_te, (Curve &)id); + case ID_OB: case ID_MB: case ID_MA: case ID_TE: diff --git a/source/blender/editors/space_outliner/tree/tree_element_id_curve.cc b/source/blender/editors/space_outliner/tree/tree_element_id_curve.cc new file mode 100644 index 00000000000..fa57c332080 --- /dev/null +++ b/source/blender/editors/space_outliner/tree/tree_element_id_curve.cc @@ -0,0 +1,44 @@ +/* SPDX-FileCopyrightText: 2023 Blender Foundation + * + * SPDX-License-Identifier: GPL-2.0-or-later */ + +/** \file + * \ingroup spoutliner + */ + +#include "DNA_curve_types.h" +#include "DNA_listBase.h" +#include "DNA_outliner_types.h" + +#include "../outliner_intern.hh" + +#include "tree_element_id_curve.hh" + +namespace blender::ed::outliner { + +TreeElementIDCurve::TreeElementIDCurve(TreeElement &legacy_te, Curve &curve) + : TreeElementID(legacy_te, curve.id), curve_(curve) +{ +} + +bool TreeElementIDCurve::isExpandValid() const +{ + return true; +} + +void TreeElementIDCurve::expand(SpaceOutliner &space_outliner) const +{ + expand_animation_data(space_outliner, curve_.adt); + + expandMaterials(space_outliner); +} + +void TreeElementIDCurve::expandMaterials(SpaceOutliner &space_outliner) const +{ + for (int a = 0; a < curve_.totcol; a++) { + outliner_add_element( + &space_outliner, &legacy_te_.subtree, curve_.mat[a], &legacy_te_, TSE_SOME_ID, a); + } +} + +} // namespace blender::ed::outliner diff --git a/source/blender/editors/space_outliner/tree/tree_element_id_curve.hh b/source/blender/editors/space_outliner/tree/tree_element_id_curve.hh new file mode 100644 index 00000000000..0d580b17987 --- /dev/null +++ b/source/blender/editors/space_outliner/tree/tree_element_id_curve.hh @@ -0,0 +1,28 @@ +/* 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 TreeElementIDCurve final : public TreeElementID { + Curve &curve_; + + public: + TreeElementIDCurve(TreeElement &legacy_te, Curve &curve); + + void expand(SpaceOutliner &) const override; + bool isExpandValid() const override; + + private: + void expandMaterials(SpaceOutliner &) const; +}; + +} // namespace blender::ed::outliner