~ubuntu-branches/ubuntu/trusty/blender/trusty

« back to all changes in this revision

Viewing changes to source/blender/editors/space_sequencer/sequencer_modifier.c

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2013-03-06 12:08:47 UTC
  • mfrom: (1.5.1) (14.1.8 experimental)
  • Revision ID: package-import@ubuntu.com-20130306120847-frjfaryb2zrotwcg
Tags: 2.66a-1ubuntu1
* Resynchronize with Debian (LP: #1076930, #1089256, #1052743, #999024,
  #1122888, #1147084)
* debian/control:
  - Lower build-depends on libavcodec-dev since we're not
    doing the libav9 transition in Ubuntu yet

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * ***** BEGIN GPL LICENSE BLOCK *****
 
3
 *
 
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.
 
8
 *
 
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.
 
13
 *
 
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.
 
17
 *
 
18
 * The Original Code is Copyright (C) 2012 Blender Foundation.
 
19
 * All rights reserved.
 
20
 *
 
21
 * Contributor(s): Blender Foundation,
 
22
 *                 Sergey Sharybin
 
23
 *
 
24
 * ***** END GPL LICENSE BLOCK *****
 
25
 */
 
26
 
 
27
 
 
28
/** \file blender/editors/space_sequencer/sequencer_modifier.c
 
29
 *  \ingroup spseq
 
30
 */
 
31
 
 
32
#include "MEM_guardedalloc.h"
 
33
 
 
34
#include "BLI_blenlib.h"
 
35
#include "BLI_math.h"
 
36
#include "BLI_utildefines.h"
 
37
 
 
38
#include "DNA_scene_types.h"
 
39
#include "DNA_mask_types.h"
 
40
#include "DNA_userdef_types.h"
 
41
 
 
42
#include "BKE_context.h"
 
43
#include "BKE_global.h"
 
44
#include "BKE_library.h"
 
45
#include "BKE_main.h"
 
46
#include "BKE_sequencer.h"
 
47
#include "BKE_movieclip.h"
 
48
#include "BKE_sequencer.h"
 
49
#include "BKE_mask.h"
 
50
#include "BKE_report.h"
 
51
 
 
52
#include "WM_api.h"
 
53
#include "WM_types.h"
 
54
 
 
55
#include "RNA_define.h"
 
56
#include "RNA_enum_types.h"
 
57
 
 
58
#include "UI_interface.h"
 
59
#include "UI_resources.h"
 
60
 
 
61
/* own include */
 
62
#include "sequencer_intern.h"
 
63
 
 
64
/*********************** Add modifier operator *************************/
 
65
 
 
66
static int strip_modifier_active_poll(bContext *C)
 
67
{
 
68
        Scene *scene = CTX_data_scene(C);
 
69
        Editing *ed = BKE_sequencer_editing_get(scene, FALSE);
 
70
 
 
71
        if (ed) {
 
72
                Sequence *seq = BKE_sequencer_active_get(scene);
 
73
 
 
74
                if (seq)
 
75
                        return BKE_sequence_supports_modifiers(seq);
 
76
        }
 
77
 
 
78
        return FALSE;
 
79
}
 
80
 
 
81
static int strip_modifier_add_exec(bContext *C, wmOperator *op)
 
82
{
 
83
        Scene *scene = CTX_data_scene(C);
 
84
        Sequence *seq = BKE_sequencer_active_get(scene);
 
85
        int type = RNA_enum_get(op->ptr, "type");
 
86
 
 
87
        BKE_sequence_modifier_new(seq, NULL, type);
 
88
 
 
89
        BKE_sequence_invalidate_cache(scene, seq);
 
90
        WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
 
91
 
 
92
        return OPERATOR_FINISHED;
 
93
}
 
94
 
 
95
void SEQUENCER_OT_strip_modifier_add(wmOperatorType *ot)
 
96
{
 
97
        PropertyRNA *prop;
 
98
 
 
99
        /* identifiers */
 
100
        ot->name = "Add Strip Modifier";
 
101
        ot->idname = "SEQUENCER_OT_strip_modifier_add";
 
102
        ot->description = "Add a modifier to strip";
 
103
 
 
104
        /* api callbacks */
 
105
        ot->exec = strip_modifier_add_exec;
 
106
        ot->poll = strip_modifier_active_poll;
 
107
 
 
108
        /* flags */
 
109
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 
110
 
 
111
        /* properties */
 
112
        prop = RNA_def_enum(ot->srna, "type", sequence_modifier_type_items, seqModifierType_ColorBalance, "Type", "");
 
113
        ot->prop = prop;
 
114
}
 
115
 
 
116
/*********************** Remove modifier operator *************************/
 
117
 
 
118
static int strip_modifier_remove_exec(bContext *C, wmOperator *op)
 
119
{
 
120
        Scene *scene = CTX_data_scene(C);
 
121
        Sequence *seq = BKE_sequencer_active_get(scene);
 
122
        char name[MAX_NAME];
 
123
        SequenceModifierData *smd;
 
124
 
 
125
        RNA_string_get(op->ptr, "name", name);
 
126
 
 
127
        smd = BKE_sequence_modifier_find_by_name(seq, name);
 
128
        if (!smd)
 
129
                return OPERATOR_CANCELLED;
 
130
 
 
131
        BLI_remlink(&seq->modifiers, smd);
 
132
        BKE_sequence_modifier_free(smd);
 
133
 
 
134
        BKE_sequence_invalidate_cache(scene, seq);
 
135
        WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
 
136
 
 
137
        return OPERATOR_FINISHED;
 
138
}
 
139
 
 
140
void SEQUENCER_OT_strip_modifier_remove(wmOperatorType *ot)
 
141
{
 
142
        /* identifiers */
 
143
        ot->name = "Remove Strip Modifier";
 
144
        ot->idname = "SEQUENCER_OT_strip_modifier_remove";
 
145
        ot->description = "Add a modifier to strip";
 
146
 
 
147
        /* api callbacks */
 
148
        ot->exec = strip_modifier_remove_exec;
 
149
        ot->poll = strip_modifier_active_poll;
 
150
 
 
151
        /* flags */
 
152
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 
153
 
 
154
        /* properties */
 
155
        RNA_def_string(ot->srna, "name", "Name", MAX_NAME, "Name", "Name of modifier to remove");
 
156
}
 
157
 
 
158
/*********************** Move operator *************************/
 
159
 
 
160
enum {
 
161
        SEQ_MODIFIER_MOVE_UP = 0,
 
162
        SEQ_MODIFIER_MOVE_DOWN
 
163
};
 
164
 
 
165
static int strip_modifier_move_exec(bContext *C, wmOperator *op)
 
166
{
 
167
        Scene *scene = CTX_data_scene(C);
 
168
        Sequence *seq = BKE_sequencer_active_get(scene);
 
169
        char name[MAX_NAME];
 
170
        int direction;
 
171
        SequenceModifierData *smd;
 
172
 
 
173
        RNA_string_get(op->ptr, "name", name);
 
174
        direction = RNA_enum_get(op->ptr, "direction");
 
175
 
 
176
        smd = BKE_sequence_modifier_find_by_name(seq, name);
 
177
        if (!smd)
 
178
                return OPERATOR_CANCELLED;
 
179
 
 
180
        if (direction == SEQ_MODIFIER_MOVE_UP) {
 
181
                if (smd->prev) {
 
182
                        BLI_remlink(&seq->modifiers, smd);
 
183
                        BLI_insertlink(&seq->modifiers, smd->prev->prev, smd);
 
184
                }
 
185
        }
 
186
        else if (direction == SEQ_MODIFIER_MOVE_DOWN) {
 
187
                if (smd->next) {
 
188
                        BLI_remlink(&seq->modifiers, smd);
 
189
                        BLI_insertlink(&seq->modifiers, smd->next, smd);
 
190
                }
 
191
        }
 
192
 
 
193
        BKE_sequence_invalidate_cache(scene, seq);
 
194
        WM_event_add_notifier(C, NC_SCENE | ND_SEQUENCER, scene);
 
195
 
 
196
        return OPERATOR_FINISHED;
 
197
}
 
198
 
 
199
void SEQUENCER_OT_strip_modifier_move(wmOperatorType *ot)
 
200
{
 
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}
 
205
        };
 
206
 
 
207
        /* identifiers */
 
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";
 
211
 
 
212
        /* api callbacks */
 
213
        ot->exec = strip_modifier_move_exec;
 
214
        ot->poll = strip_modifier_active_poll;
 
215
 
 
216
        /* flags */
 
217
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 
218
 
 
219
        /* properties */
 
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", "");
 
222
}