diff options
Diffstat (limited to 'source/blender/editors/space_outliner/tree')
5 files changed, 236 insertions, 26 deletions
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> AbstractTreeElement::createFromType(const i case TSE_RNA_ARRAY_ELEM: return std::make_unique<TreeElementRNAArrayElement>( legacy_te, *reinterpret_cast<PointerRNA *>(idv), legacy_te.index); + case TSE_SEQUENCE: + return std::make_unique<TreeElementSequence>(legacy_te, *reinterpret_cast<Sequence *>(idv)); + case TSE_SEQ_STRIP: + return std::make_unique<TreeElementSequenceStrip>(legacy_te, + *reinterpret_cast<Strip *>(idv)); + case TSE_SEQUENCE_DUP: + return std::make_unique<TreeElementSequenceStripDuplicate>( + legacy_te, *reinterpret_cast<Sequence *>(idv)); default: break; } diff --git a/source/blender/editors/space_outliner/tree/tree_element_rna.cc b/source/blender/editors/space_outliner/tree/tree_element_rna.cc index 0152f59268d..7a9f1b6f0fa 100644 --- a/source/blender/editors/space_outliner/tree/tree_element_rna.cc +++ b/source/blender/editors/space_outliner/tree/tree_element_rna.cc @@ -54,8 +54,6 @@ TreeElementRNACommon::TreeElementRNACommon(TreeElement &legacy_te, PointerRNA &r legacy_te_.name = IFACE_("(empty)"); return; } - - legacy_te_.rnaptr = rna_ptr; } bool TreeElementRNACommon::isExpandValid() const @@ -73,12 +71,24 @@ bool TreeElementRNACommon::expandPoll(const SpaceOutliner &) const return isRNAValid(); } +const PointerRNA &TreeElementRNACommon::getPointerRNA() const +{ + return rna_ptr_; +} + +PropertyRNA *TreeElementRNACommon::getPropertyRNA() const +{ + return nullptr; +} + /* -------------------------------------------------------------------- */ /* RNA Struct */ TreeElementRNAStruct::TreeElementRNAStruct(TreeElement &legacy_te, PointerRNA &rna_ptr) : TreeElementRNACommon(legacy_te, rna_ptr) { + BLI_assert(legacy_te.store_elem->type == TSE_RNA_STRUCT); + if (!isRNAValid()) { return; } @@ -95,21 +105,23 @@ TreeElementRNAStruct::TreeElementRNAStruct(TreeElement &legacy_te, PointerRNA &r void TreeElementRNAStruct::expand(SpaceOutliner &space_outliner) const { TreeStoreElem &tselem = *TREESTORE(&legacy_te_); - PointerRNA *ptr = &legacy_te_.rnaptr; + PointerRNA ptr = rna_ptr_; /* If searching don't expand RNA entries */ if (SEARCHING_OUTLINER(&space_outliner) && BLI_strcasecmp("RNA", legacy_te_.name) == 0) { tselem.flag &= ~TSE_CHILDSEARCH; } - PropertyRNA *iterprop = RNA_struct_iterator_property(ptr->type); - int tot = RNA_property_collection_length(ptr, iterprop); + PropertyRNA *iterprop = RNA_struct_iterator_property(ptr.type); + int tot = RNA_property_collection_length(&ptr, iterprop); CLAMP_MAX(tot, max_index); + TreeElementRNAProperty *parent_prop_te = legacy_te_.parent ? + tree_element_cast<TreeElementRNAProperty>( + legacy_te_.parent) : + nullptr; /* auto open these cases */ - if (!legacy_te_.parent || - (RNA_property_type(reinterpret_cast<PropertyRNA *>(legacy_te_.parent->directdata))) == - PROP_POINTER) { + if (!parent_prop_te || (RNA_property_type(parent_prop_te->getPropertyRNA()) == PROP_POINTER)) { if (!tselem.used) { tselem.flag &= ~TSE_CLOSED; } @@ -118,14 +130,10 @@ void TreeElementRNAStruct::expand(SpaceOutliner &space_outliner) const if (TSELEM_OPEN(&tselem, &space_outliner)) { for (int index = 0; index < tot; index++) { PointerRNA propptr; - RNA_property_collection_lookup_int(ptr, iterprop, index, &propptr); + RNA_property_collection_lookup_int(&ptr, iterprop, index, &propptr); if (!(RNA_property_flag(reinterpret_cast<PropertyRNA *>(propptr.data)) & PROP_HIDDEN)) { - outliner_add_element(&space_outliner, - &legacy_te_.subtree, - (void *)ptr, - &legacy_te_, - TSE_RNA_PROPERTY, - index); + outliner_add_element( + &space_outliner, &legacy_te_.subtree, &ptr, &legacy_te_, TSE_RNA_PROPERTY, index); } } } @@ -142,6 +150,8 @@ TreeElementRNAProperty::TreeElementRNAProperty(TreeElement &legacy_te, const int index) : TreeElementRNACommon(legacy_te, rna_ptr) { + BLI_assert(legacy_te.store_elem->type == TSE_RNA_PROPERTY); + if (!isRNAValid()) { return; } @@ -153,7 +163,6 @@ TreeElementRNAProperty::TreeElementRNAProperty(TreeElement &legacy_te, PropertyRNA *prop = reinterpret_cast<PropertyRNA *>(propptr.data); legacy_te_.name = RNA_property_ui_name(prop); - legacy_te_.directdata = prop; rna_prop_ = prop; } @@ -174,7 +183,7 @@ void TreeElementRNAProperty::expand(SpaceOutliner &space_outliner) const if (pptr.data) { if (TSELEM_OPEN(&tselem, &space_outliner)) { outliner_add_element( - &space_outliner, &legacy_te_.subtree, (void *)&pptr, &legacy_te_, TSE_RNA_STRUCT, -1); + &space_outliner, &legacy_te_.subtree, &pptr, &legacy_te_, TSE_RNA_STRUCT, -1); } else { legacy_te_.flag |= TE_LAZY_CLOSED; @@ -189,12 +198,8 @@ void TreeElementRNAProperty::expand(SpaceOutliner &space_outliner) const for (int index = 0; index < tot; index++) { PointerRNA pptr; RNA_property_collection_lookup_int(&rna_ptr, rna_prop_, index, &pptr); - outliner_add_element(&space_outliner, - &legacy_te_.subtree, - (void *)&pptr, - &legacy_te_, - TSE_RNA_STRUCT, - index); + outliner_add_element( + &space_outliner, &legacy_te_.subtree, &pptr, &legacy_te_, TSE_RNA_STRUCT, index); } } else if (tot) { @@ -221,6 +226,11 @@ void TreeElementRNAProperty::expand(SpaceOutliner &space_outliner) const } } +PropertyRNA *TreeElementRNAProperty::getPropertyRNA() const +{ + return rna_prop_; +} + /* -------------------------------------------------------------------- */ /* RNA Array Element */ @@ -229,11 +239,12 @@ TreeElementRNAArrayElement::TreeElementRNAArrayElement(TreeElement &legacy_te, const int index) : TreeElementRNACommon(legacy_te, rna_ptr) { - PropertyRNA *prop = reinterpret_cast<PropertyRNA *>(legacy_te_.parent->directdata); - legacy_te_.directdata = prop; + BLI_assert(legacy_te.store_elem->type == TSE_RNA_ARRAY_ELEM); + + BLI_assert(legacy_te.parent && (legacy_te.parent->store_elem->type == TSE_RNA_PROPERTY)); legacy_te_.index = index; - char c = RNA_property_array_item_char(prop, index); + char c = RNA_property_array_item_char(TreeElementRNAArrayElement::getPropertyRNA(), index); legacy_te_.name = reinterpret_cast<char *>( MEM_callocN(sizeof(char[20]), "OutlinerRNAArrayName")); @@ -246,4 +257,12 @@ TreeElementRNAArrayElement::TreeElementRNAArrayElement(TreeElement &legacy_te, legacy_te_.flag |= TE_FREE_NAME; } +PropertyRNA *TreeElementRNAArrayElement::getPropertyRNA() const +{ + /* Forward query to the parent (which is expected to be a #TreeElementRNAProperty). */ + const TreeElementRNAProperty *parent_prop_te = tree_element_cast<TreeElementRNAProperty>( + legacy_te_.parent); + return parent_prop_te ? parent_prop_te->getPropertyRNA() : nullptr; +} + } // namespace blender::ed::outliner diff --git a/source/blender/editors/space_outliner/tree/tree_element_rna.hh b/source/blender/editors/space_outliner/tree/tree_element_rna.hh index 352b8763acb..1f107ddbf88 100644 --- a/source/blender/editors/space_outliner/tree/tree_element_rna.hh +++ b/source/blender/editors/space_outliner/tree/tree_element_rna.hh @@ -43,6 +43,13 @@ class TreeElementRNACommon : public AbstractTreeElement { bool isExpandValid() const override; bool expandPoll(const SpaceOutliner &) const override; + const PointerRNA &getPointerRNA() const; + /** + * If this element represents a property or is part of a property (array element), this returns + * the property. Otherwise nullptr. + */ + virtual PropertyRNA *getPropertyRNA() const; + bool isRNAValid() const; }; @@ -63,6 +70,8 @@ class TreeElementRNAProperty : public TreeElementRNACommon { public: TreeElementRNAProperty(TreeElement &legacy_te, PointerRNA &rna_ptr, int index); void expand(SpaceOutliner &space_outliner) const override; + + PropertyRNA *getPropertyRNA() const override; }; /* -------------------------------------------------------------------- */ @@ -70,6 +79,8 @@ class TreeElementRNAProperty : public TreeElementRNACommon { class TreeElementRNAArrayElement : public TreeElementRNACommon { public: TreeElementRNAArrayElement(TreeElement &legacy_te, PointerRNA &rna_ptr, int index); + + PropertyRNA *getPropertyRNA() const override; }; } // namespace blender::ed::outliner 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..8d0b4c140c7 --- /dev/null +++ b/source/blender/editors/space_outliner/tree/tree_element_seq.cc @@ -0,0 +1,111 @@ +/* + * 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.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); + } +} + +Sequence &TreeElementSequence::getSequence() const +{ + return sequence_; +} + +/* -------------------------------------------------------------------- */ +/* 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"); + } +} + +/* -------------------------------------------------------------------- */ +/* Strip Duplicate */ + +TreeElementSequenceStripDuplicate::TreeElementSequenceStripDuplicate(TreeElement &legacy_te, + Sequence &sequence) + : AbstractTreeElement(legacy_te), sequence_(sequence) +{ + BLI_assert(legacy_te.store_elem->type == TSE_SEQUENCE_DUP); + + legacy_te_.idcode = sequence.type; + legacy_te_.name = sequence.strip->stripdata->name; +} + +Sequence &TreeElementSequenceStripDuplicate::getSequence() const +{ + return sequence_; +} + +} // 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..2b334b5b7fa --- /dev/null +++ b/source/blender/editors/space_outliner/tree/tree_element_seq.hh @@ -0,0 +1,60 @@ +/* + * 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; + + Sequence &getSequence() const; +}; + +/* -------------------------------------------------------------------- */ + +class TreeElementSequenceStrip : public AbstractTreeElement { + public: + TreeElementSequenceStrip(TreeElement &legacy_te, Strip &strip); +}; + +/* -------------------------------------------------------------------- */ + +class TreeElementSequenceStripDuplicate : public AbstractTreeElement { + Sequence &sequence_; + + public: + TreeElementSequenceStripDuplicate(TreeElement &legacy_te, Sequence &sequence); + + Sequence &getSequence() const; +}; + +} // namespace blender::ed::outliner |