Blender V5.0
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#include "DNA_workspace_types.h"
17
18#include "SEQ_sequencer.hh"
19
20#include "../outliner_intern.hh"
21#include "tree_display.hh"
22
23namespace blender::ed::outliner {
24
25template<typename T> using List = ListBaseWrapper<T>;
26
31
33{
34 ListBase tree = {nullptr};
35 Scene *sequencer_scene = source_data.workspace->sequencer_scene;
36 if (!sequencer_scene) {
37 return tree;
38 }
39
40 Editing *ed = seq::editing_get(sequencer_scene);
41 if (ed == nullptr) {
42 return tree;
43 }
44
45 for (Strip *strip : List<Strip>(ed->current_strips())) {
46 StripAddOp op = need_add_strip_dup(strip);
47 if (op == StripAddOp::None) {
48 add_element(&tree, nullptr, strip, nullptr, TSE_STRIP, 0);
49 }
50 else if (op == StripAddOp::Add) {
51 TreeElement *te = add_element(&tree, nullptr, strip, nullptr, TSE_STRIP_DUP, 0);
52 add_strip_dup(strip, te, 0);
53 }
54 }
55
56 return tree;
57}
58
59StripAddOp TreeDisplaySequencer::need_add_strip_dup(Strip *strip) const
60{
61 if ((!strip->data) || (!strip->data->stripdata)) {
62 return StripAddOp::None;
63 }
64
65 /*
66 * First check backward, if we found a duplicate
67 * sequence before this, don't need it, just return.
68 */
69 Strip *p = strip->prev;
70 while (p) {
71 if ((!p->data) || (!p->data->stripdata)) {
72 p = p->prev;
73 continue;
74 }
75
76 if (STREQ(p->data->stripdata->filename, strip->data->stripdata->filename)) {
77 return StripAddOp::Noop;
78 }
79 p = p->prev;
80 }
81
82 p = strip->next;
83 while (p) {
84 if ((!p->data) || (!p->data->stripdata)) {
85 p = p->next;
86 continue;
87 }
88
89 if (STREQ(p->data->stripdata->filename, strip->data->stripdata->filename)) {
90 return StripAddOp::Add;
91 }
92 p = p->next;
93 }
94
95 return StripAddOp::None;
96}
97
98void TreeDisplaySequencer::add_strip_dup(Strip *strip, TreeElement *te, short index)
99{
100 Strip *p = strip;
101 while (p) {
102 if ((!p->data) || (!p->data->stripdata) || (p->data->stripdata->filename[0] == '\0')) {
103 p = p->next;
104 continue;
105 }
106
107 if (STREQ(p->data->stripdata->filename, strip->data->stripdata->filename)) {
108 add_element(&te->subtree, nullptr, (void *)p, te, TSE_STRIP, index);
109 }
110 p = p->next;
111 }
112}
113
114} // 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:286
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.