97fb3531718c9bad8e5c9009dd5b84ef9da03485
[blender.git] / source / blender / editors / transform / transform_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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19  *
20  * Contributor(s): none yet.
21  *
22  * ***** END GPL LICENSE BLOCK *****
23  */
24
25 #include "MEM_guardedalloc.h"
26
27 #include "DNA_scene_types.h"
28 #include "DNA_space_types.h"
29 #include "DNA_windowmanager_types.h"
30
31 #include "RNA_access.h"
32 #include "RNA_define.h"
33 #include "RNA_enum_types.h"
34
35 #include "BLI_arithb.h"
36
37 #include "BKE_utildefines.h"
38 #include "BKE_context.h"
39
40 #include "WM_api.h"
41 #include "WM_types.h"
42
43 #include "UI_interface.h"
44
45 #include "ED_screen.h"
46
47 #include "transform.h"
48
49 typedef struct TransformModeItem
50 {
51         char *idname;
52         int             mode;
53 } TransformModeItem;
54
55 static float VecOne[3] = {1, 1, 1};
56
57 /* need constants for this */
58 EnumPropertyItem proportional_mode_types[] = {
59                 {0, "OFF", 0, "Off", ""},
60                 {1, "ON", 0, "On", ""},
61                 {2, "CONNECTED", 0, "Connected", ""},
62                 {0, NULL, 0, NULL, NULL}
63 };
64
65 EnumPropertyItem snap_mode_types[] = {
66                 {SCE_SNAP_TARGET_CLOSEST, "CLOSEST", 0, "Closest", ""},
67                 {SCE_SNAP_TARGET_CENTER,  "CENTER", 0, "Center", ""},
68                 {SCE_SNAP_TARGET_MEDIAN,  "MEDIAN", 0, "Median", ""},
69                 {SCE_SNAP_TARGET_ACTIVE,  "ACTIVE", 0, "Active", ""},
70                 {0, NULL, 0, NULL, NULL}
71 };
72
73 EnumPropertyItem proportional_falloff_types[] = {
74                 {PROP_SMOOTH, "SMOOTH", 0, "Smooth", ""},
75                 {PROP_SPHERE, "SPHERE", 0, "Sphere", ""},
76                 {PROP_ROOT, "ROOT", 0, "Root", ""},
77                 {PROP_SHARP, "SHARP", 0, "Sharp", ""},
78                 {PROP_LIN, "LINEAR", 0, "Linear", ""},
79                 {PROP_CONST, "CONSTANT", 0, "Constant", ""},
80                 {PROP_RANDOM, "RANDOM", 0, "Random", ""},
81                 {0, NULL, 0, NULL, NULL}
82 };
83
84 char OP_TRANSLATION[] = "TFM_OT_translation";
85 char OP_ROTATION[] = "TFM_OT_rotation";
86 char OP_TOSPHERE[] = "TFM_OT_tosphere";
87 char OP_RESIZE[] = "TFM_OT_resize";
88 char OP_SHEAR[] = "TFM_OT_shear";
89 char OP_WARP[] = "TFM_OT_warp";
90 char OP_SHRINK_FATTEN[] = "TFM_OT_shrink_fatten";
91 char OP_TILT[] = "TFM_OT_tilt";
92 char OP_TRACKBALL[] = "TFM_OT_trackball";
93
94
95 TransformModeItem transform_modes[] =
96 {
97         {OP_TRANSLATION, TFM_TRANSLATION},
98         {OP_ROTATION, TFM_ROTATION},
99         {OP_TOSPHERE, TFM_TOSPHERE},
100         {OP_RESIZE, TFM_RESIZE},
101         {OP_SHEAR, TFM_SHEAR},
102         {OP_WARP, TFM_WARP},
103         {OP_SHRINK_FATTEN, TFM_SHRINKFATTEN},
104         {OP_TILT, TFM_TILT},
105         {OP_TRACKBALL, TFM_TRACKBALL},
106         {NULL, 0}
107 };
108
109 static int select_orientation_exec(bContext *C, wmOperator *op)
110 {
111         int orientation = RNA_enum_get(op->ptr, "orientation");
112         int custom_index= RNA_int_get(op->ptr, "custom_index");;
113
114         if(orientation == V3D_MANIP_CUSTOM)
115                 orientation += custom_index;
116
117         BIF_selectTransformOrientationValue(C, orientation);
118
119         return OPERATOR_FINISHED;
120 }
121
122 static int select_orientation_invoke(bContext *C, wmOperator *op, wmEvent *event)
123 {
124         uiPopupMenu *pup;
125         uiLayout *layout;
126
127         pup= uiPupMenuBegin(C, "Orientation", 0);
128         layout= uiPupMenuLayout(pup);
129         BIF_menuTransformOrientation(C, layout, NULL);
130         uiPupMenuEnd(C, pup);
131
132         return OPERATOR_CANCELLED;
133 }
134
135 void TFM_OT_select_orientation(struct wmOperatorType *ot)
136 {
137         static EnumPropertyItem orientation_items[]= {
138                 {V3D_MANIP_GLOBAL, "GLOBAL", 0, "Global", ""},
139                 {V3D_MANIP_NORMAL, "NORMAL", 0, "Normal", ""},
140                 {V3D_MANIP_LOCAL, "LOCAL", 0, "Local", ""},
141                 {V3D_MANIP_VIEW, "VIEW", 0, "View", ""},
142                 {V3D_MANIP_CUSTOM, "CUSTOM", 0, "Custom", ""},
143                 {0, NULL, 0, NULL, NULL}};
144
145         /* identifiers */
146         ot->name   = "Select Orientation";
147         ot->idname = "TFM_OT_select_orientation";
148
149         /* api callbacks */
150         ot->invoke = select_orientation_invoke;
151         ot->exec   = select_orientation_exec;
152         ot->poll   = ED_operator_areaactive;
153
154         RNA_def_enum(ot->srna, "orientation", orientation_items, V3D_MANIP_CUSTOM, "Orientation", "DOC_BROKEN");
155         RNA_def_int(ot->srna, "custom_index", 0, 0, INT_MAX, "Custom Index", "", 0, INT_MAX);
156 }
157
158 static void transformops_exit(bContext *C, wmOperator *op)
159 {
160         saveTransform(C, op->customdata, op);
161         MEM_freeN(op->customdata);
162         op->customdata = NULL;
163 }
164
165 static int transformops_data(bContext *C, wmOperator *op, wmEvent *event)
166 {
167         int retval = 1;
168         if (op->customdata == NULL)
169         {
170                 TransInfo *t = MEM_callocN(sizeof(TransInfo), "TransInfo data");
171                 TransformModeItem *tmode;
172                 int mode = -1;
173
174                 for (tmode = transform_modes; tmode->idname; tmode++)
175                 {
176                         if (op->type->idname == tmode->idname)
177                         {
178                                 mode = tmode->mode;
179                         }
180                 }
181
182                 if (mode == -1)
183                 {
184                         mode = RNA_int_get(op->ptr, "mode");
185                 }
186
187                 retval = initTransform(C, t, op, event, mode);
188
189                 /* store data */
190                 op->customdata = t;
191         }
192
193         return retval; /* return 0 on error */
194 }
195
196 static int transform_modal(bContext *C, wmOperator *op, wmEvent *event)
197 {
198         int exit_code;
199
200         TransInfo *t = op->customdata;
201
202         transformEvent(t, event);
203
204         transformApply(C, t);
205
206
207         exit_code = transformEnd(C, t);
208
209         if (exit_code != OPERATOR_RUNNING_MODAL)
210         {
211                 transformops_exit(C, op);
212         }
213
214         return exit_code;
215 }
216
217 static int transform_cancel(bContext *C, wmOperator *op)
218 {
219         TransInfo *t = op->customdata;
220
221         t->state = TRANS_CANCEL;
222         transformEnd(C, t);
223         transformops_exit(C, op);
224
225         return OPERATOR_CANCELLED;
226 }
227
228 static int transform_exec(bContext *C, wmOperator *op)
229 {
230         TransInfo *t;
231
232         if (!transformops_data(C, op, NULL))
233         {
234                 return OPERATOR_CANCELLED;
235         }
236
237         t = op->customdata;
238
239         t->options |= CTX_AUTOCONFIRM;
240
241         transformApply(C, t);
242
243         transformEnd(C, t);
244
245         transformops_exit(C, op);
246
247         return OPERATOR_FINISHED;
248 }
249
250 static int transform_invoke(bContext *C, wmOperator *op, wmEvent *event)
251 {
252         if (!transformops_data(C, op, event))
253         {
254                 return OPERATOR_CANCELLED;
255         }
256
257         if(RNA_property_is_set(op->ptr, "value")) {
258                 return transform_exec(C, op);
259         }
260         else {
261                 TransInfo *t = op->customdata;
262
263                 /* add temp handler */
264                 WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
265
266                 t->flag |= T_MODAL; // XXX meh maybe somewhere else
267
268                 return OPERATOR_RUNNING_MODAL;
269         }
270 }
271
272 void Properties_Proportional(struct wmOperatorType *ot)
273 {
274         RNA_def_enum(ot->srna, "proportional", proportional_mode_types, 0, "Proportional Editing", "");
275         RNA_def_enum(ot->srna, "proportional_editing_falloff", prop_mode_items, 0, "Proportional Editing Falloff", "Falloff type for proportional editing mode.");
276         RNA_def_float(ot->srna, "proportional_size", 1, 0, FLT_MAX, "Proportional Size", "", 0, 100);
277 }
278
279 void Properties_Snapping(struct wmOperatorType *ot, short align)
280 {
281         RNA_def_boolean(ot->srna, "snap", 0, "Snap to Point", "");
282         RNA_def_enum(ot->srna, "snap_mode", snap_mode_types, 0, "Mode", "");
283         RNA_def_float_vector(ot->srna, "snap_point", 3, NULL, -FLT_MAX, FLT_MAX, "Point", "", -FLT_MAX, FLT_MAX);
284
285         if (align)
286         {
287                 RNA_def_boolean(ot->srna, "snap_align", 0, "Align with Point Normal", "");
288                 RNA_def_float_vector(ot->srna, "snap_normal", 3, NULL, -FLT_MAX, FLT_MAX, "Normal", "", -FLT_MAX, FLT_MAX);
289         }
290 }
291
292 void Properties_Constraints(struct wmOperatorType *ot)
293 {
294         RNA_def_boolean_vector(ot->srna, "constraint_axis", 3, NULL, "Constraint Axis", "");
295         RNA_def_int(ot->srna, "constraint_orientation", 0, 0, INT_MAX, "Constraint Orientation", "", 0, INT_MAX);
296 }
297
298 void TFM_OT_translation(struct wmOperatorType *ot)
299 {
300         /* identifiers */
301         ot->name   = "Translation";
302         ot->idname = OP_TRANSLATION;
303         ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
304
305         /* api callbacks */
306         ot->invoke = transform_invoke;
307         ot->exec   = transform_exec;
308         ot->modal  = transform_modal;
309         ot->cancel  = transform_cancel;
310         ot->poll   = ED_operator_areaactive;
311
312         RNA_def_float_vector(ot->srna, "value", 3, NULL, -FLT_MAX, FLT_MAX, "Vector", "", -FLT_MAX, FLT_MAX);
313
314         Properties_Proportional(ot);
315
316         RNA_def_boolean(ot->srna, "mirror", 0, "Mirror Editing", "");
317
318         Properties_Constraints(ot);
319
320         Properties_Snapping(ot, 1);
321 }
322
323 void TFM_OT_resize(struct wmOperatorType *ot)
324 {
325         /* identifiers */
326         ot->name   = "Resize";
327         ot->idname = OP_RESIZE;
328         ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
329
330         /* api callbacks */
331         ot->invoke = transform_invoke;
332         ot->exec   = transform_exec;
333         ot->modal  = transform_modal;
334         ot->cancel  = transform_cancel;
335         ot->poll   = ED_operator_areaactive;
336
337         RNA_def_float_vector(ot->srna, "value", 3, VecOne, -FLT_MAX, FLT_MAX, "Vector", "", -FLT_MAX, FLT_MAX);
338
339         Properties_Proportional(ot);
340
341         RNA_def_boolean(ot->srna, "mirror", 0, "Mirror Editing", "");
342
343         Properties_Constraints(ot);
344
345         Properties_Snapping(ot, 0);
346 }
347
348
349 void TFM_OT_trackball(struct wmOperatorType *ot)
350 {
351         /* identifiers */
352         ot->name   = "Trackball";
353         ot->idname = OP_TRACKBALL;
354         ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
355
356         /* api callbacks */
357         ot->invoke = transform_invoke;
358         ot->exec   = transform_exec;
359         ot->modal  = transform_modal;
360         ot->cancel  = transform_cancel;
361         ot->poll   = ED_operator_areaactive;
362
363         RNA_def_float_vector(ot->srna, "value", 2, VecOne, -FLT_MAX, FLT_MAX, "angle", "", -FLT_MAX, FLT_MAX);
364
365         Properties_Proportional(ot);
366
367         RNA_def_boolean(ot->srna, "mirror", 0, "Mirror Editing", "");
368 }
369
370 void TFM_OT_rotation(struct wmOperatorType *ot)
371 {
372         /* identifiers */
373         ot->name   = "Rotation";
374         ot->idname = OP_ROTATION;
375         ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
376
377         /* api callbacks */
378         ot->invoke = transform_invoke;
379         ot->exec   = transform_exec;
380         ot->modal  = transform_modal;
381         ot->cancel  = transform_cancel;
382         ot->poll   = ED_operator_areaactive;
383
384         RNA_def_float_rotation(ot->srna, "value", 1, NULL, -FLT_MAX, FLT_MAX, "Angle", "", -M_PI*2, M_PI*2);
385
386         Properties_Proportional(ot);
387
388         RNA_def_boolean(ot->srna, "mirror", 0, "Mirror Editing", "");
389
390         Properties_Constraints(ot);
391
392         Properties_Snapping(ot, 0);
393 }
394
395 void TFM_OT_tilt(struct wmOperatorType *ot)
396 {
397         /* identifiers */
398         ot->name   = "Tilt";
399         ot->idname = OP_TILT;
400         ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
401
402         /* api callbacks */
403         ot->invoke = transform_invoke;
404         ot->exec   = transform_exec;
405         ot->modal  = transform_modal;
406         ot->cancel  = transform_cancel;
407         ot->poll   = ED_operator_editcurve;
408
409         RNA_def_float_rotation(ot->srna, "value", 1, NULL, -FLT_MAX, FLT_MAX, "Angle", "", -M_PI*2, M_PI*2);
410
411         Properties_Proportional(ot);
412
413         RNA_def_boolean(ot->srna, "mirror", 0, "Mirror Editing", "");
414
415         Properties_Constraints(ot);
416 }
417
418 void TFM_OT_warp(struct wmOperatorType *ot)
419 {
420         /* identifiers */
421         ot->name   = "Warp";
422         ot->idname = OP_WARP;
423         ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
424
425         /* api callbacks */
426         ot->invoke = transform_invoke;
427         ot->exec   = transform_exec;
428         ot->modal  = transform_modal;
429         ot->cancel  = transform_cancel;
430         ot->poll   = ED_operator_areaactive;
431
432         RNA_def_float_rotation(ot->srna, "value", 1, NULL, -FLT_MAX, FLT_MAX, "Angle", "", 0, 1);
433
434         Properties_Proportional(ot);
435
436         RNA_def_boolean(ot->srna, "mirror", 0, "Mirror Editing", "");
437
438         // XXX Shear axis?
439 //      Properties_Constraints(ot);
440 }
441
442 void TFM_OT_shear(struct wmOperatorType *ot)
443 {
444         /* identifiers */
445         ot->name   = "Shear";
446         ot->idname = OP_SHEAR;
447         ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
448
449         /* api callbacks */
450         ot->invoke = transform_invoke;
451         ot->exec   = transform_exec;
452         ot->modal  = transform_modal;
453         ot->cancel  = transform_cancel;
454         ot->poll   = ED_operator_areaactive;
455
456         RNA_def_float(ot->srna, "value", 0, -FLT_MAX, FLT_MAX, "Offset", "", -FLT_MAX, FLT_MAX);
457
458         Properties_Proportional(ot);
459
460         RNA_def_boolean(ot->srna, "mirror", 0, "Mirror Editing", "");
461
462         // XXX Shear axis?
463 //      Properties_Constraints(ot);
464 }
465
466 void TFM_OT_shrink_fatten(struct wmOperatorType *ot)
467 {
468         /* identifiers */
469         ot->name   = "Shrink/Fatten";
470         ot->idname = OP_SHRINK_FATTEN;
471         ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
472
473         /* api callbacks */
474         ot->invoke = transform_invoke;
475         ot->exec   = transform_exec;
476         ot->modal  = transform_modal;
477         ot->cancel  = transform_cancel;
478         ot->poll   = ED_operator_editmesh;
479
480         RNA_def_float(ot->srna, "value", 0, -FLT_MAX, FLT_MAX, "Offset", "", -FLT_MAX, FLT_MAX);
481
482         Properties_Proportional(ot);
483
484         RNA_def_boolean(ot->srna, "mirror", 0, "Mirror Editing", "");
485 }
486
487 void TFM_OT_tosphere(struct wmOperatorType *ot)
488 {
489         /* identifiers */
490         ot->name   = "To Sphere";
491         ot->idname = OP_TOSPHERE;
492         ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
493
494         /* api callbacks */
495         ot->invoke = transform_invoke;
496         ot->exec   = transform_exec;
497         ot->modal  = transform_modal;
498         ot->cancel  = transform_cancel;
499         ot->poll   = ED_operator_areaactive;
500
501         RNA_def_float_percentage(ot->srna, "value", 0, 0, 1, "Percentage", "", 0, 1);
502
503         Properties_Proportional(ot);
504
505         RNA_def_boolean(ot->srna, "mirror", 0, "Mirror Editing", "");
506 }
507
508 void TFM_OT_transform(struct wmOperatorType *ot)
509 {
510         static EnumPropertyItem transform_mode_types[] = {
511                         {TFM_INIT, "INIT", 0, "Init", ""},
512                         {TFM_DUMMY, "DUMMY", 0, "Dummy", ""},
513                         {TFM_TRANSLATION, "TRANSLATION", 0, "Translation", ""},
514                         {TFM_ROTATION, "ROTATION", 0, "Rotation", ""},
515                         {TFM_RESIZE, "RESIZE", 0, "Resize", ""},
516                         {TFM_TOSPHERE, "TOSPHERE", 0, "Tosphere", ""},
517                         {TFM_SHEAR, "SHEAR", 0, "Shear", ""},
518                         {TFM_WARP, "WARP", 0, "Warp", ""},
519                         {TFM_SHRINKFATTEN, "SHRINKFATTEN", 0, "Shrinkfatten", ""},
520                         {TFM_TILT, "TILT", 0, "Tilt", ""},
521                         {TFM_TRACKBALL, "TRACKBALL", 0, "Trackball", ""},
522                         {TFM_PUSHPULL, "PUSHPULL", 0, "Pushpull", ""},
523                         {TFM_CREASE, "CREASE", 0, "Crease", ""},
524                         {TFM_MIRROR, "MIRROR", 0, "Mirror", ""},
525                         {TFM_BONESIZE, "BONESIZE", 0, "Bonesize", ""},
526                         {TFM_BONE_ENVELOPE, "BONE_ENVELOPE", 0, "Bone_Envelope", ""},
527                         {TFM_CURVE_SHRINKFATTEN, "CURVE_SHRINKFATTEN", 0, "Curve_Shrinkfatten", ""},
528                         {TFM_BONE_ROLL, "BONE_ROLL", 0, "Bone_Roll", ""},
529                         {TFM_TIME_TRANSLATE, "TIME_TRANSLATE", 0, "Time_Translate", ""},
530                         {TFM_TIME_SLIDE, "TIME_SLIDE", 0, "Time_Slide", ""},
531                         {TFM_TIME_SCALE, "TIME_SCALE", 0, "Time_Scale", ""},
532                         {TFM_TIME_EXTEND, "TIME_EXTEND", 0, "Time_Extend", ""},
533                         {TFM_BAKE_TIME, "BAKE_TIME", 0, "Bake_Time", ""},
534                         {TFM_BEVEL, "BEVEL", 0, "Bevel", ""},
535                         {TFM_BWEIGHT, "BWEIGHT", 0, "Bweight", ""},
536                         {TFM_ALIGN, "ALIGN", 0, "Align", ""},
537                         {0, NULL, 0, NULL, NULL}
538         };
539
540         /* identifiers */
541         ot->name   = "Transform";
542         ot->idname = "TFM_OT_transform";
543         ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
544
545         /* api callbacks */
546         ot->invoke = transform_invoke;
547         ot->exec   = transform_exec;
548         ot->modal  = transform_modal;
549         ot->cancel  = transform_cancel;
550         ot->poll   = ED_operator_areaactive;
551
552         RNA_def_enum(ot->srna, "mode", transform_mode_types, 0, "Mode", "");
553
554         RNA_def_float_vector(ot->srna, "value", 4, NULL, -FLT_MAX, FLT_MAX, "Values", "", -FLT_MAX, FLT_MAX);
555
556         Properties_Proportional(ot);
557         RNA_def_boolean(ot->srna, "mirror", 0, "Mirror Editing", "");
558
559         RNA_def_boolean_vector(ot->srna, "constraint_axis", 3, NULL, "Constraint Axis", "");
560         RNA_def_int(ot->srna, "constraint_orientation", 0, 0, INT_MAX, "Constraint Orientation", "", 0, INT_MAX);
561 }
562
563 void transform_operatortypes(void)
564 {
565         WM_operatortype_append(TFM_OT_transform);
566         WM_operatortype_append(TFM_OT_translation);
567         WM_operatortype_append(TFM_OT_rotation);
568         WM_operatortype_append(TFM_OT_tosphere);
569         WM_operatortype_append(TFM_OT_resize);
570         WM_operatortype_append(TFM_OT_shear);
571         WM_operatortype_append(TFM_OT_warp);
572         WM_operatortype_append(TFM_OT_shrink_fatten);
573         WM_operatortype_append(TFM_OT_tilt);
574         WM_operatortype_append(TFM_OT_trackball);
575
576         WM_operatortype_append(TFM_OT_select_orientation);
577 }
578
579 void transform_keymap_for_space(struct wmWindowManager *wm, struct ListBase *keymap, int spaceid)
580 {
581         wmKeymapItem *km;
582         switch(spaceid)
583         {
584                 case SPACE_VIEW3D:
585                         km = WM_keymap_add_item(keymap, "TFM_OT_translation", GKEY, KM_PRESS, 0, 0);
586
587                         km= WM_keymap_add_item(keymap, "TFM_OT_translation", EVT_TWEAK_S, KM_ANY, 0, 0);
588
589                         km = WM_keymap_add_item(keymap, "TFM_OT_rotation", RKEY, KM_PRESS, 0, 0);
590
591                         km = WM_keymap_add_item(keymap, "TFM_OT_resize", SKEY, KM_PRESS, 0, 0);
592
593                         km = WM_keymap_add_item(keymap, "TFM_OT_warp", WKEY, KM_PRESS, KM_SHIFT, 0);
594
595                         km = WM_keymap_add_item(keymap, "TFM_OT_tosphere", SKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0);
596
597                         km = WM_keymap_add_item(keymap, "TFM_OT_shear", SKEY, KM_PRESS, KM_ALT|KM_CTRL|KM_SHIFT, 0);
598
599                         km = WM_keymap_add_item(keymap, "TFM_OT_shrink_fatten", SKEY, KM_PRESS, KM_ALT, 0);
600
601                         km = WM_keymap_add_item(keymap, "TFM_OT_tilt", TKEY, KM_PRESS, 0, 0);
602
603                         km = WM_keymap_add_item(keymap, "TFM_OT_select_orientation", SPACEKEY, KM_PRESS, KM_ALT, 0);
604
605                         break;
606                 case SPACE_ACTION:
607                         km= WM_keymap_add_item(keymap, "TFM_OT_transform", GKEY, KM_PRESS, 0, 0);
608                         RNA_int_set(km->ptr, "mode", TFM_TIME_TRANSLATE);
609
610                         km= WM_keymap_add_item(keymap, "TFM_OT_transform", EVT_TWEAK_S, KM_ANY, 0, 0);
611                         RNA_int_set(km->ptr, "mode", TFM_TIME_TRANSLATE);
612
613                         km= WM_keymap_add_item(keymap, "TFM_OT_transform", EKEY, KM_PRESS, 0, 0);
614                         RNA_int_set(km->ptr, "mode", TFM_TIME_EXTEND);
615
616                         km= WM_keymap_add_item(keymap, "TFM_OT_transform", SKEY, KM_PRESS, 0, 0);
617                         RNA_int_set(km->ptr, "mode", TFM_TIME_SCALE);
618
619                         km= WM_keymap_add_item(keymap, "TFM_OT_transform", TKEY, KM_PRESS, 0, 0);
620                         RNA_int_set(km->ptr, "mode", TFM_TIME_SLIDE);
621                         break;
622                 case SPACE_IPO:
623                         km= WM_keymap_add_item(keymap, "TFM_OT_translation", GKEY, KM_PRESS, 0, 0);
624
625                         km= WM_keymap_add_item(keymap, "TFM_OT_translation", EVT_TWEAK_S, KM_ANY, 0, 0);
626
627                                 // XXX the 'mode' identifier here is not quite right
628                         km= WM_keymap_add_item(keymap, "TFM_OT_transform", EKEY, KM_PRESS, 0, 0);
629                         RNA_int_set(km->ptr, "mode", TFM_TIME_EXTEND);
630
631                         km = WM_keymap_add_item(keymap, "TFM_OT_rotation", RKEY, KM_PRESS, 0, 0);
632
633                         km = WM_keymap_add_item(keymap, "TFM_OT_resize", SKEY, KM_PRESS, 0, 0);
634                         break;
635                 case SPACE_NODE:
636                         km= WM_keymap_add_item(keymap, "TFM_OT_translation", GKEY, KM_PRESS, 0, 0);
637
638                         km= WM_keymap_add_item(keymap, "TFM_OT_translation", EVT_TWEAK_A, KM_ANY, 0, 0);
639                         km= WM_keymap_add_item(keymap, "TFM_OT_translation", EVT_TWEAK_S, KM_ANY, 0, 0);
640
641                         km = WM_keymap_add_item(keymap, "TFM_OT_rotation", RKEY, KM_PRESS, 0, 0);
642
643                         km = WM_keymap_add_item(keymap, "TFM_OT_resize", SKEY, KM_PRESS, 0, 0);
644                         break;
645                 case SPACE_SEQ:
646                         km= WM_keymap_add_item(keymap, "TFM_OT_translation", GKEY, KM_PRESS, 0, 0);
647
648                         km= WM_keymap_add_item(keymap, "TFM_OT_translation", EVT_TWEAK_S, KM_ANY, 0, 0);
649
650                         km= WM_keymap_add_item(keymap, "TFM_OT_transform", EKEY, KM_PRESS, 0, 0);
651                         RNA_int_set(km->ptr, "mode", TFM_TIME_EXTEND);
652                         break;
653                 case SPACE_IMAGE:
654                         km = WM_keymap_add_item(keymap, "TFM_OT_translation", GKEY, KM_PRESS, 0, 0);
655
656                         km= WM_keymap_add_item(keymap, "TFM_OT_translation", EVT_TWEAK_S, KM_ANY, 0, 0);
657
658                         km = WM_keymap_add_item(keymap, "TFM_OT_rotation", RKEY, KM_PRESS, 0, 0);
659
660                         km = WM_keymap_add_item(keymap, "TFM_OT_resize", SKEY, KM_PRESS, 0, 0);
661
662                         km = WM_keymap_add_item(keymap, "TFM_OT_transform", MKEY, KM_PRESS, 0, 0);
663                         RNA_int_set(km->ptr, "mode", TFM_MIRROR);
664                         break;
665                 default:
666                         break;
667         }
668 }
669