workaround for loopselect-slide (with multicut enabled) changing from vertex-select...
[blender-staging.git] / source / blender / editors / transform / transform_ops.c
1 /*
2  * ***** BEGIN GPL LICENSE BLOCK *****
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software Foundation,
16  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  *
18  * Contributor(s): none yet.
19  *
20  * ***** END GPL LICENSE BLOCK *****
21  */
22
23 /** \file blender/editors/transform/transform_ops.c
24  *  \ingroup edtransform
25  */
26
27 #include "MEM_guardedalloc.h"
28
29 #include "DNA_object_types.h"
30 #include "DNA_scene_types.h"
31
32 #include "BLI_math.h"
33 #include "BLI_utildefines.h"
34
35 #include "BLF_translation.h"
36
37 #include "BKE_context.h"
38 #include "BKE_global.h"
39 #include "BKE_armature.h"
40 #include "BKE_report.h"
41
42 #include "RNA_access.h"
43 #include "RNA_define.h"
44 #include "RNA_enum_types.h"
45
46 #include "WM_api.h"
47 #include "WM_types.h"
48
49 #include "UI_interface.h"
50 #include "UI_resources.h"
51
52 #include "ED_screen.h"
53 #include "ED_mesh.h"
54
55 #include "transform.h"
56
57 typedef struct TransformModeItem {
58         char *idname;
59         int mode;
60         void (*opfunc)(wmOperatorType *);
61 } TransformModeItem;
62
63 static float VecOne[3] = {1, 1, 1};
64
65 static char OP_TRANSLATION[] = "TRANSFORM_OT_translate";
66 static char OP_ROTATION[] = "TRANSFORM_OT_rotate";
67 static char OP_TOSPHERE[] = "TRANSFORM_OT_tosphere";
68 static char OP_RESIZE[] = "TRANSFORM_OT_resize";
69 static char OP_SKIN_RESIZE[] = "TRANSFORM_OT_skin_resize";
70 static char OP_SHEAR[] = "TRANSFORM_OT_shear";
71 static char OP_WARP[] = "TRANSFORM_OT_warp";
72 static char OP_SHRINK_FATTEN[] = "TRANSFORM_OT_shrink_fatten";
73 static char OP_PUSH_PULL[] = "TRANSFORM_OT_push_pull";
74 static char OP_TILT[] = "TRANSFORM_OT_tilt";
75 static char OP_TRACKBALL[] = "TRANSFORM_OT_trackball";
76 static char OP_MIRROR[] = "TRANSFORM_OT_mirror";
77 static char OP_EDGE_SLIDE[] = "TRANSFORM_OT_edge_slide";
78 static char OP_VERT_SLIDE[] = "TRANSFORM_OT_vert_slide";
79 static char OP_EDGE_CREASE[] = "TRANSFORM_OT_edge_crease";
80 static char OP_EDGE_BWEIGHT[] = "TRANSFORM_OT_edge_bevelweight";
81 static char OP_SEQ_SLIDE[] = "TRANSFORM_OT_seq_slide";
82
83 static void TRANSFORM_OT_translate(struct wmOperatorType *ot);
84 static void TRANSFORM_OT_rotate(struct wmOperatorType *ot);
85 static void TRANSFORM_OT_tosphere(struct wmOperatorType *ot);
86 static void TRANSFORM_OT_resize(struct wmOperatorType *ot);
87 static void TRANSFORM_OT_skin_resize(struct wmOperatorType *ot);
88 static void TRANSFORM_OT_shear(struct wmOperatorType *ot);
89 static void TRANSFORM_OT_warp(struct wmOperatorType *ot);
90 static void TRANSFORM_OT_shrink_fatten(struct wmOperatorType *ot);
91 static void TRANSFORM_OT_push_pull(struct wmOperatorType *ot);
92 static void TRANSFORM_OT_tilt(struct wmOperatorType *ot);
93 static void TRANSFORM_OT_trackball(struct wmOperatorType *ot);
94 static void TRANSFORM_OT_mirror(struct wmOperatorType *ot);
95 static void TRANSFORM_OT_edge_slide(struct wmOperatorType *ot);
96 static void TRANSFORM_OT_vert_slide(struct wmOperatorType *ot);
97 static void TRANSFORM_OT_edge_crease(struct wmOperatorType *ot);
98 static void TRANSFORM_OT_edge_bevelweight(struct wmOperatorType *ot);
99 static void TRANSFORM_OT_seq_slide(struct wmOperatorType *ot);
100
101 static TransformModeItem transform_modes[] =
102 {
103         {OP_TRANSLATION, TFM_TRANSLATION, TRANSFORM_OT_translate},
104         {OP_ROTATION, TFM_ROTATION, TRANSFORM_OT_rotate},
105         {OP_TOSPHERE, TFM_TOSPHERE, TRANSFORM_OT_tosphere},
106         {OP_RESIZE, TFM_RESIZE, TRANSFORM_OT_resize},
107         {OP_SKIN_RESIZE, TFM_SKIN_RESIZE, TRANSFORM_OT_skin_resize},
108         {OP_SHEAR, TFM_SHEAR, TRANSFORM_OT_shear},
109         {OP_WARP, TFM_WARP, TRANSFORM_OT_warp},
110         {OP_SHRINK_FATTEN, TFM_SHRINKFATTEN, TRANSFORM_OT_shrink_fatten},
111         {OP_PUSH_PULL, TFM_PUSHPULL, TRANSFORM_OT_push_pull},
112         {OP_TILT, TFM_TILT, TRANSFORM_OT_tilt},
113         {OP_TRACKBALL, TFM_TRACKBALL, TRANSFORM_OT_trackball},
114         {OP_MIRROR, TFM_MIRROR, TRANSFORM_OT_mirror},
115         {OP_EDGE_SLIDE, TFM_EDGE_SLIDE, TRANSFORM_OT_edge_slide},
116         {OP_VERT_SLIDE, TFM_VERT_SLIDE, TRANSFORM_OT_vert_slide},
117         {OP_EDGE_CREASE, TFM_CREASE, TRANSFORM_OT_edge_crease},
118         {OP_EDGE_BWEIGHT, TFM_BWEIGHT, TRANSFORM_OT_edge_bevelweight},
119         {OP_SEQ_SLIDE, TFM_SEQ_SLIDE, TRANSFORM_OT_seq_slide},
120         {NULL, 0}
121 };
122
123 EnumPropertyItem transform_mode_types[] =
124 {
125         {TFM_INIT, "INIT", 0, "Init", ""},
126         {TFM_DUMMY, "DUMMY", 0, "Dummy", ""},
127         {TFM_TRANSLATION, "TRANSLATION", 0, "Translation", ""},
128         {TFM_ROTATION, "ROTATION", 0, "Rotation", ""},
129         {TFM_RESIZE, "RESIZE", 0, "Resize", ""},
130         {TFM_SKIN_RESIZE, "SKIN_RESIZE", 0, "Skin Resize", ""},
131         {TFM_TOSPHERE, "TOSPHERE", 0, "Tosphere", ""},
132         {TFM_SHEAR, "SHEAR", 0, "Shear", ""},
133         {TFM_WARP, "WARP", 0, "Warp", ""},
134         {TFM_SHRINKFATTEN, "SHRINKFATTEN", 0, "Shrinkfatten", ""},
135         {TFM_TILT, "TILT", 0, "Tilt", ""},
136         {TFM_TRACKBALL, "TRACKBALL", 0, "Trackball", ""},
137         {TFM_PUSHPULL, "PUSHPULL", 0, "Pushpull", ""},
138         {TFM_CREASE, "CREASE", 0, "Crease", ""},
139         {TFM_MIRROR, "MIRROR", 0, "Mirror", ""},
140         {TFM_BONESIZE, "BONE_SIZE", 0, "Bonesize", ""},
141         {TFM_BONE_ENVELOPE, "BONE_ENVELOPE", 0, "Bone_Envelope", ""},
142         {TFM_CURVE_SHRINKFATTEN, "CURVE_SHRINKFATTEN", 0, "Curve_Shrinkfatten", ""},
143         {TFM_MASK_SHRINKFATTEN, "MASK_SHRINKFATTEN", 0, "Mask_Shrinkfatten", ""},
144         {TFM_BONE_ROLL, "BONE_ROLL", 0, "Bone_Roll", ""},
145         {TFM_TIME_TRANSLATE, "TIME_TRANSLATE", 0, "Time_Translate", ""},
146         {TFM_TIME_SLIDE, "TIME_SLIDE", 0, "Time_Slide", ""},
147         {TFM_TIME_SCALE, "TIME_SCALE", 0, "Time_Scale", ""},
148         {TFM_TIME_EXTEND, "TIME_EXTEND", 0, "Time_Extend", ""},
149         {TFM_BAKE_TIME, "BAKE_TIME", 0, "Bake_Time", ""},
150         {TFM_BEVEL, "BEVEL", 0, "Bevel", ""},
151         {TFM_BWEIGHT, "BWEIGHT", 0, "Bweight", ""},
152         {TFM_ALIGN, "ALIGN", 0, "Align", ""},
153         {TFM_EDGE_SLIDE, "EDGESLIDE", 0, "Edge Slide", ""},
154         {TFM_SEQ_SLIDE, "SEQSLIDE", 0, "Sequence Slide", ""},
155         {0, NULL, 0, NULL, NULL}
156 };
157
158 static int select_orientation_exec(bContext *C, wmOperator *op)
159 {
160         int orientation = RNA_enum_get(op->ptr, "orientation");
161
162         BIF_selectTransformOrientationValue(C, orientation);
163         
164         WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, CTX_wm_view3d(C));
165
166         return OPERATOR_FINISHED;
167 }
168
169 static int select_orientation_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *UNUSED(event))
170 {
171         uiPopupMenu *pup;
172         uiLayout *layout;
173
174         pup = uiPupMenuBegin(C, IFACE_("Orientation"), ICON_NONE);
175         layout = uiPupMenuLayout(pup);
176         uiItemsEnumO(layout, "TRANSFORM_OT_select_orientation", "orientation");
177         uiPupMenuEnd(C, pup);
178
179         return OPERATOR_CANCELLED;
180 }
181
182 static void TRANSFORM_OT_select_orientation(struct wmOperatorType *ot)
183 {
184         PropertyRNA *prop;
185
186         /* identifiers */
187         ot->name   = "Select Orientation";
188         ot->description = "Select transformation orientation";
189         ot->idname = "TRANSFORM_OT_select_orientation";
190         ot->flag   = OPTYPE_UNDO;
191
192         /* api callbacks */
193         ot->invoke = select_orientation_invoke;
194         ot->exec   = select_orientation_exec;
195         ot->poll   = ED_operator_view3d_active;
196
197         prop = RNA_def_property(ot->srna, "orientation", PROP_ENUM, PROP_NONE);
198         RNA_def_property_ui_text(prop, "Orientation", "Transformation orientation");
199         RNA_def_enum_funcs(prop, rna_TransformOrientation_itemf);
200 }
201
202
203 static int delete_orientation_exec(bContext *C, wmOperator *UNUSED(op))
204 {
205         View3D *v3d = CTX_wm_view3d(C);
206         int selected_index = (v3d->twmode - V3D_MANIP_CUSTOM);
207
208         BIF_removeTransformOrientationIndex(C, selected_index);
209         
210         WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, CTX_wm_view3d(C));
211         WM_event_add_notifier(C, NC_SCENE | NA_EDITED, CTX_data_scene(C));
212
213         return OPERATOR_FINISHED;
214 }
215
216 static int delete_orientation_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
217 {
218         return delete_orientation_exec(C, op);
219 }
220
221 static int delete_orientation_poll(bContext *C)
222 {
223         int selected_index = -1;
224         View3D *v3d = CTX_wm_view3d(C);
225         
226         if (ED_operator_areaactive(C) == 0)
227                 return 0;
228         
229         
230         if (v3d) {
231                 selected_index = (v3d->twmode - V3D_MANIP_CUSTOM);
232         }
233         
234         return selected_index >= 0;
235 }
236
237 static void TRANSFORM_OT_delete_orientation(struct wmOperatorType *ot)
238 {
239         /* identifiers */
240         ot->name   = "Delete Orientation";
241         ot->description = "Delete transformation orientation";
242         ot->idname = "TRANSFORM_OT_delete_orientation";
243         ot->flag   = OPTYPE_UNDO;
244
245         /* api callbacks */
246         ot->invoke = delete_orientation_invoke;
247         ot->exec   = delete_orientation_exec;
248         ot->poll   = delete_orientation_poll;
249 }
250
251 static int create_orientation_exec(bContext *C, wmOperator *op)
252 {
253         char name[MAX_NAME];
254         int use = RNA_boolean_get(op->ptr, "use");
255         int overwrite = RNA_boolean_get(op->ptr, "overwrite");
256         int use_view = RNA_boolean_get(op->ptr, "use_view");
257
258         RNA_string_get(op->ptr, "name", name);
259
260         if (use && !CTX_wm_view3d(C)) {
261                 BKE_report(op->reports, RPT_ERROR, "Create Orientation's 'use' parameter only valid in a 3DView context");
262                 return OPERATOR_CANCELLED;
263         }
264
265         BIF_createTransformOrientation(C, op->reports, name, use_view, use, overwrite);
266
267         WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, CTX_wm_view3d(C));
268         WM_event_add_notifier(C, NC_SCENE | NA_EDITED, CTX_data_scene(C));
269         
270         return OPERATOR_FINISHED;
271 }
272
273 static void TRANSFORM_OT_create_orientation(struct wmOperatorType *ot)
274 {
275         /* identifiers */
276         ot->name   = "Create Orientation";
277         ot->description = "Create transformation orientation from selection";
278         ot->idname = "TRANSFORM_OT_create_orientation";
279         ot->flag   = OPTYPE_REGISTER | OPTYPE_UNDO;
280
281         /* api callbacks */
282         ot->exec   = create_orientation_exec;
283         ot->poll   = ED_operator_areaactive;
284
285         RNA_def_string(ot->srna, "name", "", MAX_NAME, "Name", "Name of the new custom orientation");
286         RNA_def_boolean(ot->srna, "use_view", FALSE, "Use View",
287                         "Use the current view instead of the active object to create the new orientation");
288         RNA_def_boolean(ot->srna, "use", FALSE, "Use after creation", "Select orientation after its creation");
289         RNA_def_boolean(ot->srna, "overwrite", FALSE, "Overwrite previous",
290                         "Overwrite previously created orientation with same name");
291 }
292
293
294 #ifdef USE_LOOPSLIDE_HACK
295 /**
296  * Special hack for MESH_OT_loopcut_slide so we get back to the selection mode
297  */
298 static void transformops_loopsel_hack(bContext *C, wmOperator *op)
299 {
300         if (op->type->idname == OP_EDGE_SLIDE) {
301                 if (op->opm && op->opm->opm && op->opm->opm->prev) {
302                         wmOperator *op_prev = op->opm->opm->prev;
303                         Scene *scene = CTX_data_scene(C);
304                         int mesh_select_mode[3];
305                         PropertyRNA *prop = RNA_struct_find_property(op_prev->ptr, "mesh_select_mode_init");
306
307                         if (RNA_property_is_set(op_prev->ptr, prop)) {
308                                 ToolSettings *ts = scene->toolsettings;
309                                 short selectmode_orig;
310
311                                 RNA_property_boolean_get_array(op_prev->ptr, prop, mesh_select_mode);
312                                 selectmode_orig = ((mesh_select_mode[0] ? SCE_SELECT_VERTEX : 0) |
313                                                    (mesh_select_mode[1] ? SCE_SELECT_EDGE   : 0) |
314                                                    (mesh_select_mode[2] ? SCE_SELECT_FACE   : 0));
315
316                                 /* still switch if we were originally in face select mode */
317                                 if ((ts->selectmode != selectmode_orig) && (selectmode_orig != SCE_SELECT_FACE)) {
318                                         BMEditMesh *em = BKE_editmesh_from_object(scene->obedit);
319                                         em->selectmode = ts->selectmode = selectmode_orig;
320                                         EDBM_selectmode_set(em);
321                                 }
322                         }
323                 }
324         }
325 }
326 #endif  /* USE_LOOPSLIDE_HACK */
327
328
329 static void transformops_exit(bContext *C, wmOperator *op)
330 {
331 #ifdef USE_LOOPSLIDE_HACK
332         transformops_loopsel_hack(C, op);
333 #endif
334
335         saveTransform(C, op->customdata, op);
336         MEM_freeN(op->customdata);
337         op->customdata = NULL;
338         G.moving = 0;
339 }
340
341 static int transformops_data(bContext *C, wmOperator *op, const wmEvent *event)
342 {
343         int retval = 1;
344         if (op->customdata == NULL) {
345                 TransInfo *t = MEM_callocN(sizeof(TransInfo), "TransInfo data2");
346                 TransformModeItem *tmode;
347                 int mode = -1;
348
349                 for (tmode = transform_modes; tmode->idname; tmode++) {
350                         if (op->type->idname == tmode->idname) {
351                                 mode = tmode->mode;
352                                 break;
353                         }
354                 }
355
356                 if (mode == -1) {
357                         mode = RNA_enum_get(op->ptr, "mode");
358                 }
359
360                 retval = initTransform(C, t, op, event, mode);
361                 G.moving = 1;
362
363                 /* store data */
364                 if (retval) {
365                         op->customdata = t;
366                 }
367                 else {
368                         MEM_freeN(t);
369                 }
370         }
371
372         return retval; /* return 0 on error */
373 }
374
375 static int transform_modal(bContext *C, wmOperator *op, const wmEvent *event)
376 {
377         int exit_code;
378
379         TransInfo *t = op->customdata;
380         const enum TfmMode mode_prev = t->mode;
381
382 #if 0
383         // stable 2D mouse coords map to different 3D coords while the 3D mouse is active
384         // in other words, 2D deltas are no longer good enough!
385         // disable until individual 'transformers' behave better
386
387         if (event->type == NDOF_MOTION)
388                 return OPERATOR_PASS_THROUGH;
389 #endif
390
391         /* XXX insert keys are called here, and require context */
392         t->context = C;
393         exit_code = transformEvent(t, event);
394         t->context = NULL;
395
396         transformApply(C, t);
397
398         exit_code |= transformEnd(C, t);
399
400         if ((exit_code & OPERATOR_RUNNING_MODAL) == 0) {
401                 transformops_exit(C, op);
402                 exit_code &= ~OPERATOR_PASS_THROUGH; /* preventively remove passthrough */
403         }
404         else {
405                 if (mode_prev != t->mode) {
406                         /* WARNING: this is not normal to switch operator types
407                          * normally it would not be supported but transform happens
408                          * to share callbacks between differernt operators. */
409                         wmOperatorType *ot_new = NULL;
410                         TransformModeItem *item = transform_modes;
411                         while (item->idname) {
412                                 if (item->mode == t->mode) {
413                                         ot_new = WM_operatortype_find(item->idname, false);
414                                         break;
415                                 }
416                                 item++;
417                         }
418
419                         BLI_assert(ot_new != NULL);
420                         if (ot_new) {
421                                 WM_operator_type_set(op, ot_new);
422                         }
423                         /* end suspicious code */
424                 }
425         }
426
427         return exit_code;
428 }
429
430 static int transform_cancel(bContext *C, wmOperator *op)
431 {
432         TransInfo *t = op->customdata;
433
434         t->state = TRANS_CANCEL;
435         transformEnd(C, t);
436         transformops_exit(C, op);
437
438         return OPERATOR_CANCELLED;
439 }
440
441 static int transform_exec(bContext *C, wmOperator *op)
442 {
443         TransInfo *t;
444
445         if (!transformops_data(C, op, NULL)) {
446                 G.moving = 0;
447                 return OPERATOR_CANCELLED;
448         }
449
450         t = op->customdata;
451
452         t->options |= CTX_AUTOCONFIRM;
453
454         transformApply(C, t);
455
456         transformEnd(C, t);
457
458         transformops_exit(C, op);
459         
460         WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
461
462         return OPERATOR_FINISHED;
463 }
464
465 static int transform_invoke(bContext *C, wmOperator *op, const wmEvent *event)
466 {
467         if (!transformops_data(C, op, event)) {
468                 G.moving = 0;
469                 return OPERATOR_CANCELLED;
470         }
471
472         if (RNA_struct_property_is_set(op->ptr, "value")) {
473                 return transform_exec(C, op);
474         }
475         else {
476                 /* add temp handler */
477                 WM_event_add_modal_handler(C, op);
478
479                 op->flag |= OP_GRAB_POINTER; // XXX maybe we want this with the manipulator only?
480                 return OPERATOR_RUNNING_MODAL;
481         }
482 }
483
484 void Transform_Properties(struct wmOperatorType *ot, int flags)
485 {
486         PropertyRNA *prop;
487
488         if (flags & P_AXIS) {
489                 prop = RNA_def_property(ot->srna, "axis", PROP_FLOAT, PROP_DIRECTION);
490                 RNA_def_property_array(prop, 3);
491                 /* Make this not hidden when there's a nice axis selection widget */
492                 RNA_def_property_flag(prop, PROP_HIDDEN);
493                 RNA_def_property_ui_text(prop, "Axis", "The axis around which the transformation occurs");
494         }
495
496         if (flags & P_CONSTRAINT) {
497                 RNA_def_boolean_vector(ot->srna, "constraint_axis", 3, NULL, "Constraint Axis", "");
498                 prop = RNA_def_property(ot->srna, "constraint_orientation", PROP_ENUM, PROP_NONE);
499                 RNA_def_property_ui_text(prop, "Orientation", "Transformation orientation");
500                 RNA_def_enum_funcs(prop, rna_TransformOrientation_itemf);
501         }
502
503         if (flags & P_MIRROR) {
504                 RNA_def_boolean(ot->srna, "mirror", 0, "Mirror Editing", "");
505         }
506
507
508         if (flags & P_PROPORTIONAL) {
509                 RNA_def_enum(ot->srna, "proportional", proportional_editing_items, 0, "Proportional Editing", "");
510                 prop = RNA_def_enum(ot->srna, "proportional_edit_falloff", proportional_falloff_items, 0,
511                                     "Proportional Editing Falloff", "Falloff type for proportional editing mode");
512                 RNA_def_property_translation_context(prop, BLF_I18NCONTEXT_ID_CURVE); /* Abusing id_curve :/ */
513                 RNA_def_float(ot->srna, "proportional_size", 1, 0.00001f, FLT_MAX, "Proportional Size", "", 0.001, 100);
514         }
515
516         if (flags & P_SNAP) {
517                 prop = RNA_def_boolean(ot->srna, "snap", 0, "Use Snapping Options", "");
518                 RNA_def_property_flag(prop, PROP_HIDDEN);
519
520                 if (flags & P_GEO_SNAP) {
521                         prop = RNA_def_enum(ot->srna, "snap_target", snap_target_items, 0, "Target", "");
522                         RNA_def_property_flag(prop, PROP_HIDDEN);
523                         prop = RNA_def_float_vector(ot->srna, "snap_point", 3, NULL, -FLT_MAX, FLT_MAX, "Point", "", -FLT_MAX, FLT_MAX);
524                         RNA_def_property_flag(prop, PROP_HIDDEN);
525                         
526                         if (flags & P_ALIGN_SNAP) {
527                                 prop = RNA_def_boolean(ot->srna, "snap_align", 0, "Align with Point Normal", "");
528                                 RNA_def_property_flag(prop, PROP_HIDDEN);
529                                 prop = RNA_def_float_vector(ot->srna, "snap_normal", 3, NULL, -FLT_MAX, FLT_MAX, "Normal", "", -FLT_MAX, FLT_MAX);
530                                 RNA_def_property_flag(prop, PROP_HIDDEN);
531                         }
532                 }
533         }
534
535         if (flags & P_OPTIONS) {
536                 RNA_def_boolean(ot->srna, "texture_space", 0, "Edit Texture Space", "Edit Object data texture space");
537         }
538
539         if (flags & P_CORRECT_UV) {
540                 RNA_def_boolean(ot->srna, "correct_uv", 0, "Correct UVs", "Correct UV coordinates when transforming");
541         }
542
543         // Add confirm method all the time. At the end because it's not really that important and should be hidden only in log, not in keymap edit
544         /*prop =*/ RNA_def_boolean(ot->srna, "release_confirm", 0, "Confirm on Release", "Always confirm operation when releasing button");
545         //RNA_def_property_flag(prop, PROP_HIDDEN);
546 }
547
548 static void TRANSFORM_OT_translate(struct wmOperatorType *ot)
549 {
550         /* identifiers */
551         ot->name   = "Translate";
552         ot->description = "Translate (move) selected items";
553         ot->idname = OP_TRANSLATION;
554         ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
555
556         /* api callbacks */
557         ot->invoke = transform_invoke;
558         ot->exec   = transform_exec;
559         ot->modal  = transform_modal;
560         ot->cancel = transform_cancel;
561         ot->poll   = ED_operator_screenactive;
562
563         RNA_def_float_vector_xyz(ot->srna, "value", 3, NULL, -FLT_MAX, FLT_MAX, "Vector", "", -FLT_MAX, FLT_MAX);
564
565         Transform_Properties(ot, P_CONSTRAINT | P_PROPORTIONAL | P_MIRROR | P_ALIGN_SNAP | P_OPTIONS);
566 }
567
568 static void TRANSFORM_OT_resize(struct wmOperatorType *ot)
569 {
570         /* identifiers */
571         ot->name   = "Resize";
572         ot->description = "Scale (resize) selected items"; 
573         ot->idname = OP_RESIZE;
574         ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
575
576         /* api callbacks */
577         ot->invoke = transform_invoke;
578         ot->exec   = transform_exec;
579         ot->modal  = transform_modal;
580         ot->cancel = transform_cancel;
581         ot->poll   = ED_operator_screenactive;
582
583         RNA_def_float_vector(ot->srna, "value", 3, VecOne, -FLT_MAX, FLT_MAX, "Vector", "", -FLT_MAX, FLT_MAX);
584
585         Transform_Properties(ot, P_CONSTRAINT | P_PROPORTIONAL | P_MIRROR | P_GEO_SNAP | P_OPTIONS);
586 }
587
588 static int skin_resize_poll(bContext *C)
589 {
590         struct Object *obedit = CTX_data_edit_object(C);
591         if (obedit && obedit->type == OB_MESH) {
592                 BMEditMesh *em = BKE_editmesh_from_object(obedit);
593                 return (em && CustomData_has_layer(&em->bm->vdata, CD_MVERT_SKIN));
594         }
595         return 0;
596 }
597
598 static void TRANSFORM_OT_skin_resize(struct wmOperatorType *ot)
599 {
600         /* identifiers */
601         ot->name   = "Skin Resize";
602         ot->description = "Scale selected vertices' skin radii"; 
603         ot->idname = OP_SKIN_RESIZE;
604         ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
605
606         /* api callbacks */
607         ot->invoke = transform_invoke;
608         ot->exec   = transform_exec;
609         ot->modal  = transform_modal;
610         ot->cancel = transform_cancel;
611         ot->poll   = skin_resize_poll;
612
613         RNA_def_float_vector(ot->srna, "value", 3, VecOne, -FLT_MAX, FLT_MAX, "Vector", "", -FLT_MAX, FLT_MAX);
614
615         Transform_Properties(ot, P_CONSTRAINT | P_PROPORTIONAL | P_MIRROR | P_GEO_SNAP | P_OPTIONS);
616 }
617
618 static void TRANSFORM_OT_trackball(struct wmOperatorType *ot)
619 {
620         PropertyRNA *prop;
621
622         /* identifiers */
623         ot->name   = "Trackball";
624         ot->description = "Trackball style rotation of selected items";
625         ot->idname = OP_TRACKBALL;
626         ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
627
628         /* api callbacks */
629         ot->invoke = transform_invoke;
630         ot->exec   = transform_exec;
631         ot->modal  = transform_modal;
632         ot->cancel = transform_cancel;
633         ot->poll   = ED_operator_screenactive;
634
635         /* Maybe we could use float_vector_xyz here too? */
636         prop = RNA_def_float_vector(ot->srna, "value", 2, NULL, -FLT_MAX, FLT_MAX, "Angle", "", -FLT_MAX, FLT_MAX);
637         RNA_def_property_subtype(prop, PROP_ANGLE);
638
639         Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR | P_SNAP);
640 }
641
642 static void TRANSFORM_OT_rotate(struct wmOperatorType *ot)
643 {
644         PropertyRNA *prop;
645
646         /* identifiers */
647         ot->name = "Rotate";
648         ot->description = "Rotate selected items";
649         ot->idname = OP_ROTATION;
650         ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
651
652         /* api callbacks */
653         ot->invoke = transform_invoke;
654         ot->exec   = transform_exec;
655         ot->modal  = transform_modal;
656         ot->cancel = transform_cancel;
657         ot->poll   = ED_operator_screenactive;
658
659         prop = RNA_def_float(ot->srna, "value", 0.0f, -FLT_MAX, FLT_MAX, "Angle", "", -M_PI * 2, M_PI * 2);
660         RNA_def_property_subtype(prop, PROP_ANGLE);
661
662         Transform_Properties(ot, P_AXIS | P_CONSTRAINT | P_PROPORTIONAL | P_MIRROR | P_GEO_SNAP);
663 }
664
665 static void TRANSFORM_OT_tilt(struct wmOperatorType *ot)
666 {
667         PropertyRNA *prop;
668
669         /* identifiers */
670         ot->name = "Tilt";
671         /* optionals - 
672          * "Tilt selected vertices"
673          * "Specify an extra axis rotation for selected vertices of 3D curve" */
674         ot->description = "Tilt selected control vertices of 3D curve"; 
675         ot->idname = OP_TILT;
676         ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
677
678         /* api callbacks */
679         ot->invoke = transform_invoke;
680         ot->exec   = transform_exec;
681         ot->modal  = transform_modal;
682         ot->cancel = transform_cancel;
683         ot->poll   = ED_operator_editcurve_3d;
684
685         prop = RNA_def_float(ot->srna, "value", 0.0, -FLT_MAX, FLT_MAX, "Angle", "", -M_PI * 2, M_PI * 2);
686         RNA_def_property_subtype(prop, PROP_ANGLE);
687
688         Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR | P_SNAP);
689 }
690
691 static void TRANSFORM_OT_warp(struct wmOperatorType *ot)
692 {
693         /* identifiers */
694         ot->name   = "Warp";
695         ot->description = "Warp selected items around the cursor";
696         ot->idname = OP_WARP;
697         ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
698
699         /* api callbacks */
700         ot->invoke = transform_invoke;
701         ot->exec   = transform_exec;
702         ot->modal  = transform_modal;
703         ot->cancel = transform_cancel;
704         ot->poll   = ED_operator_screenactive;
705
706         RNA_def_float_rotation(ot->srna, "value", 1, NULL, -FLT_MAX, FLT_MAX, "Angle", "", -M_PI * 2, M_PI * 2);
707
708         Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR | P_SNAP);
709         // XXX Warp axis?
710 }
711
712 static void TRANSFORM_OT_shear(struct wmOperatorType *ot)
713 {
714         /* identifiers */
715         ot->name   = "Shear";
716         ot->description = "Shear selected items along the horizontal screen axis";
717         ot->idname = OP_SHEAR;
718         ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
719
720         /* api callbacks */
721         ot->invoke = transform_invoke;
722         ot->exec   = transform_exec;
723         ot->modal  = transform_modal;
724         ot->cancel = transform_cancel;
725         ot->poll   = ED_operator_screenactive;
726
727         RNA_def_float(ot->srna, "value", 0, -FLT_MAX, FLT_MAX, "Offset", "", -FLT_MAX, FLT_MAX);
728
729         Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR | P_SNAP);
730         // XXX Shear axis?
731 }
732
733 static void TRANSFORM_OT_push_pull(struct wmOperatorType *ot)
734 {
735         /* identifiers */
736         ot->name   = "Push/Pull";
737         ot->description = "Push/Pull selected items";
738         ot->idname = OP_PUSH_PULL;
739         ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
740
741         /* api callbacks */
742         ot->invoke = transform_invoke;
743         ot->exec   = transform_exec;
744         ot->modal  = transform_modal;
745         ot->cancel = transform_cancel;
746         ot->poll   = ED_operator_screenactive;
747
748         RNA_def_float(ot->srna, "value", 0, -FLT_MAX, FLT_MAX, "Distance", "", -FLT_MAX, FLT_MAX);
749
750         Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR | P_SNAP);
751 }
752
753 static void TRANSFORM_OT_shrink_fatten(struct wmOperatorType *ot)
754 {
755         /* identifiers */
756         ot->name   = "Shrink/Fatten";
757         ot->description = "Shrink/fatten selected vertices along normals";
758         ot->idname = OP_SHRINK_FATTEN;
759         ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
760
761         /* api callbacks */
762         ot->invoke = transform_invoke;
763         ot->exec   = transform_exec;
764         ot->modal  = transform_modal;
765         ot->cancel = transform_cancel;
766         ot->poll   = ED_operator_editmesh;
767
768         RNA_def_float(ot->srna, "value", 0, -FLT_MAX, FLT_MAX, "Offset", "", -FLT_MAX, FLT_MAX);
769
770         Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR | P_SNAP);
771 }
772
773 static void TRANSFORM_OT_tosphere(struct wmOperatorType *ot)
774 {
775         /* identifiers */
776         ot->name   = "To Sphere";
777         //added "around mesh center" to differentiate between "MESH_OT_vertices_to_sphere()" 
778         ot->description = "Move selected vertices outward in a spherical shape around mesh center";
779         ot->idname = OP_TOSPHERE;
780         ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
781
782         /* api callbacks */
783         ot->invoke = transform_invoke;
784         ot->exec   = transform_exec;
785         ot->modal  = transform_modal;
786         ot->cancel = transform_cancel;
787         ot->poll   = ED_operator_screenactive;
788
789         RNA_def_float_factor(ot->srna, "value", 0, 0, 1, "Factor", "", 0, 1);
790
791         Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR | P_SNAP);
792 }
793
794 static void TRANSFORM_OT_mirror(struct wmOperatorType *ot)
795 {
796         /* identifiers */
797         ot->name   = "Mirror";
798         ot->description = "Mirror selected vertices around one or more axes";
799         ot->idname = OP_MIRROR;
800         ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
801
802         /* api callbacks */
803         ot->invoke = transform_invoke;
804         ot->exec   = transform_exec;
805         ot->modal  = transform_modal;
806         ot->cancel = transform_cancel;
807         ot->poll   = ED_operator_screenactive;
808
809         Transform_Properties(ot, P_CONSTRAINT | P_PROPORTIONAL);
810 }
811
812 static void TRANSFORM_OT_edge_slide(struct wmOperatorType *ot)
813 {
814         /* identifiers */
815         ot->name   = "Edge Slide";
816         ot->description = "Slide an edge loop along a mesh"; 
817         ot->idname = OP_EDGE_SLIDE;
818         ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
819
820         /* api callbacks */
821         ot->invoke = transform_invoke;
822         ot->exec   = transform_exec;
823         ot->modal  = transform_modal;
824         ot->cancel = transform_cancel;
825         ot->poll   = ED_operator_editmesh;
826
827         RNA_def_float_factor(ot->srna, "value", 0, -1.0f, 1.0f, "Factor", "", -1.0f, 1.0f);
828
829         Transform_Properties(ot, P_MIRROR | P_SNAP | P_CORRECT_UV);
830 }
831
832 static void TRANSFORM_OT_vert_slide(struct wmOperatorType *ot)
833 {
834         /* identifiers */
835         ot->name   = "Vertex Slide";
836         ot->description = "Slide a vertex along a mesh";
837         ot->idname = OP_VERT_SLIDE;
838         ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
839
840         /* api callbacks */
841         ot->invoke = transform_invoke;
842         ot->exec   = transform_exec;
843         ot->modal  = transform_modal;
844         ot->cancel = transform_cancel;
845         ot->poll   = ED_operator_editmesh;
846
847         RNA_def_float_factor(ot->srna, "value", 0, -10.0f, 10.0f, "Factor", "", -1.0f, 1.0f);
848
849         Transform_Properties(ot, P_MIRROR | P_SNAP);
850 }
851
852 static void TRANSFORM_OT_edge_crease(struct wmOperatorType *ot)
853 {
854         /* identifiers */
855         ot->name   = "Edge Crease";
856         ot->description = "Change the crease of edges";
857         ot->idname = OP_EDGE_CREASE;
858         ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
859
860         /* api callbacks */
861         ot->invoke = transform_invoke;
862         ot->exec   = transform_exec;
863         ot->modal  = transform_modal;
864         ot->cancel = transform_cancel;
865         ot->poll   = ED_operator_editmesh;
866
867         RNA_def_float_factor(ot->srna, "value", 0, -1.0f, 1.0f, "Factor", "", -1.0f, 1.0f);
868
869         Transform_Properties(ot, P_SNAP);
870 }
871
872 static void TRANSFORM_OT_edge_bevelweight(struct wmOperatorType *ot)
873 {
874         /* identifiers */
875         ot->name   = "Edge Bevel Weight";
876         ot->description = "Change the bevel weight of edges";
877         ot->idname = OP_EDGE_BWEIGHT;
878         ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
879
880         /* api callbacks */
881         ot->invoke = transform_invoke;
882         ot->exec   = transform_exec;
883         ot->modal  = transform_modal;
884         ot->cancel = transform_cancel;
885         ot->poll   = ED_operator_editmesh;
886
887         RNA_def_float_factor(ot->srna, "value", 0, -1.0f, 1.0f, "Factor", "", -1.0f, 1.0f);
888
889         Transform_Properties(ot, P_SNAP);
890 }
891
892 static void TRANSFORM_OT_seq_slide(struct wmOperatorType *ot)
893 {
894         /* identifiers */
895         ot->name   = "Sequence Slide";
896         ot->description = "Slide a sequence strip in time";
897         ot->idname = OP_SEQ_SLIDE;
898         ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
899
900         /* api callbacks */
901         ot->invoke = transform_invoke;
902         ot->exec   = transform_exec;
903         ot->modal  = transform_modal;
904         ot->cancel = transform_cancel;
905         ot->poll   = ED_operator_sequencer_active;
906
907         RNA_def_float_vector_xyz(ot->srna, "value", 2, NULL, -FLT_MAX, FLT_MAX, "Vector", "", -FLT_MAX, FLT_MAX);
908
909         Transform_Properties(ot, P_SNAP);
910 }
911
912 static void TRANSFORM_OT_transform(struct wmOperatorType *ot)
913 {
914         PropertyRNA *prop;
915
916         /* identifiers */
917         ot->name   = "Transform";
918         ot->description = "Transform selected items by mode type";
919         ot->idname = "TRANSFORM_OT_transform";
920         ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
921
922         /* api callbacks */
923         ot->invoke = transform_invoke;
924         ot->exec   = transform_exec;
925         ot->modal  = transform_modal;
926         ot->cancel = transform_cancel;
927         ot->poll   = ED_operator_screenactive;
928
929         prop = RNA_def_enum(ot->srna, "mode", transform_mode_types, TFM_TRANSLATION, "Mode", "");
930         RNA_def_property_flag(prop, PROP_HIDDEN);
931
932         RNA_def_float_vector(ot->srna, "value", 4, NULL, -FLT_MAX, FLT_MAX, "Values", "", -FLT_MAX, FLT_MAX);
933
934         Transform_Properties(ot, P_AXIS | P_CONSTRAINT | P_PROPORTIONAL | P_MIRROR | P_ALIGN_SNAP);
935 }
936
937 void transform_operatortypes(void)
938 {
939         TransformModeItem *tmode;
940
941         for (tmode = transform_modes; tmode->idname; tmode++) {
942                 WM_operatortype_append(tmode->opfunc);
943         }
944
945         WM_operatortype_append(TRANSFORM_OT_transform);
946
947         WM_operatortype_append(TRANSFORM_OT_select_orientation);
948         WM_operatortype_append(TRANSFORM_OT_create_orientation);
949         WM_operatortype_append(TRANSFORM_OT_delete_orientation);
950 }
951
952 void transform_keymap_for_space(wmKeyConfig *keyconf, wmKeyMap *keymap, int spaceid)
953 {
954         wmKeyMapItem *kmi;
955         wmKeyMap *modalmap;
956         
957         /* transform.c, only adds modal map once, checks if it's there */
958         modalmap = transform_modal_keymap(keyconf);
959
960         /* assign map to operators only the first time */
961         if (modalmap) {
962                 TransformModeItem *tmode;
963
964                 for (tmode = transform_modes; tmode->idname; tmode++) {
965                         WM_modalkeymap_assign(modalmap, tmode->idname);
966                 }
967                 WM_modalkeymap_assign(modalmap, "TRANSFORM_OT_transform");
968         }
969         
970         switch (spaceid) {
971                 case SPACE_VIEW3D:
972                         WM_keymap_add_item(keymap, OP_TRANSLATION, GKEY, KM_PRESS, 0, 0);
973
974                         WM_keymap_add_item(keymap, OP_TRANSLATION, EVT_TWEAK_S, KM_ANY, 0, 0);
975
976                         WM_keymap_add_item(keymap, OP_ROTATION, RKEY, KM_PRESS, 0, 0);
977
978                         WM_keymap_add_item(keymap, OP_RESIZE, SKEY, KM_PRESS, 0, 0);
979
980                         WM_keymap_add_item(keymap, OP_WARP, WKEY, KM_PRESS, KM_SHIFT, 0);
981
982                         WM_keymap_add_item(keymap, OP_TOSPHERE, SKEY, KM_PRESS, KM_ALT | KM_SHIFT, 0);
983
984                         WM_keymap_add_item(keymap, OP_SHEAR, SKEY, KM_PRESS, KM_ALT | KM_CTRL | KM_SHIFT, 0);
985
986                         WM_keymap_add_item(keymap, "TRANSFORM_OT_select_orientation", SPACEKEY, KM_PRESS, KM_ALT, 0);
987
988                         kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_create_orientation", SPACEKEY, KM_PRESS, KM_CTRL | KM_ALT, 0);
989                         RNA_boolean_set(kmi->ptr, "use", TRUE);
990
991                         WM_keymap_add_item(keymap, OP_MIRROR, MKEY, KM_PRESS, KM_CTRL, 0);
992
993                         kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", TABKEY, KM_PRESS, KM_SHIFT, 0);
994                         RNA_string_set(kmi->ptr, "data_path", "tool_settings.use_snap");
995
996                         kmi = WM_keymap_add_item(keymap, "WM_OT_context_menu_enum", TABKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0);
997                         RNA_string_set(kmi->ptr, "data_path", "tool_settings.snap_element");
998
999
1000                         kmi = WM_keymap_add_item(keymap, OP_TRANSLATION, TKEY, KM_PRESS, KM_SHIFT, 0);
1001                         RNA_boolean_set(kmi->ptr, "texture_space", TRUE);
1002
1003                         kmi = WM_keymap_add_item(keymap, OP_RESIZE, TKEY, KM_PRESS, KM_SHIFT | KM_ALT, 0);
1004                         RNA_boolean_set(kmi->ptr, "texture_space", TRUE);
1005
1006                         WM_keymap_add_item(keymap, OP_SKIN_RESIZE, AKEY, KM_PRESS, KM_CTRL, 0);
1007
1008                         break;
1009                 case SPACE_ACTION:
1010                         kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", GKEY, KM_PRESS, 0, 0);
1011                         RNA_enum_set(kmi->ptr, "mode", TFM_TIME_TRANSLATE);
1012                         
1013                         kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", EVT_TWEAK_S, KM_ANY, 0, 0);
1014                         RNA_enum_set(kmi->ptr, "mode", TFM_TIME_TRANSLATE);
1015                         
1016                         kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", EKEY, KM_PRESS, 0, 0);
1017                         RNA_enum_set(kmi->ptr, "mode", TFM_TIME_EXTEND);
1018                         
1019                         kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", SKEY, KM_PRESS, 0, 0);
1020                         RNA_enum_set(kmi->ptr, "mode", TFM_TIME_SCALE);
1021                         
1022                         kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", TKEY, KM_PRESS, KM_SHIFT, 0);
1023                         RNA_enum_set(kmi->ptr, "mode", TFM_TIME_SLIDE);
1024                         break;
1025                 case SPACE_IPO:
1026                         WM_keymap_add_item(keymap, OP_TRANSLATION, GKEY, KM_PRESS, 0, 0);
1027                         
1028                         WM_keymap_add_item(keymap, OP_TRANSLATION, EVT_TWEAK_S, KM_ANY, 0, 0);
1029                         
1030                         kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", EKEY, KM_PRESS, 0, 0);
1031                         RNA_enum_set(kmi->ptr, "mode", TFM_TIME_EXTEND);
1032                         
1033                         WM_keymap_add_item(keymap, OP_ROTATION, RKEY, KM_PRESS, 0, 0);
1034                         
1035                         WM_keymap_add_item(keymap, OP_RESIZE, SKEY, KM_PRESS, 0, 0);
1036                         break;
1037                 case SPACE_NLA:
1038                         kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", GKEY, KM_PRESS, 0, 0);
1039                         RNA_enum_set(kmi->ptr, "mode", TFM_TRANSLATION);
1040                         
1041                         kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", EVT_TWEAK_S, KM_ANY, 0, 0);
1042                         RNA_enum_set(kmi->ptr, "mode", TFM_TRANSLATION);
1043                         
1044                         kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", EKEY, KM_PRESS, 0, 0);
1045                         RNA_enum_set(kmi->ptr, "mode", TFM_TIME_EXTEND);
1046                         
1047                         kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", SKEY, KM_PRESS, 0, 0);
1048                         RNA_enum_set(kmi->ptr, "mode", TFM_TIME_SCALE);
1049                         break;
1050                 case SPACE_NODE:
1051                         WM_keymap_add_item(keymap, "NODE_OT_translate_attach", GKEY, KM_PRESS, 0, 0);
1052                         WM_keymap_add_item(keymap, "NODE_OT_translate_attach", EVT_TWEAK_A, KM_ANY, 0, 0);
1053                         WM_keymap_add_item(keymap, "NODE_OT_translate_attach", EVT_TWEAK_S, KM_ANY, 0, 0);
1054
1055                         WM_keymap_add_item(keymap, OP_ROTATION, RKEY, KM_PRESS, 0, 0);
1056
1057                         WM_keymap_add_item(keymap, OP_RESIZE, SKEY, KM_PRESS, 0, 0);
1058
1059                         /* detach and translate */
1060                         WM_keymap_add_item(keymap, "NODE_OT_move_detach_links", DKEY, KM_PRESS, KM_ALT, 0);
1061                         /* XXX release_confirm is set in the macro operator definition */
1062                         WM_keymap_add_item(keymap, "NODE_OT_move_detach_links_release", EVT_TWEAK_A, KM_ANY, KM_ALT, 0);
1063                         WM_keymap_add_item(keymap, "NODE_OT_move_detach_links", EVT_TWEAK_S, KM_ANY, KM_ALT, 0);
1064
1065                         /* dettach and translate */
1066                         WM_keymap_add_item(keymap, "NODE_OT_detach_translate_attach", FKEY, KM_PRESS, KM_ALT, 0);
1067                         break;
1068                 case SPACE_SEQ:
1069                         WM_keymap_add_item(keymap, OP_SEQ_SLIDE, GKEY, KM_PRESS, 0, 0);
1070
1071                         WM_keymap_add_item(keymap, OP_SEQ_SLIDE, EVT_TWEAK_S, KM_ANY, 0, 0);
1072
1073                         kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", EKEY, KM_PRESS, 0, 0);
1074                         RNA_enum_set(kmi->ptr, "mode", TFM_TIME_EXTEND);
1075                         break;
1076                 case SPACE_IMAGE:
1077                         WM_keymap_add_item(keymap, OP_TRANSLATION, GKEY, KM_PRESS, 0, 0);
1078
1079                         WM_keymap_add_item(keymap, OP_TRANSLATION, EVT_TWEAK_S, KM_ANY, 0, 0);
1080
1081                         WM_keymap_add_item(keymap, OP_ROTATION, RKEY, KM_PRESS, 0, 0);
1082
1083                         WM_keymap_add_item(keymap, OP_RESIZE, SKEY, KM_PRESS, 0, 0);
1084
1085                         WM_keymap_add_item(keymap, OP_SHEAR, SKEY, KM_PRESS, KM_ALT | KM_CTRL | KM_SHIFT, 0);
1086
1087                         WM_keymap_add_item(keymap, "TRANSFORM_OT_mirror", MKEY, KM_PRESS, KM_CTRL, 0);
1088
1089                         kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", TABKEY, KM_PRESS, KM_SHIFT, 0);
1090                         RNA_string_set(kmi->ptr, "data_path", "tool_settings.use_snap");
1091
1092                         kmi = WM_keymap_add_item(keymap, "WM_OT_context_menu_enum", TABKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0);
1093                         RNA_string_set(kmi->ptr, "data_path", "tool_settings.snap_uv_element");
1094                         break;
1095                 case SPACE_CLIP:
1096                         WM_keymap_add_item(keymap, OP_TRANSLATION, GKEY, KM_PRESS, 0, 0);
1097                         WM_keymap_add_item(keymap, OP_TRANSLATION, EVT_TWEAK_S, KM_ANY, 0, 0);
1098                         WM_keymap_add_item(keymap, OP_RESIZE, SKEY, KM_PRESS, 0, 0);
1099                         WM_keymap_add_item(keymap, OP_ROTATION, RKEY, KM_PRESS, 0, 0);
1100                         break;
1101                 default:
1102                         break;
1103         }
1104 }
1105