diff options
author | Julian Eisel <julian@blender.org> | 2021-03-05 20:01:31 +0300 |
---|---|---|
committer | Julian Eisel <julian@blender.org> | 2021-03-05 20:07:35 +0300 |
commit | 3a907e742507dde9b26eb5f531c18ad00b0e2ab6 (patch) | |
tree | 032dc8633d90171785cb1446e49cd626404649ed /source/blender/editors/space_outliner/tree/tree_element_id.cc | |
parent | ae005393dce4746c0ee97887ea1a81281a1f726f (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/tree_element_id.cc')
-rw-r--r-- | source/blender/editors/space_outliner/tree/tree_element_id.cc | 100 |
1 files changed, 100 insertions, 0 deletions
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 |