Blender  V2.93
tree_display_sequencer.cc
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 
21 #include <cstring>
22 
23 #include "BLI_listbase.h"
24 #include "BLI_listbase_wrapper.hh"
25 #include "BLI_utildefines.h"
26 
27 #include "SEQ_sequencer.h"
28 
29 #include "../outliner_intern.h"
30 #include "tree_display.hh"
31 
32 namespace blender::ed::outliner {
33 
34 /* Convenience/readability. */
35 template<typename T> using List = ListBaseWrapper<T>;
36 
38  : AbstractTreeDisplay(space_outliner)
39 {
40 }
41 
43 {
44  ListBase tree = {nullptr};
45 
46  Editing *ed = SEQ_editing_get(source_data.scene, false);
47  if (ed == nullptr) {
48  return tree;
49  }
50 
51  for (Sequence *seq : List<Sequence>(ed->seqbasep)) {
52  SequenceAddOp op = need_add_seq_dup(seq);
53  if (op == SEQUENCE_DUPLICATE_NONE) {
55  }
56  else if (op == SEQUENCE_DUPLICATE_ADD) {
58  &space_outliner_, &tree, seq, nullptr, TSE_SEQUENCE_DUP, 0);
59  add_seq_dup(seq, te, 0);
60  }
61  }
62 
63  return tree;
64 }
65 
66 /* Helped function to put duplicate sequence in the same tree. */
67 SequenceAddOp TreeDisplaySequencer::need_add_seq_dup(Sequence *seq) const
68 {
69  if ((!seq->strip) || (!seq->strip->stripdata)) {
71  }
72 
73  /*
74  * First check backward, if we found a duplicate
75  * sequence before this, don't need it, just return.
76  */
77  Sequence *p = seq->prev;
78  while (p) {
79  if ((!p->strip) || (!p->strip->stripdata)) {
80  p = p->prev;
81  continue;
82  }
83 
84  if (STREQ(p->strip->stripdata->name, seq->strip->stripdata->name)) {
86  }
87  p = p->prev;
88  }
89 
90  p = seq->next;
91  while (p) {
92  if ((!p->strip) || (!p->strip->stripdata)) {
93  p = p->next;
94  continue;
95  }
96 
97  if (STREQ(p->strip->stripdata->name, seq->strip->stripdata->name)) {
99  }
100  p = p->next;
101  }
102 
104 }
105 
106 void TreeDisplaySequencer::add_seq_dup(Sequence *seq, TreeElement *te, short index) const
107 {
108  Sequence *p = seq;
109  while (p) {
110  if ((!p->strip) || (!p->strip->stripdata) || (p->strip->stripdata->name[0] == '\0')) {
111  p = p->next;
112  continue;
113  }
114 
115  if (STREQ(p->strip->stripdata->name, seq->strip->stripdata->name)) {
116  outliner_add_element(&space_outliner_, &te->subtree, (void *)p, te, TSE_SEQUENCE, index);
117  }
118  p = p->next;
119  }
120 }
121 
122 } // namespace blender::ed::outliner
#define STREQ(a, b)
@ TSE_SEQUENCE_DUP
@ TSE_SEQUENCE
Base Class For Tree-Displays.
Definition: tree_display.hh:55
TreeDisplaySequencer(SpaceOutliner &space_outliner)
ListBase buildTree(const TreeSourceData &source_data) override
void * tree
ListBaseWrapper< T > List
TreeElement * outliner_add_element(SpaceOutliner *space_outliner, ListBase *lb, void *idv, TreeElement *parent, short type, short index)
Editing * SEQ_editing_get(Scene *scene, bool alloc)
Definition: sequencer.c:232
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.h:39
struct Scene * scene
Definition: tree_display.h:41
Establish and manage Outliner trees for different display modes.