Cleanup: Split up new files for Outliner ID tree-elements

Splits up `tree_element_id.cc`/`tree_element_id.hh`.
If we move all ID types into this one file, it will become rather big. Smaller
files are probably easier to work with. We could still keep small classes like
`TreeElementIDLibrary` in the general file, don't mind really, but this creates
separate files for that too.
This commit is contained in:
Julian Eisel 2021-03-08 18:34:53 +01:00
parent f0ad78e17c
commit fc0de69471
7 changed files with 199 additions and 84 deletions

View File

@ -60,6 +60,8 @@ set(SRC
tree/tree_element_driver.cc
tree/tree_element_gpencil_layer.cc
tree/tree_element_id.cc
tree/tree_element_id_library.cc
tree/tree_element_id_scene.cc
tree/tree_element_nla.cc
tree/tree_element_scene_objects.cc
tree/tree_element_view_layer.cc
@ -74,6 +76,8 @@ set(SRC
tree/tree_element_driver.hh
tree/tree_element_gpencil_layer.hh
tree/tree_element_id.hh
tree/tree_element_id_library.hh
tree/tree_element_id_scene.hh
tree/tree_element_nla.hh
tree/tree_element_scene_objects.hh
tree/tree_element_view_layer.hh

View File

@ -31,6 +31,8 @@
#include "../outliner_intern.h"
#include "tree_display.h"
#include "tree_element_id_library.hh"
#include "tree_element_id_scene.hh"
#include "tree_element_id.hh"
@ -162,65 +164,4 @@ void TreeElementID::expand_animation_data(SpaceOutliner &space_outliner,
}
}
/* -------------------------------------------------------------------- */
/* 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
{
outliner_add_element(
&space_outliner, &legacy_te_.subtree, &scene_, &legacy_te_, TSE_SCENE_OBJECTS_BASE, 0);
}
} // namespace blender::ed::outliner

View File

@ -16,6 +16,8 @@
/** \file
* \ingroup spoutliner
*
* Tree element classes for the tree elements directly representing an ID (#TSE_SOME_ID).
*/
#pragma once
@ -53,27 +55,4 @@ class TreeElementID : public AbstractTreeElement {
void expand_library_overrides(SpaceOutliner &) const;
};
class TreeElementIDLibrary final : public TreeElementID {
public:
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

View File

@ -0,0 +1,40 @@
/*
* 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 "../outliner_intern.h"
#include "tree_element_id_library.hh"
namespace blender::ed::outliner {
TreeElementIDLibrary::TreeElementIDLibrary(TreeElement &legacy_te, Library &library)
: TreeElementID(legacy_te, library.id)
{
legacy_te.name = library.filepath;
}
bool TreeElementIDLibrary::isExpandValid() const
{
return true;
}
} // namespace blender::ed::outliner

View File

@ -0,0 +1,34 @@
/*
* 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_id.hh"
namespace blender::ed::outliner {
class TreeElementIDLibrary final : public TreeElementID {
public:
TreeElementIDLibrary(TreeElement &legacy_te, Library &library);
bool isExpandValid() const override;
};
} // namespace blender::ed::outliner

View File

@ -0,0 +1,74 @@
/*
* 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 "../outliner_intern.h"
#include "tree_display.h"
#include "tree_element_id_scene.hh"
namespace blender::ed::outliner {
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
{
outliner_add_element(
&space_outliner, &legacy_te_.subtree, &scene_, &legacy_te_, TSE_SCENE_OBJECTS_BASE, 0);
}
} // namespace blender::ed::outliner

View File

@ -0,0 +1,43 @@
/*
* 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_id.hh"
namespace blender::ed::outliner {
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