Blender V4.3
sequencer_modifier.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2012 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9#include "BLI_utildefines.h"
10
11#include "DNA_scene_types.h"
12
13#include "DEG_depsgraph.hh"
14
15#include "BKE_context.hh"
16
17#include "WM_api.hh"
18#include "WM_types.hh"
19
20#include "RNA_define.hh"
21#include "RNA_enum_types.hh"
22
23#include "SEQ_modifier.hh"
24#include "SEQ_relations.hh"
25#include "SEQ_select.hh"
26#include "SEQ_sequencer.hh"
27#include "SEQ_sound.hh"
28
29/* Own include. */
30#include "sequencer_intern.hh"
31
32/* -------------------------------------------------------------------- */
37{
38 Scene *scene = CTX_data_scene(C);
39 Sequence *seq = SEQ_select_active_get(scene);
40 int type = RNA_enum_get(op->ptr, "type");
41
42 SEQ_modifier_new(seq, nullptr, type);
43
46
47 return OPERATOR_FINISHED;
48}
49
51 PointerRNA * /*ptr*/,
52 PropertyRNA * /*prop*/,
53 bool * /*r_free*/)
54{
55 if (C == nullptr) {
57 }
58
59 Scene *scene = CTX_data_scene(C);
60 Sequence *seq = SEQ_select_active_get(scene);
61 if (seq) {
62 if (ELEM(seq->type, SEQ_TYPE_SOUND_RAM)) {
64 }
65 }
67}
68
70{
71 PropertyRNA *prop;
72
73 /* identifiers */
74 ot->name = "Add Strip Modifier";
75 ot->idname = "SEQUENCER_OT_strip_modifier_add";
76 ot->description = "Add a modifier to the strip";
77
78 /* api callbacks */
81
82 /* flags */
84
85 /* properties */
86 prop = RNA_def_enum(ot->srna, "type", rna_enum_dummy_NULL_items, 0, "Type", "");
88 ot->prop = prop;
89}
90
93/* -------------------------------------------------------------------- */
98{
99 Scene *scene = CTX_data_scene(C);
100 Sequence *seq = SEQ_select_active_get(scene);
101 char name[MAX_NAME];
103
104 RNA_string_get(op->ptr, "name", name);
105
106 smd = SEQ_modifier_find_by_name(seq, name);
107 if (!smd) {
108 return OPERATOR_CANCELLED;
109 }
110
111 BLI_remlink(&seq->modifiers, smd);
113
114 if (ELEM(seq->type, SEQ_TYPE_SOUND_RAM)) {
116 }
117 else {
119 }
121
122 return OPERATOR_FINISHED;
123}
124
126{
127 PropertyRNA *prop;
128
129 /* identifiers */
130 ot->name = "Remove Strip Modifier";
131 ot->idname = "SEQUENCER_OT_strip_modifier_remove";
132 ot->description = "Remove a modifier from the strip";
133
134 /* api callbacks */
137
138 /* flags */
140
141 /* properties */
142 prop = RNA_def_string(ot->srna, "name", "Name", MAX_NAME, "Name", "Name of modifier to remove");
144}
145
148/* -------------------------------------------------------------------- */
152enum {
155};
156
158{
159 Scene *scene = CTX_data_scene(C);
160 Sequence *seq = SEQ_select_active_get(scene);
161 char name[MAX_NAME];
162 int direction;
164
165 RNA_string_get(op->ptr, "name", name);
166 direction = RNA_enum_get(op->ptr, "direction");
167
168 smd = SEQ_modifier_find_by_name(seq, name);
169 if (!smd) {
170 return OPERATOR_CANCELLED;
171 }
172
173 if (direction == SEQ_MODIFIER_MOVE_UP) {
174 if (smd->prev) {
175 BLI_remlink(&seq->modifiers, smd);
176 BLI_insertlinkbefore(&seq->modifiers, smd->prev, smd);
177 }
178 }
179 else if (direction == SEQ_MODIFIER_MOVE_DOWN) {
180 if (smd->next) {
181 BLI_remlink(&seq->modifiers, smd);
182 BLI_insertlinkafter(&seq->modifiers, smd->next, smd);
183 }
184 }
185
186 if (ELEM(seq->type, SEQ_TYPE_SOUND_RAM)) {
188 }
189 else {
191 }
192
194
195 return OPERATOR_FINISHED;
196}
197
199{
200 PropertyRNA *prop;
201
202 static const EnumPropertyItem direction_items[] = {
203 {SEQ_MODIFIER_MOVE_UP, "UP", 0, "Up", "Move modifier up in the stack"},
204 {SEQ_MODIFIER_MOVE_DOWN, "DOWN", 0, "Down", "Move modifier down in the stack"},
205 {0, nullptr, 0, nullptr, nullptr},
206 };
207
208 /* identifiers */
209 ot->name = "Move Strip Modifier";
210 ot->idname = "SEQUENCER_OT_strip_modifier_move";
211 ot->description = "Move modifier up and down in the stack";
212
213 /* api callbacks */
216
217 /* flags */
219
220 /* properties */
221 prop = RNA_def_string(ot->srna, "name", "Name", MAX_NAME, "Name", "Name of modifier to remove");
223 prop = RNA_def_enum(ot->srna, "direction", direction_items, SEQ_MODIFIER_MOVE_UP, "Type", "");
225}
226
229/* -------------------------------------------------------------------- */
233enum {
236};
237
239{
240 Scene *scene = CTX_data_scene(C);
241 Editing *ed = scene->ed;
242 Sequence *seq = SEQ_select_active_get(scene);
243 const int type = RNA_enum_get(op->ptr, "type");
244
245 if (!seq || !seq->modifiers.first) {
246 return OPERATOR_CANCELLED;
247 }
248
249 int isSound = ELEM(seq->type, SEQ_TYPE_SOUND_RAM);
250
252 if (seq_iter->flag & SELECT) {
253 if (seq_iter == seq) {
254 continue;
255 }
256 int seq_iter_is_sound = ELEM(seq_iter->type, SEQ_TYPE_SOUND_RAM);
257 /* If original is sound, only copy to "sound" strips
258 * If original is not sound, only copy to "not sound" strips
259 */
260 if (isSound != seq_iter_is_sound) {
261 continue;
262 }
263
264 if (type == SEQ_MODIFIER_COPY_REPLACE) {
265 if (seq_iter->modifiers.first) {
266 SequenceModifierData *smd_tmp,
267 *smd = static_cast<SequenceModifierData *>(seq_iter->modifiers.first);
268 while (smd) {
269 smd_tmp = smd->next;
270 BLI_remlink(&seq_iter->modifiers, smd);
272 smd = smd_tmp;
273 }
274 BLI_listbase_clear(&seq_iter->modifiers);
275 }
276 }
277
278 SEQ_modifier_list_copy(seq_iter, seq);
279 }
280 }
281
282 if (ELEM(seq->type, SEQ_TYPE_SOUND_RAM)) {
284 }
285 else {
287 }
288
290
291 return OPERATOR_FINISHED;
292}
293
295{
296 static const EnumPropertyItem type_items[] = {
297 {SEQ_MODIFIER_COPY_REPLACE, "REPLACE", 0, "Replace", "Replace modifiers in destination"},
299 "APPEND",
300 0,
301 "Append",
302 "Append active modifiers to selected strips"},
303 {0, nullptr, 0, nullptr, nullptr},
304 };
305
306 /* identifiers */
307 ot->name = "Copy to Selected Strips";
308 ot->idname = "SEQUENCER_OT_strip_modifier_copy";
309 ot->description = "Copy modifiers of the active strip to all selected strips";
310
311 /* api callbacks */
315
316 /* flags */
318
319 /* properties */
320 ot->prop = RNA_def_enum(ot->srna, "type", type_items, SEQ_MODIFIER_COPY_REPLACE, "Type", "");
321}
322
325/* -------------------------------------------------------------------- */
330{
331 Scene *scene = CTX_data_scene(C);
332 Sequence *seq = SEQ_select_active_get(scene);
334 char name[MAX_NAME];
335 RNA_string_get(op->ptr, "name", name);
336 int number = RNA_enum_get(op->ptr, "graphs");
337
338 smd = SEQ_modifier_find_by_name(seq, name);
339 if (!smd) {
340 return OPERATOR_CANCELLED;
341 }
342
344
347
348 return OPERATOR_FINISHED;
349}
350
352{
353
354 static const EnumPropertyItem enum_modifier_equalizer_presets_items[] = {
355 {1, "SIMPLE", 0, "Unique", "One unique graphical definition"},
356 {2, "DOUBLE", 0, "Double", "Graphical definition in 2 sections"},
357 {3, "TRIPLE", 0, "Triplet", "Graphical definition in 3 sections"},
358 {0, nullptr, 0, nullptr, nullptr},
359 };
360 PropertyRNA *prop;
361
362 /* identifiers */
363 ot->name = "Redefine Equalizer Graphs";
364 ot->idname = "SEQUENCER_OT_strip_modifier_equalizer_redefine";
365 ot->description = "Redefine equalizer graphs";
366
367 /* api callbacks */
370
371 /* flags */
373
374 /* properties */
375 prop = RNA_def_enum(
376 ot->srna, "graphs", enum_modifier_equalizer_presets_items, 1, "Graphs", "Number of graphs");
377 ot->prop = prop;
378 prop = RNA_def_string(
379 ot->srna, "name", "Name", MAX_NAME, "Name", "Name of modifier to redefine");
381}
382
Scene * CTX_data_scene(const bContext *C)
#define LISTBASE_FOREACH(type, var, list)
BLI_INLINE void BLI_listbase_clear(struct ListBase *lb)
void BLI_insertlinkafter(struct ListBase *listbase, void *vprevlink, void *vnewlink) ATTR_NONNULL(1)
Definition listbase.cc:331
void BLI_remlink(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:130
void BLI_insertlinkbefore(struct ListBase *listbase, void *vnextlink, void *vnewlink) ATTR_NONNULL(1)
Definition listbase.cc:370
#define ELEM(...)
void DEG_id_tag_update(ID *id, unsigned int flags)
@ ID_RECALC_AUDIO
Definition DNA_ID.h:1099
@ ID_RECALC_SEQUENCER_STRIPS
Definition DNA_ID.h:1089
#define MAX_NAME
Definition DNA_defs.h:50
@ SEQ_TYPE_SOUND_RAM
@ PROP_HIDDEN
Definition RNA_types.hh:239
#define ND_SEQUENCER
Definition WM_types.hh:404
@ OPTYPE_UNDO
Definition WM_types.hh:162
@ OPTYPE_REGISTER
Definition WM_types.hh:160
#define NC_SCENE
Definition WM_types.hh:345
#define SELECT
void RNA_string_get(PointerRNA *ptr, const char *name, char *value)
int RNA_enum_get(PointerRNA *ptr, const char *name)
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
void RNA_def_enum_funcs(PropertyRNA *prop, EnumPropertyItemFunc itemfunc)
const EnumPropertyItem rna_enum_dummy_NULL_items[]
Definition rna_rna.cc:29
const EnumPropertyItem rna_enum_sequence_modifier_type_items[]
const EnumPropertyItem rna_enum_sequence_sound_modifier_type_items[]
const EnumPropertyItem rna_enum_sequence_video_modifier_type_items[]
SequenceModifierData * SEQ_modifier_new(Sequence *seq, const char *name, int type)
SequenceModifierData * SEQ_modifier_find_by_name(Sequence *seq, const char *name)
void SEQ_modifier_free(SequenceModifierData *smd)
void SEQ_modifier_list_copy(Sequence *seqn, Sequence *seq)
void SEQ_sound_equalizermodifier_set_graphs(SoundEqualizerModifierData *semd, int number)
ListBase * SEQ_active_seqbase_get(const Editing *ed)
Definition sequencer.cc:416
bool sequencer_strip_editable_poll(bContext *C)
static int strip_modifier_remove_exec(bContext *C, wmOperator *op)
void SEQUENCER_OT_strip_modifier_equalizer_redefine(wmOperatorType *ot)
void SEQUENCER_OT_strip_modifier_add(wmOperatorType *ot)
static int strip_modifier_copy_exec(bContext *C, wmOperator *op)
static const EnumPropertyItem * filter_modifiers_by_sequence_type_itemf(bContext *C, PointerRNA *, PropertyRNA *, bool *)
@ SEQ_MODIFIER_COPY_REPLACE
@ SEQ_MODIFIER_COPY_APPEND
static int strip_modifier_equalizer_redefine_exec(bContext *C, wmOperator *op)
@ SEQ_MODIFIER_MOVE_UP
@ SEQ_MODIFIER_MOVE_DOWN
void SEQUENCER_OT_strip_modifier_copy(wmOperatorType *ot)
static int strip_modifier_move_exec(bContext *C, wmOperator *op)
void SEQUENCER_OT_strip_modifier_remove(wmOperatorType *ot)
static int strip_modifier_add_exec(bContext *C, wmOperator *op)
void SEQUENCER_OT_strip_modifier_move(wmOperatorType *ot)
void SEQ_relations_invalidate_cache_preprocessed(Scene *scene, Sequence *seq)
Sequence * SEQ_select_active_get(const Scene *scene)
void * first
struct SequenceModifierData * next
struct SequenceModifierData * prev
ListBase modifiers
const char * name
Definition WM_types.hh:990
bool(* poll)(bContext *C) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1042
const char * idname
Definition WM_types.hh:992
int(* invoke)(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1022
int(* exec)(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1006
const char * description
Definition WM_types.hh:996
PropertyRNA * prop
Definition WM_types.hh:1092
StructRNA * srna
Definition WM_types.hh:1080
struct PointerRNA * ptr
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
wmOperatorType * ot
Definition wm_files.cc:4125
int WM_menu_invoke(bContext *C, wmOperator *op, const wmEvent *)