diff --git a/scripts/modules/bl_keymap_utils/versioning.py b/scripts/modules/bl_keymap_utils/versioning.py index 65febf2c399..6b794c52e29 100644 --- a/scripts/modules/bl_keymap_utils/versioning.py +++ b/scripts/modules/bl_keymap_utils/versioning.py @@ -60,4 +60,22 @@ def keyconfig_update(keyconfig_data, keyconfig_version): }.get(item_event.get("type")): item_event["type"] = ty_new + if keyconfig_version <= (3, 6, 0): + # The modal keys "Vert/Edge Slide" and "TrackBall" didn't exist until then. + # The operator reused the "Move" and "Rotate" respectively. + if not has_copy: + keyconfig_data = copy.deepcopy(keyconfig_data) + has_copy = True + + for km_name, _km_parms, km_items_data in keyconfig_data: + if km_name == "Transform Modal Map": + km_items = km_items_data["items"] + for (item_modal, item_event, _item_prop) in km_items: + if item_modal == 'TRANSLATE': + km_items.append(('VERT_EDGE_SLIDE', item_event, None)) + elif item_modal == 'ROTATE': + km_items.append(('TRACKBALL', item_event, None)) + + break + return keyconfig_data diff --git a/scripts/presets/keyconfig/keymap_data/blender_default.py b/scripts/presets/keyconfig/keymap_data/blender_default.py index b33962d5311..7f34593e2b8 100644 --- a/scripts/presets/keyconfig/keymap_data/blender_default.py +++ b/scripts/presets/keyconfig/keymap_data/blender_default.py @@ -5789,7 +5789,9 @@ def km_transform_modal_map(_params): ("PLANE_Z", {"type": 'Z', "value": 'PRESS', "shift": True}, None), ("CONS_OFF", {"type": 'C', "value": 'PRESS'}, None), ("TRANSLATE", {"type": 'G', "value": 'PRESS'}, None), + ("VERT_EDGE_SLIDE", {"type": 'G', "value": 'PRESS'}, None), ("ROTATE", {"type": 'R', "value": 'PRESS'}, None), + ("TRACKBALL", {"type": 'R', "value": 'PRESS'}, None), ("RESIZE", {"type": 'S', "value": 'PRESS'}, None), ("SNAP_TOGGLE", {"type": 'TAB', "value": 'PRESS', "shift": True}, None), ("SNAP_INV_ON", {"type": 'LEFT_CTRL', "value": 'PRESS', "any": True}, None), diff --git a/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py b/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py index 98cee34519f..90ab9e008a4 100644 --- a/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py +++ b/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py @@ -3971,7 +3971,9 @@ def km_transform_modal_map(_params): ("PLANE_Z", {"type": 'Z', "value": 'PRESS', "shift": True}, None), ("CONS_OFF", {"type": 'C', "value": 'PRESS'}, None), ("TRANSLATE", {"type": 'G', "value": 'PRESS'}, None), + ("VERT_EDGE_SLIDE", {"type": 'G', "value": 'PRESS'}, None), ("ROTATE", {"type": 'R', "value": 'PRESS'}, None), + ("TRACKBALL", {"type": 'R', "value": 'PRESS'}, None), ("RESIZE", {"type": 'S', "value": 'PRESS'}, None), ("SNAP_TOGGLE", {"type": 'TAB', "value": 'PRESS', "shift": True}, None), ("SNAP_INV_ON", {"type": 'LEFT_CTRL', "value": 'PRESS', "any": True}, None), diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h index 72b89dd634c..6f33219c7f6 100644 --- a/source/blender/blenkernel/BKE_blender_version.h +++ b/source/blender/blenkernel/BKE_blender_version.h @@ -25,7 +25,7 @@ extern "C" { /* Blender file format version. */ #define BLENDER_FILE_VERSION BLENDER_VERSION -#define BLENDER_FILE_SUBVERSION 0 +#define BLENDER_FILE_SUBVERSION 1 /* Minimum Blender version that supports reading file written with the current * version. Older Blender versions will test this and show a warning if the file diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index fb2b1153ad7..8d479b608fb 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -617,10 +617,48 @@ static bool transform_modal_item_poll(const wmOperator *op, int value) } case TFM_MODAL_TRANSLATE: case TFM_MODAL_ROTATE: - case TFM_MODAL_RESIZE: { + case TFM_MODAL_RESIZE: + case TFM_MODAL_VERT_EDGE_SLIDE: + case TFM_MODAL_TRACKBALL: { if (!transform_mode_is_changeable(t->mode)) { return false; } + if (value == TFM_MODAL_TRANSLATE && t->mode == TFM_TRANSLATION) { + return false; + } + if (value == TFM_MODAL_ROTATE && t->mode == TFM_ROTATION) { + return false; + } + if (value == TFM_MODAL_RESIZE && t->mode == TFM_RESIZE) { + return false; + } + if (value == TFM_MODAL_VERT_EDGE_SLIDE && + (t->data_type != &TransConvertType_Mesh || + /* WORKAROUND: Avoid repeated keys in status bar. + * + * Previously, `Vert/Edge Slide` and `Move` were triggered by the same modal key. + * But now, to fix #100129 (Status bar incorrectly shows "[G] Move"), `Vert/Edge Slide` + * has its own modal key. However by default it uses the same key as `Move` (G). So, to + * avoid displaying the same key twice (G and G), only display this modal key during the + * `Move` operation. + * + * Ideally we should check if it really uses the same key. */ + t->mode != TFM_TRANSLATION)) { + return false; + } + if (value == TFM_MODAL_TRACKBALL && + /* WORKAROUND: Avoid repeated keys in status bar. + * + * Previously, `Trackball` and `Rotate` were triggered by the same modal key. + * But to fix the status bar incorrectly showing "[R] Rotate", `Trackball` has now its + * own modal key. However by default it uses the same key as `Rotate` (R). So, to avoid + * displaying the same key twice (R and R), only display this modal key during the + * `Rotate` operation. + * + * Ideally we should check if it really uses the same key. */ + t->mode != TFM_ROTATION) { + return false; + } break; } } @@ -667,7 +705,9 @@ wmKeyMap *transform_modal_keymap(wmKeyConfig *keyconf) {TFM_MODAL_NODE_ATTACH_ON, "NODE_ATTACH_ON", 0, "Node Attachment", ""}, {TFM_MODAL_NODE_ATTACH_OFF, "NODE_ATTACH_OFF", 0, "Node Attachment (Off)", ""}, {TFM_MODAL_TRANSLATE, "TRANSLATE", 0, "Move", ""}, + {TFM_MODAL_VERT_EDGE_SLIDE, "VERT_EDGE_SLIDE", 0, "Vert/Edge Slide", ""}, {TFM_MODAL_ROTATE, "ROTATE", 0, "Rotate", ""}, + {TFM_MODAL_TRACKBALL, "TRACKBALL", 0, "TrackBall", ""}, {TFM_MODAL_RESIZE, "RESIZE", 0, "Resize", ""}, {TFM_MODAL_AUTOCONSTRAINT, "AUTOCONSTRAIN", 0, "Automatic Constraint", ""}, {TFM_MODAL_AUTOCONSTRAINTPLANE, "AUTOCONSTRAINPLANE", 0, "Automatic Constraint Plane", ""}, @@ -913,8 +953,15 @@ int transformEvent(TransInfo *t, const wmEvent *event) handled = true; break; case TFM_MODAL_TRANSLATE: + case TFM_MODAL_VERT_EDGE_SLIDE: /* only switch when... */ - if (t->mode == TFM_TRANSLATION) { + if (!transform_mode_is_changeable(t->mode)) { + break; + } + if (event->val == TFM_MODAL_VERT_EDGE_SLIDE) { + if (ELEM(t->mode, TFM_VERT_SLIDE, TFM_EDGE_SLIDE)) { + break; + } if ((t->obedit_type == OB_MESH) && (t->spacetype == SPACE_VIEW3D)) { restoreTransObjects(t); resetTransModal(t); @@ -948,7 +995,10 @@ int transformEvent(TransInfo *t, const wmEvent *event) handled = true; } } - else if (transform_mode_is_changeable(t->mode)) { + else { + if (t->mode == TFM_TRANSLATION) { + break; + } restoreTransObjects(t); resetTransModal(t); resetTransRestrictions(t); @@ -959,24 +1009,34 @@ int transformEvent(TransInfo *t, const wmEvent *event) } break; case TFM_MODAL_ROTATE: + case TFM_MODAL_TRACKBALL: /* only switch when... */ - if (!(t->options & CTX_TEXTURE_SPACE) && !(t->options & (CTX_MOVIECLIP | CTX_MASK))) { - if (transform_mode_is_changeable(t->mode)) { - restoreTransObjects(t); - resetTransModal(t); - resetTransRestrictions(t); - - if (t->mode == TFM_ROTATION) { - transform_mode_init(t, NULL, TFM_TRACKBALL); - } - else { - transform_mode_init(t, NULL, TFM_ROTATION); - } - initSnapping(t, NULL); /* need to reinit after mode change */ - t->redraw |= TREDRAW_HARD; - handled = true; + if (!transform_mode_is_changeable(t->mode)) { + break; + } + if (event->val == TFM_MODAL_TRACKBALL) { + if (t->mode == TFM_TRACKBALL) { + break; } } + else if (t->mode == TFM_ROTATION) { + break; + } + if (!(t->options & CTX_TEXTURE_SPACE) && !(t->options & (CTX_MOVIECLIP | CTX_MASK))) { + restoreTransObjects(t); + resetTransModal(t); + resetTransRestrictions(t); + + if (event->val == TFM_MODAL_TRACKBALL) { + transform_mode_init(t, NULL, TFM_TRACKBALL); + } + else { + transform_mode_init(t, NULL, TFM_ROTATION); + } + initSnapping(t, NULL); /* need to reinit after mode change */ + t->redraw |= TREDRAW_HARD; + handled = true; + } break; case TFM_MODAL_RESIZE: /* only switch when... */ diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h index c5248f67f9a..353f4ac7072 100644 --- a/source/blender/editors/transform/transform.h +++ b/source/blender/editors/transform/transform.h @@ -265,6 +265,9 @@ enum { TFM_MODAL_AUTOCONSTRAINTPLANE = 29, TFM_MODAL_PRECISION = 30, + + TFM_MODAL_VERT_EDGE_SLIDE = 31, + TFM_MODAL_TRACKBALL = 32, }; /** \} */