Blender  V2.93
sequencer_modifier.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2012 Blender Foundation.
17  * All rights reserved.
18  */
19 
24 #include "BLI_blenlib.h"
25 #include "BLI_utildefines.h"
26 
27 #include "DNA_scene_types.h"
28 
29 #include "BKE_context.h"
30 
31 #include "WM_api.h"
32 #include "WM_types.h"
33 
34 #include "RNA_define.h"
35 #include "RNA_enum_types.h"
36 
37 #include "SEQ_iterator.h"
38 #include "SEQ_modifier.h"
39 #include "SEQ_relations.h"
40 #include "SEQ_select.h"
41 #include "SEQ_sequencer.h"
42 
43 /* Own include. */
44 #include "sequencer_intern.h"
45 
46 /*********************** Add modifier operator *************************/
47 
49 {
51  Editing *ed = SEQ_editing_get(scene, false);
52 
53  if (ed) {
55 
56  if (seq) {
58  }
59  }
60 
61  return false;
62 }
63 
65 {
68  int type = RNA_enum_get(op->ptr, "type");
69 
70  SEQ_modifier_new(seq, NULL, type);
71 
74 
75  return OPERATOR_FINISHED;
76 }
77 
79 {
80  PropertyRNA *prop;
81 
82  /* identifiers */
83  ot->name = "Add Strip Modifier";
84  ot->idname = "SEQUENCER_OT_strip_modifier_add";
85  ot->description = "Add a modifier to the strip";
86 
87  /* api callbacks */
90 
91  /* flags */
93 
94  /* properties */
95  prop = RNA_def_enum(ot->srna,
96  "type",
99  "Type",
100  "");
101  ot->prop = prop;
102 }
103 
104 /*********************** Remove modifier operator *************************/
105 
107 {
110  char name[MAX_NAME];
112 
113  RNA_string_get(op->ptr, "name", name);
114 
115  smd = SEQ_modifier_find_by_name(seq, name);
116  if (!smd) {
117  return OPERATOR_CANCELLED;
118  }
119 
120  BLI_remlink(&seq->modifiers, smd);
121  SEQ_modifier_free(smd);
122 
125 
126  return OPERATOR_FINISHED;
127 }
128 
130 {
131  PropertyRNA *prop;
132 
133  /* identifiers */
134  ot->name = "Remove Strip Modifier";
135  ot->idname = "SEQUENCER_OT_strip_modifier_remove";
136  ot->description = "Remove a modifier from the strip";
137 
138  /* api callbacks */
141 
142  /* flags */
144 
145  /* properties */
146  prop = RNA_def_string(ot->srna, "name", "Name", MAX_NAME, "Name", "Name of modifier to remove");
148 }
149 
150 /*********************** Move operator *************************/
151 
152 enum {
155 };
156 
158 {
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 
188 
189  return OPERATOR_FINISHED;
190 }
191 
193 {
194  PropertyRNA *prop;
195 
196  static const EnumPropertyItem direction_items[] = {
197  {SEQ_MODIFIER_MOVE_UP, "UP", 0, "Up", "Move modifier up in the stack"},
198  {SEQ_MODIFIER_MOVE_DOWN, "DOWN", 0, "Down", "Move modifier down in the stack"},
199  {0, NULL, 0, NULL, NULL},
200  };
201 
202  /* identifiers */
203  ot->name = "Move Strip Modifier";
204  ot->idname = "SEQUENCER_OT_strip_modifier_move";
205  ot->description = "Move modifier up and down in the stack";
206 
207  /* api callbacks */
210 
211  /* flags */
213 
214  /* properties */
215  prop = RNA_def_string(ot->srna, "name", "Name", MAX_NAME, "Name", "Name of modifier to remove");
217  prop = RNA_def_enum(ot->srna, "direction", direction_items, SEQ_MODIFIER_MOVE_UP, "Type", "");
219 }
220 
221 /*********************** Copy to selected operator *************************/
222 
223 enum {
226 };
227 
229 {
231  Editing *ed = scene->ed;
233  const int type = RNA_enum_get(op->ptr, "type");
234 
235  if (!seq || !seq->modifiers.first) {
236  return OPERATOR_CANCELLED;
237  }
238 
240  if (seq_iter->flag & SELECT) {
241  if (seq_iter == seq) {
242  continue;
243  }
244 
246  if (seq_iter->modifiers.first) {
247  SequenceModifierData *smd_tmp, *smd = seq_iter->modifiers.first;
248  while (smd) {
249  smd_tmp = smd->next;
250  BLI_remlink(&seq_iter->modifiers, smd);
251  SEQ_modifier_free(smd);
252  smd = smd_tmp;
253  }
254  BLI_listbase_clear(&seq_iter->modifiers);
255  }
256  }
257 
258  SEQ_modifier_list_copy(seq_iter, seq);
259  }
260  }
261 
264 
265  return OPERATOR_FINISHED;
266 }
267 
269 {
270  static const EnumPropertyItem type_items[] = {
271  {SEQ_MODIFIER_COPY_REPLACE, "REPLACE", 0, "Replace", "Replace modifiers in destination"},
273  "APPEND",
274  0,
275  "Append",
276  "Append active modifiers to selected strips"},
277  {0, NULL, 0, NULL, NULL},
278  };
279 
280  /* identifiers */
281  ot->name = "Copy to Selected Strips";
282  ot->idname = "SEQUENCER_OT_strip_modifier_copy";
283  ot->description = "Copy modifiers of the active strip to all selected strips";
284 
285  /* api callbacks */
289 
290  /* flags */
292 
293  /* properties */
294  ot->prop = RNA_def_enum(ot->srna, "type", type_items, SEQ_MODIFIER_COPY_REPLACE, "Type", "");
295 }
struct Scene * CTX_data_scene(const bContext *C)
Definition: context.c:1034
#define LISTBASE_FOREACH(type, var, list)
Definition: BLI_listbase.h:172
BLI_INLINE void BLI_listbase_clear(struct ListBase *lb)
Definition: BLI_listbase.h:128
void BLI_insertlinkafter(struct ListBase *listbase, void *vprevlink, void *vnewlink) ATTR_NONNULL(1)
Definition: listbase.c:352
void BLI_remlink(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:133
void BLI_insertlinkbefore(struct ListBase *listbase, void *vnextlink, void *vnewlink) ATTR_NONNULL(1)
Definition: listbase.c:395
#define MAX_NAME
Definition: DNA_defs.h:62
@ 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:202
#define C
Definition: RandGen.cpp:39
#define ND_SEQUENCER
Definition: WM_types.h:337
@ OPTYPE_UNDO
Definition: WM_types.h:155
@ OPTYPE_REGISTER
Definition: WM_types.h:153
#define NC_SCENE
Definition: WM_types.h:279
#define SELECT
Scene scene
void RNA_string_get(PointerRNA *ptr, const char *name, char *value)
Definition: rna_access.c:6514
int RNA_enum_get(PointerRNA *ptr, const char *name)
Definition: rna_access.c:6402
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:3675
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
Definition: rna_define.c:1512
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:3771
const EnumPropertyItem rna_enum_sequence_modifier_type_items[]
Definition: rna_sequencer.c:72
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:350
Editing * SEQ_editing_get(Scene *scene, bool alloc)
Definition: sequencer.c:232
static int strip_modifier_remove_exec(bContext *C, wmOperator *op)
@ SEQ_MODIFIER_MOVE_UP
@ SEQ_MODIFIER_MOVE_DOWN
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)
@ SEQ_MODIFIER_COPY_REPLACE
@ SEQ_MODIFIER_COPY_APPEND
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(Scene *scene)
Definition: strip_select.c:35
void * first
Definition: DNA_listBase.h:47
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:752
const char * name
Definition: WM_types.h:721
const char * idname
Definition: WM_types.h:723
bool(* poll)(struct bContext *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:776
struct StructRNA * srna
Definition: WM_types.h:802
const char * description
Definition: WM_types.h:726
int(* exec)(struct bContext *, struct wmOperator *) ATTR_WARN_UNUSED_RESULT
Definition: WM_types.h:736
PropertyRNA * prop
Definition: WM_types.h:814
struct PointerRNA * ptr
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
wmOperatorType * ot
Definition: wm_files.c:3156
int WM_menu_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
Definition: wm_operators.c:982