Blender V4.5
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
24#include "SEQ_modifier.hh"
25#include "SEQ_relations.hh"
26#include "SEQ_select.hh"
27#include "SEQ_sequencer.hh"
28#include "SEQ_sound.hh"
29
30/* Own include. */
31#include "sequencer_intern.hh"
32
33namespace blender::ed::vse {
34
35/* -------------------------------------------------------------------- */
38
40{
41 Scene *scene = CTX_data_scene(C);
42 Strip *strip = seq::select_active_get(scene);
43 int type = RNA_enum_get(op->ptr, "type");
44
45 seq::modifier_new(strip, nullptr, type);
46
49
50 return OPERATOR_FINISHED;
51}
52
54 PointerRNA * /*ptr*/,
55 PropertyRNA * /*prop*/,
56 bool * /*r_free*/)
57{
58 if (C == nullptr) {
60 }
61
62 Scene *scene = CTX_data_scene(C);
63 Strip *strip = seq::select_active_get(scene);
64 if (strip) {
65 if (ELEM(strip->type, STRIP_TYPE_SOUND_RAM)) {
67 }
68 }
70}
71
73{
74 PropertyRNA *prop;
75
76 /* identifiers */
77 ot->name = "Add Strip Modifier";
78 ot->idname = "SEQUENCER_OT_strip_modifier_add";
79 ot->description = "Add a modifier to the strip";
80
81 /* API callbacks. */
84
85 /* flags */
87
88 /* properties */
89 prop = RNA_def_enum(ot->srna, "type", rna_enum_dummy_NULL_items, 0, "Type", "");
91 ot->prop = prop;
92}
93
95
96/* -------------------------------------------------------------------- */
99
101{
102 Scene *scene = CTX_data_scene(C);
103 Strip *strip = seq::select_active_get(scene);
104 char name[MAX_NAME];
106
107 RNA_string_get(op->ptr, "name", name);
108
109 smd = seq::modifier_find_by_name(strip, name);
110 if (!smd) {
111 return OPERATOR_CANCELLED;
112 }
113
114 BLI_remlink(&strip->modifiers, smd);
116
117 if (ELEM(strip->type, STRIP_TYPE_SOUND_RAM)) {
119 }
120 else {
122 }
124
125 return OPERATOR_FINISHED;
126}
127
129{
130 PropertyRNA *prop;
131
132 /* identifiers */
133 ot->name = "Remove Strip Modifier";
134 ot->idname = "SEQUENCER_OT_strip_modifier_remove";
135 ot->description = "Remove a modifier from the strip";
136
137 /* API callbacks. */
140
141 /* flags */
143
144 /* properties */
145 prop = RNA_def_string(ot->srna, "name", "Name", MAX_NAME, "Name", "Name of modifier to remove");
147}
148
150
151/* -------------------------------------------------------------------- */
154
155enum {
158};
159
161{
162 Scene *scene = CTX_data_scene(C);
163 Strip *strip = seq::select_active_get(scene);
164 char name[MAX_NAME];
165 int direction;
167
168 RNA_string_get(op->ptr, "name", name);
169 direction = RNA_enum_get(op->ptr, "direction");
170
171 smd = seq::modifier_find_by_name(strip, name);
172 if (!smd) {
173 return OPERATOR_CANCELLED;
174 }
175
176 if (direction == SEQ_MODIFIER_MOVE_UP) {
177 if (smd->prev) {
178 BLI_remlink(&strip->modifiers, smd);
179 BLI_insertlinkbefore(&strip->modifiers, smd->prev, smd);
180 }
181 }
182 else if (direction == SEQ_MODIFIER_MOVE_DOWN) {
183 if (smd->next) {
184 BLI_remlink(&strip->modifiers, smd);
185 BLI_insertlinkafter(&strip->modifiers, smd->next, smd);
186 }
187 }
188
189 if (ELEM(strip->type, STRIP_TYPE_SOUND_RAM)) {
191 }
192 else {
194 }
195
197
198 return OPERATOR_FINISHED;
199}
200
202{
203 PropertyRNA *prop;
204
205 static const EnumPropertyItem direction_items[] = {
206 {SEQ_MODIFIER_MOVE_UP, "UP", 0, "Up", "Move modifier up in the stack"},
207 {SEQ_MODIFIER_MOVE_DOWN, "DOWN", 0, "Down", "Move modifier down in the stack"},
208 {0, nullptr, 0, nullptr, nullptr},
209 };
210
211 /* identifiers */
212 ot->name = "Move Strip Modifier";
213 ot->idname = "SEQUENCER_OT_strip_modifier_move";
214 ot->description = "Move modifier up and down in the stack";
215
216 /* API callbacks. */
219
220 /* flags */
222
223 /* properties */
224 prop = RNA_def_string(ot->srna, "name", "Name", MAX_NAME, "Name", "Name of modifier to remove");
226 prop = RNA_def_enum(ot->srna, "direction", direction_items, SEQ_MODIFIER_MOVE_UP, "Type", "");
228}
229
231
232/* -------------------------------------------------------------------- */
235
236enum {
239};
240
242{
243 Scene *scene = CTX_data_scene(C);
244 Editing *ed = scene->ed;
245 Strip *strip = seq::select_active_get(scene);
246 const int type = RNA_enum_get(op->ptr, "type");
247
248 if (!strip || !strip->modifiers.first) {
249 return OPERATOR_CANCELLED;
250 }
251
252 int isSound = ELEM(strip->type, STRIP_TYPE_SOUND_RAM);
253
255 if (strip_iter->flag & SELECT) {
256 if (strip_iter == strip) {
257 continue;
258 }
259 int strip_iter_is_sound = ELEM(strip_iter->type, STRIP_TYPE_SOUND_RAM);
260 /* If original is sound, only copy to "sound" strips
261 * If original is not sound, only copy to "not sound" strips
262 */
263 if (isSound != strip_iter_is_sound) {
264 continue;
265 }
266
267 if (type == SEQ_MODIFIER_COPY_REPLACE) {
268 if (strip_iter->modifiers.first) {
269 StripModifierData *smd_tmp,
270 *smd = static_cast<StripModifierData *>(strip_iter->modifiers.first);
271 while (smd) {
272 smd_tmp = smd->next;
273 BLI_remlink(&strip_iter->modifiers, smd);
275 smd = smd_tmp;
276 }
277 BLI_listbase_clear(&strip_iter->modifiers);
278 }
279 }
280
281 seq::modifier_list_copy(strip_iter, strip);
282 }
283 }
284
285 if (ELEM(strip->type, STRIP_TYPE_SOUND_RAM)) {
287 }
288 else {
290 }
291
293
294 return OPERATOR_FINISHED;
295}
296
298{
299 static const EnumPropertyItem type_items[] = {
300 {SEQ_MODIFIER_COPY_REPLACE, "REPLACE", 0, "Replace", "Replace modifiers in destination"},
302 "APPEND",
303 0,
304 "Append",
305 "Append active modifiers to selected strips"},
306 {0, nullptr, 0, nullptr, nullptr},
307 };
308
309 /* identifiers */
310 ot->name = "Copy to Selected Strips";
311 ot->idname = "SEQUENCER_OT_strip_modifier_copy";
312 ot->description = "Copy modifiers of the active strip to all selected strips";
313
314 /* API callbacks. */
315 ot->invoke = WM_menu_invoke;
318
319 /* flags */
321
322 /* properties */
323 ot->prop = RNA_def_enum(ot->srna, "type", type_items, SEQ_MODIFIER_COPY_REPLACE, "Type", "");
324}
325
327
328/* -------------------------------------------------------------------- */
331
333{
334 Scene *scene = CTX_data_scene(C);
335 Strip *strip = seq::select_active_get(scene);
337 char name[MAX_NAME];
338 RNA_string_get(op->ptr, "name", name);
339 int number = RNA_enum_get(op->ptr, "graphs");
340
341 smd = seq::modifier_find_by_name(strip, name);
342 if (!smd) {
343 return OPERATOR_CANCELLED;
344 }
345
347
350
351 return OPERATOR_FINISHED;
352}
353
355{
356
357 static const EnumPropertyItem enum_modifier_equalizer_presets_items[] = {
358 {1, "SIMPLE", 0, "Unique", "One unique graphical definition"},
359 {2, "DOUBLE", 0, "Double", "Graphical definition in 2 sections"},
360 {3, "TRIPLE", 0, "Triplet", "Graphical definition in 3 sections"},
361 {0, nullptr, 0, nullptr, nullptr},
362 };
363 PropertyRNA *prop;
364
365 /* identifiers */
366 ot->name = "Redefine Equalizer Graphs";
367 ot->idname = "SEQUENCER_OT_strip_modifier_equalizer_redefine";
368 ot->description = "Redefine equalizer graphs";
369
370 /* API callbacks. */
373
374 /* flags */
376
377 /* properties */
378 prop = RNA_def_enum(
379 ot->srna, "graphs", enum_modifier_equalizer_presets_items, 1, "Graphs", "Number of graphs");
380 ot->prop = prop;
381 prop = RNA_def_string(
382 ot->srna, "name", "Name", MAX_NAME, "Name", "Name of modifier to redefine");
384}
385
387
388} // namespace blender::ed::vse
Scene * CTX_data_scene(const bContext *C)
#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:1040
@ ID_RECALC_SEQUENCER_STRIPS
Definition DNA_ID.h:1030
@ STRIP_TYPE_SOUND_RAM
@ OPERATOR_CANCELLED
@ OPERATOR_FINISHED
@ PROP_HIDDEN
Definition RNA_types.hh:324
#define C
Definition RandGen.cpp:29
#define ND_SEQUENCER
Definition WM_types.hh:434
#define NC_SCENE
Definition WM_types.hh:375
@ OPTYPE_UNDO
Definition WM_types.hh:182
@ OPTYPE_REGISTER
Definition WM_types.hh:180
#define SELECT
#define MAX_NAME
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 *)
static wmOperatorStatus strip_modifier_remove_exec(bContext *C, wmOperator *op)
void SEQUENCER_OT_strip_modifier_remove(wmOperatorType *ot)
void SEQUENCER_OT_strip_modifier_equalizer_redefine(wmOperatorType *ot)
bool sequencer_strip_editable_poll(bContext *C)
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)
void relations_invalidate_cache(Scene *scene, Strip *strip)
StripModifierData * modifier_find_by_name(Strip *strip, const char *name)
Strip * select_active_get(const Scene *scene)
void modifier_free(StripModifierData *smd)
StripModifierData * modifier_new(Strip *strip, const char *name, int type)
void sound_equalizermodifier_set_graphs(SoundEqualizerModifierData *semd, int number)
void modifier_list_copy(Strip *strip_new, Strip *strip)
ListBase * active_seqbase_get(const Editing *ed)
Definition sequencer.cc:420
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: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 Editing * ed
struct StripModifierData * prev
struct StripModifierData * next
ListBase modifiers
struct PointerRNA * ptr
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
wmOperatorType * ot
Definition wm_files.cc:4226
wmOperatorStatus WM_menu_invoke(bContext *C, wmOperator *op, const wmEvent *)