Navigation: Right drag orbits option; picking the SolidWorks preset turns it off (#6492) (#6497)

* claim: #6492

* feat(navigation): Right drag orbits option, off when picking the SolidWorks preset, which also fits on middle double-click (#6492)
This commit is contained in:
Lars Jansen
2026-10-29 10:24:37 +00:00
committed by GitHub
parent fe3f913d76
commit 375dc01602
7 changed files with 131 additions and 5 deletions
@@ -0,0 +1,34 @@
{
"en": {
"nav.right_drag_orbits.label": "Right drag orbits",
"nav.right_drag_orbits.help": "Off: a right drag leaves the camera alone and the right button only opens the context menu. Picking the SolidWorks mouse mapping turns it off."
},
"de": {
"nav.right_drag_orbits.label": "Rechtes Ziehen dreht",
"nav.right_drag_orbits.help": "Aus: rechtes Ziehen lässt die Kamera unverändert, die rechte Maustaste öffnet nur das Kontextmenü. Die Mausbelegung SolidWorks schaltet es beim Auswählen aus."
},
"ja": {
"nav.right_drag_orbits.label": "右ドラッグで回転",
"nav.right_drag_orbits.help": "オフ:右ドラッグではカメラは動かず、右ボタンはコンテキストメニューを開くだけです。マウス割り当てで SolidWorks を選ぶとオフになります。"
},
"ko": {
"nav.right_drag_orbits.label": "오른쪽 드래그로 회전",
"nav.right_drag_orbits.help": "끄면 오른쪽 드래그는 카메라에 영향을 주지 않고 오른쪽 버튼은 컨텍스트 메뉴만 엽니다. SolidWorks 마우스 매핑을 선택하면 꺼집니다."
},
"zh": {
"nav.right_drag_orbits.label": "右键拖动旋转",
"nav.right_drag_orbits.help": "关闭:右键拖动不会移动相机,右键只打开上下文菜单。选择 SolidWorks 鼠标映射时会关闭此项。"
},
"ar": {
"nav.right_drag_orbits.label": "السحب بالزر الأيمن يدوّر العرض",
"nav.right_drag_orbits.help": "عند الإيقاف: لا يحرّك السحب بالزر الأيمن الكاميرا، ويفتح الزر الأيمن قائمة السياق فقط. اختيار تعيين الفأرة SolidWorks يوقفه."
},
"he": {
"nav.right_drag_orbits.label": "גרירה ימנית מסובבת",
"nav.right_drag_orbits.help": "כבוי: גרירה בכפתור הימני לא מזיזה את המצלמה, והכפתור הימני רק פותח את תפריט ההקשר. בחירת מיפוי העכבר SolidWorks מכבה זאת."
},
"vi": {
"nav.right_drag_orbits.label": "Kéo chuột phải để xoay",
"nav.right_drag_orbits.help": "Tắt: kéo chuột phải không di chuyển camera, và nút phải chỉ mở menu ngữ cảnh. Chọn kiểu chuột SolidWorks sẽ tắt tùy chọn này."
}
}
+1 -2
View File
@@ -609,8 +609,7 @@ pub(crate) fn nav_rows(app: &mut SolveApp, ui: &mut egui::Ui, t: &Tokens) {
crate::ui_kit::Text::Hint("mouse_gesture_mode"),
);
if crate::ui_kit::button(ui, crate::i18n::tr_label("Use the SolidWorks mouse mode"), crate::ui_kit::Button::Normal).clicked() {
app.preferences.nav = MOUSE_MODE.to_string();
app.preferences.zoom_reverse = crate::prefs::nav_preset(MOUSE_MODE).reverse_zoom;
crate::prefs::choose_nav_preset(&mut app.preferences, crate::prefs::nav_preset(MOUSE_MODE));
}
} else if app.preferences.mouse_gestures.enabled {
crate::ui_kit::text(
+15
View File
@@ -1467,6 +1467,21 @@ mod tests {
}
}
#[test]
fn right_drag_orbits_off_leaves_the_camera_to_the_middle_button() {
use serde_json::json;
let mut h = crate::scenario::Harness::new();
h.app.home.open = false;
crate::prefs::choose_nav_preset(&mut h.app.preferences, crate::prefs::nav_preset("solidworks"));
let before = h.app.cam;
for shift in [false, true] {
h.call("ui.drag", json!({"x0":800,"y0":400,"x1":850,"y1":440,"button":"right","shift":shift,"steps":20}));
assert_eq!(h.app.cam.back(), before.back(), "shift {shift}: a right drag leaves the camera alone (#6492)");
}
h.call("ui.drag", json!({"x0":800,"y0":400,"x1":850,"y1":440,"button":"middle","steps":20}));
assert_ne!(h.app.cam.back(), before.back(), "the middle button still orbits");
}
#[test]
fn solidworks_device_and_mouse_keep_turning_with_the_same_screen_axes() {
use super::*;
+68 -1
View File
@@ -86,6 +86,10 @@ pub struct NavPreset {
pub help: &'static str,
/// Choosing the preset turns the wheel the other way.
pub reverse_zoom: bool,
/// Choosing the preset sets what a middle double-click does (`None` leaves it as it is).
pub middle_double_click: Option<&'static str>,
/// Choosing the preset sets "Right drag orbits" (`None` leaves it as it is).
pub right_drag_orbits: Option<bool>,
pub bindings: &'static [NavBinding],
}
@@ -106,6 +110,8 @@ pub const NAV_PRESETS: &[NavPreset] = &[
label: "Fusion",
help: "Middle drag pans, Shift+middle orbits, right drag orbits",
reverse_zoom: false,
middle_double_click: None,
right_drag_orbits: None,
bindings: &[bind(Middle, NavKeys::SHIFT, Orbit), bind(Middle, NavKeys::NONE, Pan), bind(Right, NavKeys::NONE, Orbit)],
},
NavPreset {
@@ -113,6 +119,9 @@ pub const NAV_PRESETS: &[NavPreset] = &[
label: "SolidWorks",
help: "Middle drag orbits, Ctrl+middle pans, Shift+middle zooms, right drag orbits",
reverse_zoom: true,
// Picked here, the right button is left to the context menu and mouse gestures (#6492).
middle_double_click: Some("fit"),
right_drag_orbits: Some(false),
bindings: &[
bind(Middle, NavKeys::CTRL, Pan),
bind(Middle, NavKeys::SHIFT, Zoom),
@@ -125,6 +134,8 @@ pub const NAV_PRESETS: &[NavPreset] = &[
label: "Inventor",
help: "Middle drag pans, Shift+middle orbits, Ctrl+middle zooms, right drag orbits",
reverse_zoom: false,
middle_double_click: None,
right_drag_orbits: None,
bindings: &[
bind(Middle, NavKeys::SHIFT, Orbit),
bind(Middle, NavKeys::CTRL, Zoom),
@@ -137,6 +148,8 @@ pub const NAV_PRESETS: &[NavPreset] = &[
label: "Alias",
help: "Shift+Alt+left drag orbits, Shift+Alt+middle pans, Shift+Alt+right zooms; middle drag also pans and right drag orbits",
reverse_zoom: false,
middle_double_click: None,
right_drag_orbits: None,
bindings: &[
bind(Left, NavKeys::SHIFT_ALT, Orbit),
bind(Middle, NavKeys::SHIFT_ALT, Pan),
@@ -151,6 +164,8 @@ pub const NAV_PRESETS: &[NavPreset] = &[
label: "Maya",
help: "Alt+left drag orbits, Alt+middle pans, Alt+right zooms; middle drag also pans",
reverse_zoom: false,
middle_double_click: None,
right_drag_orbits: None,
bindings: &[
bind(Left, NavKeys::ALT, Orbit),
bind(Middle, NavKeys::ALT, Pan),
@@ -163,6 +178,8 @@ pub const NAV_PRESETS: &[NavPreset] = &[
label: "Blender",
help: "Middle drag orbits, Shift+middle pans, Ctrl+middle zooms; right drag leaves the camera alone",
reverse_zoom: false,
middle_double_click: None,
right_drag_orbits: None,
bindings: &[bind(Middle, NavKeys::SHIFT, Pan), bind(Middle, NavKeys::CTRL, Zoom), bind(Middle, NavKeys::NONE, Orbit)],
},
NavPreset {
@@ -170,6 +187,8 @@ pub const NAV_PRESETS: &[NavPreset] = &[
label: "Tinkercad",
help: "Right drag orbits, middle or Shift+right drag pans",
reverse_zoom: false,
middle_double_click: None,
right_drag_orbits: None,
bindings: &[bind(Right, NavKeys::SHIFT, Pan), bind(Right, NavKeys::NONE, Orbit), bind(Middle, NavKeys::NONE, Pan)],
},
NavPreset {
@@ -177,6 +196,8 @@ pub const NAV_PRESETS: &[NavPreset] = &[
label: "OpenSCAD",
help: "Left drag on empty space orbits, Shift+left drag box-selects, sketch geometry drags edit; right or middle drag pans, Shift+right or Shift+middle drag zooms",
reverse_zoom: false,
middle_double_click: None,
right_drag_orbits: None,
bindings: &[
bind(Left, NavKeys::NONE, Orbit),
bind(Right, NavKeys::SHIFT, Zoom),
@@ -190,6 +211,8 @@ pub const NAV_PRESETS: &[NavPreset] = &[
label: "HFSS",
help: "Alt+left drag pans, Shift+Alt+left zooms, Ctrl+left drag on empty space orbits",
reverse_zoom: false,
middle_double_click: None,
right_drag_orbits: None,
// Ctrl+left orbit is the drag from empty space every preset has: as a binding it would
// also take a Ctrl+click on geometry, which adds to the selection.
bindings: &[bind(Left, NavKeys::SHIFT_ALT, Zoom), bind(Left, NavKeys::ALT, Pan)],
@@ -199,6 +222,8 @@ pub const NAV_PRESETS: &[NavPreset] = &[
label: "Touchpad",
help: "Hold Shift and move the pointer to pan; hold Alt/Option and move it to orbit. No mouse button is needed. Vertical scroll zooms.",
reverse_zoom: false,
middle_double_click: None,
right_drag_orbits: None,
bindings: &[bind(Middle, NavKeys::NONE, Pan), bind(Right, NavKeys::NONE, Orbit)],
},
];
@@ -232,6 +257,19 @@ impl Prefs {
pub fn nav_preset(id: &str) -> &'static NavPreset {
NAV_PRESETS.iter().find(|p| p.id == id).unwrap_or(&NAV_PRESETS[0])
}
/// Picks `preset` the way the Preferences page does: its bindings, wheel direction and, when the
/// preset names them, middle double-click and "Right drag orbits".
pub fn choose_nav_preset(prefs: &mut Prefs, preset: &NavPreset) {
prefs.nav = preset.id.into();
prefs.zoom_reverse = preset.reverse_zoom;
if let Some(double_click) = preset.middle_double_click {
prefs.middle_double_click = double_click.into();
}
if let Some(orbits) = preset.right_drag_orbits {
prefs.right_drag_orbits = orbits;
}
}
/// Stable control-channel names; presentation labels may be shorter.
pub const PAGES: &[&str] = &["General", "Interface", "Design", "Navigation", "Keyboard Shortcuts", "Sketch", "Graphics", "AI", "Plugins"];
pub const PAGE_GENERAL: usize = 0;
@@ -783,6 +821,8 @@ preference_settings! {
/// With free orbit, mouse drags turn sideways about the world's up axis (a turntable without
/// the pole limit) instead of the screen's.
free_orbit_upright: bool = false, PAGE_NAVIGATION => check_tr("nav.free_orbit_upright.label");
/// Off: a right drag that the mouse mapping would orbit leaves the camera alone (#6492).
right_drag_orbits: bool = true, PAGE_NAVIGATION => check_tr("nav.right_drag_orbits.label");
/// View orientation widget: original signed axes (default) or compact cube.
navigator_style: NavigatorStyle = NavigatorStyle::default(), PAGE_NAVIGATION;
/// Show the radial ring and enable hold/flick gestures for viewport context menus.
@@ -1778,7 +1818,12 @@ pub fn nav_mode(app: &SolveApp, button: NavButton, mods: Modifiers) -> Option<Na
if button == NavButton::Right && crate::mouse_gesture::active(app) {
return None;
}
nav_preset(&app.preferences.nav).mode(button, mods)
let mode = nav_preset(&app.preferences.nav).mode(button, mods);
// "Right drag orbits" off leaves the right button to the context menu (#6492).
if button == NavButton::Right && mode == Some(NavMode::Orbit) && !app.preferences.right_drag_orbits {
return None;
}
mode
}
/// +1, or −1 when horizontal scrolling pans the other way (#2007).
@@ -5836,6 +5881,28 @@ mod tests {
assert_eq!(app.preferences.nav, "touchpad");
}
#[test]
fn choosing_the_solidworks_preset_frees_the_right_button_and_fits_on_middle_double_click() {
let none = Modifiers::default();
let mut app = SolveApp::new(solidcraft_engine::Session::default(), Default::default());
app.preferences.middle_double_click = "off".into();
set(&mut app, &json!({"nav": "solidworks"})).unwrap();
assert!(app.preferences.right_drag_orbits, "a saved SolidWorks preset keeps its right-drag orbit");
assert_eq!(nav_mode(&app, NavButton::Right, none), Some(NavMode::Orbit));
choose_nav_preset(&mut app.preferences, nav_preset("fusion"));
let p = &app.preferences;
assert_eq!((p.nav.as_str(), p.zoom_reverse, p.middle_double_click.as_str(), p.right_drag_orbits), ("fusion", false, "off", true));
choose_nav_preset(&mut app.preferences, nav_preset("solidworks"));
let p = &app.preferences;
assert_eq!((p.nav.as_str(), p.zoom_reverse, p.middle_double_click.as_str(), p.right_drag_orbits), ("solidworks", true, "fit", false));
assert_eq!(nav_mode(&app, NavButton::Right, none), None, "right drag is left to the context menu (#6492)");
assert_eq!(nav_mode(&app, NavButton::Middle, none), Some(NavMode::Orbit));
set(&mut app, &json!({"nav": "openscad"})).unwrap();
assert_eq!(nav_mode(&app, NavButton::Right, none), Some(NavMode::Pan), "only an orbiting right drag is affected");
set(&mut app, &json!({"right_drag_orbits": true, "nav": "solidworks"})).unwrap();
assert_eq!(nav_mode(&app, NavButton::Right, none), Some(NavMode::Orbit), "turned back on, the right drag orbits again");
}
#[test]
fn openscad_preset_maps_navigation_and_persists() {
let mut app = SolveApp::new(solidcraft_engine::Session::default(), Default::default());
+7 -2
View File
@@ -8,6 +8,7 @@ pub(super) fn show(app: &mut SolveApp, ui: &mut egui::Ui, t: &Tokens) {
.bindings
.iter()
.filter(|binding| !(crate::mouse_gesture::active(app) && binding.button == NavButton::Right))
.filter(|binding| app.preferences.right_drag_orbits || !(binding.button == NavButton::Right && binding.mode == NavMode::Orbit))
.map(|binding| {
let button = match binding.button {
NavButton::Left => "prefs.button_left",
@@ -55,8 +56,7 @@ pub(super) fn show(app: &mut SolveApp, ui: &mut egui::Ui, t: &Tokens) {
let picker = ui_kit::dropdown_menu(ui, "pref_nav", nav_preset(&app.preferences.nav).translated_label(), |ui| {
for preset in NAV_PRESETS {
if ui_kit::list_picker(ui, preset.id, preset.translated_label(), app.preferences.nav == preset.id).clicked() {
app.preferences.nav = preset.id.into();
app.preferences.zoom_reverse = preset.reverse_zoom;
choose_nav_preset(&mut app.preferences, preset);
}
}
});
@@ -77,6 +77,11 @@ pub(super) fn show(app: &mut SolveApp, ui: &mut egui::Ui, t: &Tokens) {
ui_kit::text(ui, crate::i18n::tr("nav.free_orbit_upright.help"), ui_kit::Text::Hint("free_orbit_upright"));
}
}
// Only shown where the mapping orbits on a right drag (#6492).
if nav_preset(&app.preferences.nav).bindings.iter().any(|b| b.button == NavButton::Right && b.mode == NavMode::Orbit) {
let right_drag = setting::right_drag_orbits(app, ui).on_hover_text(crate::i18n::tr("nav.right_drag_orbits.help"));
crate::scenario::publish_target("prefs:right_drag_orbits", right_drag.rect);
}
let help = if app.preferences.nav == TOUCHPAD_NAV {
app.tr("nav.touchpad.help").to_owned()
} else if !app.preferences.free_orbit && app.preferences.nav != OPENSCAD_NAV {
+5
View File
@@ -57,6 +57,11 @@
preset. With SolidWorks navigation, right-click a planar face and choose **Normal to Selection**
to use Look At (also Ctrl+8); repeat to flip the side, preserving scale and projection.
**Right drag orbits** (Preferences › Navigation, on by default) is shown where the mouse
preset orbits on a right drag. Off, a right drag leaves the camera alone and the right button
only opens the context menu. Picking the SolidWorks preset turns it off and sets Middle
double-click to Fit; both can be changed back afterwards.
**Mouse gestures** (Preferences › Navigation, off by default) work with the SolidWorks mouse preset
only (the wheel orbits, Ctrl + wheel pans) and take over the right button, which then no longer
orbits: hold it and move the pointer 4 pt to open a ring of tools (280 pt inside, 350 pt outside), even
+1
View File
@@ -367,6 +367,7 @@ One setting per line, sorted by name. A change that adds a setting adds its own
- `pan_reverse_x` (default false: horizontal scrolling pans the other way)
- `pan_reverse_y` (default false: vertical scrolling pans the other way)
- `placement_handles` (default false: handles on the preview of a Rest, Boss or Snap Fit that move it across the model and turn it)
- `right_drag_orbits` (default true; false: a right drag the mouse preset would orbit leaves the camera alone, #6492)
- `show_frame_rate` (default false: frames per second in the view's bottom-right corner, counting the frames the view draws anyway; it reads 0 FPS once the view is idle)
- `sketch_auto_dimensions` (default false: each shape drawn in a sketch gets all its dimensions at the sizes drawn, as `sketch.draw.dimensioned` with `as_drawn`; typed values win)
- `sketch_auto_locate` (default false; with `sketch_auto_dimensions`, new shapes are also placed from the sketch origin until fully constrained, as `sketch.draw.dimensioned` with `locate`)