2 * ***** BEGIN GPL LICENSE BLOCK *****
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.
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.
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.
18 * Contributor(s): none yet.
20 * ***** END GPL LICENSE BLOCK *****
23 /** \file blender/editors/transform/transform_ops.c
24 * \ingroup edtransform
27 #include "MEM_guardedalloc.h"
29 #include "DNA_mesh_types.h"
30 #include "DNA_object_types.h"
31 #include "DNA_scene_types.h"
34 #include "BLI_utildefines.h"
36 #include "BLT_translation.h"
38 #include "BKE_context.h"
39 #include "BKE_global.h"
40 #include "BKE_report.h"
41 #include "BKE_editmesh.h"
43 #include "RNA_access.h"
44 #include "RNA_define.h"
45 #include "RNA_enum_types.h"
50 #include "UI_interface.h"
51 #include "UI_resources.h"
53 #include "ED_screen.h"
54 /* for USE_LOOPSLIDE_HACK only */
57 #include "transform.h"
59 typedef struct TransformModeItem {
62 void (*opfunc)(wmOperatorType *);
65 static const float VecOne[3] = {1, 1, 1};
67 static const char OP_TRANSLATION[] = "TRANSFORM_OT_translate";
68 static const char OP_ROTATION[] = "TRANSFORM_OT_rotate";
69 static const char OP_TOSPHERE[] = "TRANSFORM_OT_tosphere";
70 static const char OP_RESIZE[] = "TRANSFORM_OT_resize";
71 static const char OP_SKIN_RESIZE[] = "TRANSFORM_OT_skin_resize";
72 static const char OP_SHEAR[] = "TRANSFORM_OT_shear";
73 static const char OP_BEND[] = "TRANSFORM_OT_bend";
74 static const char OP_SHRINK_FATTEN[] = "TRANSFORM_OT_shrink_fatten";
75 static const char OP_PUSH_PULL[] = "TRANSFORM_OT_push_pull";
76 static const char OP_TILT[] = "TRANSFORM_OT_tilt";
77 static const char OP_TRACKBALL[] = "TRANSFORM_OT_trackball";
78 static const char OP_MIRROR[] = "TRANSFORM_OT_mirror";
79 static const char OP_EDGE_SLIDE[] = "TRANSFORM_OT_edge_slide";
80 static const char OP_VERT_SLIDE[] = "TRANSFORM_OT_vert_slide";
81 static const char OP_EDGE_CREASE[] = "TRANSFORM_OT_edge_crease";
82 static const char OP_EDGE_BWEIGHT[] = "TRANSFORM_OT_edge_bevelweight";
83 static const char OP_SEQ_SLIDE[] = "TRANSFORM_OT_seq_slide";
85 static void TRANSFORM_OT_translate(struct wmOperatorType *ot);
86 static void TRANSFORM_OT_rotate(struct wmOperatorType *ot);
87 static void TRANSFORM_OT_tosphere(struct wmOperatorType *ot);
88 static void TRANSFORM_OT_resize(struct wmOperatorType *ot);
89 static void TRANSFORM_OT_skin_resize(struct wmOperatorType *ot);
90 static void TRANSFORM_OT_shear(struct wmOperatorType *ot);
91 static void TRANSFORM_OT_bend(struct wmOperatorType *ot);
92 static void TRANSFORM_OT_shrink_fatten(struct wmOperatorType *ot);
93 static void TRANSFORM_OT_push_pull(struct wmOperatorType *ot);
94 static void TRANSFORM_OT_tilt(struct wmOperatorType *ot);
95 static void TRANSFORM_OT_trackball(struct wmOperatorType *ot);
96 static void TRANSFORM_OT_mirror(struct wmOperatorType *ot);
97 static void TRANSFORM_OT_edge_slide(struct wmOperatorType *ot);
98 static void TRANSFORM_OT_vert_slide(struct wmOperatorType *ot);
99 static void TRANSFORM_OT_edge_crease(struct wmOperatorType *ot);
100 static void TRANSFORM_OT_edge_bevelweight(struct wmOperatorType *ot);
101 static void TRANSFORM_OT_seq_slide(struct wmOperatorType *ot);
103 static TransformModeItem transform_modes[] =
105 {OP_TRANSLATION, TFM_TRANSLATION, TRANSFORM_OT_translate},
106 {OP_ROTATION, TFM_ROTATION, TRANSFORM_OT_rotate},
107 {OP_TOSPHERE, TFM_TOSPHERE, TRANSFORM_OT_tosphere},
108 {OP_RESIZE, TFM_RESIZE, TRANSFORM_OT_resize},
109 {OP_SKIN_RESIZE, TFM_SKIN_RESIZE, TRANSFORM_OT_skin_resize},
110 {OP_SHEAR, TFM_SHEAR, TRANSFORM_OT_shear},
111 {OP_BEND, TFM_BEND, TRANSFORM_OT_bend},
112 {OP_SHRINK_FATTEN, TFM_SHRINKFATTEN, TRANSFORM_OT_shrink_fatten},
113 {OP_PUSH_PULL, TFM_PUSHPULL, TRANSFORM_OT_push_pull},
114 {OP_TILT, TFM_TILT, TRANSFORM_OT_tilt},
115 {OP_TRACKBALL, TFM_TRACKBALL, TRANSFORM_OT_trackball},
116 {OP_MIRROR, TFM_MIRROR, TRANSFORM_OT_mirror},
117 {OP_EDGE_SLIDE, TFM_EDGE_SLIDE, TRANSFORM_OT_edge_slide},
118 {OP_VERT_SLIDE, TFM_VERT_SLIDE, TRANSFORM_OT_vert_slide},
119 {OP_EDGE_CREASE, TFM_CREASE, TRANSFORM_OT_edge_crease},
120 {OP_EDGE_BWEIGHT, TFM_BWEIGHT, TRANSFORM_OT_edge_bevelweight},
121 {OP_SEQ_SLIDE, TFM_SEQ_SLIDE, TRANSFORM_OT_seq_slide},
125 const EnumPropertyItem rna_enum_transform_mode_types[] =
127 {TFM_INIT, "INIT", 0, "Init", ""},
128 {TFM_DUMMY, "DUMMY", 0, "Dummy", ""},
129 {TFM_TRANSLATION, "TRANSLATION", 0, "Translation", ""},
130 {TFM_ROTATION, "ROTATION", 0, "Rotation", ""},
131 {TFM_RESIZE, "RESIZE", 0, "Resize", ""},
132 {TFM_SKIN_RESIZE, "SKIN_RESIZE", 0, "Skin Resize", ""},
133 {TFM_TOSPHERE, "TOSPHERE", 0, "Tosphere", ""},
134 {TFM_SHEAR, "SHEAR", 0, "Shear", ""},
135 {TFM_BEND, "BEND", 0, "Bend", ""},
136 {TFM_SHRINKFATTEN, "SHRINKFATTEN", 0, "Shrinkfatten", ""},
137 {TFM_TILT, "TILT", 0, "Tilt", ""},
138 {TFM_TRACKBALL, "TRACKBALL", 0, "Trackball", ""},
139 {TFM_PUSHPULL, "PUSHPULL", 0, "Pushpull", ""},
140 {TFM_CREASE, "CREASE", 0, "Crease", ""},
141 {TFM_MIRROR, "MIRROR", 0, "Mirror", ""},
142 {TFM_BONESIZE, "BONE_SIZE", 0, "Bonesize", ""},
143 {TFM_BONE_ENVELOPE, "BONE_ENVELOPE", 0, "Bone_Envelope", ""},
144 {TFM_BONE_ENVELOPE_DIST, "BONE_ENVELOPE_DIST", 0, "Bone_Envelope_Distance", ""},
145 {TFM_CURVE_SHRINKFATTEN, "CURVE_SHRINKFATTEN", 0, "Curve_Shrinkfatten", ""},
146 {TFM_MASK_SHRINKFATTEN, "MASK_SHRINKFATTEN", 0, "Mask_Shrinkfatten", ""},
147 {TFM_GPENCIL_SHRINKFATTEN, "GPENCIL_SHRINKFATTEN", 0, "GPencil_Shrinkfatten", ""},
148 {TFM_BONE_ROLL, "BONE_ROLL", 0, "Bone_Roll", ""},
149 {TFM_TIME_TRANSLATE, "TIME_TRANSLATE", 0, "Time_Translate", ""},
150 {TFM_TIME_SLIDE, "TIME_SLIDE", 0, "Time_Slide", ""},
151 {TFM_TIME_SCALE, "TIME_SCALE", 0, "Time_Scale", ""},
152 {TFM_TIME_EXTEND, "TIME_EXTEND", 0, "Time_Extend", ""},
153 {TFM_BAKE_TIME, "BAKE_TIME", 0, "Bake_Time", ""},
154 {TFM_BWEIGHT, "BWEIGHT", 0, "Bweight", ""},
155 {TFM_ALIGN, "ALIGN", 0, "Align", ""},
156 {TFM_EDGE_SLIDE, "EDGESLIDE", 0, "Edge Slide", ""},
157 {TFM_SEQ_SLIDE, "SEQSLIDE", 0, "Sequence Slide", ""},
158 {0, NULL, 0, NULL, NULL}
161 static int select_orientation_exec(bContext *C, wmOperator *op)
163 int orientation = RNA_enum_get(op->ptr, "orientation");
165 BIF_selectTransformOrientationValue(C, orientation);
167 WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, CTX_wm_view3d(C));
169 return OPERATOR_FINISHED;
172 static int select_orientation_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *UNUSED(event))
177 pup = UI_popup_menu_begin(C, IFACE_("Orientation"), ICON_NONE);
178 layout = UI_popup_menu_layout(pup);
179 uiItemsEnumO(layout, "TRANSFORM_OT_select_orientation", "orientation");
180 UI_popup_menu_end(C, pup);
182 return OPERATOR_INTERFACE;
185 static void TRANSFORM_OT_select_orientation(struct wmOperatorType *ot)
190 ot->name = "Select Orientation";
191 ot->description = "Select transformation orientation";
192 ot->idname = "TRANSFORM_OT_select_orientation";
193 ot->flag = OPTYPE_UNDO;
196 ot->invoke = select_orientation_invoke;
197 ot->exec = select_orientation_exec;
198 ot->poll = ED_operator_view3d_active;
200 prop = RNA_def_property(ot->srna, "orientation", PROP_ENUM, PROP_NONE);
201 RNA_def_property_ui_text(prop, "Orientation", "Transformation orientation");
202 RNA_def_enum_funcs(prop, rna_TransformOrientation_itemf);
206 static int delete_orientation_exec(bContext *C, wmOperator *UNUSED(op))
208 View3D *v3d = CTX_wm_view3d(C);
209 int selected_index = (v3d->twmode - V3D_MANIP_CUSTOM);
211 BIF_removeTransformOrientationIndex(C, selected_index);
213 WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d);
214 WM_event_add_notifier(C, NC_SCENE | NA_EDITED, CTX_data_scene(C));
216 return OPERATOR_FINISHED;
219 static int delete_orientation_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
221 return delete_orientation_exec(C, op);
224 static bool delete_orientation_poll(bContext *C)
226 int selected_index = -1;
227 View3D *v3d = CTX_wm_view3d(C);
229 if (ED_operator_areaactive(C) == 0)
234 selected_index = (v3d->twmode - V3D_MANIP_CUSTOM);
237 return selected_index >= 0;
240 static void TRANSFORM_OT_delete_orientation(struct wmOperatorType *ot)
243 ot->name = "Delete Orientation";
244 ot->description = "Delete transformation orientation";
245 ot->idname = "TRANSFORM_OT_delete_orientation";
246 ot->flag = OPTYPE_UNDO;
249 ot->invoke = delete_orientation_invoke;
250 ot->exec = delete_orientation_exec;
251 ot->poll = delete_orientation_poll;
254 static int create_orientation_exec(bContext *C, wmOperator *op)
257 const bool use = RNA_boolean_get(op->ptr, "use");
258 const bool overwrite = RNA_boolean_get(op->ptr, "overwrite");
259 const bool use_view = RNA_boolean_get(op->ptr, "use_view");
260 View3D *v3d = CTX_wm_view3d(C);
262 RNA_string_get(op->ptr, "name", name);
265 BKE_report(op->reports, RPT_ERROR, "Create Orientation's 'use' parameter only valid in a 3DView context");
266 return OPERATOR_CANCELLED;
269 BIF_createTransformOrientation(C, op->reports, name, use_view, use, overwrite);
271 WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d);
272 WM_event_add_notifier(C, NC_SCENE | NA_EDITED, CTX_data_scene(C));
274 return OPERATOR_FINISHED;
277 static void TRANSFORM_OT_create_orientation(struct wmOperatorType *ot)
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;
286 ot->exec = create_orientation_exec;
287 ot->poll = ED_operator_areaactive;
289 RNA_def_string(ot->srna, "name", NULL, MAX_NAME, "Name", "Name of the new custom orientation");
290 RNA_def_boolean(ot->srna, "use_view", false, "Use View",
291 "Use the current view instead of the active object to create the new orientation");
292 RNA_def_boolean(ot->srna, "use", false, "Use after creation", "Select orientation after its creation");
293 RNA_def_boolean(ot->srna, "overwrite", false, "Overwrite previous",
294 "Overwrite previously created orientation with same name");
298 #ifdef USE_LOOPSLIDE_HACK
300 * Special hack for MESH_OT_loopcut_slide so we get back to the selection mode
302 static void transformops_loopsel_hack(bContext *C, wmOperator *op)
304 if (op->type->idname == OP_EDGE_SLIDE) {
305 if (op->opm && op->opm->opm && op->opm->opm->prev) {
306 wmOperator *op_prev = op->opm->opm->prev;
307 Scene *scene = CTX_data_scene(C);
308 bool mesh_select_mode[3];
309 PropertyRNA *prop = RNA_struct_find_property(op_prev->ptr, "mesh_select_mode_init");
311 if (prop && RNA_property_is_set(op_prev->ptr, prop)) {
312 ToolSettings *ts = scene->toolsettings;
313 short selectmode_orig;
315 RNA_property_boolean_get_array(op_prev->ptr, prop, mesh_select_mode);
316 selectmode_orig = ((mesh_select_mode[0] ? SCE_SELECT_VERTEX : 0) |
317 (mesh_select_mode[1] ? SCE_SELECT_EDGE : 0) |
318 (mesh_select_mode[2] ? SCE_SELECT_FACE : 0));
320 /* still switch if we were originally in face select mode */
321 if ((ts->selectmode != selectmode_orig) && (selectmode_orig != SCE_SELECT_FACE)) {
322 BMEditMesh *em = BKE_editmesh_from_object(scene->obedit);
323 em->selectmode = ts->selectmode = selectmode_orig;
324 EDBM_selectmode_set(em);
331 /* prevent removal by cleanup */
332 # error "loopslide hack removed!"
333 #endif /* USE_LOOPSLIDE_HACK */
336 static void transformops_exit(bContext *C, wmOperator *op)
338 #ifdef USE_LOOPSLIDE_HACK
339 transformops_loopsel_hack(C, op);
342 saveTransform(C, op->customdata, op);
343 MEM_freeN(op->customdata);
344 op->customdata = NULL;
348 static int transformops_data(bContext *C, wmOperator *op, const wmEvent *event)
351 if (op->customdata == NULL) {
352 TransInfo *t = MEM_callocN(sizeof(TransInfo), "TransInfo data2");
353 TransformModeItem *tmode;
356 for (tmode = transform_modes; tmode->idname; tmode++) {
357 if (op->type->idname == tmode->idname) {
364 mode = RNA_enum_get(op->ptr, "mode");
367 retval = initTransform(C, t, op, event, mode);
371 G.moving = special_transform_moving(t);
379 return retval; /* return 0 on error */
382 static int transform_modal(bContext *C, wmOperator *op, const wmEvent *event)
386 TransInfo *t = op->customdata;
387 const enum TfmMode mode_prev = t->mode;
389 #if defined(WITH_INPUT_NDOF) && 0
390 // stable 2D mouse coords map to different 3D coords while the 3D mouse is active
391 // in other words, 2D deltas are no longer good enough!
392 // disable until individual 'transformers' behave better
394 if (event->type == NDOF_MOTION)
395 return OPERATOR_PASS_THROUGH;
398 /* XXX insert keys are called here, and require context */
400 exit_code = transformEvent(t, event);
403 /* XXX, workaround: active needs to be calculated before transforming,
404 * since we're not reading from 'td->center' in this case. see: T40241 */
405 if (t->tsnap.target == SCE_SNAP_TARGET_ACTIVE) {
406 /* In camera view, tsnap callback is not set (see initSnappingMode() in transfrom_snap.c, and T40348). */
407 if (t->tsnap.targetSnap && ((t->tsnap.status & TARGET_INIT) == 0)) {
408 t->tsnap.targetSnap(t);
412 transformApply(C, t);
414 exit_code |= transformEnd(C, t);
416 if ((exit_code & OPERATOR_RUNNING_MODAL) == 0) {
417 transformops_exit(C, op);
418 exit_code &= ~OPERATOR_PASS_THROUGH; /* preventively remove passthrough */
421 if (mode_prev != t->mode) {
422 /* WARNING: this is not normal to switch operator types
423 * normally it would not be supported but transform happens
424 * to share callbacks between different operators. */
425 wmOperatorType *ot_new = NULL;
426 TransformModeItem *item = transform_modes;
427 while (item->idname) {
428 if (item->mode == t->mode) {
429 ot_new = WM_operatortype_find(item->idname, false);
435 BLI_assert(ot_new != NULL);
437 WM_operator_type_set(op, ot_new);
439 /* end suspicious code */
446 static void transform_cancel(bContext *C, wmOperator *op)
448 TransInfo *t = op->customdata;
450 t->state = TRANS_CANCEL;
452 transformops_exit(C, op);
455 static int transform_exec(bContext *C, wmOperator *op)
459 if (!transformops_data(C, op, NULL)) {
461 return OPERATOR_CANCELLED;
466 t->options |= CTX_AUTOCONFIRM;
468 transformApply(C, t);
472 transformops_exit(C, op);
474 WM_event_add_notifier(C, NC_OBJECT | ND_TRANSFORM, NULL);
476 return OPERATOR_FINISHED;
479 static int transform_invoke(bContext *C, wmOperator *op, const wmEvent *event)
481 if (!transformops_data(C, op, event)) {
483 return OPERATOR_CANCELLED;
486 if (RNA_struct_property_is_set(op->ptr, "value")) {
487 return transform_exec(C, op);
490 /* add temp handler */
491 WM_event_add_modal_handler(C, op);
493 op->flag |= OP_IS_MODAL_GRAB_CURSOR; // XXX maybe we want this with the manipulator only?
494 return OPERATOR_RUNNING_MODAL;
498 static bool transform_poll_property(const bContext *UNUSED(C), wmOperator *op, const PropertyRNA *prop)
500 const char *prop_id = RNA_property_identifier(prop);
502 /* Orientation/Constraints. */
504 /* Hide orientation axis if no constraints are set, since it wont be used. */
505 PropertyRNA *prop_con = RNA_struct_find_property(op->ptr, "constraint_axis");
506 if (prop_con && !RNA_property_is_set(op->ptr, prop_con)) {
507 if (STRPREFIX(prop_id, "constraint")) {
513 /* Proportional Editing. */
515 PropertyRNA *prop_pet = RNA_struct_find_property(op->ptr, "proportional");
516 if (prop_pet && (prop_pet != prop) &&
517 (RNA_property_enum_get(op->ptr, prop_pet) == PROP_EDIT_OFF))
519 if (STRPREFIX(prop_id, "proportional")) {
528 void Transform_Properties(struct wmOperatorType *ot, int flags)
532 if (flags & P_AXIS) {
533 prop = RNA_def_property(ot->srna, "axis", PROP_FLOAT, PROP_DIRECTION);
534 RNA_def_property_array(prop, 3);
535 /* Make this not hidden when there's a nice axis selection widget */
536 RNA_def_property_flag(prop, PROP_HIDDEN);
537 RNA_def_property_ui_text(prop, "Axis", "The axis around which the transformation occurs");
540 if (flags & P_CONSTRAINT) {
541 RNA_def_boolean_vector(ot->srna, "constraint_axis", 3, NULL, "Constraint Axis", "");
542 prop = RNA_def_property(ot->srna, "constraint_orientation", PROP_ENUM, PROP_NONE);
543 RNA_def_property_ui_text(prop, "Orientation", "Transformation orientation");
544 RNA_def_enum_funcs(prop, rna_TransformOrientation_itemf);
547 if (flags & P_MIRROR) {
548 prop = RNA_def_boolean(ot->srna, "mirror", 0, "Mirror Editing", "");
549 if (flags & P_MIRROR_DUMMY) {
550 /* only used so macros can disable this option */
551 RNA_def_property_flag(prop, PROP_HIDDEN);
556 if (flags & P_PROPORTIONAL) {
557 RNA_def_enum(ot->srna, "proportional", rna_enum_proportional_editing_items, 0, "Proportional Editing", "");
558 prop = RNA_def_enum(ot->srna, "proportional_edit_falloff", rna_enum_proportional_falloff_items, 0,
559 "Proportional Editing Falloff", "Falloff type for proportional editing mode");
560 RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_CURVE); /* Abusing id_curve :/ */
561 RNA_def_float(ot->srna, "proportional_size", 1, T_PROP_SIZE_MIN, T_PROP_SIZE_MAX,
562 "Proportional Size", "", 0.001f, 100.0f);
565 if (flags & P_SNAP) {
566 prop = RNA_def_boolean(ot->srna, "snap", 0, "Use Snapping Options", "");
567 RNA_def_property_flag(prop, PROP_HIDDEN);
569 if (flags & P_GEO_SNAP) {
570 prop = RNA_def_enum(ot->srna, "snap_target", rna_enum_snap_target_items, 0, "Target", "");
571 RNA_def_property_flag(prop, PROP_HIDDEN);
572 prop = RNA_def_float_vector(ot->srna, "snap_point", 3, NULL, -FLT_MAX, FLT_MAX, "Point", "", -FLT_MAX, FLT_MAX);
573 RNA_def_property_flag(prop, PROP_HIDDEN);
575 if (flags & P_ALIGN_SNAP) {
576 prop = RNA_def_boolean(ot->srna, "snap_align", 0, "Align with Point Normal", "");
577 RNA_def_property_flag(prop, PROP_HIDDEN);
578 prop = RNA_def_float_vector(ot->srna, "snap_normal", 3, NULL, -FLT_MAX, FLT_MAX, "Normal", "", -FLT_MAX, FLT_MAX);
579 RNA_def_property_flag(prop, PROP_HIDDEN);
584 if (flags & P_GPENCIL_EDIT) {
585 RNA_def_boolean(ot->srna, "gpencil_strokes", 0, "Edit Grease Pencil", "Edit selected Grease Pencil strokes");
588 if ((flags & P_OPTIONS) && !(flags & P_NO_TEXSPACE)) {
589 RNA_def_boolean(ot->srna, "texture_space", 0, "Edit Texture Space", "Edit Object data texture space");
590 prop = RNA_def_boolean(ot->srna, "remove_on_cancel", 0, "Remove on Cancel", "Remove elements on cancel");
591 RNA_def_property_flag(prop, PROP_HIDDEN);
594 if (flags & P_CORRECT_UV) {
595 RNA_def_boolean(ot->srna, "correct_uv", 0, "Correct UVs", "Correct UV coordinates when transforming");
598 if (flags & P_CENTER) {
599 /* For manipulators that define their own center. */
600 prop = RNA_def_property(ot->srna, "center_override", PROP_FLOAT, PROP_XYZ);
601 RNA_def_property_array(prop, 3);
602 RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
603 RNA_def_property_ui_text(prop, "Center Override", "Force using this center value (when set)");
606 if ((flags & P_NO_DEFAULTS) == 0) {
607 prop = RNA_def_boolean(ot->srna, "release_confirm", 0, "Confirm on Release", "Always confirm operation when releasing button");
608 RNA_def_property_flag(prop, PROP_HIDDEN);
610 prop = RNA_def_boolean(ot->srna, "use_accurate", 0, "Accurate", "Use accurate transformation");
611 RNA_def_property_flag(prop, PROP_HIDDEN);
615 static void TRANSFORM_OT_translate(struct wmOperatorType *ot)
618 ot->name = "Translate";
619 ot->description = "Translate (move) selected items";
620 ot->idname = OP_TRANSLATION;
621 ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
624 ot->invoke = transform_invoke;
625 ot->exec = transform_exec;
626 ot->modal = transform_modal;
627 ot->cancel = transform_cancel;
628 ot->poll = ED_operator_screenactive;
629 ot->poll_property = transform_poll_property;
631 RNA_def_float_vector_xyz(ot->srna, "value", 3, NULL, -FLT_MAX, FLT_MAX, "Move", "", -FLT_MAX, FLT_MAX);
633 Transform_Properties(ot, P_CONSTRAINT | P_PROPORTIONAL | P_MIRROR | P_ALIGN_SNAP | P_OPTIONS | P_GPENCIL_EDIT);
636 static void TRANSFORM_OT_resize(struct wmOperatorType *ot)
640 ot->description = "Scale (resize) selected items";
641 ot->idname = OP_RESIZE;
642 ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
645 ot->invoke = transform_invoke;
646 ot->exec = transform_exec;
647 ot->modal = transform_modal;
648 ot->cancel = transform_cancel;
649 ot->poll = ED_operator_screenactive;
650 ot->poll_property = transform_poll_property;
652 RNA_def_float_vector(ot->srna, "value", 3, VecOne, -FLT_MAX, FLT_MAX, "Scale", "", -FLT_MAX, FLT_MAX);
654 Transform_Properties(
655 ot, P_CONSTRAINT | P_PROPORTIONAL | P_MIRROR | P_GEO_SNAP | P_OPTIONS | P_GPENCIL_EDIT | P_CENTER);
658 static bool skin_resize_poll(bContext *C)
660 struct Object *obedit = CTX_data_edit_object(C);
661 if (obedit && obedit->type == OB_MESH) {
662 BMEditMesh *em = BKE_editmesh_from_object(obedit);
663 return (em && CustomData_has_layer(&em->bm->vdata, CD_MVERT_SKIN));
668 static void TRANSFORM_OT_skin_resize(struct wmOperatorType *ot)
671 ot->name = "Skin Resize";
672 ot->description = "Scale selected vertices' skin radii";
673 ot->idname = OP_SKIN_RESIZE;
674 ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
677 ot->invoke = transform_invoke;
678 ot->exec = transform_exec;
679 ot->modal = transform_modal;
680 ot->cancel = transform_cancel;
681 ot->poll = skin_resize_poll;
682 ot->poll_property = transform_poll_property;
684 RNA_def_float_vector(ot->srna, "value", 3, VecOne, -FLT_MAX, FLT_MAX, "Scale", "", -FLT_MAX, FLT_MAX);
686 Transform_Properties(ot, P_CONSTRAINT | P_PROPORTIONAL | P_MIRROR | P_GEO_SNAP | P_OPTIONS | P_NO_TEXSPACE);
689 static void TRANSFORM_OT_trackball(struct wmOperatorType *ot)
692 ot->name = "Trackball";
693 ot->description = "Trackball style rotation of selected items";
694 ot->idname = OP_TRACKBALL;
695 ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
698 ot->invoke = transform_invoke;
699 ot->exec = transform_exec;
700 ot->modal = transform_modal;
701 ot->cancel = transform_cancel;
702 ot->poll = ED_operator_screenactive;
703 ot->poll_property = transform_poll_property;
705 /* Maybe we could use float_vector_xyz here too? */
706 RNA_def_float_rotation(ot->srna, "value", 2, NULL, -FLT_MAX, FLT_MAX, "Angle", "", -FLT_MAX, FLT_MAX);
708 Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR | P_SNAP | P_GPENCIL_EDIT | P_CENTER);
711 static void TRANSFORM_OT_rotate(struct wmOperatorType *ot)
715 ot->description = "Rotate selected items";
716 ot->idname = OP_ROTATION;
717 ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
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 ot->poll_property = transform_poll_property;
727 RNA_def_float_rotation(ot->srna, "value", 0, NULL, -FLT_MAX, FLT_MAX, "Angle", "", -M_PI * 2, M_PI * 2);
729 Transform_Properties(
730 ot, P_AXIS | P_CONSTRAINT | P_PROPORTIONAL | P_MIRROR | P_GEO_SNAP | P_GPENCIL_EDIT | P_CENTER);
733 static void TRANSFORM_OT_tilt(struct wmOperatorType *ot)
738 * "Tilt selected vertices"
739 * "Specify an extra axis rotation for selected vertices of 3D curve" */
740 ot->description = "Tilt selected control vertices of 3D curve";
741 ot->idname = OP_TILT;
742 ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
745 ot->invoke = transform_invoke;
746 ot->exec = transform_exec;
747 ot->modal = transform_modal;
748 ot->cancel = transform_cancel;
749 ot->poll = ED_operator_editcurve_3d;
750 ot->poll_property = transform_poll_property;
752 RNA_def_float_rotation(ot->srna, "value", 0, NULL, -FLT_MAX, FLT_MAX, "Angle", "", -M_PI * 2, M_PI * 2);
754 Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR | P_SNAP);
757 static void TRANSFORM_OT_bend(struct wmOperatorType *ot)
761 ot->description = "Bend selected items between the 3D cursor and the mouse";
762 ot->idname = OP_BEND;
763 ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
766 ot->invoke = transform_invoke;
767 // ot->exec = transform_exec; // unsupported
768 ot->modal = transform_modal;
769 ot->cancel = transform_cancel;
770 ot->poll = ED_operator_region_view3d_active;
771 ot->poll_property = transform_poll_property;
773 RNA_def_float_rotation(ot->srna, "value", 1, NULL, -FLT_MAX, FLT_MAX, "Angle", "", -M_PI * 2, M_PI * 2);
775 Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR | P_SNAP | P_GPENCIL_EDIT | P_CENTER);
778 static void TRANSFORM_OT_shear(struct wmOperatorType *ot)
782 ot->description = "Shear selected items along the horizontal screen axis";
783 ot->idname = OP_SHEAR;
784 ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
787 ot->invoke = transform_invoke;
788 ot->exec = transform_exec;
789 ot->modal = transform_modal;
790 ot->cancel = transform_cancel;
791 ot->poll = ED_operator_screenactive;
792 ot->poll_property = transform_poll_property;
794 RNA_def_float(ot->srna, "value", 0, -FLT_MAX, FLT_MAX, "Offset", "", -FLT_MAX, FLT_MAX);
796 Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR | P_SNAP | P_GPENCIL_EDIT);
800 static void TRANSFORM_OT_push_pull(struct wmOperatorType *ot)
803 ot->name = "Push/Pull";
804 ot->description = "Push/Pull selected items";
805 ot->idname = OP_PUSH_PULL;
806 ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
809 ot->invoke = transform_invoke;
810 ot->exec = transform_exec;
811 ot->modal = transform_modal;
812 ot->cancel = transform_cancel;
813 ot->poll = ED_operator_screenactive;
814 ot->poll_property = transform_poll_property;
816 RNA_def_float(ot->srna, "value", 0, -FLT_MAX, FLT_MAX, "Distance", "", -FLT_MAX, FLT_MAX);
818 Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR | P_SNAP | P_CENTER);
821 static void TRANSFORM_OT_shrink_fatten(struct wmOperatorType *ot)
824 ot->name = "Shrink/Fatten";
825 ot->description = "Shrink/fatten selected vertices along normals";
826 ot->idname = OP_SHRINK_FATTEN;
827 ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
830 ot->invoke = transform_invoke;
831 ot->exec = transform_exec;
832 ot->modal = transform_modal;
833 ot->cancel = transform_cancel;
834 ot->poll = ED_operator_editmesh;
835 ot->poll_property = transform_poll_property;
837 RNA_def_float(ot->srna, "value", 0, -FLT_MAX, FLT_MAX, "Offset", "", -FLT_MAX, FLT_MAX);
839 RNA_def_boolean(ot->srna, "use_even_offset", true, "Offset Even", "Scale the offset to give more even thickness");
841 Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR | P_SNAP);
844 static void TRANSFORM_OT_tosphere(struct wmOperatorType *ot)
847 ot->name = "To Sphere";
848 //added "around mesh center" to differentiate between "MESH_OT_vertices_to_sphere()"
849 ot->description = "Move selected vertices outward in a spherical shape around mesh center";
850 ot->idname = OP_TOSPHERE;
851 ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
854 ot->invoke = transform_invoke;
855 ot->exec = transform_exec;
856 ot->modal = transform_modal;
857 ot->cancel = transform_cancel;
858 ot->poll = ED_operator_screenactive;
859 ot->poll_property = transform_poll_property;
861 RNA_def_float_factor(ot->srna, "value", 0, 0, 1, "Factor", "", 0, 1);
863 Transform_Properties(ot, P_PROPORTIONAL | P_MIRROR | P_SNAP | P_GPENCIL_EDIT | P_CENTER);
866 static void TRANSFORM_OT_mirror(struct wmOperatorType *ot)
870 ot->description = "Mirror selected items around one or more axes";
871 ot->idname = OP_MIRROR;
872 ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
875 ot->invoke = transform_invoke;
876 ot->exec = transform_exec;
877 ot->modal = transform_modal;
878 ot->cancel = transform_cancel;
879 ot->poll = ED_operator_screenactive;
880 ot->poll_property = transform_poll_property;
882 Transform_Properties(ot, P_CONSTRAINT | P_PROPORTIONAL | P_GPENCIL_EDIT | P_CENTER);
885 static void TRANSFORM_OT_edge_slide(struct wmOperatorType *ot)
890 ot->name = "Edge Slide";
891 ot->description = "Slide an edge loop along a mesh";
892 ot->idname = OP_EDGE_SLIDE;
893 ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
896 ot->invoke = transform_invoke;
897 ot->exec = transform_exec;
898 ot->modal = transform_modal;
899 ot->cancel = transform_cancel;
900 ot->poll = ED_operator_editmesh_region_view3d;
901 ot->poll_property = transform_poll_property;
903 RNA_def_float_factor(ot->srna, "value", 0, -10.0f, 10.0f, "Factor", "", -1.0f, 1.0f);
905 prop = RNA_def_boolean(ot->srna, "single_side", false, "Single Side", "");
906 RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
907 RNA_def_boolean(ot->srna, "use_even", false, "Even",
908 "Make the edge loop match the shape of the adjacent edge loop");
909 RNA_def_boolean(ot->srna, "flipped", false, "Flipped",
910 "When Even mode is active, flips between the two adjacent edge loops");
911 RNA_def_boolean(ot->srna, "use_clamp", true, "Clamp",
912 "Clamp within the edge extents");
914 Transform_Properties(ot, P_MIRROR | P_SNAP | P_CORRECT_UV);
917 static void TRANSFORM_OT_vert_slide(struct wmOperatorType *ot)
920 ot->name = "Vertex Slide";
921 ot->description = "Slide a vertex along a mesh";
922 ot->idname = OP_VERT_SLIDE;
923 ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
926 ot->invoke = transform_invoke;
927 ot->exec = transform_exec;
928 ot->modal = transform_modal;
929 ot->cancel = transform_cancel;
930 ot->poll = ED_operator_editmesh_region_view3d;
931 ot->poll_property = transform_poll_property;
933 RNA_def_float_factor(ot->srna, "value", 0, -10.0f, 10.0f, "Factor", "", -1.0f, 1.0f);
934 RNA_def_boolean(ot->srna, "use_even", false, "Even",
935 "Make the edge loop match the shape of the adjacent edge loop");
936 RNA_def_boolean(ot->srna, "flipped", false, "Flipped",
937 "When Even mode is active, flips between the two adjacent edge loops");
938 RNA_def_boolean(ot->srna, "use_clamp", true, "Clamp",
939 "Clamp within the edge extents");
941 Transform_Properties(ot, P_MIRROR | P_SNAP | P_CORRECT_UV);
944 static void TRANSFORM_OT_edge_crease(struct wmOperatorType *ot)
947 ot->name = "Edge Crease";
948 ot->description = "Change the crease of edges";
949 ot->idname = OP_EDGE_CREASE;
950 ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
953 ot->invoke = transform_invoke;
954 ot->exec = transform_exec;
955 ot->modal = transform_modal;
956 ot->cancel = transform_cancel;
957 ot->poll = ED_operator_editmesh;
958 ot->poll_property = transform_poll_property;
960 RNA_def_float_factor(ot->srna, "value", 0, -1.0f, 1.0f, "Factor", "", -1.0f, 1.0f);
962 Transform_Properties(ot, P_SNAP);
965 static int edge_bevelweight_exec(bContext *C, wmOperator *op)
967 Mesh *me = (Mesh *)CTX_data_edit_object(C)->data;
969 /* auto-enable bevel edge weight drawing, then chain to common transform code */
970 me->drawflag |= ME_DRAWBWEIGHTS;
972 return transform_exec(C, op);
975 static int edge_bevelweight_invoke(bContext *C, wmOperator *op, const wmEvent *event)
977 Mesh *me = (Mesh *)CTX_data_edit_object(C)->data;
979 /* auto-enable bevel edge weight drawing, then chain to common transform code */
980 me->drawflag |= ME_DRAWBWEIGHTS;
982 return transform_invoke(C, op, event);
986 static void TRANSFORM_OT_edge_bevelweight(struct wmOperatorType *ot)
989 ot->name = "Edge Bevel Weight";
990 ot->description = "Change the bevel weight of edges";
991 ot->idname = OP_EDGE_BWEIGHT;
992 ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
995 ot->invoke = edge_bevelweight_invoke;
996 ot->exec = edge_bevelweight_exec;
997 ot->modal = transform_modal;
998 ot->cancel = transform_cancel;
999 ot->poll = ED_operator_editmesh;
1001 RNA_def_float_factor(ot->srna, "value", 0, -1.0f, 1.0f, "Factor", "", -1.0f, 1.0f);
1003 Transform_Properties(ot, P_SNAP);
1006 static void TRANSFORM_OT_seq_slide(struct wmOperatorType *ot)
1009 ot->name = "Sequence Slide";
1010 ot->description = "Slide a sequence strip in time";
1011 ot->idname = OP_SEQ_SLIDE;
1012 ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
1015 ot->invoke = transform_invoke;
1016 ot->exec = transform_exec;
1017 ot->modal = transform_modal;
1018 ot->cancel = transform_cancel;
1019 ot->poll = ED_operator_sequencer_active;
1021 RNA_def_float_vector_xyz(ot->srna, "value", 2, NULL, -FLT_MAX, FLT_MAX, "Offset", "", -FLT_MAX, FLT_MAX);
1023 Transform_Properties(ot, P_SNAP);
1026 static void TRANSFORM_OT_transform(struct wmOperatorType *ot)
1031 ot->name = "Transform";
1032 ot->description = "Transform selected items by mode type";
1033 ot->idname = "TRANSFORM_OT_transform";
1034 ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_BLOCKING;
1037 ot->invoke = transform_invoke;
1038 ot->exec = transform_exec;
1039 ot->modal = transform_modal;
1040 ot->cancel = transform_cancel;
1041 ot->poll = ED_operator_screenactive;
1042 ot->poll_property = transform_poll_property;
1044 prop = RNA_def_enum(ot->srna, "mode", rna_enum_transform_mode_types, TFM_TRANSLATION, "Mode", "");
1045 RNA_def_property_flag(prop, PROP_HIDDEN);
1047 RNA_def_float_vector(ot->srna, "value", 4, NULL, -FLT_MAX, FLT_MAX, "Values", "", -FLT_MAX, FLT_MAX);
1049 Transform_Properties(
1050 ot, P_AXIS | P_CONSTRAINT | P_PROPORTIONAL | P_MIRROR | P_ALIGN_SNAP | P_GPENCIL_EDIT | P_CENTER);
1053 void transform_operatortypes(void)
1055 TransformModeItem *tmode;
1057 for (tmode = transform_modes; tmode->idname; tmode++) {
1058 WM_operatortype_append(tmode->opfunc);
1061 WM_operatortype_append(TRANSFORM_OT_transform);
1063 WM_operatortype_append(TRANSFORM_OT_select_orientation);
1064 WM_operatortype_append(TRANSFORM_OT_create_orientation);
1065 WM_operatortype_append(TRANSFORM_OT_delete_orientation);
1068 void transform_keymap_for_space(wmKeyConfig *keyconf, wmKeyMap *keymap, int spaceid)
1073 /* transform.c, only adds modal map once, checks if it's there */
1074 modalmap = transform_modal_keymap(keyconf);
1076 /* assign map to operators only the first time */
1078 TransformModeItem *tmode;
1080 for (tmode = transform_modes; tmode->idname; tmode++) {
1081 WM_modalkeymap_assign(modalmap, tmode->idname);
1083 WM_modalkeymap_assign(modalmap, "TRANSFORM_OT_transform");
1088 WM_keymap_add_item(keymap, OP_TRANSLATION, GKEY, KM_PRESS, 0, 0);
1090 WM_keymap_add_item(keymap, OP_TRANSLATION, EVT_TWEAK_S, KM_ANY, 0, 0);
1092 WM_keymap_add_item(keymap, OP_ROTATION, RKEY, KM_PRESS, 0, 0);
1094 WM_keymap_add_item(keymap, OP_RESIZE, SKEY, KM_PRESS, 0, 0);
1096 WM_keymap_add_item(keymap, OP_BEND, WKEY, KM_PRESS, KM_SHIFT, 0);
1098 WM_keymap_add_item(keymap, OP_TOSPHERE, SKEY, KM_PRESS, KM_ALT | KM_SHIFT, 0);
1100 WM_keymap_add_item(keymap, OP_SHEAR, SKEY, KM_PRESS, KM_ALT | KM_CTRL | KM_SHIFT, 0);
1102 WM_keymap_add_item(keymap, "TRANSFORM_OT_select_orientation", SPACEKEY, KM_PRESS, KM_ALT, 0);
1104 kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_create_orientation", SPACEKEY, KM_PRESS, KM_CTRL | KM_ALT, 0);
1105 RNA_boolean_set(kmi->ptr, "use", true);
1107 WM_keymap_add_item(keymap, OP_MIRROR, MKEY, KM_PRESS, KM_CTRL, 0);
1109 kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", TABKEY, KM_PRESS, KM_SHIFT, 0);
1110 RNA_string_set(kmi->ptr, "data_path", "tool_settings.use_snap");
1112 kmi = WM_keymap_add_item(keymap, "WM_OT_context_menu_enum", TABKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0);
1113 RNA_string_set(kmi->ptr, "data_path", "tool_settings.snap_element");
1116 kmi = WM_keymap_add_item(keymap, OP_TRANSLATION, TKEY, KM_PRESS, KM_SHIFT, 0);
1117 RNA_boolean_set(kmi->ptr, "texture_space", true);
1119 kmi = WM_keymap_add_item(keymap, OP_RESIZE, TKEY, KM_PRESS, KM_SHIFT | KM_ALT, 0);
1120 RNA_boolean_set(kmi->ptr, "texture_space", true);
1122 WM_keymap_add_item(keymap, OP_SKIN_RESIZE, AKEY, KM_PRESS, KM_CTRL, 0);
1126 kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", GKEY, KM_PRESS, 0, 0);
1127 RNA_enum_set(kmi->ptr, "mode", TFM_TIME_TRANSLATE);
1129 kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", EVT_TWEAK_S, KM_ANY, 0, 0);
1130 RNA_enum_set(kmi->ptr, "mode", TFM_TIME_TRANSLATE);
1132 kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", EKEY, KM_PRESS, 0, 0);
1133 RNA_enum_set(kmi->ptr, "mode", TFM_TIME_EXTEND);
1135 kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", SKEY, KM_PRESS, 0, 0);
1136 RNA_enum_set(kmi->ptr, "mode", TFM_TIME_SCALE);
1138 kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", TKEY, KM_PRESS, KM_SHIFT, 0);
1139 RNA_enum_set(kmi->ptr, "mode", TFM_TIME_SLIDE);
1142 WM_keymap_add_item(keymap, OP_TRANSLATION, GKEY, KM_PRESS, 0, 0);
1144 WM_keymap_add_item(keymap, OP_TRANSLATION, EVT_TWEAK_S, KM_ANY, 0, 0);
1146 kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", EKEY, KM_PRESS, 0, 0);
1147 RNA_enum_set(kmi->ptr, "mode", TFM_TIME_EXTEND);
1149 WM_keymap_add_item(keymap, OP_ROTATION, RKEY, KM_PRESS, 0, 0);
1151 WM_keymap_add_item(keymap, OP_RESIZE, SKEY, KM_PRESS, 0, 0);
1154 kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", GKEY, KM_PRESS, 0, 0);
1155 RNA_enum_set(kmi->ptr, "mode", TFM_TRANSLATION);
1157 kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", EVT_TWEAK_S, KM_ANY, 0, 0);
1158 RNA_enum_set(kmi->ptr, "mode", TFM_TRANSLATION);
1160 kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", EKEY, KM_PRESS, 0, 0);
1161 RNA_enum_set(kmi->ptr, "mode", TFM_TIME_EXTEND);
1163 kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", SKEY, KM_PRESS, 0, 0);
1164 RNA_enum_set(kmi->ptr, "mode", TFM_TIME_SCALE);
1167 WM_keymap_add_item(keymap, "NODE_OT_translate_attach", GKEY, KM_PRESS, 0, 0);
1168 WM_keymap_add_item(keymap, "NODE_OT_translate_attach", EVT_TWEAK_A, KM_ANY, 0, 0);
1169 WM_keymap_add_item(keymap, "NODE_OT_translate_attach", EVT_TWEAK_S, KM_ANY, 0, 0);
1170 /* NB: small trick: macro operator poll may fail due to library data edit,
1171 * in that case the secondary regular operators are called with same keymap.
1173 kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_translate", GKEY, KM_PRESS, 0, 0);
1174 RNA_boolean_set(kmi->ptr, "release_confirm", true);
1175 kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_translate", EVT_TWEAK_A, KM_ANY, 0, 0);
1176 RNA_boolean_set(kmi->ptr, "release_confirm", true);
1177 kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_translate", EVT_TWEAK_S, KM_ANY, 0, 0);
1178 RNA_boolean_set(kmi->ptr, "release_confirm", true);
1180 WM_keymap_add_item(keymap, OP_ROTATION, RKEY, KM_PRESS, 0, 0);
1182 WM_keymap_add_item(keymap, OP_RESIZE, SKEY, KM_PRESS, 0, 0);
1184 /* detach and translate */
1185 WM_keymap_add_item(keymap, "NODE_OT_move_detach_links", DKEY, KM_PRESS, KM_ALT, 0);
1186 /* XXX release_confirm is set in the macro operator definition */
1187 WM_keymap_add_item(keymap, "NODE_OT_move_detach_links_release", EVT_TWEAK_A, KM_ANY, KM_ALT, 0);
1188 WM_keymap_add_item(keymap, "NODE_OT_move_detach_links", EVT_TWEAK_S, KM_ANY, KM_ALT, 0);
1190 kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", TABKEY, KM_PRESS, KM_SHIFT, 0);
1191 RNA_string_set(kmi->ptr, "data_path", "tool_settings.use_snap");
1192 kmi = WM_keymap_add_item(keymap, "WM_OT_context_menu_enum", TABKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0);
1193 RNA_string_set(kmi->ptr, "data_path", "tool_settings.snap_node_element");
1196 WM_keymap_add_item(keymap, OP_SEQ_SLIDE, GKEY, KM_PRESS, 0, 0);
1198 WM_keymap_add_item(keymap, OP_SEQ_SLIDE, EVT_TWEAK_S, KM_ANY, 0, 0);
1200 kmi = WM_keymap_add_item(keymap, "TRANSFORM_OT_transform", EKEY, KM_PRESS, 0, 0);
1201 RNA_enum_set(kmi->ptr, "mode", TFM_TIME_EXTEND);
1204 WM_keymap_add_item(keymap, OP_TRANSLATION, GKEY, KM_PRESS, 0, 0);
1206 WM_keymap_add_item(keymap, OP_TRANSLATION, EVT_TWEAK_S, KM_ANY, 0, 0);
1208 WM_keymap_add_item(keymap, OP_ROTATION, RKEY, KM_PRESS, 0, 0);
1210 WM_keymap_add_item(keymap, OP_RESIZE, SKEY, KM_PRESS, 0, 0);
1212 WM_keymap_add_item(keymap, OP_SHEAR, SKEY, KM_PRESS, KM_ALT | KM_CTRL | KM_SHIFT, 0);
1214 WM_keymap_add_item(keymap, "TRANSFORM_OT_mirror", MKEY, KM_PRESS, KM_CTRL, 0);
1216 kmi = WM_keymap_add_item(keymap, "WM_OT_context_toggle", TABKEY, KM_PRESS, KM_SHIFT, 0);
1217 RNA_string_set(kmi->ptr, "data_path", "tool_settings.use_snap");
1219 kmi = WM_keymap_add_item(keymap, "WM_OT_context_menu_enum", TABKEY, KM_PRESS, KM_SHIFT | KM_CTRL, 0);
1220 RNA_string_set(kmi->ptr, "data_path", "tool_settings.snap_uv_element");
1223 WM_keymap_add_item(keymap, OP_TRANSLATION, GKEY, KM_PRESS, 0, 0);
1224 WM_keymap_add_item(keymap, OP_TRANSLATION, EVT_TWEAK_S, KM_ANY, 0, 0);
1225 WM_keymap_add_item(keymap, OP_RESIZE, SKEY, KM_PRESS, 0, 0);
1226 WM_keymap_add_item(keymap, OP_ROTATION, RKEY, KM_PRESS, 0, 0);