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