doxygen: blender/editors tagged.
[blender.git] / source / blender / editors / space_action / action_ops.c
1 /*
2  * $Id$
3  *
4  * ***** BEGIN GPL LICENSE BLOCK *****
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version. 
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software Foundation,
18  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19  *
20  * The Original Code is Copyright (C) 2008 Blender Foundation.
21  * All rights reserved.
22  *
23  * 
24  * Contributor(s): Blender Foundation
25  *
26  * ***** END GPL LICENSE BLOCK *****
27  */
28
29 /** \file blender/editors/space_action/action_ops.c
30  *  \ingroup spaction
31  */
32
33
34 #include <stdlib.h>
35 #include <math.h>
36
37
38 #include "DNA_space_types.h"
39
40 #include "BLI_blenlib.h"
41
42
43
44 #include "ED_transform.h"
45
46 #include "action_intern.h"
47
48 #include "RNA_access.h"
49
50 #include "WM_api.h"
51 #include "WM_types.h"
52
53 /* ************************** registration - operator types **********************************/
54
55 void action_operatortypes(void)
56 {
57         /* keyframes */
58                 /* selection */
59         WM_operatortype_append(ACTION_OT_clickselect);
60         WM_operatortype_append(ACTION_OT_select_all_toggle);
61         WM_operatortype_append(ACTION_OT_select_border);
62         WM_operatortype_append(ACTION_OT_select_column);
63         WM_operatortype_append(ACTION_OT_select_linked);
64         WM_operatortype_append(ACTION_OT_select_more);
65         WM_operatortype_append(ACTION_OT_select_less);
66         WM_operatortype_append(ACTION_OT_select_leftright);
67         
68                 /* editing */
69         WM_operatortype_append(ACTION_OT_snap);
70         WM_operatortype_append(ACTION_OT_mirror);
71         WM_operatortype_append(ACTION_OT_frame_jump);
72         WM_operatortype_append(ACTION_OT_handle_type);
73         WM_operatortype_append(ACTION_OT_interpolation_type);
74         WM_operatortype_append(ACTION_OT_extrapolation_type);
75         WM_operatortype_append(ACTION_OT_keyframe_type);
76         WM_operatortype_append(ACTION_OT_sample);
77         WM_operatortype_append(ACTION_OT_clean);
78         WM_operatortype_append(ACTION_OT_delete);
79         WM_operatortype_append(ACTION_OT_duplicate);
80         WM_operatortype_append(ACTION_OT_keyframe_insert);
81         WM_operatortype_append(ACTION_OT_copy);
82         WM_operatortype_append(ACTION_OT_paste);
83         WM_operatortype_append(ACTION_OT_new);
84         
85         WM_operatortype_append(ACTION_OT_previewrange_set);
86         WM_operatortype_append(ACTION_OT_view_all);
87         
88         WM_operatortype_append(ACTION_OT_markers_make_local);
89 }
90
91 /* ************************** registration - keymaps **********************************/
92
93 static void action_keymap_keyframes (wmKeyConfig *keyconf, wmKeyMap *keymap)
94 {
95         wmKeyMapItem *kmi;
96         
97         /* action_select.c - selection tools */
98                 /* click-select */
99         WM_keymap_add_item(keymap, "ACTION_OT_clickselect", SELECTMOUSE, KM_PRESS, 0, 0);
100         kmi= WM_keymap_add_item(keymap, "ACTION_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_ALT, 0);
101                 RNA_boolean_set(kmi->ptr, "column", 1);
102         kmi= WM_keymap_add_item(keymap, "ACTION_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0);
103                 RNA_boolean_set(kmi->ptr, "extend", 1);
104         kmi= WM_keymap_add_item(keymap, "ACTION_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_ALT|KM_SHIFT, 0);
105                 RNA_boolean_set(kmi->ptr, "extend", 1);
106                 RNA_boolean_set(kmi->ptr, "column", 1);
107                 
108                 /* select left/right */
109         WM_keymap_add_item(keymap, "ACTION_OT_select_leftright", SELECTMOUSE, KM_PRESS, KM_CTRL, 0);
110         kmi= WM_keymap_add_item(keymap, "ACTION_OT_select_leftright", SELECTMOUSE, KM_PRESS, KM_CTRL|KM_SHIFT, 0);
111                 RNA_boolean_set(kmi->ptr, "extend", 1);
112         
113         kmi= WM_keymap_add_item(keymap, "ACTION_OT_select_leftright", LEFTBRACKETKEY, KM_PRESS, 0, 0);
114                 RNA_enum_set(kmi->ptr, "mode", ACTKEYS_LRSEL_LEFT);
115         kmi= WM_keymap_add_item(keymap, "ACTION_OT_select_leftright", RIGHTBRACKETKEY, KM_PRESS, 0, 0);
116                 RNA_enum_set(kmi->ptr, "mode", ACTKEYS_LRSEL_RIGHT);
117         
118                 /* deselect all */
119         WM_keymap_add_item(keymap, "ACTION_OT_select_all_toggle", AKEY, KM_PRESS, 0, 0);
120         RNA_boolean_set(WM_keymap_add_item(keymap, "ACTION_OT_select_all_toggle", IKEY, KM_PRESS, KM_CTRL, 0)->ptr, "invert", 1);
121         
122                 /* borderselect */
123         WM_keymap_add_item(keymap, "ACTION_OT_select_border", BKEY, KM_PRESS, 0, 0);
124         RNA_boolean_set(WM_keymap_add_item(keymap, "ACTION_OT_select_border", BKEY, KM_PRESS, KM_ALT, 0)->ptr, "axis_range", 1);
125         
126                 /* column select */
127         RNA_enum_set(WM_keymap_add_item(keymap, "ACTION_OT_select_column", KKEY, KM_PRESS, 0, 0)->ptr, "mode", ACTKEYS_COLUMNSEL_KEYS);
128         RNA_enum_set(WM_keymap_add_item(keymap, "ACTION_OT_select_column", KKEY, KM_PRESS, KM_CTRL, 0)->ptr, "mode", ACTKEYS_COLUMNSEL_CFRA);
129         RNA_enum_set(WM_keymap_add_item(keymap, "ACTION_OT_select_column", KKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", ACTKEYS_COLUMNSEL_MARKERS_COLUMN);
130         RNA_enum_set(WM_keymap_add_item(keymap, "ACTION_OT_select_column", KKEY, KM_PRESS, KM_ALT, 0)->ptr, "mode", ACTKEYS_COLUMNSEL_MARKERS_BETWEEN);
131         
132                 /* select more/less */
133         WM_keymap_add_item(keymap, "ACTION_OT_select_more", PADPLUSKEY, KM_PRESS, KM_CTRL, 0);
134         WM_keymap_add_item(keymap, "ACTION_OT_select_less", PADMINUS, KM_PRESS, KM_CTRL, 0);
135         
136                 /* select linekd */
137         WM_keymap_add_item(keymap, "ACTION_OT_select_linked", LKEY, KM_PRESS, 0, 0);
138         
139         
140         /* action_edit.c */
141                 /* snap - current frame to selected keys */
142                 // TODO: maybe since this is called jump, we're better to have it on <something>-J?
143         WM_keymap_add_item(keymap, "ACTION_OT_frame_jump", SKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0);
144                 
145                 /* menu + single-step transform */
146         WM_keymap_add_item(keymap, "ACTION_OT_snap", SKEY, KM_PRESS, KM_SHIFT, 0);
147         WM_keymap_add_item(keymap, "ACTION_OT_mirror", MKEY, KM_PRESS, KM_SHIFT, 0);
148         
149                 /* menu + set setting */
150         WM_keymap_add_item(keymap, "ACTION_OT_handle_type", VKEY, KM_PRESS, 0, 0);
151         WM_keymap_add_item(keymap, "ACTION_OT_interpolation_type", TKEY, KM_PRESS, KM_SHIFT, 0);
152         WM_keymap_add_item(keymap, "ACTION_OT_extrapolation_type", EKEY, KM_PRESS, KM_SHIFT, 0); 
153         WM_keymap_add_item(keymap, "ACTION_OT_keyframe_type", RKEY, KM_PRESS, 0, 0); 
154         
155                 /* destructive */
156         WM_keymap_add_item(keymap, "ACTION_OT_clean", OKEY, KM_PRESS, 0, 0);
157         WM_keymap_add_item(keymap, "ACTION_OT_sample", OKEY, KM_PRESS, KM_SHIFT, 0);
158         
159         WM_keymap_add_item(keymap, "ACTION_OT_delete", XKEY, KM_PRESS, 0, 0);
160         WM_keymap_add_item(keymap, "ACTION_OT_delete", DELKEY, KM_PRESS, 0, 0);
161         
162         WM_keymap_add_item(keymap, "ACTION_OT_duplicate", DKEY, KM_PRESS, KM_SHIFT, 0);
163         WM_keymap_add_item(keymap, "ACTION_OT_keyframe_insert", IKEY, KM_PRESS, 0, 0);
164         
165                 /* copy/paste */
166         WM_keymap_add_item(keymap, "ACTION_OT_copy", CKEY, KM_PRESS, KM_CTRL, 0);
167         WM_keymap_add_item(keymap, "ACTION_OT_paste", VKEY, KM_PRESS, KM_CTRL, 0);
168         
169                 /* auto-set range */
170         WM_keymap_add_item(keymap, "ACTION_OT_previewrange_set", PKEY, KM_PRESS, KM_CTRL|KM_ALT, 0);
171         WM_keymap_add_item(keymap, "ACTION_OT_view_all", HOMEKEY, KM_PRESS, 0, 0);
172         
173         /* animation module */
174                 /* channels list 
175                  * NOTE: these operators were originally for the channels list, but are added here too for convenience...
176                  */
177         WM_keymap_add_item(keymap, "ANIM_OT_channels_editable_toggle", TABKEY, KM_PRESS, 0, 0);
178         
179         /* transform system */
180         transform_keymap_for_space(keyconf, keymap, SPACE_ACTION);
181 }
182
183 /* --------------- */
184
185 void action_keymap(wmKeyConfig *keyconf)
186 {
187         wmKeyMap *keymap;
188         
189         /* channels */
190         /* Channels are not directly handled by the Action Editor module, but are inherited from the Animation module. 
191          * All the relevant operations, keymaps, drawing, etc. can therefore all be found in that module instead, as these
192          * are all used for the Graph-Editor too.
193          */
194         
195         /* keyframes */
196         keymap= WM_keymap_find(keyconf, "Dopesheet", SPACE_ACTION, 0);
197         action_keymap_keyframes(keyconf, keymap);
198 }
199