2
* ***** BEGIN GPL LICENSE BLOCK *****
4
* This program is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU General Public License
6
* as published by the Free Software Foundation; either version 2
7
* of the License, or (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software Foundation,
16
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18
* The Original Code is Copyright (C) 2012 Blender Foundation.
19
* All rights reserved.
21
* Contributor(s): Blender Foundation,
24
* ***** END GPL LICENSE BLOCK *****
28
/** \file blender/editors/space_sequencer/sequencer_modifier.c
32
#include "MEM_guardedalloc.h"
34
#include "BLI_blenlib.h"
36
#include "BLI_utildefines.h"
38
#include "DNA_scene_types.h"
39
#include "DNA_mask_types.h"
40
#include "DNA_userdef_types.h"
42
#include "BKE_context.h"
43
#include "BKE_global.h"
44
#include "BKE_library.h"
46
#include "BKE_sequencer.h"
47
#include "BKE_movieclip.h"
48
#include "BKE_sequencer.h"
50
#include "BKE_report.h"
55
#include "RNA_define.h"
56
#include "RNA_enum_types.h"
58
#include "UI_interface.h"
59
#include "UI_resources.h"
62
#include "sequencer_intern.h"
64
/*********************** Add modifier operator *************************/
66
static int strip_modifier_active_poll(bContext *C)
68
Scene *scene = CTX_data_scene(C);
69
Editing *ed = BKE_sequencer_editing_get(scene, FALSE);
72
Sequence *seq = BKE_sequencer_active_get(scene);
75
return BKE_sequence_supports_modifiers(seq);
81
static int strip_modifier_add_exec(bContext *C, wmOperator *op)
83
Scene *scene = CTX_data_scene(C);
84
Sequence *seq = BKE_sequencer_active_get(scene);
85
int type = RNA_enum_get(op->ptr, "type");
87
BKE_sequence_modifier_new(seq, NULL, type);
89
BKE_sequence_invalidate_cache(scene, seq);
90
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
92
return OPERATOR_FINISHED;
95
void SEQUENCER_OT_strip_modifier_add(wmOperatorType *ot)
100
ot->name = "Add Strip Modifier";
101
ot->idname = "SEQUENCER_OT_strip_modifier_add";
102
ot->description = "Add a modifier to strip";
105
ot->exec = strip_modifier_add_exec;
106
ot->poll = strip_modifier_active_poll;
109
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
112
prop = RNA_def_enum(ot->srna, "type", sequence_modifier_type_items, seqModifierType_ColorBalance, "Type", "");
116
/*********************** Remove modifier operator *************************/
118
static int strip_modifier_remove_exec(bContext *C, wmOperator *op)
120
Scene *scene = CTX_data_scene(C);
121
Sequence *seq = BKE_sequencer_active_get(scene);
123
SequenceModifierData *smd;
125
RNA_string_get(op->ptr, "name", name);
127
smd = BKE_sequence_modifier_find_by_name(seq, name);
129
return OPERATOR_CANCELLED;
131
BLI_remlink(&seq->modifiers, smd);
132
BKE_sequence_modifier_free(smd);
134
BKE_sequence_invalidate_cache(scene, seq);
135
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
137
return OPERATOR_FINISHED;
140
void SEQUENCER_OT_strip_modifier_remove(wmOperatorType *ot)
143
ot->name = "Remove Strip Modifier";
144
ot->idname = "SEQUENCER_OT_strip_modifier_remove";
145
ot->description = "Add a modifier to strip";
148
ot->exec = strip_modifier_remove_exec;
149
ot->poll = strip_modifier_active_poll;
152
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
155
RNA_def_string(ot->srna, "name", "Name", MAX_NAME, "Name", "Name of modifier to remove");
158
/*********************** Move operator *************************/
161
SEQ_MODIFIER_MOVE_UP = 0,
162
SEQ_MODIFIER_MOVE_DOWN
165
static int strip_modifier_move_exec(bContext *C, wmOperator *op)
167
Scene *scene = CTX_data_scene(C);
168
Sequence *seq = BKE_sequencer_active_get(scene);
171
SequenceModifierData *smd;
173
RNA_string_get(op->ptr, "name", name);
174
direction = RNA_enum_get(op->ptr, "direction");
176
smd = BKE_sequence_modifier_find_by_name(seq, name);
178
return OPERATOR_CANCELLED;
180
if (direction == SEQ_MODIFIER_MOVE_UP) {
182
BLI_remlink(&seq->modifiers, smd);
183
BLI_insertlink(&seq->modifiers, smd->prev->prev, smd);
186
else if (direction == SEQ_MODIFIER_MOVE_DOWN) {
188
BLI_remlink(&seq->modifiers, smd);
189
BLI_insertlink(&seq->modifiers, smd->next, smd);
193
BKE_sequence_invalidate_cache(scene, seq);
194
WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
196
return OPERATOR_FINISHED;
199
void SEQUENCER_OT_strip_modifier_move(wmOperatorType *ot)
201
static EnumPropertyItem direction_items[] = {
202
{SEQ_MODIFIER_MOVE_UP, "UP", 0, "Up", "Move modifier up in the stack"},
203
{SEQ_MODIFIER_MOVE_DOWN, "DOWN", 0, "Down", "Move modifier down in the stack"},
204
{0, NULL, 0, NULL, NULL}
208
ot->name = "Move Strip Modifier";
209
ot->idname = "SEQUENCER_OT_strip_modifier_move";
210
ot->description = "Move modifier up and down in the stack";
213
ot->exec = strip_modifier_move_exec;
214
ot->poll = strip_modifier_active_poll;
217
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
220
RNA_def_string(ot->srna, "name", "Name", MAX_NAME, "Name", "Name of modifier to remove");
221
RNA_def_enum(ot->srna, "direction", direction_items, SEQ_MODIFIER_MOVE_UP, "Type", "");