Merged changes in the trunk up to revision 54992.
[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 "BLF_translation.h"
41
42 #include "BKE_context.h"
43 #include "BKE_global.h"
44 #include "BKE_armature.h"
45 #include "BKE_report.h"
46
47 #include "WM_api.h"
48 #include "WM_types.h"
49
50 #include "UI_interface.h"
51 #include "UI_resources.h"
52
53 #include "ED_screen.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), 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, 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         
257         RNA_string_get(op->ptr, "name", name);
258
259         if (use && !CTX_wm_view3d(C)) {
260                 BKE_report(op->reports, RPT_ERROR, "Create Orientation's 'use' parameter only valid in a 3DView context");
261                 return OPERATOR_CANCELLED;
262         }
263
264         BIF_createTransformOrientation(C, op->reports, name, use, overwrite);
265
266         WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, CTX_wm_view3d(C));
267         WM_event_add_notifier(C, NC_SCENE | NA_EDITED, CTX_data_scene(C));
268         
269         return OPERATOR_FINISHED;
270 }
271
272 static int create_orientation_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
273 {
274         return create_orientation_exec(C, op);
275 }
276
277 static void TRANSFORM_OT_create_orientation(struct wmOperatorType *ot)
278 {
279         /* identifiers */
280         ot->name   = "Create Orientation";
281         ot->description = "Create transformation orientation from selection";
282         ot->idname = "TRANSFORM_OT_create_orientation";
283         ot->flag   = OPTYPE_REGISTER | OPTYPE_UNDO;
284
285         /* api callbacks */
286         ot->invoke = create_orientation_invoke;
287         ot->exec   = create_orientation_exec;
288         ot->poll   = ED_operator_areaactive;
289         ot->flag   = OPTYPE_REGISTER | OPTYPE_UNDO;
290
291         RNA_def_string(ot->srna, "name", "", MAX_NAME, "Name", "Text to insert at the cursor position");
292         RNA_def_boolean(ot->srna, "use", 0, "Use after creation", "Select orientation after its creation");
293         RNA_def_boolean(ot->srna, "overwrite", 0, "Overwrite previous", "Overwrite previously created orientation with same name");
294 }
295
296 static void transformops_exit(bContext *C, wmOperator *op)
297 {
298         saveTransform(C, op->customdata, op);
299         MEM_freeN(op->customdata);
300         op->customdata = NULL;
301         G.moving = 0;
302 }
303
304 static int transformops_data(bContext *C, wmOperator *op, wmEvent *event)
305 {
306         int retval = 1;
307         if (op->customdata == NULL) {
308                 TransInfo *t = MEM_callocN(sizeof(TransInfo), "TransInfo data2");
309                 TransformModeItem *tmode;
310                 int mode = -1;
311
312                 for (tmode = transform_modes; tmode->idname; tmode++) {
313                         if (op->type->idname == tmode->idname) {
314                                 mode = tmode->mode;
315                                 break;
316                         }
317                 }
318
319                 if (mode == -1) {
320                         mode = RNA_enum_get(op->ptr, "mode");
321                 }
322
323                 retval = initTransform(C, t, op, event, mode);
324                 G.moving = 1;
325
326                 /* store data */
327                 if (retval) {
328                         op->customdata = t;
329                 }
330                 else {
331                         MEM_freeN(t);
332                 }
333         }
334
335         return retval; /* return 0 on error */
336 }
337
338 static int transform_modal(bContext *C, wmOperator *op, wmEvent *event)
339 {
340         int exit_code;
341
342         TransInfo *t = op->customdata;
343
344 #if 0
345         // stable 2D mouse coords map to different 3D coords while the 3D mouse is active
346         // in other words, 2D deltas are no longer good enough!
347         // disable until individual 'transformers' behave better
348
349         if (event->type == NDOF_MOTION)
350                 return OPERATOR_PASS_THROUGH;
351 #endif
352
353         /* XXX insert keys are called here, and require context */
354         t->context = C;
355         exit_code = transformEvent(t, event);
356         t->context = NULL;
357
358         transformApply(C, t);
359
360         exit_code |= transformEnd(C, t);
361
362         if ((exit_code & OPERATOR_RUNNING_MODAL) == 0) {
363                 transformops_exit(C, op);
364                 exit_code &= ~OPERATOR_PASS_THROUGH; /* preventively remove passthrough */
365         }
366
367         return exit_code;
368 }
369
370 static int transform_cancel(bContext *C, wmOperator *op)
371 {
372         TransInfo *t = op->customdata;
373
374         t->state = TRANS_CANCEL;
375         transformEnd(C, t);
376         transformops_exit(C, op);
377
378         return OPERATOR_CANCELLED;
379 }
380
381 static int transform_exec(bContext *C, wmOperator *op)
382 {
383         TransInfo *t;
384
385         if (!transformops_data(C, op, NULL)) {
386                 G.moving = 0;
387                 return OPERATOR_CANCELLED;
388         }
389
390         t = op->customdata;
391
392         t->options |= CTX_AUTOCONFIRM;
393
394         transformApply(C, t);
395
396         transformEnd(C, t);
397
398         transformops_exit(C, op);
399         
400         WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
401
402         return OPERATOR_FINISHED;
403 }
404
405 static int transform_invoke(bContext *C, wmOperator *op, wmEvent *event)
406 {
407         if (!transformops_data(C, op, event)) {
408                 G.moving = 0;
409                 return OPERATOR_CANCELLED;
410         }
411
412         if (RNA_struct_property_is_set(op->ptr, "value")) {
413                 return transform_exec(C, op);
414         }
415         else {
416                 /* add temp handler */
417                 WM_event_add_modal_handler(C, op);
418
419                 op->flag |= OP_GRAB_POINTER; // XXX maybe we want this with the manipulator only?
420                 return OPERATOR_RUNNING_MODAL;
421         }
422 }
423
424 void Transform_Properties(struct wmOperatorType *ot, int flags)
425 {
426         PropertyRNA *prop;
427
428         if (flags & P_AXIS) {
429                 prop = RNA_def_property(ot->srna, "axis", PROP_FLOAT, PROP_DIRECTION);
430                 RNA_def_property_array(prop, 3);
431                 /* Make this not hidden when there's a nice axis selection widget */
432                 RNA_def_property_flag(prop, PROP_HIDDEN);
433                 RNA_def_property_ui_text(prop, "Axis", "The axis around which the transformation occurs");
434
435         }
436
437         if (flags & P_CONSTRAINT) {
438                 RNA_def_boolean_vector(ot->srna, "constraint_axis", 3, NULL, "Constraint Axis", "");
439                 prop = RNA_def_property(ot->srna, "constraint_orientation", PROP_ENUM, PROP_NONE);
440                 RNA_def_property_ui_text(prop, "Orientation", "Transformation orientation");
441                 RNA_def_enum_funcs(prop, rna_TransformOrientation_itemf);
442
443                 
444         }
445
446         if (flags & P_MIRROR) {
447                 RNA_def_boolean(ot->srna, "mirror", 0, "Mirror Editing", "");
448         }
449
450
451         if (flags & P_PROPORTIONAL) {
452                 RNA_def_enum(ot->srna, "proportional", proportional_editing_items, 0, "Proportional Editing", "");
453                 RNA_def_enum(ot->srna, "proportional_edit_falloff", proportional_falloff_items, 0, "Proportional Editing Falloff", "Falloff type for proportional editing mode");
454                 RNA_def_float(ot->srna, "proportional_size", 1, 0.00001f, FLT_MAX, "Proportional Size", "", 0.001, 100);
455         }
456
457         if (flags & P_SNAP) {
458                 prop = RNA_def_boolean(ot->srna, "snap", 0, "Use Snapping Options", "");
459                 RNA_def_property_flag(prop, PROP_HIDDEN);
460
461                 if (flags & P_GEO_SNAP) {
462                         prop = RNA_def_enum(ot->srna, "snap_target", snap_target_items, 0, "Target", "");
463                         RNA_def_property_flag(prop, PROP_HIDDEN);
464                         prop = RNA_def_float_vector(ot->srna, "snap_point", 3, NULL, -FLT_MAX, FLT_MAX, "Point", "", -FLT_MAX, FLT_MAX);
465                         RNA_def_property_flag(prop, PROP_HIDDEN);
466                         
467                         if (flags & P_ALIGN_SNAP) {
468                                 prop = RNA_def_boolean(ot->srna, "snap_align", 0, "Align with Point Normal", "");
469                                 RNA_def_property_flag(prop, PROP_HIDDEN);
470                                 prop = RNA_def_float_vector(ot->srna, "snap_normal", 3, NULL, -FLT_MAX, FLT_MAX, "Normal", "", -FLT_MAX, FLT_MAX);
471                                 RNA_def_property_flag(prop, PROP_HIDDEN);
472                         }
473                 }
474         }
475
476         if (flags & P_OPTIONS) {
477                 RNA_def_boolean(ot->srna, "texture_space", 0, "Edit Texture Space", "Edit Object data texture space");
478         }
479
480         if (flags & P_CORRECT_UV) {
481                 RNA_def_boolean(ot->srna, "correct_uv", 0, "Correct UVs", "Correct UV coordinates when transforming");
482         }
483
484         // 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
485         /*prop =*/ RNA_def_boolean(ot->srna, "release_confirm", 0, "Confirm on Release", "Always confirm operation when releasing button");
486         //RNA_def_property_flag(prop, PROP_HIDDEN);
487 }
488
489 static void TRANSFORM_OT_translate(struct wmOperatorType *ot)
490 {
491         /* identifiers */
492         ot->name   = "Translate";
493         ot->description = "Translate (move) selected items";
494         ot->idname = OP_TRANSLATION;
495         ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
496
497         /* api callbacks */
498         ot->invoke = transform_invoke;
499         ot->exec   = transform_exec;
500         ot->modal  = transform_modal;
501         ot->cancel = transform_cancel;
502         ot->poll   = ED_operator_screenactive;
503
504         RNA_def_float_vector_xyz(ot->srna, "value", 3, NULL, -FLT_MAX, FLT_MAX, "Vector", "", -FLT_MAX, FLT_MAX);
505
506         Transform_Properties(ot, P_CONSTRAINT | P_PROPORTIONAL | P_MIRROR | P_ALIGN_SNAP | P_OPTIONS);
507 }
508
509 static void TRANSFORM_OT_resize(struct wmOperatorType *ot)
510 {
511         /* identifiers */
512         ot->name   = "Resize";
513         ot->description = "Scale (resize) selected items"; 
514         ot->idname = OP_RESIZE;
515         ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
516
517         /* api callbacks */
518         ot->invoke = transform_invoke;
519         ot->exec   = transform_exec;
520         ot->modal  = transform_modal;
521         ot->cancel = transform_cancel;
522         ot->poll   = ED_operator_screenactive;
523
524         RNA_def_float_vector(ot->srna, "value", 3, VecOne, -FLT_MAX, FLT_MAX, "Vector", "", -FLT_MAX, FLT_MAX);
525
526         Transform_Properties(ot, P_CONSTRAINT | P_PROPORTIONAL | P_MIRROR | P_GEO_SNAP | P_OPTIONS);
527 }
528
529 static int skin_resize_poll(bContext *C)
530 {
531         struct Object *obedit = CTX_data_edit_object(C);
532         if (obedit && obedit->type == OB_MESH) {
533                 BMEditMesh *em = BMEdit_FromObject(obedit);
534                 return (em && CustomData_has_layer(&em->bm->vdata, CD_MVERT_SKIN));
535         }
536         return 0;
537 }
538
539 static void TRANSFORM_OT_skin_resize(struct wmOperatorType *ot)
540 {
541         /* identifiers */
542         ot->name   = "Skin Resize";
543         ot->description = "Scale selected vertices' skin radii"; 
544         ot->idname = OP_SKIN_RESIZE;
545         ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
546
547         /* api callbacks */
548         ot->invoke = transform_invoke;
549         ot->exec   = transform_exec;
550         ot->modal  = transform_modal;
551         ot->cancel = transform_cancel;
552         ot->poll   = skin_resize_poll;
553
554         RNA_def_float_vector(ot->srna, "value", 3, VecOne, -FLT_MAX, FLT_MAX, "Vector", "", -FLT_MAX, FLT_MAX);
555
556         Transform_Properties(ot, P_CONSTRAINT | P_PROPORTIONAL | P_MIRROR | P_GEO_SNAP | P_OPTIONS);
557 }
558
559 static void TRANSFORM_OT_trackball(struct wmOperatorType *ot)
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         RNA_def_float_vector(ot->srna, "value", 2, VecOne, -FLT_MAX, FLT_MAX, "Angle", "", -FLT_MAX, FLT_MAX);
575
576         Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR | P_SNAP);
577 }
578
579 static void TRANSFORM_OT_rotate(struct wmOperatorType *ot)
580 {
581         PropertyRNA *prop;
582
583         /* identifiers */
584         ot->name = "Rotate";
585         ot->description = "Rotate selected items";
586         ot->idname = OP_ROTATION;
587         ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
588
589         /* api callbacks */
590         ot->invoke = transform_invoke;
591         ot->exec   = transform_exec;
592         ot->modal  = transform_modal;
593         ot->cancel = transform_cancel;
594         ot->poll   = ED_operator_screenactive;
595
596         prop = RNA_def_float(ot->srna, "value", 0.0f, -FLT_MAX, FLT_MAX, "Angle", "", -M_PI * 2, M_PI * 2);
597         RNA_def_property_subtype(prop, PROP_ANGLE);
598
599         Transform_Properties(ot, P_AXIS | P_CONSTRAINT | P_PROPORTIONAL | P_MIRROR | P_GEO_SNAP);
600 }
601
602 static void TRANSFORM_OT_tilt(struct wmOperatorType *ot)
603 {
604         PropertyRNA *prop;
605
606         /* identifiers */
607         ot->name = "Tilt";
608         /* optionals - 
609          * "Tilt selected vertices"
610          * "Specify an extra axis rotation for selected vertices of 3D curve" */
611         ot->description = "Tilt selected control vertices of 3D curve"; 
612         ot->idname = OP_TILT;
613         ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
614
615         /* api callbacks */
616         ot->invoke = transform_invoke;
617         ot->exec   = transform_exec;
618         ot->modal  = transform_modal;
619         ot->cancel = transform_cancel;
620         ot->poll   = ED_operator_editcurve_3d;
621
622         prop = RNA_def_float(ot->srna, "value", 0.0, -FLT_MAX, FLT_MAX, "Angle", "", -M_PI * 2, M_PI * 2);
623         RNA_def_property_subtype(prop, PROP_ANGLE);
624
625         Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR | P_SNAP);
626 }
627
628 static void TRANSFORM_OT_warp(struct wmOperatorType *ot)
629 {
630         /* identifiers */
631         ot->name   = "Warp";
632         ot->description = "Warp selected items around the cursor";
633         ot->idname = OP_WARP;
634         ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
635
636         /* api callbacks */
637         ot->invoke = transform_invoke;
638         ot->exec   = transform_exec;
639         ot->modal  = transform_modal;
640         ot->cancel = transform_cancel;
641         ot->poll   = ED_operator_screenactive;
642
643         RNA_def_float_rotation(ot->srna, "value", 1, NULL, -FLT_MAX, FLT_MAX, "Angle", "", -M_PI * 2, M_PI * 2);
644
645         Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR | P_SNAP);
646         // XXX Warp axis?
647 }
648
649 static void TRANSFORM_OT_shear(struct wmOperatorType *ot)
650 {
651         /* identifiers */
652         ot->name   = "Shear";
653         ot->description = "Shear selected items along the horizontal screen axis";
654         ot->idname = OP_SHEAR;
655         ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
656
657         /* api callbacks */
658         ot->invoke = transform_invoke;
659         ot->exec   = transform_exec;
660         ot->modal  = transform_modal;
661         ot->cancel = transform_cancel;
662         ot->poll   = ED_operator_screenactive;
663
664         RNA_def_float(ot->srna, "value", 0, -FLT_MAX, FLT_MAX, "Offset", "", -FLT_MAX, FLT_MAX);
665
666         Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR | P_SNAP);
667         // XXX Shear axis?
668 }
669
670 static void TRANSFORM_OT_push_pull(struct wmOperatorType *ot)
671 {
672         /* identifiers */
673         ot->name   = "Push/Pull";
674         ot->description = "Push/Pull selected items";
675         ot->idname = OP_PUSH_PULL;
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_screenactive;
684
685         RNA_def_float(ot->srna, "value", 0, -FLT_MAX, FLT_MAX, "Distance", "", -FLT_MAX, FLT_MAX);
686
687         Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR | P_SNAP);
688 }
689
690 static void TRANSFORM_OT_shrink_fatten(struct wmOperatorType *ot)
691 {
692         /* identifiers */
693         ot->name   = "Shrink/Fatten";
694         ot->description = "Shrink/fatten selected vertices along normals";
695         ot->idname = OP_SHRINK_FATTEN;
696         ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
697
698         /* api callbacks */
699         ot->invoke = transform_invoke;
700         ot->exec   = transform_exec;
701         ot->modal  = transform_modal;
702         ot->cancel = transform_cancel;
703         ot->poll   = ED_operator_editmesh;
704
705         RNA_def_float(ot->srna, "value", 0, -FLT_MAX, FLT_MAX, "Offset", "", -FLT_MAX, FLT_MAX);
706
707         Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR | P_SNAP);
708 }
709
710 static void TRANSFORM_OT_tosphere(struct wmOperatorType *ot)
711 {
712         /* identifiers */
713         ot->name   = "To Sphere";
714         //added "around mesh center" to differentiate between "MESH_OT_vertices_to_sphere()" 
715         ot->description = "Move selected vertices outward in a spherical shape around mesh center";
716         ot->idname = OP_TOSPHERE;
717         ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
718
719         /* api callbacks */
720         ot->invoke = transform_invoke;
721         ot->exec   = transform_exec;
722         ot->modal  = transform_modal;
723         ot->cancel = transform_cancel;
724         ot->poll   = ED_operator_screenactive;
725
726         RNA_def_float_factor(ot->srna, "value", 0, 0, 1, "Factor", "", 0, 1);
727
728         Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR | P_SNAP);
729 }
730
731 static void TRANSFORM_OT_mirror(struct wmOperatorType *ot)
732 {
733         /* identifiers */
734         ot->name   = "Mirror";
735         ot->description = "Mirror selected vertices around one or more axes";
736         ot->idname = OP_MIRROR;
737         ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
738
739         /* api callbacks */
740         ot->invoke = transform_invoke;
741         ot->exec   = transform_exec;
742         ot->modal  = transform_modal;
743         ot->cancel = transform_cancel;
744         ot->poll   = ED_operator_screenactive;
745
746         Transform_Properties(ot, P_CONSTRAINT | P_PROPORTIONAL);
747 }
748
749 static void TRANSFORM_OT_edge_slide(struct wmOperatorType *ot)
750 {
751         /* identifiers */
752         ot->name   = "Edge Slide";
753         ot->description = "Slide an edge loop along a mesh"; 
754         ot->idname = OP_EDGE_SLIDE;
755         ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
756
757         /* api callbacks */
758         ot->invoke = transform_invoke;
759         ot->exec   = transform_exec;
760         ot->modal  = transform_modal;
761         ot->cancel = transform_cancel;
762         ot->poll   = ED_operator_editmesh;
763
764         RNA_def_float_factor(ot->srna, "value", 0, -1.0f, 1.0f, "Factor", "", -1.0f, 1.0f);
765
766         Transform_Properties(ot, P_MIRROR | P_SNAP | P_CORRECT_UV);
767 }
768
769 static void TRANSFORM_OT_vert_slide(struct wmOperatorType *ot)
770 {
771         /* identifiers */
772         ot->name   = "Vertex Slide";
773         ot->description = "Slide a vertex along a mesh";
774         ot->idname = OP_VERT_SLIDE;
775         ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
776
777         /* api callbacks */
778         ot->invoke = transform_invoke;
779         ot->exec   = transform_exec;
780         ot->modal  = transform_modal;
781         ot->cancel = transform_cancel;
782         ot->poll   = ED_operator_editmesh;
783
784         RNA_def_float_factor(ot->srna, "value", 0, -10.0f, 10.0f, "Factor", "", -1.0f, 1.0f);
785
786         Transform_Properties(ot, P_MIRROR | P_SNAP);
787 }
788
789 static void TRANSFORM_OT_edge_crease(struct wmOperatorType *ot)
790 {
791         /* identifiers */
792         ot->name   = "Edge Crease";
793         ot->description = "Change the crease of edges";
794         ot->idname = OP_EDGE_CREASE;
795         ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
796
797         /* api callbacks */
798         ot->invoke = transform_invoke;
799         ot->exec   = transform_exec;
800         ot->modal  = transform_modal;
801         ot->cancel = transform_cancel;
802         ot->poll   = ED_operator_editmesh;
803
804         RNA_def_float_factor(ot->srna, "value", 0, -1.0f, 1.0f, "Factor", "", -1.0f, 1.0f);
805
806         Transform_Properties(ot, P_SNAP);
807 }
808
809 static void TRANSFORM_OT_edge_bevelweight(struct wmOperatorType *ot)
810 {
811         /* identifiers */
812         ot->name   = "Edge Bevel Weight";
813         ot->description = "Change the bevel weight of edges";
814         ot->idname = OP_EDGE_BWEIGHT;
815         ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
816
817         /* api callbacks */
818         ot->invoke = transform_invoke;
819         ot->exec   = transform_exec;
820         ot->modal  = transform_modal;
821         ot->cancel = transform_cancel;
822         ot->poll   = ED_operator_editmesh;
823
824         RNA_def_float_factor(ot->srna, "value", 0, -1.0f, 1.0f, "Factor", "", -1.0f, 1.0f);
825
826         Transform_Properties(ot, P_SNAP);
827 }
828
829 static void TRANSFORM_OT_seq_slide(struct wmOperatorType *ot)
830 {
831         /* identifiers */
832         ot->name   = "Sequence Slide";
833         ot->description = "Slide a sequence strip in time";
834         ot->idname = OP_SEQ_SLIDE;
835         ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
836
837         /* api callbacks */
838         ot->invoke = transform_invoke;
839         ot->exec   = transform_exec;
840         ot->modal  = transform_modal;
841         ot->cancel = transform_cancel;
842         ot->poll   = ED_operator_sequencer_active;
843
844         RNA_def_float_vector(ot->srna, "value", 2, VecOne, -FLT_MAX, FLT_MAX, "Angle", "", -FLT_MAX, FLT_MAX);
845
846         Transform_Properties(ot, P_SNAP);
847 }
848
849 static void TRANSFORM_OT_transform(struct wmOperatorType *ot)
850 {
851         PropertyRNA *prop;
852
853         /* identifiers */
854         ot->name   = "Transform";
855         ot->description = "Transform selected items by mode type";
856         ot->idname = "TRANSFORM_OT_transform";
857         ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
858
859         /* api callbacks */
860         ot->invoke = transform_invoke;
861         ot->exec   = transform_exec;
862         ot->modal  = transform_modal;
863         ot->cancel = transform_cancel;
864         ot->poll   = ED_operator_screenactive;
865
866         prop = RNA_def_enum(ot->srna, "mode", transform_mode_types, TFM_TRANSLATION, "Mode", "");
867         RNA_def_property_flag(prop, PROP_HIDDEN);
868
869         RNA_def_float_vector(ot->srna, "value", 4, NULL, -FLT_MAX, FLT_MAX, "Values", "", -FLT_MAX, FLT_MAX);
870
871         Transform_Properties(ot, P_AXIS | P_CONSTRAINT | P_PROPORTIONAL | P_MIRROR | P_ALIGN_SNAP);
872 }
873
874 void transform_operatortypes(void)
875 {
876         TransformModeItem *tmode;
877
878         for (tmode = transform_modes; tmode->idname; tmode++) {
879                 WM_operatortype_append(tmode->opfunc);
880         }
881
882         WM_operatortype_append(TRANSFORM_OT_transform);
883
884         WM_operatortype_append(TRANSFORM_OT_select_orientation);
885         WM_operatortype_append(TRANSFORM_OT_create_orientation);
886         WM_operatortype_append(TRANSFORM_OT_delete_orientation);
887 }
888
889 void transform_keymap_for_space(wmKeyConfig *keyconf, wmKeyMap *keymap, int spaceid)
890 {
891         wmKeyMapItem *kmi;
892         wmKeyMap *modalmap;
893         
894         /* transform.c, only adds modal map once, checks if it's there */
895         modalmap = transform_modal_keymap(keyconf);
896
897         /* assign map to operators only the first time */
898         if (modalmap) {
899                 TransformModeItem *tmode;
900
901                 for (tmode = transform_modes; tmode->idname; tmode++) {
902                         WM_modalkeymap_assign(modalmap, tmode->idname);
903                 }
904                 WM_modalkeymap_assign(modalmap, "TRANSFORM_OT_transform");
905         }
906         
907         switch (spaceid) {
908                 case SPACE_VIEW3D:
909                         WM_keymap_add_item(keymap, OP_TRANSLATION, GKEY, KM_PRESS, 0, 0);
910
911                         WM_keymap_add_item(keymap, OP_TRANSLATION, EVT_TWEAK_S, KM_ANY, 0, 0);
912
913                         WM_keymap_add_item(keymap, OP_ROTATION, RKEY, KM_PRESS, 0, 0);
914
915                         WM_keymap_add_item(keymap, OP_RESIZE, SKEY, KM_PRESS, 0, 0);
916
917                         WM_keymap_add_item(keymap, OP_WARP, WKEY, KM_PRESS, KM_SHIFT, 0);
918
919                         WM_keymap_add_item(keymap, OP_TOSPHERE, SKEY, KM_PRESS, KM_ALT | KM_SHIFT, 0);
920
921                         WM_keymap_add_item(keymap, OP_SHEAR, SKEY, KM_PRESS, KM_ALT | KM_CTRL | KM_SHIFT, 0);
922
923                         WM_keymap_add_item(keymap, "TRANSFORM_OT_select_orientation", SPACEKEY, KM_PRESS, KM_ALT, 0);
924
925                         kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_create_orientation", SPACEKEY, KM_PRESS, KM_CTRL | KM_ALT, 0);
926                         RNA_boolean_set(kmi->ptr, "use", TRUE);
927
928                         WM_keymap_add_item(keymap, OP_MIRROR, MKEY, KM_PRESS, KM_CTRL, 0);
929
930                         kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", TABKEY, KM_PRESS, KM_SHIFT, 0);
931                         RNA_string_set(kmi->ptr, "data_path", "tool_settings.use_snap");
932
933                         kmi = WM_keymap_add_item(keymap, "WM_OT_context_menu_enum", TABKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0);
934                         RNA_string_set(kmi->ptr, "data_path", "tool_settings.snap_element");
935
936
937                         kmi = WM_keymap_add_item(keymap, OP_TRANSLATION, TKEY, KM_PRESS, KM_SHIFT, 0);
938                         RNA_boolean_set(kmi->ptr, "texture_space", TRUE);
939
940                         kmi = WM_keymap_add_item(keymap, OP_RESIZE, TKEY, KM_PRESS, KM_SHIFT | KM_ALT, 0);
941                         RNA_boolean_set(kmi->ptr, "texture_space", TRUE);
942
943                         WM_keymap_add_item(keymap, OP_SKIN_RESIZE, AKEY, KM_PRESS, KM_CTRL, 0);
944
945                         break;
946                 case SPACE_ACTION:
947                         kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", GKEY, KM_PRESS, 0, 0);
948                         RNA_enum_set(kmi->ptr, "mode", TFM_TIME_TRANSLATE);
949                         
950                         kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", EVT_TWEAK_S, KM_ANY, 0, 0);
951                         RNA_enum_set(kmi->ptr, "mode", TFM_TIME_TRANSLATE);
952                         
953                         kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", EKEY, KM_PRESS, 0, 0);
954                         RNA_enum_set(kmi->ptr, "mode", TFM_TIME_EXTEND);
955                         
956                         kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", SKEY, KM_PRESS, 0, 0);
957                         RNA_enum_set(kmi->ptr, "mode", TFM_TIME_SCALE);
958                         
959                         kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", TKEY, KM_PRESS, KM_SHIFT, 0);
960                         RNA_enum_set(kmi->ptr, "mode", TFM_TIME_SLIDE);
961                         break;
962                 case SPACE_IPO:
963                         WM_keymap_add_item(keymap, OP_TRANSLATION, GKEY, KM_PRESS, 0, 0);
964                         
965                         WM_keymap_add_item(keymap, OP_TRANSLATION, EVT_TWEAK_S, KM_ANY, 0, 0);
966                         
967                         kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", EKEY, KM_PRESS, 0, 0);
968                         RNA_enum_set(kmi->ptr, "mode", TFM_TIME_EXTEND);
969                         
970                         WM_keymap_add_item(keymap, OP_ROTATION, RKEY, KM_PRESS, 0, 0);
971                         
972                         WM_keymap_add_item(keymap, OP_RESIZE, SKEY, KM_PRESS, 0, 0);
973                         break;
974                 case SPACE_NLA:
975                         kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", GKEY, KM_PRESS, 0, 0);
976                         RNA_enum_set(kmi->ptr, "mode", TFM_TRANSLATION);
977                         
978                         kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", EVT_TWEAK_S, KM_ANY, 0, 0);
979                         RNA_enum_set(kmi->ptr, "mode", TFM_TRANSLATION);
980                         
981                         kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", EKEY, KM_PRESS, 0, 0);
982                         RNA_enum_set(kmi->ptr, "mode", TFM_TIME_EXTEND);
983                         
984                         kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", SKEY, KM_PRESS, 0, 0);
985                         RNA_enum_set(kmi->ptr, "mode", TFM_TIME_SCALE);
986                         break;
987                 case SPACE_NODE:
988                         WM_keymap_add_item(keymap, "NODE_OT_translate_attach", GKEY, KM_PRESS, 0, 0);
989                         WM_keymap_add_item(keymap, "NODE_OT_translate_attach", EVT_TWEAK_A, KM_ANY, 0, 0);
990                         WM_keymap_add_item(keymap, "NODE_OT_translate_attach", EVT_TWEAK_S, KM_ANY, 0, 0);
991
992                         WM_keymap_add_item(keymap, OP_ROTATION, RKEY, KM_PRESS, 0, 0);
993
994                         WM_keymap_add_item(keymap, OP_RESIZE, SKEY, KM_PRESS, 0, 0);
995
996                         /* detach and translate */
997                         WM_keymap_add_item(keymap, "NODE_OT_move_detach_links", DKEY, KM_PRESS, KM_ALT, 0);
998                         /* XXX release_confirm is set in the macro operator definition */
999                         WM_keymap_add_item(keymap, "NODE_OT_move_detach_links_release", EVT_TWEAK_A, KM_ANY, KM_ALT, 0);
1000                         WM_keymap_add_item(keymap, "NODE_OT_move_detach_links", EVT_TWEAK_S, KM_ANY, KM_ALT, 0);
1001
1002                         /* dettach and translate */
1003                         WM_keymap_add_item(keymap, "NODE_OT_detach_translate_attach", FKEY, KM_PRESS, KM_ALT, 0);
1004                         break;
1005                 case SPACE_SEQ:
1006                         WM_keymap_add_item(keymap, OP_SEQ_SLIDE, GKEY, KM_PRESS, 0, 0);
1007
1008                         WM_keymap_add_item(keymap, OP_SEQ_SLIDE, EVT_TWEAK_S, KM_ANY, 0, 0);
1009
1010                         kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", EKEY, KM_PRESS, 0, 0);
1011                         RNA_enum_set(kmi->ptr, "mode", TFM_TIME_EXTEND);
1012                         break;
1013                 case SPACE_IMAGE:
1014                         WM_keymap_add_item(keymap, OP_TRANSLATION, GKEY, KM_PRESS, 0, 0);
1015
1016                         WM_keymap_add_item(keymap, OP_TRANSLATION, EVT_TWEAK_S, KM_ANY, 0, 0);
1017
1018                         WM_keymap_add_item(keymap, OP_ROTATION, RKEY, KM_PRESS, 0, 0);
1019
1020                         WM_keymap_add_item(keymap, OP_RESIZE, SKEY, KM_PRESS, 0, 0);
1021
1022                         WM_keymap_add_item(keymap, OP_SHEAR, SKEY, KM_PRESS, KM_ALT | KM_CTRL | KM_SHIFT, 0);
1023
1024                         WM_keymap_add_item(keymap, "TRANSFORM_OT_mirror", MKEY, KM_PRESS, KM_CTRL, 0);
1025
1026                         kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", TABKEY, KM_PRESS, KM_SHIFT, 0);
1027                         RNA_string_set(kmi->ptr, "data_path", "tool_settings.use_snap");
1028
1029                         kmi = WM_keymap_add_item(keymap, "WM_OT_context_menu_enum", TABKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0);
1030                         RNA_string_set(kmi->ptr, "data_path", "tool_settings.snap_uv_element");
1031                         break;
1032                 case SPACE_CLIP:
1033                         WM_keymap_add_item(keymap, OP_TRANSLATION, GKEY, KM_PRESS, 0, 0);
1034                         WM_keymap_add_item(keymap, OP_TRANSLATION, EVT_TWEAK_S, KM_ANY, 0, 0);
1035                         WM_keymap_add_item(keymap, OP_RESIZE, SKEY, KM_PRESS, 0, 0);
1036                         WM_keymap_add_item(keymap, OP_ROTATION, RKEY, KM_PRESS, 0, 0);
1037                         break;
1038                 default:
1039                         break;
1040         }
1041 }
1042