08d0c56c2608751d3d2ca0e1dc269c491272ac3d
[blender-staging.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_add_duplicate);
75         WM_operatortype_append(SEQUENCER_OT_delete);
76         WM_operatortype_append(SEQUENCER_OT_separate_images);
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
81         WM_operatortype_append(SEQUENCER_OT_view_all);
82         WM_operatortype_append(SEQUENCER_OT_view_selected);
83         WM_operatortype_append(SEQUENCER_OT_view_zoom);
84         
85         /* sequencer_select.c */
86         WM_operatortype_append(SEQUENCER_OT_deselect_all);
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_pick_linked);
92         WM_operatortype_append(SEQUENCER_OT_select_linked);
93         WM_operatortype_append(SEQUENCER_OT_select_handles);
94         WM_operatortype_append(SEQUENCER_OT_borderselect);
95         
96         /* sequencer_add.c */
97         WM_operatortype_append(SEQUENCER_OT_add_scene_strip);
98         WM_operatortype_append(SEQUENCER_OT_add_movie_strip);
99         WM_operatortype_append(SEQUENCER_OT_add_sound_strip);
100         WM_operatortype_append(SEQUENCER_OT_add_image_strip);
101         WM_operatortype_append(SEQUENCER_OT_add_effect_strip);
102 }
103
104
105 void sequencer_keymap(wmWindowManager *wm)
106 {
107         ListBase *keymap= WM_keymap_listbase(wm, "Sequencer", SPACE_SEQ, 0);
108         
109         WM_keymap_add_item(keymap, "SEQUENCER_OT_deselect_all", AKEY, KM_PRESS, 0, 0);
110         WM_keymap_add_item(keymap, "SEQUENCER_OT_select_invert", IKEY, KM_PRESS, KM_CTRL, 0);
111         
112         RNA_enum_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_cut", KKEY, KM_PRESS, 0, 0)->ptr, "type", SEQ_CUT_SOFT);
113         RNA_enum_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_cut", KKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "type", SEQ_CUT_HARD);
114         
115         RNA_enum_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_mute", HKEY, KM_PRESS, 0, 0)->ptr, "type", SEQ_SELECTED);
116         RNA_enum_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_mute", HKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "type", SEQ_UNSELECTED);
117         
118         RNA_enum_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_unmute", HKEY, KM_PRESS, KM_ALT, 0)->ptr, "type", SEQ_SELECTED);
119         RNA_enum_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_unmute", HKEY, KM_PRESS, KM_ALT|KM_SHIFT, 0)->ptr, "type", SEQ_UNSELECTED);
120
121         WM_keymap_add_item(keymap, "SEQUENCER_OT_lock", LKEY, KM_PRESS, KM_SHIFT, 0);
122         WM_keymap_add_item(keymap, "SEQUENCER_OT_unlock", HKEY, KM_PRESS, KM_SHIFT|KM_ALT, 0);
123
124         WM_keymap_add_item(keymap, "SEQUENCER_OT_reload", RKEY, KM_PRESS, KM_ALT, 0);
125
126         WM_keymap_add_item(keymap, "SEQUENCER_OT_add_duplicate", DKEY, KM_PRESS, KM_SHIFT, 0);
127
128         WM_keymap_add_item(keymap, "SEQUENCER_OT_delete", XKEY, KM_PRESS, 0, 0);
129         WM_keymap_add_item(keymap, "SEQUENCER_OT_delete", DELKEY, KM_PRESS, 0, 0);
130         
131         WM_keymap_add_item(keymap, "SEQUENCER_OT_separate_images", YKEY, KM_PRESS, 0, 0);
132
133         WM_keymap_add_item(keymap, "SEQUENCER_OT_meta_toggle", TABKEY, KM_PRESS, 0, 0);
134
135         WM_keymap_add_item(keymap, "SEQUENCER_OT_meta_make", MKEY, KM_PRESS, 0, 0);
136         WM_keymap_add_item(keymap, "SEQUENCER_OT_meta_separate", MKEY, KM_PRESS, KM_ALT, 0);
137
138         WM_keymap_add_item(keymap, "SEQUENCER_OT_view_all", HOMEKEY, KM_PRESS, 0, 0);
139         WM_keymap_add_item(keymap, "SEQUENCER_OT_view_selected", PADPERIOD, KM_PRESS, 0, 0);
140         WM_keymap_add_item(keymap, "SEQUENCER_OT_view_zoom", BKEY, KM_PRESS, KM_SHIFT, 0);
141
142         
143         WM_keymap_add_item(keymap, "SEQUENCER_OT_select", SELECTMOUSE, KM_PRESS, 0, 0);
144         RNA_enum_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_select", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "type", 1);
145         
146         WM_keymap_add_item(keymap, "SEQUENCER_OT_select_more", PADPLUSKEY, KM_PRESS, KM_CTRL, 0);
147         WM_keymap_add_item(keymap, "SEQUENCER_OT_select_less", PADMINUS, KM_PRESS, KM_CTRL, 0);
148         
149         WM_keymap_add_item(keymap, "SEQUENCER_OT_select_pick_linked", LKEY, KM_PRESS, 0, 0);
150         RNA_enum_set(WM_keymap_add_item(keymap, "SEQUENCER_OT_select_pick_linked", LKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "type", 1);
151         
152         WM_keymap_add_item(keymap, "SEQUENCER_OT_select_linked", LKEY, KM_PRESS, KM_CTRL, 0);
153         
154         WM_keymap_add_item(keymap, "SEQUENCER_OT_borderselect", BKEY, KM_PRESS, 0, 0);
155         
156         WM_keymap_verify_item(keymap, "ANIM_OT_change_frame", LEFTMOUSE, KM_PRESS, 0, 0);
157
158         WM_keymap_tweak(keymap, SELECTMOUSE, KM_PRESS, 0, 0);
159
160         transform_keymap_for_space(wm, keymap, SPACE_SEQ);
161 }
162