doxygen: prevent GPL license block from being parsed as doxygen comment.
[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 #include <stdlib.h>
30 #include <math.h>
31
32
33 #include "DNA_space_types.h"
34
35 #include "BLI_blenlib.h"
36
37
38
39 #include "ED_transform.h"
40
41 #include "action_intern.h"
42
43 #include "RNA_access.h"
44
45 #include "WM_api.h"
46 #include "WM_types.h"
47
48 /* ************************** registration - operator types **********************************/
49
50 void action_operatortypes(void)
51 {
52         /* keyframes */
53                 /* selection */
54         WM_operatortype_append(ACTION_OT_clickselect);
55         WM_operatortype_append(ACTION_OT_select_all_toggle);
56         WM_operatortype_append(ACTION_OT_select_border);
57         WM_operatortype_append(ACTION_OT_select_column);
58         WM_operatortype_append(ACTION_OT_select_linked);
59         WM_operatortype_append(ACTION_OT_select_more);
60         WM_operatortype_append(ACTION_OT_select_less);
61         WM_operatortype_append(ACTION_OT_select_leftright);
62         
63                 /* editing */
64         WM_operatortype_append(ACTION_OT_snap);
65         WM_operatortype_append(ACTION_OT_mirror);
66         WM_operatortype_append(ACTION_OT_frame_jump);
67         WM_operatortype_append(ACTION_OT_handle_type);
68         WM_operatortype_append(ACTION_OT_interpolation_type);
69         WM_operatortype_append(ACTION_OT_extrapolation_type);
70         WM_operatortype_append(ACTION_OT_keyframe_type);
71         WM_operatortype_append(ACTION_OT_sample);
72         WM_operatortype_append(ACTION_OT_clean);
73         WM_operatortype_append(ACTION_OT_delete);
74         WM_operatortype_append(ACTION_OT_duplicate);
75         WM_operatortype_append(ACTION_OT_keyframe_insert);
76         WM_operatortype_append(ACTION_OT_copy);
77         WM_operatortype_append(ACTION_OT_paste);
78         WM_operatortype_append(ACTION_OT_new);
79         
80         WM_operatortype_append(ACTION_OT_previewrange_set);
81         WM_operatortype_append(ACTION_OT_view_all);
82 }
83
84 /* ************************** registration - keymaps **********************************/
85
86 static void action_keymap_keyframes (wmKeyConfig *keyconf, wmKeyMap *keymap)
87 {
88         wmKeyMapItem *kmi;
89         
90         /* action_select.c - selection tools */
91                 /* click-select */
92         WM_keymap_add_item(keymap, "ACTION_OT_clickselect", SELECTMOUSE, KM_PRESS, 0, 0);
93         kmi= WM_keymap_add_item(keymap, "ACTION_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_ALT, 0);
94                 RNA_boolean_set(kmi->ptr, "column", 1);
95         kmi= WM_keymap_add_item(keymap, "ACTION_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_SHIFT, 0);
96                 RNA_boolean_set(kmi->ptr, "extend", 1);
97         kmi= WM_keymap_add_item(keymap, "ACTION_OT_clickselect", SELECTMOUSE, KM_PRESS, KM_ALT|KM_SHIFT, 0);
98                 RNA_boolean_set(kmi->ptr, "extend", 1);
99                 RNA_boolean_set(kmi->ptr, "column", 1);
100                 
101                 /* select left/right */
102         WM_keymap_add_item(keymap, "ACTION_OT_select_leftright", SELECTMOUSE, KM_PRESS, KM_CTRL, 0);
103         kmi= WM_keymap_add_item(keymap, "ACTION_OT_select_leftright", SELECTMOUSE, KM_PRESS, KM_CTRL|KM_SHIFT, 0);
104                 RNA_boolean_set(kmi->ptr, "extend", 1);
105         
106         kmi= WM_keymap_add_item(keymap, "ACTION_OT_select_leftright", LEFTBRACKETKEY, KM_PRESS, 0, 0);
107                 RNA_enum_set(kmi->ptr, "mode", ACTKEYS_LRSEL_LEFT);
108         kmi= WM_keymap_add_item(keymap, "ACTION_OT_select_leftright", RIGHTBRACKETKEY, KM_PRESS, 0, 0);
109                 RNA_enum_set(kmi->ptr, "mode", ACTKEYS_LRSEL_RIGHT);
110         
111                 /* deselect all */
112         WM_keymap_add_item(keymap, "ACTION_OT_select_all_toggle", AKEY, KM_PRESS, 0, 0);
113         RNA_boolean_set(WM_keymap_add_item(keymap, "ACTION_OT_select_all_toggle", IKEY, KM_PRESS, KM_CTRL, 0)->ptr, "invert", 1);
114         
115                 /* borderselect */
116         WM_keymap_add_item(keymap, "ACTION_OT_select_border", BKEY, KM_PRESS, 0, 0);
117         RNA_boolean_set(WM_keymap_add_item(keymap, "ACTION_OT_select_border", BKEY, KM_PRESS, KM_ALT, 0)->ptr, "axis_range", 1);
118         
119                 /* column select */
120         RNA_enum_set(WM_keymap_add_item(keymap, "ACTION_OT_select_column", KKEY, KM_PRESS, 0, 0)->ptr, "mode", ACTKEYS_COLUMNSEL_KEYS);
121         RNA_enum_set(WM_keymap_add_item(keymap, "ACTION_OT_select_column", KKEY, KM_PRESS, KM_CTRL, 0)->ptr, "mode", ACTKEYS_COLUMNSEL_CFRA);
122         RNA_enum_set(WM_keymap_add_item(keymap, "ACTION_OT_select_column", KKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "mode", ACTKEYS_COLUMNSEL_MARKERS_COLUMN);
123         RNA_enum_set(WM_keymap_add_item(keymap, "ACTION_OT_select_column", KKEY, KM_PRESS, KM_ALT, 0)->ptr, "mode", ACTKEYS_COLUMNSEL_MARKERS_BETWEEN);
124         
125                 /* select more/less */
126         WM_keymap_add_item(keymap, "ACTION_OT_select_more", PADPLUSKEY, KM_PRESS, KM_CTRL, 0);
127         WM_keymap_add_item(keymap, "ACTION_OT_select_less", PADMINUS, KM_PRESS, KM_CTRL, 0);
128         
129                 /* select linekd */
130         WM_keymap_add_item(keymap, "ACTION_OT_select_linked", LKEY, KM_PRESS, 0, 0);
131         
132         
133         /* action_edit.c */
134                 /* snap - current frame to selected keys */
135                 // TODO: maybe since this is called jump, we're better to have it on <something>-J?
136         WM_keymap_add_item(keymap, "ACTION_OT_frame_jump", SKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0);
137                 
138                 /* menu + single-step transform */
139         WM_keymap_add_item(keymap, "ACTION_OT_snap", SKEY, KM_PRESS, KM_SHIFT, 0);
140         WM_keymap_add_item(keymap, "ACTION_OT_mirror", MKEY, KM_PRESS, KM_SHIFT, 0);
141         
142                 /* menu + set setting */
143         WM_keymap_add_item(keymap, "ACTION_OT_handle_type", VKEY, KM_PRESS, 0, 0);
144         WM_keymap_add_item(keymap, "ACTION_OT_interpolation_type", TKEY, KM_PRESS, KM_SHIFT, 0);
145         WM_keymap_add_item(keymap, "ACTION_OT_extrapolation_type", EKEY, KM_PRESS, KM_SHIFT, 0); 
146         WM_keymap_add_item(keymap, "ACTION_OT_keyframe_type", RKEY, KM_PRESS, 0, 0); 
147         
148                 /* destructive */
149         WM_keymap_add_item(keymap, "ACTION_OT_clean", OKEY, KM_PRESS, 0, 0);
150         WM_keymap_add_item(keymap, "ACTION_OT_sample", OKEY, KM_PRESS, KM_SHIFT, 0);
151         
152         WM_keymap_add_item(keymap, "ACTION_OT_delete", XKEY, KM_PRESS, 0, 0);
153         WM_keymap_add_item(keymap, "ACTION_OT_delete", DELKEY, KM_PRESS, 0, 0);
154         
155         WM_keymap_add_item(keymap, "ACTION_OT_duplicate", DKEY, KM_PRESS, KM_SHIFT, 0);
156         WM_keymap_add_item(keymap, "ACTION_OT_keyframe_insert", IKEY, KM_PRESS, 0, 0);
157         
158                 /* copy/paste */
159         WM_keymap_add_item(keymap, "ACTION_OT_copy", CKEY, KM_PRESS, KM_CTRL, 0);
160         WM_keymap_add_item(keymap, "ACTION_OT_paste", VKEY, KM_PRESS, KM_CTRL, 0);
161         
162                 /* auto-set range */
163         WM_keymap_add_item(keymap, "ACTION_OT_previewrange_set", PKEY, KM_PRESS, KM_CTRL|KM_ALT, 0);
164         WM_keymap_add_item(keymap, "ACTION_OT_view_all", HOMEKEY, KM_PRESS, 0, 0);
165         
166         /* animation module */
167                 /* channels list 
168                  * NOTE: these operators were originally for the channels list, but are added here too for convenience...
169                  */
170         WM_keymap_add_item(keymap, "ANIM_OT_channels_editable_toggle", TABKEY, KM_PRESS, 0, 0);
171         
172         /* transform system */
173         transform_keymap_for_space(keyconf, keymap, SPACE_ACTION);
174 }
175
176 /* --------------- */
177
178 void action_keymap(wmKeyConfig *keyconf)
179 {
180         wmKeyMap *keymap;
181         
182         /* channels */
183         /* Channels are not directly handled by the Action Editor module, but are inherited from the Animation module. 
184          * All the relevant operations, keymaps, drawing, etc. can therefore all be found in that module instead, as these
185          * are all used for the Graph-Editor too.
186          */
187         
188         /* keyframes */
189         keymap= WM_keymap_find(keyconf, "Dopesheet", SPACE_ACTION, 0);
190         action_keymap_keyframes(keyconf, keymap);
191 }
192