Blender V5.0
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
8
9#include "BLI_listbase.h"
10#include "BLI_utildefines.h"
11
12#include "DNA_scene_types.h"
13
14#include "DEG_depsgraph.hh"
15
16#include "BKE_context.hh"
17
18#include "WM_api.hh"
19#include "WM_types.hh"
20
21#include "RNA_define.hh"
22#include "RNA_enum_types.hh"
23#include "RNA_prototypes.hh"
24
25#include "SEQ_modifier.hh"
26#include "SEQ_relations.hh"
27#include "SEQ_select.hh"
28#include "SEQ_sequencer.hh"
29#include "SEQ_sound.hh"
30
31#include "UI_interface_c.hh"
32
33/* Own include. */
34#include "sequencer_intern.hh"
35
36namespace blender::ed::vse {
37
38/* -------------------------------------------------------------------- */
41
43{
45 Strip *strip = seq::select_active_get(scene);
46 int type = RNA_enum_get(op->ptr, "type");
47
48 StripModifierData *smd = seq::modifier_new(strip, nullptr, type);
50
53
54 return OPERATOR_FINISHED;
55}
56
58 PointerRNA * /*ptr*/,
59 PropertyRNA * /*prop*/,
60 bool * /*r_free*/)
61{
62 if (C == nullptr) {
64 }
65
67 Strip *strip = seq::select_active_get(scene);
68 if (strip) {
69 if (ELEM(strip->type, STRIP_TYPE_SOUND_RAM)) {
71 }
72 }
74}
75
77{
78 PropertyRNA *prop;
79
80 /* identifiers */
81 ot->name = "Add Strip Modifier";
82 ot->idname = "SEQUENCER_OT_strip_modifier_add";
83 ot->description = "Add a modifier to the strip";
84
85 /* API callbacks. */
88
89 /* flags */
91
92 /* properties */
93 prop = RNA_def_enum(ot->srna, "type", rna_enum_dummy_NULL_items, 0, "Type", "");
95 ot->prop = prop;
96}
97
99
100/* -------------------------------------------------------------------- */
103
105{
107 Strip *strip = seq::select_active_get(scene);
108 char name[MAX_NAME];
110
111 RNA_string_get(op->ptr, "name", name);
112
113 smd = seq::modifier_find_by_name(strip, name);
114 if (!smd) {
115 return OPERATOR_CANCELLED;
116 }
117
118 BLI_remlink(&strip->modifiers, smd);
120
121 if (ELEM(strip->type, STRIP_TYPE_SOUND_RAM)) {
123 }
124 else {
126 }
128
129 return OPERATOR_FINISHED;
130}
131
133{
134 PropertyRNA *prop;
135
136 /* identifiers */
137 ot->name = "Remove Strip Modifier";
138 ot->idname = "SEQUENCER_OT_strip_modifier_remove";
139 ot->description = "Remove a modifier from the strip";
140
141 /* API callbacks. */
144
145 /* flags */
147
148 /* properties */
149 prop = RNA_def_string(ot->srna, "name", "Name", MAX_NAME, "Name", "Name of modifier to remove");
151}
152
154
155/* -------------------------------------------------------------------- */
158
159enum {
162};
163
165{
167 Strip *strip = seq::select_active_get(scene);
168 char name[MAX_NAME];
169 int direction;
171
172 RNA_string_get(op->ptr, "name", name);
173 direction = RNA_enum_get(op->ptr, "direction");
174
175 smd = seq::modifier_find_by_name(strip, name);
176 if (!smd) {
177 return OPERATOR_CANCELLED;
178 }
179
180 if (direction == SEQ_MODIFIER_MOVE_UP) {
181 if (smd->prev) {
182 BLI_remlink(&strip->modifiers, smd);
183 BLI_insertlinkbefore(&strip->modifiers, smd->prev, smd);
184 }
185 }
186 else if (direction == SEQ_MODIFIER_MOVE_DOWN) {
187 if (smd->next) {
188 BLI_remlink(&strip->modifiers, smd);
189 BLI_insertlinkafter(&strip->modifiers, smd->next, smd);
190 }
191 }
192
193 if (ELEM(strip->type, STRIP_TYPE_SOUND_RAM)) {
195 }
196 else {
198 }
199
201
202 return OPERATOR_FINISHED;
203}
204
206{
207 PropertyRNA *prop;
208
209 static const EnumPropertyItem direction_items[] = {
210 {SEQ_MODIFIER_MOVE_UP, "UP", 0, "Up", "Move modifier up in the stack"},
211 {SEQ_MODIFIER_MOVE_DOWN, "DOWN", 0, "Down", "Move modifier down in the stack"},
212 {0, nullptr, 0, nullptr, nullptr},
213 };
214
215 /* identifiers */
216 ot->name = "Move Strip Modifier";
217 ot->idname = "SEQUENCER_OT_strip_modifier_move";
218 ot->description = "Move modifier up and down in the stack";
219
220 /* API callbacks. */
223
224 /* flags */
226
227 /* properties */
228 prop = RNA_def_string(ot->srna, "name", "Name", MAX_NAME, "Name", "Name of modifier to remove");
230 prop = RNA_def_enum(ot->srna, "direction", direction_items, SEQ_MODIFIER_MOVE_UP, "Type", "");
232}
233
235
236/* -------------------------------------------------------------------- */
239
240enum {
243};
244
246{
248 Strip *active_strip = seq::select_active_get(scene);
249 const int type = RNA_enum_get(op->ptr, "type");
250
251 if (!active_strip || !active_strip->modifiers.first) {
252 return OPERATOR_CANCELLED;
253 }
254
255 int isSound = ELEM(active_strip->type, STRIP_TYPE_SOUND_RAM);
256
258 selected.remove(active_strip);
259
260 for (Strip *strip_iter : selected) {
261 int strip_iter_is_sound = ELEM(strip_iter->type, STRIP_TYPE_SOUND_RAM);
262 /* If original is sound, only copy to "sound" strips
263 * If original is not sound, only copy to "not sound" strips
264 */
265 if (isSound != strip_iter_is_sound) {
266 continue;
267 }
268
269 if (type == SEQ_MODIFIER_COPY_REPLACE) {
270 if (strip_iter->modifiers.first) {
271 StripModifierData *smd_tmp,
272 *smd = static_cast<StripModifierData *>(strip_iter->modifiers.first);
273 while (smd) {
274 smd_tmp = smd->next;
275 BLI_remlink(&strip_iter->modifiers, smd);
277 smd = smd_tmp;
278 }
279 BLI_listbase_clear(&strip_iter->modifiers);
280 }
281 }
282
283 LISTBASE_FOREACH (StripModifierData *, smd, &active_strip->modifiers) {
284 StripModifierData *smd_new = seq::modifier_copy(*strip_iter, smd);
285 seq::modifier_persistent_uid_init(*strip_iter, *smd_new);
286 }
287 }
288
289 if (ELEM(active_strip->type, STRIP_TYPE_SOUND_RAM)) {
291 }
292 else {
293 seq::relations_invalidate_cache(scene, active_strip);
294 }
295
297
298 return OPERATOR_FINISHED;
299}
300
302{
303 static const EnumPropertyItem type_items[] = {
304 {SEQ_MODIFIER_COPY_REPLACE, "REPLACE", 0, "Replace", "Replace modifiers in destination"},
306 "APPEND",
307 0,
308 "Append",
309 "Append active modifiers to selected strips"},
310 {0, nullptr, 0, nullptr, nullptr},
311 };
312
313 /* identifiers */
314 ot->name = "Copy to Selected Strips";
315 ot->idname = "SEQUENCER_OT_strip_modifier_copy";
316 ot->description = "Copy modifiers of the active strip to all selected strips";
317
318 /* API callbacks. */
319 ot->invoke = WM_menu_invoke;
322
323 /* flags */
325
326 /* properties */
327 ot->prop = RNA_def_enum(ot->srna, "type", type_items, SEQ_MODIFIER_COPY_REPLACE, "Type", "");
328}
329
331
332/* -------------------------------------------------------------------- */
335
337{
339 Strip *strip = seq::select_active_get(scene);
341 char name[MAX_NAME];
342 RNA_string_get(op->ptr, "name", name);
343 int number = RNA_enum_get(op->ptr, "graphs");
344
345 smd = seq::modifier_find_by_name(strip, name);
346 if (!smd) {
347 return OPERATOR_CANCELLED;
348 }
349
351
354
355 return OPERATOR_FINISHED;
356}
357
359{
360
361 static const EnumPropertyItem enum_modifier_equalizer_presets_items[] = {
362 {1, "SIMPLE", 0, "Unique", "One unique graphical definition"},
363 {2, "DOUBLE", 0, "Double", "Graphical definition in 2 sections"},
364 {3, "TRIPLE", 0, "Triplet", "Graphical definition in 3 sections"},
365 {0, nullptr, 0, nullptr, nullptr},
366 };
367 PropertyRNA *prop;
368
369 /* identifiers */
370 ot->name = "Redefine Equalizer Graphs";
371 ot->idname = "SEQUENCER_OT_strip_modifier_equalizer_redefine";
372 ot->description = "Redefine equalizer graphs";
373
374 /* API callbacks. */
377
378 /* flags */
380
381 /* properties */
382 prop = RNA_def_enum(
383 ot->srna, "graphs", enum_modifier_equalizer_presets_items, 1, "Graphs", "Number of graphs");
384 ot->prop = prop;
385 prop = RNA_def_string(
386 ot->srna, "name", "Name", MAX_NAME, "Name", "Name of modifier to redefine");
388}
389
391
392/* ------------------------------------------------------------------- */
395
397{
399 Strip *strip = seq::select_active_get(scene);
400
401 char name[MAX_NAME];
402 RNA_string_get(op->ptr, "modifier", name);
403 const int index = RNA_int_get(op->ptr, "index");
404
406 if (!smd) {
407 return OPERATOR_CANCELLED;
408 }
409
410 if (!seq::modifier_move_to_index(strip, smd, index)) {
411 return OPERATOR_CANCELLED;
412 }
413
414 if (ELEM(strip->type, STRIP_TYPE_SOUND_RAM)) {
416 }
417 else {
419 }
420
422
423 return OPERATOR_FINISHED;
424}
425
427 wmOperator *op,
428 const wmEvent * /*event*/)
429{
430 BLI_assert(RNA_struct_property_is_set(op->ptr, "modifier"));
431 return modifier_move_to_index_exec(C, op);
432}
433
435{
436 PropertyRNA *prop;
437
438 ot->name = "Move Active Strip Modifier to Index";
439 ot->description =
440 "Change the strip modifier's index in the stack so it evaluates after the set number of "
441 "others";
442 ot->idname = "SEQUENCER_OT_strip_modifier_move_to_index";
443
447
448 /* flags */
450
451 prop = RNA_def_string(
452 ot->srna, "modifier", nullptr, MAX_NAME, "Modifier", "Name of the modifier to edit");
455 ot->srna, "index", 0, 0, INT_MAX, "Index", "The index to move the modifier to", 0, INT_MAX);
456}
457
459
460/* ------------------------------------------------------------------- */
463
465{
467 Strip *strip = seq::select_active_get(scene);
468
469 char name[MAX_NAME];
470 RNA_string_get(op->ptr, "modifier", name);
471
473 /* If there is no modifier set for this operator, clear the active modifier field. */
475
477
478 return OPERATOR_FINISHED;
479}
480
482 wmOperator *op,
483 const wmEvent * /*event*/)
484{
485 BLI_assert(RNA_struct_property_is_set(op->ptr, "modifier"));
486 return modifier_set_active_exec(C, op);
487}
488
490{
491 ot->name = "Set Active Strip Modifier";
492 ot->description = "Activate the strip modifier to use as the context";
493 ot->idname = "SEQUENCER_OT_strip_modifier_set_active";
494
498
500
501 ot->prop = RNA_def_string(
502 ot->srna, "modifier", nullptr, MAX_NAME, "Modifier", "Name of the strip modifier to edit");
504}
505
507
508} // namespace blender::ed::vse
Scene * CTX_data_sequencer_scene(const bContext *C)
#define BLI_assert(a)
Definition BLI_assert.h:46
#define LISTBASE_FOREACH(type, var, list)
BLI_INLINE void BLI_listbase_clear(ListBase *lb)
void BLI_insertlinkafter(ListBase *listbase, void *vprevlink, void *vnewlink) ATTR_NONNULL(1)
Definition listbase.cc:332
void BLI_remlink(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:131
void BLI_insertlinkbefore(ListBase *listbase, void *vnextlink, void *vnewlink) ATTR_NONNULL(1)
Definition listbase.cc:371
#define ELEM(...)
void DEG_id_tag_update(ID *id, unsigned int flags)
@ ID_RECALC_AUDIO
Definition DNA_ID.h:1132
@ ID_RECALC_SEQUENCER_STRIPS
Definition DNA_ID.h:1122
#define MAX_NAME
Definition DNA_defs.h:50
@ STRIP_TYPE_SOUND_RAM
@ OPERATOR_CANCELLED
@ OPERATOR_FINISHED
@ PROP_HIDDEN
Definition RNA_types.hh:338
#define C
Definition RandGen.cpp:29
#define ND_SEQUENCER
Definition WM_types.hh:437
#define NC_SCENE
Definition WM_types.hh:378
@ OPTYPE_INTERNAL
Definition WM_types.hh:202
@ OPTYPE_UNDO
Definition WM_types.hh:182
@ OPTYPE_REGISTER
Definition WM_types.hh:180
bool remove(const Key &key)
static wmOperatorStatus modifier_set_active_exec(bContext *C, wmOperator *op)
static wmOperatorStatus strip_modifier_move_exec(bContext *C, wmOperator *op)
static wmOperatorStatus strip_modifier_equalizer_redefine_exec(bContext *C, wmOperator *op)
static const EnumPropertyItem * filter_modifiers_by_sequence_type_itemf(bContext *C, PointerRNA *, PropertyRNA *, bool *)
blender::VectorSet< Strip * > selected_strips_from_context(bContext *C)
static wmOperatorStatus strip_modifier_remove_exec(bContext *C, wmOperator *op)
void SEQUENCER_OT_strip_modifier_remove(wmOperatorType *ot)
static wmOperatorStatus modifier_move_to_index_invoke(bContext *C, wmOperator *op, const wmEvent *)
void SEQUENCER_OT_strip_modifier_set_active(wmOperatorType *ot)
static wmOperatorStatus modifier_set_active_invoke(bContext *C, wmOperator *op, const wmEvent *)
void SEQUENCER_OT_strip_modifier_equalizer_redefine(wmOperatorType *ot)
static wmOperatorStatus modifier_move_to_index_exec(bContext *C, wmOperator *op)
bool sequencer_strip_editable_poll(bContext *C)
void SEQUENCER_OT_strip_modifier_move_to_index(wmOperatorType *ot)
void SEQUENCER_OT_strip_modifier_move(wmOperatorType *ot)
static wmOperatorStatus strip_modifier_copy_exec(bContext *C, wmOperator *op)
void SEQUENCER_OT_strip_modifier_add(wmOperatorType *ot)
void SEQUENCER_OT_strip_modifier_copy(wmOperatorType *ot)
static wmOperatorStatus strip_modifier_add_exec(bContext *C, wmOperator *op)
bool modifier_move_to_index(Strip *strip, StripModifierData *smd, const int new_index)
void relations_invalidate_cache(Scene *scene, Strip *strip)
StripModifierData * modifier_copy(Strip &strip_dst, StripModifierData *mod_src)
void modifier_persistent_uid_init(const Strip &strip, StripModifierData &smd)
StripModifierData * modifier_find_by_name(Strip *strip, const char *name)
Strip * select_active_get(const Scene *scene)
void modifier_free(StripModifierData *smd)
void modifier_set_active(Strip *strip, StripModifierData *smd)
StripModifierData * modifier_new(Strip *strip, const char *name, int type)
void sound_equalizermodifier_set_graphs(SoundEqualizerModifierData *semd, int number)
const char * name
int RNA_int_get(PointerRNA *ptr, const char *name)
std::string RNA_string_get(PointerRNA *ptr, const char *name)
bool RNA_struct_property_is_set(PointerRNA *ptr, const char *identifier)
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)
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, const int default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
const EnumPropertyItem rna_enum_dummy_NULL_items[]
Definition rna_rna.cc:26
const EnumPropertyItem rna_enum_strip_video_modifier_type_items[]
const EnumPropertyItem rna_enum_strip_modifier_type_items[]
const EnumPropertyItem rna_enum_strip_sound_modifier_type_items[]
void * first
struct StripModifierData * prev
struct StripModifierData * next
ListBase modifiers
struct PointerRNA * ptr
void WM_main_add_notifier(uint type, void *reference)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
wmOperatorType * ot
Definition wm_files.cc:4237
wmOperatorStatus WM_menu_invoke(bContext *C, wmOperator *op, const wmEvent *)