diff options
author | Julian Eisel <julian@blender.org> | 2022-01-26 18:24:59 +0300 |
---|---|---|
committer | Julian Eisel <julian@blender.org> | 2022-01-26 21:15:57 +0300 |
commit | fc0dd5583c3132cde4208bc8944469a92a601c62 (patch) | |
tree | 849b47b95ea7bd550412bf76ee7763c438813523 /source/blender/editors/space_outliner | |
parent | 08e2885796f79a34cfa7233945d194d382b47d23 (diff) |
Cleanup: Reduce `void *` reliance of new sequencer C++ Outliner elements
Plan is to remove things like `TreeElement.directdata` and to instead
expose specific queries in the new type specific tree-element classes.
e.g. like here: `TreeElementSequence.getSequence()`
For now uses `tree_element_cast<>()` to get the new type specific
tree-element, later these should replace `TreeElement` all together.
Diffstat (limited to 'source/blender/editors/space_outliner')
5 files changed, 33 insertions, 9 deletions
diff --git a/source/blender/editors/space_outliner/outliner_intern.hh b/source/blender/editors/space_outliner/outliner_intern.hh index 0538cd3a4ae..5eb8b955dc5 100644 --- a/source/blender/editors/space_outliner/outliner_intern.hh +++ b/source/blender/editors/space_outliner/outliner_intern.hh @@ -107,7 +107,7 @@ typedef struct TreeElement { short idcode; /* From TreeStore id. */ short xend; /* Width of item display, for select. */ const char *name; - void *directdata; /* Armature Bones, Base, Sequence, Strip... */ + void *directdata; /* Armature Bones, Base, ... */ PointerRNA rnaptr; /* RNA Pointer. */ } TreeElement; diff --git a/source/blender/editors/space_outliner/outliner_select.cc b/source/blender/editors/space_outliner/outliner_select.cc index c2a7bfb9b37..3ff8b9e973f 100644 --- a/source/blender/editors/space_outliner/outliner_select.cc +++ b/source/blender/editors/space_outliner/outliner_select.cc @@ -80,6 +80,9 @@ #include "RNA_define.h" #include "outliner_intern.hh" +#include "tree/tree_element_seq.hh" + +using namespace blender::ed::outliner; /** * \note changes to selection are by convention and not essential. @@ -676,7 +679,8 @@ static void tree_element_sequence_activate(bContext *C, TreeElement *te, const eOLSetState set) { - Sequence *seq = (Sequence *)te->directdata; + const TreeElementSequence *te_seq = tree_element_cast<TreeElementSequence>(te); + Sequence *seq = &te_seq->getSequence(); Editing *ed = SEQ_editing_get(scene); if (BLI_findindex(ed->seqbasep, seq) != -1) { @@ -954,7 +958,8 @@ static eOLDrawState tree_element_posegroup_state_get(const ViewLayer *view_layer static eOLDrawState tree_element_sequence_state_get(const Scene *scene, const TreeElement *te) { - const Sequence *seq = (const Sequence *)te->directdata; + const TreeElementSequence *te_seq = tree_element_cast<TreeElementSequence>(te); + const Sequence *seq = &te_seq->getSequence(); const Editing *ed = scene->ed; if (ed && ed->act_seq == seq && seq->flag & SELECT) { @@ -965,7 +970,9 @@ static eOLDrawState tree_element_sequence_state_get(const Scene *scene, const Tr static eOLDrawState tree_element_sequence_dup_state_get(const TreeElement *te) { - const Sequence *seq = (const Sequence *)te->directdata; + const TreeElementSequenceStripDuplicate *te_dup = + tree_element_cast<TreeElementSequenceStripDuplicate>(te); + const Sequence *seq = &te_dup->getSequence(); if (seq->flag & SELECT) { return OL_DRAWSEL_NORMAL; } diff --git a/source/blender/editors/space_outliner/outliner_tools.cc b/source/blender/editors/space_outliner/outliner_tools.cc index 1c1a4f6f4c2..eae77d70ac2 100644 --- a/source/blender/editors/space_outliner/outliner_tools.cc +++ b/source/blender/editors/space_outliner/outliner_tools.cc @@ -96,9 +96,12 @@ #include "SEQ_sequencer.h" #include "outliner_intern.hh" +#include "tree/tree_element_seq.hh" static CLG_LogRef LOG = {"ed.outliner.tools"}; +using namespace blender::ed::outliner; + /* -------------------------------------------------------------------- */ /** \name ID/Library/Data Set/Un-link Utilities * \{ */ @@ -1285,7 +1288,8 @@ static void ebone_fn(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem), static void sequence_fn(int event, TreeElement *te, TreeStoreElem *UNUSED(tselem), void *scene_ptr) { - Sequence *seq = (Sequence *)te->directdata; + TreeElementSequence *te_seq = tree_element_cast<TreeElementSequence>(te); + Sequence *seq = &te_seq->getSequence(); Scene *scene = (Scene *)scene_ptr; Editing *ed = SEQ_editing_get(scene); if (BLI_findindex(ed->seqbasep, seq) != -1) { diff --git a/source/blender/editors/space_outliner/tree/tree_element_seq.cc b/source/blender/editors/space_outliner/tree/tree_element_seq.cc index 33ab51e7fff..8d0b4c140c7 100644 --- a/source/blender/editors/space_outliner/tree/tree_element_seq.cc +++ b/source/blender/editors/space_outliner/tree/tree_element_seq.cc @@ -41,7 +41,6 @@ TreeElementSequence::TreeElementSequence(TreeElement &legacy_te, Sequence &seque * so this is "safe". */ legacy_te.idcode = sequence_.type; - legacy_te.directdata = &sequence_; legacy_te.name = sequence_.name + 2; } @@ -70,6 +69,11 @@ void TreeElementSequence::expand(SpaceOutliner &space_outliner) const } } +Sequence &TreeElementSequence::getSequence() const +{ + return sequence_; +} + /* -------------------------------------------------------------------- */ /* Strip */ @@ -84,7 +88,6 @@ TreeElementSequenceStrip::TreeElementSequenceStrip(TreeElement &legacy_te, Strip else { legacy_te_.name = IFACE_("Strip None"); } - legacy_te_.directdata = &strip; } /* -------------------------------------------------------------------- */ @@ -92,13 +95,17 @@ TreeElementSequenceStrip::TreeElementSequenceStrip(TreeElement &legacy_te, Strip TreeElementSequenceStripDuplicate::TreeElementSequenceStripDuplicate(TreeElement &legacy_te, Sequence &sequence) - : AbstractTreeElement(legacy_te) + : AbstractTreeElement(legacy_te), sequence_(sequence) { 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; } +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 index 72f13750538..2b334b5b7fa 100644 --- a/source/blender/editors/space_outliner/tree/tree_element_seq.hh +++ b/source/blender/editors/space_outliner/tree/tree_element_seq.hh @@ -35,6 +35,8 @@ class TreeElementSequence : public AbstractTreeElement { bool expandPoll(const SpaceOutliner &) const override; void expand(SpaceOutliner &) const override; + + Sequence &getSequence() const; }; /* -------------------------------------------------------------------- */ @@ -47,8 +49,12 @@ class TreeElementSequenceStrip : public AbstractTreeElement { /* -------------------------------------------------------------------- */ class TreeElementSequenceStripDuplicate : public AbstractTreeElement { + Sequence &sequence_; + public: TreeElementSequenceStripDuplicate(TreeElement &legacy_te, Sequence &sequence); + + Sequence &getSequence() const; }; } // namespace blender::ed::outliner |