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