Transform: Expose the hardcoded Precision Key

As shown on the T85383, attempts are made to edit the precision mode key.

But that key was hardcoded.

That key now appears among the custom modal keymap items.
This commit is contained in:
Germano Cavalcante 2021-02-09 12:28:51 -03:00
parent e44b2ada3e
commit b926c9f345
5 changed files with 20 additions and 29 deletions

View File

@ -5131,6 +5131,8 @@ def km_transform_modal_map(_params):
("INSERTOFS_TOGGLE_DIR", {"type": 'T', "value": 'PRESS'}, None),
("AUTOCONSTRAIN", {"type": 'MIDDLEMOUSE', "value": 'ANY'}, None),
("AUTOCONSTRAINPLANE", {"type": 'MIDDLEMOUSE', "value": 'ANY', "shift": True}, None),
("PRECISION", {"type": 'LEFT_SHIFT', "value": 'ANY', "any": True}, None),
("PRECISION", {"type": 'RIGHT_SHIFT', "value": 'ANY', "any": True}, None),
])
return keymap

View File

@ -3962,6 +3962,8 @@ def km_transform_modal_map(_params):
("INSERTOFS_TOGGLE_DIR", {"type": 'T', "value": 'PRESS'}, None),
("AUTOCONSTRAIN", {"type": 'MIDDLEMOUSE', "value": 'ANY'}, None),
("AUTOCONSTRAINPLANE", {"type": 'MIDDLEMOUSE', "value": 'ANY', "shift": True}, None),
("PRECISION", {"type": 'LEFT_SHIFT', "value": 'ANY', "any": True}, None),
("PRECISION", {"type": 'RIGHT_SHIFT', "value": 'ANY', "any": True}, None),
])
return keymap

View File

@ -695,6 +695,7 @@ wmKeyMap *transform_modal_keymap(wmKeyConfig *keyconf)
{TFM_MODAL_RESIZE, "RESIZE", 0, "Resize", ""},
{TFM_MODAL_AUTOCONSTRAINT, "AUTOCONSTRAIN", 0, "Automatic Constraint", ""},
{TFM_MODAL_AUTOCONSTRAINTPLANE, "AUTOCONSTRAINPLANE", 0, "Automatic Constraint Plane", ""},
{TFM_MODAL_PRECISION, "PRECISION", 0, "Precision Mode", ""},
{0, NULL, 0, NULL, NULL},
};
@ -806,8 +807,6 @@ int transformEvent(TransInfo *t, const wmEvent *event)
const int modifiers_prev = t->modifiers;
const int mode_prev = t->mode;
t->redraw |= handleMouseInput(t, &t->mouse, event);
/* Handle modal numinput events first, if already activated. */
if (((event->val == KM_PRESS) || (event->type == EVT_MODAL_MAP)) && hasNumInput(&t->num) &&
handleNumInput(t->context, &(t->num), event)) {
@ -1095,6 +1094,19 @@ int transformEvent(TransInfo *t, const wmEvent *event)
handled = true;
}
break;
case TFM_MODAL_PRECISION:
if (event->prevval == KM_PRESS) {
t->modifiers |= MOD_PRECISION;
/* Shift is modifier for higher precision transform. */
t->mouse.precision = 1;
t->redraw |= TREDRAW_HARD;
}
else if (event->prevval == KM_RELEASE) {
t->modifiers &= ~MOD_PRECISION;
t->mouse.precision = 0;
t->redraw |= TREDRAW_HARD;
}
break;
/* Those two are only handled in transform's own handler, see T44634! */
case TFM_MODAL_EDGESLIDE_UP:
case TFM_MODAL_EDGESLIDE_DOWN:

View File

@ -285,6 +285,8 @@ enum {
TFM_MODAL_AUTOCONSTRAINT = 28,
TFM_MODAL_AUTOCONSTRAINTPLANE = 29,
TFM_MODAL_PRECISION = 30,
};
/** \} */
@ -720,9 +722,6 @@ typedef enum {
void initMouseInput(
TransInfo *t, MouseInput *mi, const float center[2], const int mval[2], const bool precision);
void initMouseInputMode(TransInfo *t, MouseInput *mi, MouseInputMode mode);
eRedrawFlag handleMouseInput(struct TransInfo *t,
struct MouseInput *mi,
const struct wmEvent *event);
void applyMouseInput(struct TransInfo *t,
struct MouseInput *mi,
const int mval[2],

View File

@ -499,28 +499,4 @@ void applyMouseInput(TransInfo *t, MouseInput *mi, const int mval[2], float outp
}
}
eRedrawFlag handleMouseInput(TransInfo *t, MouseInput *mi, const wmEvent *event)
{
eRedrawFlag redraw = TREDRAW_NOTHING;
switch (event->type) {
case EVT_LEFTSHIFTKEY:
case EVT_RIGHTSHIFTKEY:
if (event->val == KM_PRESS) {
t->modifiers |= MOD_PRECISION;
/* Shift is modifier for higher precision transform. */
mi->precision = 1;
redraw = TREDRAW_HARD;
}
else if (event->val == KM_RELEASE) {
t->modifiers &= ~MOD_PRECISION;
mi->precision = 0;
redraw = TREDRAW_HARD;
}
break;
}
return redraw;
}
/** \} */