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