Industry Compat keymap: Use Ctrl/Cmd + Up/Left/Right for navigating the file browser...
[blender.git] / source / blender / editors / armature / armature_ops.c
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2009 Blender Foundation.
17  * All rights reserved.
18  */
19
20 /** \file
21  * \ingroup edarmature
22  */
23
24 #include "RNA_access.h"
25
26 #include "WM_api.h"
27 #include "WM_types.h"
28
29 #include "ED_armature.h"
30 #include "ED_screen.h"
31 #include "ED_select_utils.h"
32 #include "ED_transform.h"
33
34 #include "armature_intern.h"
35
36 /* ************************** registration **********************************/
37
38 /* Both operators ARMATURE_OT_xxx and POSE_OT_xxx here */
39 void ED_operatortypes_armature(void)
40 {
41   /* EDIT ARMATURE */
42   WM_operatortype_append(ARMATURE_OT_bone_primitive_add);
43
44   WM_operatortype_append(ARMATURE_OT_align);
45   WM_operatortype_append(ARMATURE_OT_calculate_roll);
46   WM_operatortype_append(ARMATURE_OT_roll_clear);
47   WM_operatortype_append(ARMATURE_OT_switch_direction);
48   WM_operatortype_append(ARMATURE_OT_subdivide);
49
50   WM_operatortype_append(ARMATURE_OT_parent_set);
51   WM_operatortype_append(ARMATURE_OT_parent_clear);
52
53   WM_operatortype_append(ARMATURE_OT_select_all);
54   WM_operatortype_append(ARMATURE_OT_select_mirror);
55   WM_operatortype_append(ARMATURE_OT_select_more);
56   WM_operatortype_append(ARMATURE_OT_select_less);
57   WM_operatortype_append(ARMATURE_OT_select_hierarchy);
58   WM_operatortype_append(ARMATURE_OT_select_linked);
59   WM_operatortype_append(ARMATURE_OT_select_similar);
60   WM_operatortype_append(ARMATURE_OT_shortest_path_pick);
61
62   WM_operatortype_append(ARMATURE_OT_delete);
63   WM_operatortype_append(ARMATURE_OT_dissolve);
64   WM_operatortype_append(ARMATURE_OT_duplicate);
65   WM_operatortype_append(ARMATURE_OT_symmetrize);
66   WM_operatortype_append(ARMATURE_OT_extrude);
67   WM_operatortype_append(ARMATURE_OT_hide);
68   WM_operatortype_append(ARMATURE_OT_reveal);
69   WM_operatortype_append(ARMATURE_OT_click_extrude);
70   WM_operatortype_append(ARMATURE_OT_fill);
71   WM_operatortype_append(ARMATURE_OT_merge);
72   WM_operatortype_append(ARMATURE_OT_separate);
73   WM_operatortype_append(ARMATURE_OT_split);
74
75   WM_operatortype_append(ARMATURE_OT_autoside_names);
76   WM_operatortype_append(ARMATURE_OT_flip_names);
77
78   WM_operatortype_append(ARMATURE_OT_layers_show_all);
79   WM_operatortype_append(ARMATURE_OT_armature_layers);
80   WM_operatortype_append(ARMATURE_OT_bone_layers);
81
82   /* POSE */
83   WM_operatortype_append(POSE_OT_hide);
84   WM_operatortype_append(POSE_OT_reveal);
85
86   WM_operatortype_append(POSE_OT_armature_apply);
87   WM_operatortype_append(POSE_OT_visual_transform_apply);
88
89   WM_operatortype_append(POSE_OT_rot_clear);
90   WM_operatortype_append(POSE_OT_loc_clear);
91   WM_operatortype_append(POSE_OT_scale_clear);
92   WM_operatortype_append(POSE_OT_transforms_clear);
93   WM_operatortype_append(POSE_OT_user_transforms_clear);
94
95   WM_operatortype_append(POSE_OT_copy);
96   WM_operatortype_append(POSE_OT_paste);
97
98   WM_operatortype_append(POSE_OT_select_all);
99
100   WM_operatortype_append(POSE_OT_select_parent);
101   WM_operatortype_append(POSE_OT_select_hierarchy);
102   WM_operatortype_append(POSE_OT_select_linked);
103   WM_operatortype_append(POSE_OT_select_constraint_target);
104   WM_operatortype_append(POSE_OT_select_grouped);
105   WM_operatortype_append(POSE_OT_select_mirror);
106
107   WM_operatortype_append(POSE_OT_group_add);
108   WM_operatortype_append(POSE_OT_group_remove);
109   WM_operatortype_append(POSE_OT_group_move);
110   WM_operatortype_append(POSE_OT_group_sort);
111   WM_operatortype_append(POSE_OT_group_assign);
112   WM_operatortype_append(POSE_OT_group_unassign);
113   WM_operatortype_append(POSE_OT_group_select);
114   WM_operatortype_append(POSE_OT_group_deselect);
115
116   WM_operatortype_append(POSE_OT_paths_calculate);
117   WM_operatortype_append(POSE_OT_paths_update);
118   WM_operatortype_append(POSE_OT_paths_clear);
119   WM_operatortype_append(POSE_OT_paths_range_update);
120
121   WM_operatortype_append(POSE_OT_autoside_names);
122   WM_operatortype_append(POSE_OT_flip_names);
123
124   WM_operatortype_append(POSE_OT_rotation_mode_set);
125
126   WM_operatortype_append(POSE_OT_quaternions_flip);
127
128   WM_operatortype_append(POSE_OT_bone_layers);
129
130   WM_operatortype_append(POSE_OT_propagate);
131
132   /* POSELIB */
133   WM_operatortype_append(POSELIB_OT_browse_interactive);
134   WM_operatortype_append(POSELIB_OT_apply_pose);
135
136   WM_operatortype_append(POSELIB_OT_pose_add);
137   WM_operatortype_append(POSELIB_OT_pose_remove);
138   WM_operatortype_append(POSELIB_OT_pose_rename);
139   WM_operatortype_append(POSELIB_OT_pose_move);
140
141   WM_operatortype_append(POSELIB_OT_new);
142   WM_operatortype_append(POSELIB_OT_unlink);
143
144   WM_operatortype_append(POSELIB_OT_action_sanitize);
145
146   /* POSE SLIDING */
147   WM_operatortype_append(POSE_OT_push);
148   WM_operatortype_append(POSE_OT_relax);
149   WM_operatortype_append(POSE_OT_push_rest);
150   WM_operatortype_append(POSE_OT_relax_rest);
151   WM_operatortype_append(POSE_OT_breakdown);
152 }
153
154 void ED_operatormacros_armature(void)
155 {
156   wmOperatorType *ot;
157   wmOperatorTypeMacro *otmacro;
158
159   ot = WM_operatortype_append_macro(
160       "ARMATURE_OT_duplicate_move",
161       "Duplicate",
162       "Make copies of the selected bones within the same armature and move them",
163       OPTYPE_UNDO | OPTYPE_REGISTER);
164   WM_operatortype_macro_define(ot, "ARMATURE_OT_duplicate");
165   otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
166   RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
167
168   ot = WM_operatortype_append_macro("ARMATURE_OT_extrude_move",
169                                     "Extrude",
170                                     "Create new bones from the selected joints and move them",
171                                     OPTYPE_UNDO | OPTYPE_REGISTER);
172   otmacro = WM_operatortype_macro_define(ot, "ARMATURE_OT_extrude");
173   RNA_boolean_set(otmacro->ptr, "forked", false);
174   otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
175   RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
176
177   /* XXX would it be nicer to just be able to have standard extrude_move,
178    * but set the forked property separate?
179    * that would require fixing a properties bug T19733. */
180   ot = WM_operatortype_append_macro("ARMATURE_OT_extrude_forked",
181                                     "Extrude Forked",
182                                     "Create new bones from the selected joints and move them",
183                                     OPTYPE_UNDO | OPTYPE_REGISTER);
184   otmacro = WM_operatortype_macro_define(ot, "ARMATURE_OT_extrude");
185   RNA_boolean_set(otmacro->ptr, "forked", true);
186   otmacro = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
187   RNA_boolean_set(otmacro->ptr, "use_proportional_edit", false);
188 }
189
190 void ED_keymap_armature(wmKeyConfig *keyconf)
191 {
192   wmKeyMap *keymap;
193
194   /* Armature ------------------------ */
195   /* only set in editmode armature, by space_view3d listener */
196   keymap = WM_keymap_ensure(keyconf, "Armature", 0, 0);
197   keymap->poll = ED_operator_editarmature;
198
199   /* Pose ------------------------ */
200   /* only set in posemode, by space_view3d listener */
201   keymap = WM_keymap_ensure(keyconf, "Pose", 0, 0);
202   keymap->poll = ED_operator_posemode;
203 }