sequencer clipboard
[blender.git] / source / blender / editors / space_sequencer / sequencer_ops.c
1
2 /**
3  * $Id:
4  *
5  * ***** BEGIN GPL LICENSE BLOCK *****
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software Foundation,
19  * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
20  *
21  * The Original Code is Copyright (C) 2008 Blender Foundation.
22  * All rights reserved.
23  *
24  *
25  * Contributor(s): Blender Foundation
26  *
27  * ***** END GPL LICENSE BLOCK *****
28  */
29
30 #include <stdlib.h>
31 #include <math.h>
32
33 #include "MEM_guardedalloc.h"
34
35 #include "DNA_scene_types.h"
36 #include "DNA_screen_types.h"
37 #include "DNA_space_types.h"
38 #include "DNA_userdef_types.h"
39 #include "DNA_windowmanager_types.h"
40
41 #include "BLI_math.h"
42 #include "BLI_blenlib.h"
43
44 #include "BKE_context.h"
45 #include "BKE_global.h"
46 #include "BKE_utildefines.h"
47
48 #include "RNA_access.h"
49 #include "RNA_define.h"
50
51 #include "WM_api.h"
52 #include "WM_types.h"
53
54 #include "ED_screen.h"
55 #include "ED_transform.h" /* transform keymap */
56
57 #include "sequencer_intern.h"
58
59
60 /* ************************** registration **********************************/
61
62
63 void sequencer_operatortypes(void)
64 {
65         /* sequencer_edit.c */
66         WM_operatortype_append(SEQUENCER_OT_cut);
67         WM_operatortype_append(SEQUENCER_OT_mute);
68         WM_operatortype_append(SEQUENCER_OT_unmute);
69         WM_operatortype_append(SEQUENCER_OT_lock);
70         WM_operatortype_append(SEQUENCER_OT_unlock);
71         WM_operatortype_append(SEQUENCER_OT_reload);
72         WM_operatortype_append(SEQUENCER_OT_refresh_all);
73         WM_operatortype_append(SEQUENCER_OT_duplicate);
74         WM_operatortype_append(SEQUENCER_OT_delete);
75         WM_operatortype_append(SEQUENCER_OT_images_separate);
76         WM_operatortype_append(SEQUENCER_OT_meta_toggle);
77         WM_operatortype_append(SEQUENCER_OT_meta_make);
78         WM_operatortype_append(SEQUENCER_OT_meta_separate);
79         WM_operatortype_append(SEQUENCER_OT_snap);
80         WM_operatortype_append(SEQUENCER_OT_next_edit);
81         WM_operatortype_append(SEQUENCER_OT_previous_edit);
82         WM_operatortype_append(SEQUENCER_OT_swap);
83         WM_operatortype_append(SEQUENCER_OT_rendersize);
84
85         WM_operatortype_append(SEQUENCER_OT_view_all);
86         WM_operatortype_append(SEQUENCER_OT_view_selected);
87         WM_operatortype_append(SEQUENCER_OT_view_all_preview);
88         WM_operatortype_append(SEQUENCER_OT_view_toggle);
89
90         /* sequencer_select.c */
91         WM_operatortype_append(SEQUENCER_OT_select_all_toggle);
92         WM_operatortype_append(SEQUENCER_OT_select_inverse);
93         WM_operatortype_append(SEQUENCER_OT_select);
94         WM_operatortype_append(SEQUENCER_OT_select_more);
95         WM_operatortype_append(SEQUENCER_OT_select_less);
96         WM_operatortype_append(SEQUENCER_OT_select_linked_pick);
97         WM_operatortype_append(SEQUENCER_OT_select_linked);
98         WM_operatortype_append(SEQUENCER_OT_select_handles);
99         WM_operatortype_append(SEQUENCER_OT_select_active_side);
100         WM_operatortype_append(SEQUENCER_OT_select_border);
101         
102         /* sequencer_add.c */
103         WM_operatortype_append(SEQUENCER_OT_scene_strip_add);
104         WM_operatortype_append(SEQUENCER_OT_movie_strip_add);
105         WM_operatortype_append(SEQUENCER_OT_sound_strip_add);
106         WM_operatortype_append(SEQUENCER_OT_image_strip_add);
107         WM_operatortype_append(SEQUENCER_OT_effect_strip_add);
108         WM_operatortype_append(SEQUENCER_OT_properties);
109
110         WM_operatortype_append(SEQUENCER_OT_copy);
111         WM_operatortype_append(SEQUENCER_OT_paste);
112 }
113
114
115 void sequencer_keymap(wmKeyConfig *keyconf)
116 {
117         wmKeyMap *keymap= WM_keymap_find(keyconf, "SequencerCommon", SPACE_SEQ, 0);
118         wmKeyMapItem *kmi;
119
120         /* operators common to sequence and preview view */
121         WM_keymap_add_item(keymap, "SEQUENCER_OT_view_toggle", TABKEY, KM_PRESS, KM_CTRL, 0);
122
123         /* operators for sequence */
124         keymap= WM_keymap_find(keyconf, "Sequencer", SPACE_SEQ, 0);
125         WM_keymap_add_item(keymap, "SEQUENCER_OT_properties", NKEY, KM_PRESS, 0, 0);
126         
127         WM_keymap_add_item(keymap, "SEQUENCER_OT_select_all_toggle", AKEY, KM_PRESS, 0, 0);
128         WM_keymap_add_item(keymap, "SEQUENCER_OT_select_inverse", IKEY, KM_PRESS, KM_CTRL, 0);
129         
130         RNA_enum_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_cut", KKEY, KM_PRESS, 0, 0)->ptr, "type", SEQ_CUT_SOFT);
131         RNA_enum_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_cut", KKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "type", SEQ_CUT_HARD);
132         
133         WM_keymap_add_item(keymap, "SEQUENCER_OT_mute", HKEY, KM_PRESS, 0, 0);
134         RNA_boolean_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_mute", HKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "unselected", 1);
135         
136         WM_keymap_add_item(keymap, "SEQUENCER_OT_unmute", HKEY, KM_PRESS, KM_ALT, 0);
137         RNA_boolean_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_unmute", HKEY, KM_PRESS, KM_ALT|KM_SHIFT, 0)->ptr, "unselected", 1);
138
139         WM_keymap_add_item(keymap, "SEQUENCER_OT_lock", LKEY, KM_PRESS, KM_SHIFT, 0);
140         WM_keymap_add_item(keymap, "SEQUENCER_OT_unlock", LKEY, KM_PRESS, KM_SHIFT|KM_ALT, 0);
141
142         WM_keymap_add_item(keymap, "SEQUENCER_OT_reload", RKEY, KM_PRESS, KM_ALT, 0);
143
144         WM_keymap_add_item(keymap, "SEQUENCER_OT_duplicate", DKEY, KM_PRESS, KM_SHIFT, 0);
145
146         WM_keymap_add_item(keymap, "SEQUENCER_OT_delete", XKEY, KM_PRESS, 0, 0);
147         WM_keymap_add_item(keymap, "SEQUENCER_OT_delete", DELKEY, KM_PRESS, 0, 0);
148         
149         WM_keymap_add_item(keymap, "SEQUENCER_OT_images_separate", YKEY, KM_PRESS, 0, 0);
150
151         WM_keymap_add_item(keymap, "SEQUENCER_OT_meta_toggle", TABKEY, KM_PRESS, 0, 0);
152
153         WM_keymap_add_item(keymap, "SEQUENCER_OT_meta_make", MKEY, KM_PRESS, 0, 0);
154         WM_keymap_add_item(keymap, "SEQUENCER_OT_meta_separate", MKEY, KM_PRESS, KM_ALT, 0);
155
156         WM_keymap_add_item(keymap, "SEQUENCER_OT_view_all", HOMEKEY, KM_PRESS, 0, 0);
157         WM_keymap_add_item(keymap, "SEQUENCER_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0);
158
159         WM_keymap_add_item(keymap, "SEQUENCER_OT_next_edit", PAGEUPKEY, KM_PRESS, 0, 0);
160         WM_keymap_add_item(keymap, "SEQUENCER_OT_previous_edit", PAGEDOWNKEY, KM_PRESS, 0, 0);
161
162         RNA_enum_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_swap", LEFTARROWKEY, KM_PRESS, KM_ALT, 0)->ptr, "side", SEQ_SIDE_LEFT);
163         RNA_enum_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_swap", RIGHTARROWKEY, KM_PRESS, KM_ALT, 0)->ptr, "side", SEQ_SIDE_RIGHT);
164         
165         WM_keymap_add_item(keymap, "SEQUENCER_OT_snap", SKEY, KM_PRESS, KM_SHIFT, 0);
166         
167
168         /* Mouse selection, a bit verbose :/ */
169         WM_keymap_add_item(keymap, "SEQUENCER_OT_select", SELECTMOUSE, KM_PRESS, 0, 0);
170         RNA_boolean_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "extend", 1);
171
172
173         /* 2.4x method, now use Alt for handles and select the side based on which handle was selected */
174         /*
175         RNA_boolean_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_select", SELECTMOUSE, KM_PRESS, KM_CTRL, 0)->ptr, "linked_left", 1);
176         RNA_boolean_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_select", SELECTMOUSE, KM_PRESS, KM_ALT, 0)->ptr, "linked_right", 1);
177         
178         kmi= WM_keymap_add_item(keymap, "SEQUENCER_OT_select", SELECTMOUSE, KM_PRESS, KM_CTRL|KM_ALT, 0);
179         RNA_boolean_set(kmi->ptr, "linked_left", 1);
180         RNA_boolean_set(kmi->ptr, "linked_right", 1);
181
182         kmi= WM_keymap_add_item(keymap, "SEQUENCER_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT|KM_CTRL|KM_ALT, 0);
183         RNA_boolean_set(kmi->ptr, "extend", 1);
184         RNA_boolean_set(kmi->ptr, "linked_left", 1);
185         RNA_boolean_set(kmi->ptr, "linked_right", 1);
186
187         kmi= WM_keymap_add_item(keymap, "SEQUENCER_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT|KM_CTRL, 0);
188         RNA_boolean_set(kmi->ptr, "extend", 1);
189         RNA_boolean_set(kmi->ptr, "linked_left", 1);
190
191         kmi= WM_keymap_add_item(keymap, "SEQUENCER_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT|KM_ALT, 0);
192         RNA_boolean_set(kmi->ptr, "extend", 1);
193         RNA_boolean_set(kmi->ptr, "linked_right", 1);
194          */
195
196         /* 2.5 method, Alt and use selected handle */
197         RNA_boolean_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_select", SELECTMOUSE, KM_PRESS, KM_ALT, 0)->ptr, "linked_handle", 1);
198
199         kmi= WM_keymap_add_item(keymap, "SEQUENCER_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT|KM_ALT, 0);
200         RNA_boolean_set(kmi->ptr, "extend", 1);
201         RNA_boolean_set(kmi->ptr, "linked_handle", 1);
202
203         /* match action editor */
204         kmi= WM_keymap_add_item(keymap, "SEQUENCER_OT_select", SELECTMOUSE, KM_PRESS, KM_CTRL, 0);
205         RNA_boolean_set(kmi->ptr, "left_right", 1); /* grr, these conflict - only use left_right if not over an active seq */
206         RNA_boolean_set(kmi->ptr, "linked_time", 1);
207         /* adjusted since 2.4 */
208
209         kmi= WM_keymap_add_item(keymap, "SEQUENCER_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT|KM_CTRL, 0);
210         RNA_boolean_set(kmi->ptr, "extend", 1);
211         RNA_boolean_set(kmi->ptr, "linked_time", 1);
212
213         WM_keymap_add_item(keymap, "SEQUENCER_OT_select_more", PADPLUSKEY, KM_PRESS, KM_CTRL, 0);
214         WM_keymap_add_item(keymap, "SEQUENCER_OT_select_less", PADMINUS, KM_PRESS, KM_CTRL, 0);
215         
216         WM_keymap_add_item(keymap, "SEQUENCER_OT_select_linked_pick", LKEY, KM_PRESS, 0, 0);
217         RNA_boolean_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_select_linked_pick", LKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "extend", 1);
218         
219         WM_keymap_add_item(keymap, "SEQUENCER_OT_select_linked", LKEY, KM_PRESS, KM_CTRL, 0);
220         
221         WM_keymap_add_item(keymap, "SEQUENCER_OT_select_border", BKEY, KM_PRESS, 0, 0);
222
223         WM_keymap_add_menu(keymap, "SEQUENCER_MT_add", AKEY, KM_PRESS, KM_SHIFT, 0);
224         
225         transform_keymap_for_space(keyconf, keymap, SPACE_SEQ);
226
227         keymap= WM_keymap_find(keyconf, "SequencerPreview", SPACE_SEQ, 0);
228         WM_keymap_add_item(keymap, "SEQUENCER_OT_view_all_preview", HOMEKEY, KM_PRESS, 0, 0);
229 }
230