Blender  V3.3
tree_display_sequencer.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
7 #include <cstring>
8 
9 #include "BLI_listbase.h"
10 #include "BLI_listbase_wrapper.hh"
11 #include "BLI_utildefines.h"
12 
13 #include "DNA_sequence_types.h"
14 #include "DNA_space_types.h"
15 
16 #include "SEQ_sequencer.h"
17 
18 #include "../outliner_intern.hh"
19 #include "tree_display.hh"
20 #include "tree_element.hh"
21 
22 namespace blender::ed::outliner {
23 
24 template<typename T> using List = ListBaseWrapper<T>;
25 
27  : AbstractTreeDisplay(space_outliner)
28 {
29 }
30 
32 {
33  ListBase tree = {nullptr};
34 
35  Editing *ed = SEQ_editing_get(source_data.scene);
36  if (ed == nullptr) {
37  return tree;
38  }
39 
40  for (Sequence *seq : List<Sequence>(ed->seqbasep)) {
41  SequenceAddOp op = need_add_seq_dup(seq);
42  if (op == SEQUENCE_DUPLICATE_NONE) {
44  }
45  else if (op == SEQUENCE_DUPLICATE_ADD) {
47  &space_outliner_, &tree, seq, nullptr, TSE_SEQUENCE_DUP, 0);
48  add_seq_dup(seq, te, 0);
49  }
50  }
51 
52  return tree;
53 }
54 
55 SequenceAddOp TreeDisplaySequencer::need_add_seq_dup(Sequence *seq) const
56 {
57  if ((!seq->strip) || (!seq->strip->stripdata)) {
59  }
60 
61  /*
62  * First check backward, if we found a duplicate
63  * sequence before this, don't need it, just return.
64  */
65  Sequence *p = seq->prev;
66  while (p) {
67  if ((!p->strip) || (!p->strip->stripdata)) {
68  p = p->prev;
69  continue;
70  }
71 
72  if (STREQ(p->strip->stripdata->name, seq->strip->stripdata->name)) {
74  }
75  p = p->prev;
76  }
77 
78  p = seq->next;
79  while (p) {
80  if ((!p->strip) || (!p->strip->stripdata)) {
81  p = p->next;
82  continue;
83  }
84 
85  if (STREQ(p->strip->stripdata->name, seq->strip->stripdata->name)) {
87  }
88  p = p->next;
89  }
90 
92 }
93 
94 void TreeDisplaySequencer::add_seq_dup(Sequence *seq, TreeElement *te, short index) const
95 {
96  Sequence *p = seq;
97  while (p) {
98  if ((!p->strip) || (!p->strip->stripdata) || (p->strip->stripdata->name[0] == '\0')) {
99  p = p->next;
100  continue;
101  }
102 
103  if (STREQ(p->strip->stripdata->name, seq->strip->stripdata->name)) {
104  outliner_add_element(&space_outliner_, &te->subtree, (void *)p, te, TSE_SEQUENCE, index);
105  }
106  p = p->next;
107  }
108 }
109 
110 } // namespace blender::ed::outliner
#define STREQ(a, b)
@ TSE_SEQUENCE_DUP
@ TSE_SEQUENCE
Base Class For Tree-Displays.
Definition: tree_display.hh:62
TreeDisplaySequencer(SpaceOutliner &space_outliner)
ListBase buildTree(const TreeSourceData &source_data) override
void * tree
TreeElement * outliner_add_element(SpaceOutliner *space_outliner, ListBase *lb, void *idv, TreeElement *parent, short type, short index, const bool expand)
ListBaseWrapper< T > List
Editing * SEQ_editing_get(const Scene *scene)
Definition: sequencer.c:241
ListBase * seqbasep
struct Sequence * prev
struct Sequence * next
char name[256]
StripElem * stripdata
ListBase subtree
The data to build the tree from.
Definition: tree_display.hh:43
Establish and manage Outliner trees for different display modes.