Blender V4.5
tree_display_sequencer.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include <cstring>
10
12#include "BLI_utildefines.h"
13
14#include "DNA_sequence_types.h"
15#include "DNA_space_types.h"
16
17#include "SEQ_sequencer.hh"
18
19#include "../outliner_intern.hh"
20#include "tree_display.hh"
21
22namespace blender::ed::outliner {
23
24template<typename T> using List = ListBaseWrapper<T>;
25
30
32{
33 ListBase tree = {nullptr};
34
36 if (ed == nullptr) {
37 return tree;
38 }
39
40 for (Strip *strip : List<Strip>(ed->seqbasep)) {
41 StripAddOp op = need_add_strip_dup(strip);
42 if (op == StripAddOp::None) {
43 add_element(&tree, nullptr, strip, nullptr, TSE_STRIP, 0);
44 }
45 else if (op == StripAddOp::Add) {
46 TreeElement *te = add_element(&tree, nullptr, strip, nullptr, TSE_STRIP_DUP, 0);
47 add_strip_dup(strip, te, 0);
48 }
49 }
50
51 return tree;
52}
53
54StripAddOp TreeDisplaySequencer::need_add_strip_dup(Strip *strip) const
55{
56 if ((!strip->data) || (!strip->data->stripdata)) {
57 return StripAddOp::None;
58 }
59
60 /*
61 * First check backward, if we found a duplicate
62 * sequence before this, don't need it, just return.
63 */
64 Strip *p = strip->prev;
65 while (p) {
66 if ((!p->data) || (!p->data->stripdata)) {
67 p = p->prev;
68 continue;
69 }
70
71 if (STREQ(p->data->stripdata->filename, strip->data->stripdata->filename)) {
72 return StripAddOp::Noop;
73 }
74 p = p->prev;
75 }
76
77 p = strip->next;
78 while (p) {
79 if ((!p->data) || (!p->data->stripdata)) {
80 p = p->next;
81 continue;
82 }
83
84 if (STREQ(p->data->stripdata->filename, strip->data->stripdata->filename)) {
85 return StripAddOp::Add;
86 }
87 p = p->next;
88 }
89
90 return StripAddOp::None;
91}
92
93void TreeDisplaySequencer::add_strip_dup(Strip *strip, TreeElement *te, short index)
94{
95 Strip *p = strip;
96 while (p) {
97 if ((!p->data) || (!p->data->stripdata) || (p->data->stripdata->filename[0] == '\0')) {
98 p = p->next;
99 continue;
100 }
101
102 if (STREQ(p->data->stripdata->filename, strip->data->stripdata->filename)) {
103 add_element(&te->subtree, nullptr, (void *)p, te, TSE_STRIP, index);
104 }
105 p = p->next;
106 }
107}
108
109} // namespace blender::ed::outliner
#define STREQ(a, b)
@ TSE_STRIP_DUP
@ TSE_STRIP
struct Strip Strip
AbstractTreeDisplay(SpaceOutliner &space_outliner)
static TreeElement * add_element(SpaceOutliner *space_outliner, ListBase *lb, ID *owner_id, void *create_data, TreeElement *parent, short type, short index, const bool expand=true)
ListBase build_tree(const TreeSourceData &source_data) override
TreeDisplaySequencer(SpaceOutliner &space_outliner)
GPU_SHADER_INTERFACE_INFO(depth_2d_update_iface).smooth(Type fragColor push_constant(Type::float2_t, "extent") .push_constant(Type source_data
KDTree_3d * tree
Editing * editing_get(const Scene *scene)
Definition sequencer.cc:272
ListBaseWrapperTemplate< ListBase, T > ListBaseWrapper
StripElem * stripdata
char filename[256]
StripData * data
struct Strip * prev
struct Strip * next
The data to build the tree from.
Establish and manage Outliner trees for different display modes.