Blender  V3.3
sequencer_modifier.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2012 Blender Foundation. All rights reserved. */
3 
8 #include "BLI_blenlib.h"
9 #include "BLI_utildefines.h"
10 
11 #include "DNA_scene_types.h"
12 
13 #include "BKE_context.h"
14 
15 #include "WM_api.h"
16 #include "WM_types.h"
17 
18 #include "RNA_define.h"
19 #include "RNA_enum_types.h"
20 
21 #include "SEQ_iterator.h"
22 #include "SEQ_modifier.h"
23 #include "SEQ_relations.h"
24 #include "SEQ_select.h"
25 #include "SEQ_sequencer.h"
26 
27 /* Own include. */
28 #include "sequencer_intern.h"
29 
30 /*********************** Add modifier operator *************************/
31 
33 {
36 
37  if (ed) {
39 
40  if (seq) {
42  }
43  }
44 
45  return false;
46 }
47 
49 {
52  int type = RNA_enum_get(op->ptr, "type");
53 
54  SEQ_modifier_new(seq, NULL, type);
55 
58 
59  return OPERATOR_FINISHED;
60 }
61 
63 {
64  PropertyRNA *prop;
65 
66  /* identifiers */
67  ot->name = "Add Strip Modifier";
68  ot->idname = "SEQUENCER_OT_strip_modifier_add";
69  ot->description = "Add a modifier to the strip";
70 
71  /* api callbacks */
74 
75  /* flags */
77 
78  /* properties */
79  prop = RNA_def_enum(ot->srna,
80  "type",
83  "Type",
84  "");
85  ot->prop = prop;
86 }
87 
88 /*********************** Remove modifier operator *************************/
89 
91 {
94  char name[MAX_NAME];
96 
97  RNA_string_get(op->ptr, "name", name);
98 
99  smd = SEQ_modifier_find_by_name(seq, name);
100  if (!smd) {
101  return OPERATOR_CANCELLED;
102  }
103 
104  BLI_remlink(&seq->modifiers, smd);
105  SEQ_modifier_free(smd);
106 
109 
110  return OPERATOR_FINISHED;
111 }
112 
114 {
115  PropertyRNA *prop;
116 
117  /* identifiers */
118  ot->name = "Remove Strip Modifier";
119  ot->idname = "SEQUENCER_OT_strip_modifier_remove";
120  ot->description = "Remove a modifier from the strip";
121 
122  /* api callbacks */
125 
126  /* flags */
128 
129  /* properties */
130  prop = RNA_def_string(ot->srna, "name", "Name", MAX_NAME, "Name", "Name of modifier to remove");
132 }
133 
134 /*********************** Move operator *************************/
135 
136 enum {
139 };
140 
142 {
145  char name[MAX_NAME];
146  int direction;
148 
149  RNA_string_get(op->ptr, "name", name);
150  direction = RNA_enum_get(op->ptr, "direction");
151 
152  smd = SEQ_modifier_find_by_name(seq, name);
153  if (!smd) {
154  return OPERATOR_CANCELLED;
155  }
156 
157  if (direction == SEQ_MODIFIER_MOVE_UP) {
158  if (smd->prev) {
159  BLI_remlink(&seq->modifiers, smd);
160  BLI_insertlinkbefore(&seq->modifiers, smd->prev, smd);
161  }
162  }
163  else if (direction == SEQ_MODIFIER_MOVE_DOWN) {
164  if (smd->next) {
165  BLI_remlink(&seq->modifiers, smd);
166  BLI_insertlinkafter(&seq->modifiers, smd->next, smd);
167  }
168  }
169 
172 
173  return OPERATOR_FINISHED;
174 }
175 
177 {
178  PropertyRNA *prop;
179 
180  static const EnumPropertyItem direction_items[] = {
181  {SEQ_MODIFIER_MOVE_UP, "UP", 0, "Up", "Move modifier up in the stack"},
182  {SEQ_MODIFIER_MOVE_DOWN, "DOWN", 0, "Down", "Move modifier down in the stack"},
183  {0, NULL, 0, NULL, NULL},
184  };
185 
186  /* identifiers */
187  ot->name = "Move Strip Modifier";
188  ot->idname = "SEQUENCER_OT_strip_modifier_move";
189  ot->description = "Move modifier up and down in the stack";
190 
191  /* api callbacks */
194 
195  /* flags */
197 
198  /* properties */
199  prop = RNA_def_string(ot->srna, "name", "Name", MAX_NAME, "Name", "Name of modifier to remove");
201  prop = RNA_def_enum(ot->srna, "direction", direction_items, SEQ_MODIFIER_MOVE_UP, "Type", "");
203 }
204 
205 /*********************** Copy to selected operator *************************/
206 
207 enum {
210 };
211 
213 {
215  Editing *ed = scene->ed;
217  const int type = RNA_enum_get(op->ptr, "type");
218 
219  if (!seq || !seq->modifiers.first) {
220  return OPERATOR_CANCELLED;
221  }
222 
224  if (seq_iter->flag & SELECT) {
225  if (seq_iter == seq) {
226  continue;
227  }
228 
230  if (seq_iter->modifiers.first) {
231  SequenceModifierData *smd_tmp, *smd = seq_iter->modifiers.first;
232  while (smd) {
233  smd_tmp = smd->next;
234  BLI_remlink(&seq_iter->modifiers, smd);
235  SEQ_modifier_free(smd);
236  smd = smd_tmp;
237  }
238  BLI_listbase_clear(&seq_iter->modifiers);
239  }
240  }
241 
242  SEQ_modifier_list_copy(seq_iter, seq);
243  }
244  }
245 
248 
249  return OPERATOR_FINISHED;
250 }
251 
253 {
254  static const EnumPropertyItem type_items[] = {
255  {SEQ_MODIFIER_COPY_REPLACE, "REPLACE", 0, "Replace", "Replace modifiers in destination"},
257  "APPEND",
258  0,
259  "Append",
260  "Append active modifiers to selected strips"},
261  {0, NULL, 0, NULL, NULL},
262  };
263 
264  /* identifiers */
265  ot->name = "Copy to Selected Strips";
266  ot->idname = "SEQUENCER_OT_strip_modifier_copy";
267  ot->description = "Copy modifiers of the active strip to all selected strips";
268 
269  /* api callbacks */
273 
274  /* flags */
276 
277  /* properties */
278  ot->prop = RNA_def_enum(ot->srna, "type", type_items, SEQ_MODIFIER_COPY_REPLACE, "Type", "");
279 }
struct Scene * CTX_data_scene(const bContext *C)
Definition: context.c:1090
#define LISTBASE_FOREACH(type, var, list)
Definition: BLI_listbase.h:336
BLI_INLINE void BLI_listbase_clear(struct ListBase *lb)
Definition: BLI_listbase.h:273
void BLI_insertlinkafter(struct ListBase *listbase, void *vprevlink, void *vnewlink) ATTR_NONNULL(1)
Definition: listbase.c:301
void BLI_remlink(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:100
void BLI_insertlinkbefore(struct ListBase *listbase, void *vnextlink, void *vnewlink) ATTR_NONNULL(1)
Definition: listbase.c:340
#define MAX_NAME
Definition: DNA_defs.h:48
@ seqModifierType_ColorBalance
@ OPERATOR_CANCELLED
@ OPERATOR_FINISHED
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
@ PROP_HIDDEN
Definition: RNA_types.h:216
#define C
Definition: RandGen.cpp:25
#define ND_SEQUENCER
Definition: WM_types.h:385
@ OPTYPE_UNDO
Definition: WM_types.h:148
@ OPTYPE_REGISTER
Definition: WM_types.h:146
#define NC_SCENE
Definition: WM_types.h:328
#define SELECT
Scene scene
void RNA_string_get(PointerRNA *ptr, const char *name, char *value)
Definition: rna_access.c:5116
int RNA_enum_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:5004
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, int maxlen, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3687
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
Definition: rna_define.c:1490
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, int default_value, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3783
const EnumPropertyItem rna_enum_sequence_modifier_type_items[]
Definition: rna_sequencer.c:63
SequenceModifierData * SEQ_modifier_new(Sequence *seq, const char *name, int type)
void SEQ_modifier_free(SequenceModifierData *smd)
SequenceModifierData * SEQ_modifier_find_by_name(Sequence *seq, const char *name)
void SEQ_modifier_list_copy(Sequence *seqn, Sequence *seq)
int SEQ_sequence_supports_modifiers(Sequence *seq)
ListBase * SEQ_active_seqbase_get(const Editing *ed)
Definition: sequencer.c:388
Editing * SEQ_editing_get(const Scene *scene)
Definition: sequencer.c:241
static int strip_modifier_remove_exec(bContext *C, wmOperator *op)
@ SEQ_MODIFIER_COPY_REPLACE
@ SEQ_MODIFIER_COPY_APPEND
void SEQUENCER_OT_strip_modifier_add(wmOperatorType *ot)
static bool strip_modifier_active_poll(bContext *C)
static int strip_modifier_copy_exec(bContext *C, wmOperator *op)
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)
@ SEQ_MODIFIER_MOVE_UP
@ SEQ_MODIFIER_MOVE_DOWN
void SEQUENCER_OT_strip_modifier_move(wmOperatorType *ot)
void SEQ_relations_invalidate_cache_preprocessed(Scene *scene, Sequence *seq)
Sequence * SEQ_select_active_get(Scene *scene)
Definition: strip_select.c:18
void * first
Definition: DNA_listBase.h:31
struct Editing * ed
struct SequenceModifierData * next
struct SequenceModifierData * prev
ListBase modifiers
int(* invoke)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:919
const char * name
Definition: WM_types.h:888
const char * idname
Definition: WM_types.h:890
bool(* poll)(struct bContext *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:943
struct StructRNA * srna
Definition: WM_types.h:969
const char * description
Definition: WM_types.h:893
int(* exec)(struct bContext *, struct wmOperator *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:903
PropertyRNA * prop
Definition: WM_types.h:981
struct PointerRNA * ptr
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
wmOperatorType * ot
Definition: wm_files.c:3479
int WM_menu_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))