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