Blender V4.3
channels.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2022 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9#include <cstring>
10
11#include "MEM_guardedalloc.h"
12
13#include "DNA_listBase.h"
14#include "DNA_sequence_types.h"
15
16#include "BLI_blenlib.h"
17
18#include "BLT_translation.hh"
19
20#include "SEQ_channels.hh"
21#include "SEQ_sequencer.hh"
22
27
32
34{
35 /* Allocate channels. Channel 0 is never used, but allocated to prevent off by 1 issues. */
36 for (int i = 0; i < SEQ_MAX_CHANNELS + 1; i++) {
37 SeqTimelineChannel *channel = static_cast<SeqTimelineChannel *>(
38 MEM_callocN(sizeof(SeqTimelineChannel), "seq timeline channel"));
39 SNPRINTF(channel->name, DATA_("Channel %d"), i);
40 channel->index = i;
41 BLI_addtail(channels, channel);
42 }
43}
44
45void SEQ_channels_duplicate(ListBase *channels_dst, ListBase *channels_src)
46{
47 LISTBASE_FOREACH (SeqTimelineChannel *, channel, channels_src) {
48 SeqTimelineChannel *channel_duplicate = static_cast<SeqTimelineChannel *>(
49 MEM_dupallocN(channel));
50 BLI_addtail(channels_dst, channel_duplicate);
51 }
52}
53
55{
56 LISTBASE_FOREACH_MUTABLE (SeqTimelineChannel *, channel, channels) {
57 MEM_freeN(channel);
58 }
59}
60
61SeqTimelineChannel *SEQ_channel_get_by_index(const ListBase *channels, const int channel_index)
62{
63 return static_cast<SeqTimelineChannel *>(BLI_findlink(channels, channel_index));
64}
65
66char *SEQ_channel_name_get(ListBase *channels, const int channel_index)
67{
68 SeqTimelineChannel *channel = SEQ_channel_get_by_index(channels, channel_index);
69 return channel->name;
70}
71
73{
74 return channel->index;
75}
76
78{
79 return (channel->flag & SEQ_CHANNEL_LOCK) != 0;
80}
81
83{
84 return (channel->flag & SEQ_CHANNEL_MUTE) != 0;
85}
86
88{
89 ListBase *lb = nullptr;
90
91 LISTBASE_FOREACH (Sequence *, iseq, seqbase) {
92 if (seq == iseq) {
93 return channels;
94 }
95 if ((lb = SEQ_get_channels_by_seq(&iseq->seqbase, &iseq->channels, seq))) {
96 return lb;
97 }
98 }
99
100 return nullptr;
101}
#define LISTBASE_FOREACH(type, var, list)
#define LISTBASE_FOREACH_MUTABLE(type, var, list)
void * BLI_findlink(const struct ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:110
#define SNPRINTF(dst, format,...)
Definition BLI_string.h:597
#define DATA_(msgid)
These structs are the foundation for all linked lists in the library system.
@ SEQ_CHANNEL_MUTE
@ SEQ_CHANNEL_LOCK
Read Guarded memory(de)allocation.
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Brightness Control the brightness and contrast of the input color Vector Map input vector components with curves Camera Retrieve information about the camera and how it relates to the current shading point s position Clamp a value between a minimum and a maximum Vector Perform vector math operation Invert Invert a producing a negative Combine Generate a color from its and blue channels(Deprecated)") DefNode(ShaderNode
constexpr int SEQ_MAX_CHANNELS
ListBase * SEQ_get_channels_by_seq(ListBase *seqbase, ListBase *channels, const Sequence *seq)
Definition channels.cc:87
SeqTimelineChannel * SEQ_channel_get_by_index(const ListBase *channels, const int channel_index)
Definition channels.cc:61
void SEQ_channels_duplicate(ListBase *channels_dst, ListBase *channels_src)
Definition channels.cc:45
int SEQ_channel_index_get(const SeqTimelineChannel *channel)
Definition channels.cc:72
bool SEQ_channel_is_locked(const SeqTimelineChannel *channel)
Definition channels.cc:77
void SEQ_channels_free(ListBase *channels)
Definition channels.cc:54
void SEQ_channels_ensure(ListBase *channels)
Definition channels.cc:33
ListBase * SEQ_channels_displayed_get(Editing *ed)
Definition channels.cc:23
void SEQ_channels_displayed_set(Editing *ed, ListBase *channels)
Definition channels.cc:28
bool SEQ_channel_is_muted(const SeqTimelineChannel *channel)
Definition channels.cc:82
char * SEQ_channel_name_get(ListBase *channels, const int channel_index)
Definition channels.cc:66
void MEM_freeN(void *vmemh)
Definition mallocn.cc:105
void *(* MEM_callocN)(size_t len, const char *str)
Definition mallocn.cc:42
void *(* MEM_dupallocN)(const void *vmemh)
Definition mallocn.cc:39
ListBase * displayed_channels