[Bf-blender-cvs] [4df75e5] master: Make Shift+LMB on transform manipulator configurable
Julian Eisel
noreply at git.blender.org
Fri Dec 16 02:50:11 CET 2016
Commit: 4df75e536a0847cf5e5f567f92f1391f1f72c211
Author: Julian Eisel
Date: Fri Dec 16 02:35:36 2016 +0100
Branches: master
https://developer.blender.org/rB4df75e536a0847cf5e5f567f92f1391f1f72c211
Make Shift+LMB on transform manipulator configurable
It's now possible to change the shortcut that enables planar transformation with the transform manipulators (shift+LMB on axis).
This actually fixes the workaround added in rB20681f49801fd. Thing is that we needed to allow using the manipulators, even if a modifier key is held so things like snapping work right away. That's why normal LMB behavior uses KM_ANY. However, event handling would always execute the KM_ANY keymap handler because it's iterated over first. Simply solved this by registering the KM_SHIFT keymap item first, so it has priority over the KM_ANY one.
===================================================================
M source/blender/editors/physics/physics_ops.c
M source/blender/editors/space_view3d/view3d_edit.c
M source/blender/editors/space_view3d/view3d_ops.c
M source/blender/editors/transform/transform_manipulator.c
===================================================================
diff --git a/source/blender/editors/physics/physics_ops.c b/source/blender/editors/physics/physics_ops.c
index 7ba4b2b..0c907f1 100644
--- a/source/blender/editors/physics/physics_ops.c
+++ b/source/blender/editors/physics/physics_ops.c
@@ -137,8 +137,14 @@ static void keymap_particle(wmKeyConfig *keyconf)
kmi = WM_keymap_add_item(keymap, "PARTICLE_OT_hide", HKEY, KM_PRESS, KM_SHIFT, 0);
RNA_boolean_set(kmi->ptr, "unselected", true);
- kmi = WM_keymap_verify_item(keymap, "VIEW3D_OT_manipulator", LEFTMOUSE, KM_PRESS, KM_ANY, 0);
+ /* Shift+LMB behavior first, so it has priority over KM_ANY item below. */
+ kmi = WM_keymap_verify_item(keymap, "VIEW3D_OT_manipulator", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0);
RNA_boolean_set(kmi->ptr, "release_confirm", true);
+ RNA_boolean_set(kmi->ptr, "use_planar_constraint", true);
+ /* Using KM_ANY here to allow holding modifiers before starting to transform. */
+ kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_manipulator", LEFTMOUSE, KM_PRESS, KM_ANY, 0);
+ RNA_boolean_set(kmi->ptr, "release_confirm", true);
+ RNA_boolean_set(kmi->ptr, "use_planar_constraint", false);
WM_keymap_add_item(keymap, "PARTICLE_OT_brush_edit", LEFTMOUSE, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "PARTICLE_OT_brush_edit", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0);
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index 080f205..eb4d1b3 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -4782,13 +4782,10 @@ static int manipulator_invoke(bContext *C, wmOperator *op, const wmEvent *event)
if (!(v3d->twflag & V3D_USE_MANIPULATOR)) return OPERATOR_PASS_THROUGH;
if (!(v3d->twflag & V3D_DRAW_MANIPULATOR)) return OPERATOR_PASS_THROUGH;
- /* only no modifier or shift */
- if (event->keymodifier != 0 && event->keymodifier != KM_SHIFT) return OPERATOR_PASS_THROUGH;
-
/* note; otherwise opengl won't work */
view3d_operator_needs_opengl(C);
- if (0 == BIF_do_manipulator(C, event, op))
+ if (BIF_do_manipulator(C, event, op) == 0)
return OPERATOR_PASS_THROUGH;
return OPERATOR_FINISHED;
@@ -4809,6 +4806,9 @@ void VIEW3D_OT_manipulator(wmOperatorType *ot)
/* properties to pass to transform */
Transform_Properties(ot, P_CONSTRAINT);
+
+ RNA_def_boolean(ot->srna, "use_planar_constraint", false, "Planar Constraint", "Limit the transformation to the "
+ "two axes that have not been clicked (translate/scale only)");
}
static int enable_manipulator_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
diff --git a/source/blender/editors/space_view3d/view3d_ops.c b/source/blender/editors/space_view3d/view3d_ops.c
index cfeb8af..0fa6841 100644
--- a/source/blender/editors/space_view3d/view3d_ops.c
+++ b/source/blender/editors/space_view3d/view3d_ops.c
@@ -240,13 +240,15 @@ void view3d_keymap(wmKeyConfig *keyconf)
/* only for region 3D window */
keymap = WM_keymap_find(keyconf, "3D View", SPACE_VIEW3D, 0);
- kmi = WM_keymap_verify_item(keymap, "VIEW3D_OT_manipulator", LEFTMOUSE, KM_PRESS, KM_ANY, 0);
+ /* Shift+LMB behavior first, so it has priority over KM_ANY item below. */
+ kmi = WM_keymap_verify_item(keymap, "VIEW3D_OT_manipulator", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0);
RNA_boolean_set(kmi->ptr, "release_confirm", true);
- /*
- * Doesn't work with KM_SHIFT, have to use KM_ANY and filter in invoke
- * */
- // WM_keymap_verify_item(keymap, "VIEW3D_OT_manipulator", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0);
-
+ RNA_boolean_set(kmi->ptr, "use_planar_constraint", true);
+ /* Using KM_ANY here to allow holding modifiers before starting to transform. */
+ kmi = WM_keymap_add_item(keymap, "VIEW3D_OT_manipulator", LEFTMOUSE, KM_PRESS, KM_ANY, 0);
+ RNA_boolean_set(kmi->ptr, "release_confirm", true);
+ RNA_boolean_set(kmi->ptr, "use_planar_constraint", false);
+
WM_keymap_verify_item(keymap, "VIEW3D_OT_cursor3d", ACTIONMOUSE, KM_PRESS, 0, 0);
WM_keymap_verify_item(keymap, "VIEW3D_OT_rotate", MIDDLEMOUSE, KM_PRESS, 0, 0);
diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c
index 075f311..e141724 100644
--- a/source/blender/editors/transform/transform_manipulator.c
+++ b/source/blender/editors/transform/transform_manipulator.c
@@ -1835,7 +1835,7 @@ int BIF_do_manipulator(bContext *C, const struct wmEvent *event, wmOperator *op)
ARegion *ar = CTX_wm_region(C);
int constraint_axis[3] = {0, 0, 0};
int val;
- int shift = event->shift;
+ const bool use_planar = RNA_boolean_get(op->ptr, "use_planar_constraint");
if (!(v3d->twflag & V3D_USE_MANIPULATOR)) return 0;
if (!(v3d->twflag & V3D_DRAW_MANIPULATOR)) return 0;
@@ -1856,7 +1856,7 @@ int BIF_do_manipulator(bContext *C, const struct wmEvent *event, wmOperator *op)
case MAN_TRANS_C:
break;
case MAN_TRANS_X:
- if (shift) {
+ if (use_planar) {
constraint_axis[1] = 1;
constraint_axis[2] = 1;
}
@@ -1864,7 +1864,7 @@ int BIF_do_manipulator(bContext *C, const struct wmEvent *event, wmOperator *op)
constraint_axis[0] = 1;
break;
case MAN_TRANS_Y:
- if (shift) {
+ if (use_planar) {
constraint_axis[0] = 1;
constraint_axis[2] = 1;
}
@@ -1872,7 +1872,7 @@ int BIF_do_manipulator(bContext *C, const struct wmEvent *event, wmOperator *op)
constraint_axis[1] = 1;
break;
case MAN_TRANS_Z:
- if (shift) {
+ if (use_planar) {
constraint_axis[0] = 1;
constraint_axis[1] = 1;
}
@@ -1886,7 +1886,7 @@ int BIF_do_manipulator(bContext *C, const struct wmEvent *event, wmOperator *op)
else if (drawflags & MAN_SCALE_C) {
switch (drawflags) {
case MAN_SCALE_X:
- if (shift) {
+ if (use_planar) {
constraint_axis[1] = 1;
constraint_axis[2] = 1;
}
@@ -1894,7 +1894,7 @@ int BIF_do_manipulator(bContext *C, const struct wmEvent *event, wmOperator *op)
constraint_axis[0] = 1;
break;
case MAN_SCALE_Y:
- if (shift) {
+ if (use_planar) {
constraint_axis[0] = 1;
constraint_axis[2] = 1;
}
@@ -1902,7 +1902,7 @@ int BIF_do_manipulator(bContext *C, const struct wmEvent *event, wmOperator *op)
constraint_axis[1] = 1;
break;
case MAN_SCALE_Z:
- if (shift) {
+ if (use_planar) {
constraint_axis[0] = 1;
constraint_axis[1] = 1;
}
More information about the Bf-blender-cvs
mailing list