2.5: various one-liner fixes
[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 "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
81         WM_operatortype_append(SEQUENCER_OT_view_all);
82         WM_operatortype_append(SEQUENCER_OT_view_selected);
83         
84         /* sequencer_select.c */
85         WM_operatortype_append(SEQUENCER_OT_select_all_toggle);
86         WM_operatortype_append(SEQUENCER_OT_select_inverse);
87         WM_operatortype_append(SEQUENCER_OT_select);
88         WM_operatortype_append(SEQUENCER_OT_select_more);
89         WM_operatortype_append(SEQUENCER_OT_select_less);
90         WM_operatortype_append(SEQUENCER_OT_select_linked_pick);
91         WM_operatortype_append(SEQUENCER_OT_select_linked);
92         WM_operatortype_append(SEQUENCER_OT_select_handles);
93         WM_operatortype_append(SEQUENCER_OT_select_active_side);
94         WM_operatortype_append(SEQUENCER_OT_select_border);
95         
96         /* sequencer_add.c */
97         WM_operatortype_append(SEQUENCER_OT_scene_strip_add);
98         WM_operatortype_append(SEQUENCER_OT_movie_strip_add);
99         WM_operatortype_append(SEQUENCER_OT_sound_strip_add);
100         WM_operatortype_append(SEQUENCER_OT_image_strip_add);
101         WM_operatortype_append(SEQUENCER_OT_effect_strip_add);
102         WM_operatortype_append(SEQUENCER_OT_properties);
103 }
104
105
106 void sequencer_keymap(wmWindowManager *wm)
107 {
108         ListBase *keymap= WM_keymap_listbase(wm, "Sequencer", SPACE_SEQ, 0);
109         wmKeymapItem *kmi;
110         
111         WM_keymap_add_item(keymap, "SEQUENCER_OT_properties", NKEY, KM_PRESS, 0, 0);
112         
113         WM_keymap_add_item(keymap, "SEQUENCER_OT_select_all_toggle", AKEY, KM_PRESS, 0, 0);
114         WM_keymap_add_item(keymap, "SEQUENCER_OT_select_inverse", IKEY, KM_PRESS, KM_CTRL, 0);
115         
116         RNA_enum_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_cut", KKEY, KM_PRESS, 0, 0)->ptr, "type", SEQ_CUT_SOFT);
117         RNA_enum_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_cut", KKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "type", SEQ_CUT_HARD);
118         
119         WM_keymap_add_item(keymap, "SEQUENCER_OT_mute", HKEY, KM_PRESS, 0, 0);
120         RNA_boolean_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_mute", HKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "unselected", 1);
121         
122         WM_keymap_add_item(keymap, "SEQUENCER_OT_unmute", HKEY, KM_PRESS, KM_ALT, 0);
123         RNA_boolean_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_unmute", HKEY, KM_PRESS, KM_ALT|KM_SHIFT, 0)->ptr, "unselected", 1);
124
125         WM_keymap_add_item(keymap, "SEQUENCER_OT_lock", LKEY, KM_PRESS, KM_SHIFT, 0);
126         WM_keymap_add_item(keymap, "SEQUENCER_OT_unlock", LKEY, KM_PRESS, KM_SHIFT|KM_ALT, 0);
127
128         WM_keymap_add_item(keymap, "SEQUENCER_OT_reload", RKEY, KM_PRESS, KM_ALT, 0);
129
130         WM_keymap_add_item(keymap, "SEQUENCER_OT_duplicate", DKEY, KM_PRESS, KM_SHIFT, 0);
131
132         WM_keymap_add_item(keymap, "SEQUENCER_OT_delete", XKEY, KM_PRESS, 0, 0);
133         WM_keymap_add_item(keymap, "SEQUENCER_OT_delete", DELKEY, KM_PRESS, 0, 0);
134         
135         WM_keymap_add_item(keymap, "SEQUENCER_OT_images_separate", YKEY, KM_PRESS, 0, 0);
136
137         WM_keymap_add_item(keymap, "SEQUENCER_OT_meta_toggle", TABKEY, KM_PRESS, 0, 0);
138
139         WM_keymap_add_item(keymap, "SEQUENCER_OT_meta_make", MKEY, KM_PRESS, 0, 0);
140         WM_keymap_add_item(keymap, "SEQUENCER_OT_meta_separate", MKEY, KM_PRESS, KM_ALT, 0);
141
142         WM_keymap_add_item(keymap, "SEQUENCER_OT_view_all", HOMEKEY, KM_PRESS, 0, 0);
143         WM_keymap_add_item(keymap, "SEQUENCER_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0);
144
145
146         /* Mouse selection, a bit verbose :/ */
147         WM_keymap_add_item(keymap, "SEQUENCER_OT_select", SELECTMOUSE, KM_PRESS, 0, 0);
148         RNA_boolean_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "extend", 1);
149         RNA_boolean_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_select", SELECTMOUSE, KM_PRESS, KM_CTRL, 0)->ptr, "linked_left", 1);
150         RNA_boolean_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_select", SELECTMOUSE, KM_PRESS, KM_ALT, 0)->ptr, "linked_right", 1);
151         
152         kmi= WM_keymap_add_item(keymap, "SEQUENCER_OT_select", SELECTMOUSE, KM_PRESS, KM_CTRL|KM_ALT, 0);
153         RNA_boolean_set(kmi->ptr, "linked_left", 1);
154         RNA_boolean_set(kmi->ptr, "linked_right", 1);
155
156         kmi= WM_keymap_add_item(keymap, "SEQUENCER_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT|KM_CTRL|KM_ALT, 0);
157         RNA_boolean_set(kmi->ptr, "extend", 1);
158         RNA_boolean_set(kmi->ptr, "linked_left", 1);
159         RNA_boolean_set(kmi->ptr, "linked_right", 1);
160
161         kmi= WM_keymap_add_item(keymap, "SEQUENCER_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT|KM_CTRL, 0);
162         RNA_boolean_set(kmi->ptr, "extend", 1);
163         RNA_boolean_set(kmi->ptr, "linked_left", 1);
164
165         kmi= WM_keymap_add_item(keymap, "SEQUENCER_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT|KM_ALT, 0);
166         RNA_boolean_set(kmi->ptr, "extend", 1);
167         RNA_boolean_set(kmi->ptr, "linked_right", 1);
168
169         
170
171         WM_keymap_add_item(keymap, "SEQUENCER_OT_select_more", PADPLUSKEY, KM_PRESS, KM_CTRL, 0);
172         WM_keymap_add_item(keymap, "SEQUENCER_OT_select_less", PADMINUS, KM_PRESS, KM_CTRL, 0);
173         
174         WM_keymap_add_item(keymap, "SEQUENCER_OT_select_linked_pick", LKEY, KM_PRESS, 0, 0);
175         RNA_boolean_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_select_linked_pick", LKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "extend", 1);
176         
177         WM_keymap_add_item(keymap, "SEQUENCER_OT_select_linked", LKEY, KM_PRESS, KM_CTRL, 0);
178         
179         WM_keymap_add_item(keymap, "SEQUENCER_OT_select_border", BKEY, KM_PRESS, 0, 0);
180         
181         WM_keymap_verify_item(keymap, "ANIM_OT_change_frame", LEFTMOUSE, KM_PRESS, 0, 0);
182
183         transform_keymap_for_space(wm, keymap, SPACE_SEQ);
184 }
185