Blender  V3.3
channels.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2022 Blender Foundation. All rights reserved. */
3 
8 #include <string.h>
9 
10 #include "MEM_guardedalloc.h"
11 
12 #include "DNA_listBase.h"
13 #include "DNA_scene_types.h"
14 #include "DNA_sequence_types.h"
15 
16 #include "BLI_blenlib.h"
17 
18 #include "SEQ_channels.h"
19 #include "SEQ_iterator.h"
20 #include "SEQ_relations.h"
21 #include "SEQ_sequencer.h"
22 
24 {
25  return ed->displayed_channels;
26 }
27 
29 {
31 }
32 
34 {
35  /* Allocate channels. Channel 0 is never used, but allocated to prevent off by 1 issues. */
36  for (int i = 0; i < MAXSEQ + 1; i++) {
37  SeqTimelineChannel *channel = MEM_callocN(sizeof(SeqTimelineChannel), "seq timeline channel");
38  BLI_snprintf(channel->name, sizeof(channel->name), "Channel %d", i);
39  channel->index = i;
40  BLI_addtail(channels, channel);
41  }
42 }
43 
44 void SEQ_channels_duplicate(ListBase *channels_dst, ListBase *channels_src)
45 {
46  LISTBASE_FOREACH (SeqTimelineChannel *, channel, channels_src) {
47  SeqTimelineChannel *channel_duplicate = MEM_dupallocN(channel);
48  BLI_addtail(channels_dst, channel_duplicate);
49  }
50 }
51 
53 {
55  MEM_freeN(channel);
56  }
57 }
58 
60 {
61  return BLI_findlink(channels, channel_index);
62 }
63 
64 char *SEQ_channel_name_get(ListBase *channels, const int channel_index)
65 {
66  SeqTimelineChannel *channel = SEQ_channel_get_by_index(channels, channel_index);
67  return channel->name;
68 }
69 
71 {
72  return channel->index;
73 }
74 
76 {
77  return (channel->flag & SEQ_CHANNEL_LOCK) != 0;
78 }
79 
81 {
82  return (channel->flag & SEQ_CHANNEL_MUTE) != 0;
83 }
84 
86 {
87  ListBase *lb = NULL;
88 
89  LISTBASE_FOREACH (Sequence *, iseq, seqbase) {
90  if (seq == iseq) {
91  return channels;
92  }
93  if ((lb = SEQ_get_channels_by_seq(&iseq->seqbase, &iseq->channels, seq))) {
94  return lb;
95  }
96  }
97 
98  return NULL;
99 }
#define LISTBASE_FOREACH(type, var, list)
Definition: BLI_listbase.h:336
#define LISTBASE_FOREACH_MUTABLE(type, var, list)
Definition: BLI_listbase.h:354
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:80
void * BLI_findlink(const struct ListBase *listbase, int number) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
size_t BLI_snprintf(char *__restrict dst, size_t maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
These structs are the foundation for all linked lists in the library system.
@ SEQ_CHANNEL_MUTE
@ SEQ_CHANNEL_LOCK
#define MAXSEQ
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 Bright Control the brightness and contrast of the input color Vector Map an input vectors to used to fine tune the interpolation of the input 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 a producing a negative Combine Generate a color from its and blue channels(Deprecated)") DefNode(ShaderNode
SeqTimelineChannel * SEQ_channel_get_by_index(const ListBase *channels, const int channel_index)
Definition: channels.c:59
void SEQ_channels_duplicate(ListBase *channels_dst, ListBase *channels_src)
Definition: channels.c:44
int SEQ_channel_index_get(const SeqTimelineChannel *channel)
Definition: channels.c:70
bool SEQ_channel_is_locked(const SeqTimelineChannel *channel)
Definition: channels.c:75
void SEQ_channels_free(ListBase *channels)
Definition: channels.c:52
void SEQ_channels_ensure(ListBase *channels)
Definition: channels.c:33
void SEQ_channels_displayed_set(Editing *ed, ListBase *channels)
Definition: channels.c:28
char * SEQ_channel_name_get(ListBase *channels, const int channel_index)
Definition: channels.c:64
bool SEQ_channel_is_muted(const SeqTimelineChannel *channel)
Definition: channels.c:80
ListBase * SEQ_channels_displayed_get(Editing *ed)
Definition: channels.c:23
ListBase * SEQ_get_channels_by_seq(ListBase *seqbase, ListBase *channels, const Sequence *seq)
Definition: channels.c:85
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:27
void *(* MEM_dupallocN)(const void *vmemh)
Definition: mallocn.c:28
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:31
ListBase * displayed_channels