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:
authorJulian Eisel <julian@blender.org>2021-03-05 20:01:31 +0300
committerJulian Eisel <julian@blender.org>2021-03-05 20:07:35 +0300
commit3a907e742507dde9b26eb5f531c18ad00b0e2ab6 (patch)
tree032dc8633d90171785cb1446e49cd626404649ed /source/blender/editors/space_outliner/tree
parentae005393dce4746c0ee97887ea1a81281a1f726f (diff)
Outliner: Barebones to port IDs to new Outliner tree-element code design
Continuation of work in 2e221de4ceee and 249e4df110e0 . This prepares things so we can start porting the individual ID types to the new code design. I already added some code for library IDs, because they need some special handling during construction, which I didn't want to break. The `AbstractTreeElement::isExpandValid()` check can be removed once types were ported and can be assumed to have a proper `expand()` implemenation. Also makes `TreeElementGPencilLayer` `final` which I forgot in e0442a955bad.
Diffstat (limited to 'source/blender/editors/space_outliner/tree')
-rw-r--r--source/blender/editors/space_outliner/tree/tree_element.cc9
-rw-r--r--source/blender/editors/space_outliner/tree/tree_element.h1
-rw-r--r--source/blender/editors/space_outliner/tree/tree_element.hh9
-rw-r--r--source/blender/editors/space_outliner/tree/tree_element_gpencil_layer.hh2
-rw-r--r--source/blender/editors/space_outliner/tree/tree_element_id.cc100
-rw-r--r--source/blender/editors/space_outliner/tree/tree_element_id.hh48
6 files changed, 168 insertions, 1 deletions
diff --git a/source/blender/editors/space_outliner/tree/tree_element.cc b/source/blender/editors/space_outliner/tree/tree_element.cc
index a692aae37c3..79c2831475f 100644
--- a/source/blender/editors/space_outliner/tree/tree_element.cc
+++ b/source/blender/editors/space_outliner/tree/tree_element.cc
@@ -23,6 +23,7 @@
#include "tree_element_anim_data.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.h"
@@ -37,6 +38,8 @@ static AbstractTreeElement *tree_element_create(int type, TreeElement &legacy_te
ID &id = *static_cast<ID *>(idv);
switch (type) {
+ case TSE_SOME_ID:
+ return TreeElementID::createFromID(legacy_te, id);
case TSE_ANIM_DATA:
return new TreeElementAnimData(legacy_te, id);
case TSE_DRIVER_BASE:
@@ -82,6 +85,12 @@ void outliner_tree_element_type_expand(TreeElementType *type, SpaceOutliner *spa
outliner::tree_element_expand(reinterpret_cast<outliner::AbstractTreeElement &>(*type),
*space_outliner);
}
+bool outliner_tree_element_type_is_expand_valid(TreeElementType *type)
+{
+ outliner::AbstractTreeElement &element = reinterpret_cast<outliner::AbstractTreeElement &>(
+ *type);
+ return element.isExpandValid();
+}
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 d88c37180b3..c3dec1bf68a 100644
--- a/source/blender/editors/space_outliner/tree/tree_element.h
+++ b/source/blender/editors/space_outliner/tree/tree_element.h
@@ -39,6 +39,7 @@ TreeElementType *outliner_tree_element_type_create(int type, TreeElement *legacy
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);
#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 8a1ebb51eae..3e61dd25898 100644
--- a/source/blender/editors/space_outliner/tree/tree_element.hh
+++ b/source/blender/editors/space_outliner/tree/tree_element.hh
@@ -48,6 +48,15 @@ class AbstractTreeElement {
virtual void expand(SpaceOutliner &) const
{
}
+
+ /**
+ * Just while transitioning to the new tree-element design: Some types are only partially ported,
+ * and the expanding isn't done yet.
+ */
+ virtual bool isExpandValid() const
+ {
+ return true;
+ }
};
} // namespace blender::ed::outliner
diff --git a/source/blender/editors/space_outliner/tree/tree_element_gpencil_layer.hh b/source/blender/editors/space_outliner/tree/tree_element_gpencil_layer.hh
index dd18dd42344..da57ef63f1f 100644
--- a/source/blender/editors/space_outliner/tree/tree_element_gpencil_layer.hh
+++ b/source/blender/editors/space_outliner/tree/tree_element_gpencil_layer.hh
@@ -26,7 +26,7 @@ struct bGPDlayer;
namespace blender::ed::outliner {
-class TreeElementGPencilLayer : public AbstractTreeElement {
+class TreeElementGPencilLayer final : public AbstractTreeElement {
public:
TreeElementGPencilLayer(TreeElement &legacy_te, bGPDlayer &gplayer);
};
diff --git a/source/blender/editors/space_outliner/tree/tree_element_id.cc b/source/blender/editors/space_outliner/tree/tree_element_id.cc
new file mode 100644
index 00000000000..26787475635
--- /dev/null
+++ b/source/blender/editors/space_outliner/tree/tree_element_id.cc
@@ -0,0 +1,100 @@
+/*
+ * 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_ID.h"
+
+#include "BLI_utildefines.h"
+
+#include "../outliner_intern.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)
+{
+ switch (ID_Type type = GS(id.name); type) {
+ case ID_LI:
+ return new TreeElementIDLibrary(legacy_te, id);
+ case ID_SCE:
+ case ID_OB:
+ case ID_ME:
+ case ID_CU:
+ case ID_MB:
+ case ID_MA:
+ case ID_TE:
+ case ID_LT:
+ case ID_LA:
+ case ID_CA:
+ case ID_KE:
+ case ID_SCR:
+ case ID_WO:
+ case ID_SPK:
+ case ID_GR:
+ case ID_NT:
+ case ID_BR:
+ case ID_PA:
+ case ID_MC:
+ case ID_MSK:
+ case ID_LS:
+ case ID_LP:
+ case ID_GD:
+ case ID_WS:
+ case ID_HA:
+ case ID_PT:
+ case ID_VO:
+ case ID_SIM:
+ case ID_WM:
+ case ID_IM:
+ case ID_VF:
+ case ID_TXT:
+ case ID_SO:
+ case ID_AR:
+ case ID_AC:
+ case ID_PAL:
+ case ID_PC:
+ case ID_CF:
+ return new TreeElementID(legacy_te, id);
+ /* Deprecated */
+ case ID_IP:
+ BLI_assert(!"Outliner trying to build tree-element for deprecated ID type");
+ return nullptr;
+ }
+
+ return nullptr;
+}
+
+TreeElementIDLibrary::TreeElementIDLibrary(TreeElement &legacy_te, const ID &id)
+ : TreeElementID(legacy_te, id)
+{
+ legacy_te.name = ((Library &)id).filepath;
+}
+
+} // 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
new file mode 100644
index 00000000000..d1e672ed387
--- /dev/null
+++ b/source/blender/editors/space_outliner/tree/tree_element_id.hh
@@ -0,0 +1,48 @@
+/*
+ * 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 TreeElementID : public AbstractTreeElement {
+ public:
+ TreeElementID(TreeElement &legacy_te, const ID &id);
+
+ static TreeElementID *createFromID(TreeElement &legacy_te, const ID &id);
+
+ /**
+ * Expanding not implemented for all types yet. Once it is, this can be set to true or
+ * `AbstractTreeElement::expandValid()` can be removed alltogether.
+ */
+ bool isExpandValid() const override
+ {
+ return false;
+ }
+};
+
+class TreeElementIDLibrary final : public TreeElementID {
+ public:
+ TreeElementIDLibrary(TreeElement &legacy_te, const ID &id);
+};
+
+} // namespace blender::ed::outliner