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