patch from Xavier Thomas, add back the sequencer snap operator
[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_arithb.h"
42 #include "BLI_blenlib.h"
43
44 #include "BIF_transform.h" /* transform keymap */
45
46 #include "BKE_context.h"
47 #include "BKE_global.h"
48 #include "BKE_utildefines.h"
49
50 #include "RNA_access.h"
51 #include "RNA_define.h"
52
53 #include "WM_api.h"
54 #include "WM_types.h"
55
56 #include "ED_screen.h"
57
58 #include "sequencer_intern.h"
59
60
61 /* ************************** registration **********************************/
62
63
64 void sequencer_operatortypes(void)
65 {
66         /* sequencer_edit.c */
67         WM_operatortype_append(SEQUENCER_OT_cut);
68         WM_operatortype_append(SEQUENCER_OT_mute);
69         WM_operatortype_append(SEQUENCER_OT_unmute);
70         WM_operatortype_append(SEQUENCER_OT_lock);
71         WM_operatortype_append(SEQUENCER_OT_unlock);
72         WM_operatortype_append(SEQUENCER_OT_reload);
73         WM_operatortype_append(SEQUENCER_OT_refresh_all);
74         WM_operatortype_append(SEQUENCER_OT_duplicate_add);
75         WM_operatortype_append(SEQUENCER_OT_delete);
76         WM_operatortype_append(SEQUENCER_OT_images_separate);
77         WM_operatortype_append(SEQUENCER_OT_meta_toggle);
78         WM_operatortype_append(SEQUENCER_OT_meta_make);
79         WM_operatortype_append(SEQUENCER_OT_meta_separate);
80         WM_operatortype_append(SEQUENCER_OT_snap);
81
82         WM_operatortype_append(SEQUENCER_OT_view_all);
83         WM_operatortype_append(SEQUENCER_OT_view_selected);
84         
85         /* sequencer_select.c */
86         WM_operatortype_append(SEQUENCER_OT_select_all_toggle);
87         WM_operatortype_append(SEQUENCER_OT_select_invert);
88         WM_operatortype_append(SEQUENCER_OT_select);
89         WM_operatortype_append(SEQUENCER_OT_select_more);
90         WM_operatortype_append(SEQUENCER_OT_select_less);
91         WM_operatortype_append(SEQUENCER_OT_select_linked_pick);
92         WM_operatortype_append(SEQUENCER_OT_select_linked);
93         WM_operatortype_append(SEQUENCER_OT_select_handles);
94         WM_operatortype_append(SEQUENCER_OT_select_active_side);
95         WM_operatortype_append(SEQUENCER_OT_select_border);
96         
97         /* sequencer_add.c */
98         WM_operatortype_append(SEQUENCER_OT_scene_strip_add);
99         WM_operatortype_append(SEQUENCER_OT_movie_strip_add);
100         WM_operatortype_append(SEQUENCER_OT_sound_strip_add);
101         WM_operatortype_append(SEQUENCER_OT_image_strip_add);
102         WM_operatortype_append(SEQUENCER_OT_effect_strip_add);
103         WM_operatortype_append(SEQUENCER_OT_properties);
104 }
105
106
107 void sequencer_keymap(wmWindowManager *wm)
108 {
109         ListBase *keymap= WM_keymap_listbase(wm, "Sequencer", SPACE_SEQ, 0);
110         wmKeymapItem *kmi;
111         
112         WM_keymap_add_item(keymap, "SEQUENCER_OT_properties", NKEY, KM_PRESS, 0, 0);
113         
114         WM_keymap_add_item(keymap, "SEQUENCER_OT_select_all_toggle", AKEY, KM_PRESS, 0, 0);
115         WM_keymap_add_item(keymap, "SEQUENCER_OT_select_invert", IKEY, KM_PRESS, KM_CTRL, 0);
116         
117         RNA_enum_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_cut", KKEY, KM_PRESS, 0, 0)->ptr, "type", SEQ_CUT_SOFT);
118         RNA_enum_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_cut", KKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "type", SEQ_CUT_HARD);
119         
120         RNA_enum_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_mute", HKEY, KM_PRESS, 0, 0)->ptr, "type", SEQ_SELECTED);
121         RNA_enum_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_mute", HKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "type", SEQ_UNSELECTED);
122         
123         RNA_enum_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_unmute", HKEY, KM_PRESS, KM_ALT, 0)->ptr, "type", SEQ_SELECTED);
124         RNA_enum_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_unmute", HKEY, KM_PRESS, KM_ALT|KM_SHIFT, 0)->ptr, "type", SEQ_UNSELECTED);
125
126         WM_keymap_add_item(keymap, "SEQUENCER_OT_lock", LKEY, KM_PRESS, KM_SHIFT, 0);
127         WM_keymap_add_item(keymap, "SEQUENCER_OT_unlock", HKEY, KM_PRESS, KM_SHIFT|KM_ALT, 0);
128
129         WM_keymap_add_item(keymap, "SEQUENCER_OT_reload", RKEY, KM_PRESS, KM_ALT, 0);
130
131         WM_keymap_add_item(keymap, "SEQUENCER_OT_duplicate_add", DKEY, KM_PRESS, KM_SHIFT, 0);
132
133         WM_keymap_add_item(keymap, "SEQUENCER_OT_delete", XKEY, KM_PRESS, 0, 0);
134         WM_keymap_add_item(keymap, "SEQUENCER_OT_delete", DELKEY, KM_PRESS, 0, 0);
135         
136         WM_keymap_add_item(keymap, "SEQUENCER_OT_images_separate", YKEY, KM_PRESS, 0, 0);
137
138         WM_keymap_add_item(keymap, "SEQUENCER_OT_meta_toggle", TABKEY, KM_PRESS, 0, 0);
139
140         WM_keymap_add_item(keymap, "SEQUENCER_OT_meta_make", MKEY, KM_PRESS, 0, 0);
141         WM_keymap_add_item(keymap, "SEQUENCER_OT_meta_separate", MKEY, KM_PRESS, KM_ALT, 0);
142
143         WM_keymap_add_item(keymap, "SEQUENCER_OT_view_all", HOMEKEY, KM_PRESS, 0, 0);
144         WM_keymap_add_item(keymap, "SEQUENCER_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0);
145
146
147         /* Mouse selection, a bit verbose :/ */
148         WM_keymap_add_item(keymap, "SEQUENCER_OT_select", SELECTMOUSE, KM_PRESS, 0, 0);
149         RNA_boolean_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "extend", 1);
150         RNA_boolean_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_select", SELECTMOUSE, KM_PRESS, KM_CTRL, 0)->ptr, "linked_left", 1);
151         RNA_boolean_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_select", SELECTMOUSE, KM_PRESS, KM_ALT, 0)->ptr, "linked_right", 1);
152         
153         kmi= WM_keymap_add_item(keymap, "SEQUENCER_OT_select", SELECTMOUSE, KM_PRESS, KM_CTRL|KM_ALT, 0);
154         RNA_boolean_set(kmi->ptr, "linked_left", 1);
155         RNA_boolean_set(kmi->ptr, "linked_right", 1);
156
157         kmi= WM_keymap_add_item(keymap, "SEQUENCER_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT|KM_CTRL|KM_ALT, 0);
158         RNA_boolean_set(kmi->ptr, "extend", 1);
159         RNA_boolean_set(kmi->ptr, "linked_left", 1);
160         RNA_boolean_set(kmi->ptr, "linked_right", 1);
161
162         kmi= WM_keymap_add_item(keymap, "SEQUENCER_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT|KM_CTRL, 0);
163         RNA_boolean_set(kmi->ptr, "extend", 1);
164         RNA_boolean_set(kmi->ptr, "linked_left", 1);
165
166         kmi= WM_keymap_add_item(keymap, "SEQUENCER_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT|KM_ALT, 0);
167         RNA_boolean_set(kmi->ptr, "extend", 1);
168         RNA_boolean_set(kmi->ptr, "linked_right", 1);
169
170         
171
172         WM_keymap_add_item(keymap, "SEQUENCER_OT_select_more", PADPLUSKEY, KM_PRESS, KM_CTRL, 0);
173         WM_keymap_add_item(keymap, "SEQUENCER_OT_select_less", PADMINUS, KM_PRESS, KM_CTRL, 0);
174         
175         WM_keymap_add_item(keymap, "SEQUENCER_OT_select_linked_pick", LKEY, KM_PRESS, 0, 0);
176         RNA_boolean_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_select_linked_pick", LKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "extend", 1);
177         
178         WM_keymap_add_item(keymap, "SEQUENCER_OT_select_linked", LKEY, KM_PRESS, KM_CTRL, 0);
179         
180         WM_keymap_add_item(keymap, "SEQUENCER_OT_select_border", BKEY, KM_PRESS, 0, 0);
181         
182         WM_keymap_verify_item(keymap, "ANIM_OT_change_frame", LEFTMOUSE, KM_PRESS, 0, 0);
183
184         transform_keymap_for_space(wm, keymap, SPACE_SEQ);
185 }
186