From da1b6c4c02d5390df08f710d01b9d7628478d089 Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Wed, 26 Jan 2022 14:59:22 +0100 Subject: Outliner: Port sequencer elements to new tree-element design Continuation of work started in 2e221de4ceee and 249e4df110e0. Adds new tree-element classes for sequences, strips and strip duplicates. --- .../blender/editors/space_outliner/CMakeLists.txt | 2 + .../editors/space_outliner/outliner_tree.cc | 53 +---------- .../editors/space_outliner/tree/tree_element.cc | 9 ++ .../space_outliner/tree/tree_element_seq.cc | 104 +++++++++++++++++++++ .../space_outliner/tree/tree_element_seq.hh | 54 +++++++++++ 5 files changed, 173 insertions(+), 49 deletions(-) create mode 100644 source/blender/editors/space_outliner/tree/tree_element_seq.cc create mode 100644 source/blender/editors/space_outliner/tree/tree_element_seq.hh (limited to 'source/blender/editors/space_outliner') diff --git a/source/blender/editors/space_outliner/CMakeLists.txt b/source/blender/editors/space_outliner/CMakeLists.txt index 60b881fb32b..bc6db978a4f 100644 --- a/source/blender/editors/space_outliner/CMakeLists.txt +++ b/source/blender/editors/space_outliner/CMakeLists.txt @@ -67,6 +67,7 @@ set(SRC tree/tree_element_overrides.cc tree/tree_element_rna.cc tree/tree_element_scene_objects.cc + tree/tree_element_seq.cc tree/tree_element_view_layer.cc outliner_intern.hh @@ -84,6 +85,7 @@ set(SRC tree/tree_element_overrides.hh tree/tree_element_rna.hh tree/tree_element_scene_objects.hh + tree/tree_element_seq.hh tree/tree_element_view_layer.hh ) diff --git a/source/blender/editors/space_outliner/outliner_tree.cc b/source/blender/editors/space_outliner/outliner_tree.cc index 8ad40b503bd..eb885eba20d 100644 --- a/source/blender/editors/space_outliner/outliner_tree.cc +++ b/source/blender/editors/space_outliner/outliner_tree.cc @@ -928,57 +928,12 @@ TreeElement *outliner_add_element(SpaceOutliner *space_outliner, TSE_GP_LAYER, TSE_RNA_STRUCT, TSE_RNA_PROPERTY, - TSE_RNA_ARRAY_ELEM)) { + TSE_RNA_ARRAY_ELEM, + TSE_SEQUENCE, + TSE_SEQ_STRIP, + TSE_SEQUENCE_DUP)) { BLI_assert_msg(false, "Element type should already use new AbstractTreeElement design"); } - else if (type == TSE_SEQUENCE) { - Sequence *seq = (Sequence *)idv; - - /* - * The idcode is a little hack, but the outliner - * only check te->idcode if te->type is equal to zero, - * so this is "safe". - */ - te->idcode = seq->type; - te->directdata = seq; - te->name = seq->name + 2; - - if (!(seq->type & SEQ_TYPE_EFFECT)) { - /* - * This work like the sequence. - * If the sequence have a name (not default name) - * show it, in other case put the filename. - */ - - if (seq->type == SEQ_TYPE_META) { - LISTBASE_FOREACH (Sequence *, p, &seq->seqbase) { - outliner_add_element(space_outliner, &te->subtree, (void *)p, te, TSE_SEQUENCE, index); - } - } - else { - outliner_add_element( - space_outliner, &te->subtree, (void *)seq->strip, te, TSE_SEQ_STRIP, index); - } - } - } - else if (type == TSE_SEQ_STRIP) { - Strip *strip = (Strip *)idv; - - if (strip->dir[0] != '\0') { - te->name = strip->dir; - } - else { - te->name = IFACE_("Strip None"); - } - te->directdata = strip; - } - else if (type == TSE_SEQUENCE_DUP) { - Sequence *seq = (Sequence *)idv; - - te->idcode = seq->type; - te->directdata = seq; - te->name = seq->strip->stripdata->name; - } if (tree_element_warnings_get(te, nullptr, nullptr)) { te->flag |= TE_HAS_WARNING; diff --git a/source/blender/editors/space_outliner/tree/tree_element.cc b/source/blender/editors/space_outliner/tree/tree_element.cc index bed28e59f0b..5685d8964f5 100644 --- a/source/blender/editors/space_outliner/tree/tree_element.cc +++ b/source/blender/editors/space_outliner/tree/tree_element.cc @@ -35,6 +35,7 @@ #include "tree_element_overrides.hh" #include "tree_element_rna.hh" #include "tree_element_scene_objects.hh" +#include "tree_element_seq.hh" #include "tree_element_view_layer.hh" #include "../outliner_intern.hh" @@ -96,6 +97,14 @@ std::unique_ptr AbstractTreeElement::createFromType(const i case TSE_RNA_ARRAY_ELEM: return std::make_unique( legacy_te, *reinterpret_cast(idv), legacy_te.index); + case TSE_SEQUENCE: + return std::make_unique(legacy_te, *reinterpret_cast(idv)); + case TSE_SEQ_STRIP: + return std::make_unique(legacy_te, + *reinterpret_cast(idv)); + case TSE_SEQUENCE_DUP: + return std::make_unique( + legacy_te, *reinterpret_cast(idv)); default: break; } diff --git a/source/blender/editors/space_outliner/tree/tree_element_seq.cc b/source/blender/editors/space_outliner/tree/tree_element_seq.cc new file mode 100644 index 00000000000..33ab51e7fff --- /dev/null +++ b/source/blender/editors/space_outliner/tree/tree_element_seq.cc @@ -0,0 +1,104 @@ +/* + * 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_outliner_types.h" +#include "DNA_sequence_types.h" + +#include "BLI_listbase.h" + +#include "BLT_translation.h" + +#include "../outliner_intern.hh" +#include "tree_element_seq.hh" + +namespace blender::ed::outliner { + +TreeElementSequence::TreeElementSequence(TreeElement &legacy_te, Sequence &sequence) + : AbstractTreeElement(legacy_te), sequence_(sequence) +{ + BLI_assert(legacy_te.store_elem->type == TSE_SEQUENCE); + + /* + * The idcode is a little hack, but the outliner + * only check te->idcode if te->type is equal to zero, + * so this is "safe". + */ + legacy_te.idcode = sequence_.type; + legacy_te.directdata = &sequence_; + legacy_te.name = sequence_.name + 2; +} + +bool TreeElementSequence::expandPoll(const SpaceOutliner & /*space_outliner*/) const +{ + return !(sequence_.type & SEQ_TYPE_EFFECT); +} + +void TreeElementSequence::expand(SpaceOutliner &space_outliner) const +{ + /* + * This work like the sequence. + * If the sequence have a name (not default name) + * show it, in other case put the filename. + */ + + if (sequence_.type == SEQ_TYPE_META) { + LISTBASE_FOREACH (Sequence *, child, &sequence_.seqbase) { + outliner_add_element( + &space_outliner, &legacy_te_.subtree, child, &legacy_te_, TSE_SEQUENCE, 0); + } + } + else { + outliner_add_element( + &space_outliner, &legacy_te_.subtree, sequence_.strip, &legacy_te_, TSE_SEQ_STRIP, 0); + } +} + +/* -------------------------------------------------------------------- */ +/* Strip */ + +TreeElementSequenceStrip::TreeElementSequenceStrip(TreeElement &legacy_te, Strip &strip) + : AbstractTreeElement(legacy_te) +{ + BLI_assert(legacy_te.store_elem->type == TSE_SEQ_STRIP); + + if (strip.dir[0] != '\0') { + legacy_te_.name = strip.dir; + } + else { + legacy_te_.name = IFACE_("Strip None"); + } + legacy_te_.directdata = &strip; +} + +/* -------------------------------------------------------------------- */ +/* Strip Duplicate */ + +TreeElementSequenceStripDuplicate::TreeElementSequenceStripDuplicate(TreeElement &legacy_te, + Sequence &sequence) + : AbstractTreeElement(legacy_te) +{ + BLI_assert(legacy_te.store_elem->type == TSE_SEQUENCE_DUP); + + legacy_te_.idcode = sequence.type; + legacy_te_.directdata = &sequence; + legacy_te_.name = sequence.strip->stripdata->name; +} + +} // namespace blender::ed::outliner diff --git a/source/blender/editors/space_outliner/tree/tree_element_seq.hh b/source/blender/editors/space_outliner/tree/tree_element_seq.hh new file mode 100644 index 00000000000..72f13750538 --- /dev/null +++ b/source/blender/editors/space_outliner/tree/tree_element_seq.hh @@ -0,0 +1,54 @@ +/* + * 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" + +struct Sequence; +struct Strip; + +namespace blender::ed::outliner { + +class TreeElementSequence : public AbstractTreeElement { + Sequence &sequence_; + + public: + TreeElementSequence(TreeElement &legacy_te, Sequence &sequence); + + bool expandPoll(const SpaceOutliner &) const override; + void expand(SpaceOutliner &) const override; +}; + +/* -------------------------------------------------------------------- */ + +class TreeElementSequenceStrip : public AbstractTreeElement { + public: + TreeElementSequenceStrip(TreeElement &legacy_te, Strip &strip); +}; + +/* -------------------------------------------------------------------- */ + +class TreeElementSequenceStripDuplicate : public AbstractTreeElement { + public: + TreeElementSequenceStripDuplicate(TreeElement &legacy_te, Sequence &sequence); +}; + +} // namespace blender::ed::outliner -- cgit v1.2.3