Skip to content

SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.

Preferences: reverse trackpad orbit direction (#8410) (#8484)

Logan Nightbda5f69c5cde
diff --git a/assets/locales/pending/reverse-trackpad-orbit.json b/assets/locales/pending/reverse-trackpad-orbit.json
new file mode 100644
index 0000000000..694dd1784e
--- /dev/null
+++ b/assets/locales/pending/reverse-trackpad-orbit.json
@@ -0,0 +1,34 @@
+{
+ "en": {
+ "ui.reverse_trackpad_orbit_direction": "Reverse trackpad orbit direction",
+ "ui.reverse_trackpad_orbit_tip": "Shift with two-finger scrolling orbits the other way"
+ },
+ "ar": {
+ "ui.reverse_trackpad_orbit_direction": "عكس اتجاه تدوير العرض بلوحة اللمس",
+ "ui.reverse_trackpad_orbit_tip": "التمرير بإصبعين مع Shift يدوّر العرض في الاتجاه المعاكس"
+ },
+ "de": {
+ "ui.reverse_trackpad_orbit_direction": "Drehrichtung am Touchpad umkehren",
+ "ui.reverse_trackpad_orbit_tip": "Umschalt mit Zwei-Finger-Scrollen dreht die Ansicht in die andere Richtung"
+ },
+ "he": {
+ "ui.reverse_trackpad_orbit_direction": "היפוך כיוון סיבוב המבט במשטח המגע",
+ "ui.reverse_trackpad_orbit_tip": "גלילה בשתי אצבעות עם Shift מסובבת את המבט בכיוון ההפוך"
+ },
+ "ja": {
+ "ui.reverse_trackpad_orbit_direction": "トラックパッドのオービット方向を反転",
+ "ui.reverse_trackpad_orbit_tip": "Shift を押しながらの2本指スクロールで、反対方向にオービットします"
+ },
+ "ko": {
+ "ui.reverse_trackpad_orbit_direction": "트랙패드 회전 방향 반전",
+ "ui.reverse_trackpad_orbit_tip": "Shift를 누른 채 두 손가락으로 스크롤하면 반대 방향으로 회전합니다"
+ },
+ "vi": {
+ "ui.reverse_trackpad_orbit_direction": "Đảo hướng xoay góc nhìn bằng bàn di cảm ứng",
+ "ui.reverse_trackpad_orbit_tip": "Giữ Shift và cuộn bằng hai ngón tay sẽ xoay góc nhìn theo hướng ngược lại"
+ },
+ "zh": {
+ "ui.reverse_trackpad_orbit_direction": "反转触控板环绕方向",
+ "ui.reverse_trackpad_orbit_tip": "按住 Shift 双指滚动时向相反方向环绕"
+ }
+}
diff --git a/crates/ui-egui/src/navigation.rs b/crates/ui-egui/src/navigation.rs
index b44dcd750b..d06101ef35 100644
--- a/crates/ui-egui/src/navigation.rs
+++ b/crates/ui-egui/src/navigation.rs
@@ -564,7 +564,8 @@ pub(crate) fn handle(app: &mut SolveApp, ui: &mut egui::Ui, rect: Rect, resp: &e
if inside && caps.orbit && trackpad_orbit && raw.shift_pan != egui::Vec2::ZERO {
app.cancel_view_animation();
app.viewport.orbit_free = None;
- orbit(app, rect, f64::from(raw.shift_pan.x), f64::from(raw.shift_pan.y), hover);
+ let sign = crate::prefs::orbit_sign(app);
+ orbit(app, rect, sign * f64::from(raw.shift_pan.x), sign * f64::from(raw.shift_pan.y), hover);
}
// A left press with the preset's keys (Alias: Shift+Alt) navigates until the button is let
// go (kept through the release frame, so the end of the drag doesn't select either).
diff --git a/crates/ui-egui/src/prefs.rs b/crates/ui-egui/src/prefs.rs
index c9b88166c9..3314b53962 100644
--- a/crates/ui-egui/src/prefs.rs
+++ b/crates/ui-egui/src/prefs.rs
@@ -991,6 +991,9 @@ preference_settings! {
pan_reverse_x: bool = false, PAGE_NAVIGATION => check("Reverse horizontal pan direction", "Horizontal two-finger scrolling and the thumb wheel pan the other way");
/// Vertical trackpad scrolling pans the view the other way (#5240).
pan_reverse_y: bool = false, PAGE_NAVIGATION => check("Reverse vertical pan direction", "Vertical two-finger scrolling pans the other way");
+ /// Shift with two-finger trackpad scrolling orbits the view the other way, both ways at once,
+ /// as natural scrolling turns it (#8410).
+ orbit_reverse: bool = false, PAGE_NAVIGATION => check("Reverse trackpad orbit direction", "Shift with two-finger scrolling orbits the other way");
/// View changes (axis view, Look At, Home) animate; `look_at_speed` scales how fast.
look_at_anim: bool = true, PAGE_NAVIGATION => check("Animate view changes", "Axis view, Look At, Home and Fit");
look_at_speed: f32 = 1.0, PAGE_NAVIGATION, accept(0.25..=4.0) => enabled_slider(look_at_anim, "Animation speed", 0.5..=3.0, 0.25, |v| format!("{v:.2}×"));
@@ -1726,6 +1729,11 @@ pub fn pan_sign_y(app: &SolveApp) -> f32 {
if app.preferences.pan_reverse_y { -1.0 } else { 1.0 }
}
+/// +1, or −1 when Shift with two-finger scrolling orbits the other way (#8410).
+pub fn orbit_sign(app: &SolveApp) -> f64 {
+ if app.preferences.orbit_reverse { -1.0 } else { 1.0 }
+}
+
/// Whether the configured suppress-snap chord is held.
pub fn suppress_sketch_snap_held(app: &SolveApp, m: Modifiers) -> bool {
let c = app.preferences.suppress_sketch_snap;
@@ -5752,6 +5760,19 @@ mod tests {
assert!(other.preferences.pan_reverse_x);
}
+ #[test]
+ fn orbit_reverse_defaults_off_persists_and_flips_the_sign() {
+ assert!(!serde_json::from_value::<Prefs>(json!({})).unwrap().orbit_reverse);
+ let mut app = SolveApp::new(solidcraft_engine::Session::default(), Default::default());
+ assert_eq!(orbit_sign(&app), 1.0);
+ set(&mut app, &json!({"orbit_reverse": true})).unwrap();
+ assert_eq!(orbit_sign(&app), -1.0);
+ assert_eq!((pan_sign_x(&app), pan_sign_y(&app)), (1.0, 1.0));
+ let mut other = SolveApp::new(solidcraft_engine::Session::default(), Default::default());
+ other.load_prefs(&app.prefs());
+ assert!(other.preferences.orbit_reverse);
+ }
+
#[test]
fn pan_reverse_y_defaults_off_persists_and_flips_the_sign() {
assert!(!serde_json::from_value::<Prefs>(json!({})).unwrap().pan_reverse_y);
diff --git a/crates/ui-egui/src/prefs/navigation.rs b/crates/ui-egui/src/prefs/navigation.rs
index d05dc325f1..7cd4c0c76d 100644
--- a/crates/ui-egui/src/prefs/navigation.rs
+++ b/crates/ui-egui/src/prefs/navigation.rs
@@ -120,6 +120,7 @@ pub(super) fn show(app: &mut SolveApp, ui: &mut egui::Ui, t: &Tokens) {
setting::zoom_reverse(app, ui);
setting::pan_reverse_x(app, ui);
setting::pan_reverse_y(app, ui);
+ setting::orbit_reverse(app, ui);
});
ui.allocate_ui_with_layout(egui::vec2(width, 0.0), egui::Layout::top_down(egui::Align::Min), |ui| {
setting::smooth_wheel_zoom(app, ui);
diff --git a/crates/ui-egui/src/viewport.rs b/crates/ui-egui/src/viewport.rs
index 51bb2b62cd..82228cd8ad 100644
--- a/crates/ui-egui/src/viewport.rs
+++ b/crates/ui-egui/src/viewport.rs
@@ -9029,6 +9029,31 @@ mod tests {
h.step(&json!({"shot":"fusion-trackpad-pan"})).unwrap();
}
+ /// #8410: with the trackpad orbit reversed, Shift with two fingers orbits exactly the other way
+ /// on both axes, and a plain two-finger pan is the same as without it.
+ #[test]
+ fn reversed_trackpad_orbit_turns_the_other_way_and_leaves_pan_alone() {
+ let step = |orbit_reverse: bool, modifiers: egui::Modifiers| {
+ let mut h = crate::scenario::Harness::new();
+ h.app.preferences.nav = "fusion".into();
+ h.app.preferences.orbit_around = crate::prefs::OrbitAround::ViewCentre;
+ h.app.preferences.orbit_reverse = orbit_reverse;
+ h.call("ui.move", json!({"x":800,"y":500}));
+ let gesture = |phase| egui::Event::MouseWheel { unit: egui::MouseWheelUnit::Point, delta: vec2(20.0, -10.0), modifiers, phase };
+ h.app.synthetic.push(gesture(egui::TouchPhase::Start));
+ h.frame();
+ let before = h.app.cam;
+ h.app.synthetic.push(gesture(egui::TouchPhase::Move));
+ h.frame();
+ (before, h.app.cam)
+ };
+ let (before, after) = step(true, egui::Modifiers::SHIFT);
+ let mut expected = before;
+ expected.orbit(-20.0, 10.0);
+ assert_eq!(after, expected, "a reversed orbit turns the other way");
+ assert_eq!(step(true, egui::Modifiers::NONE), step(false, egui::Modifiers::NONE), "a pan does not change");
+ }
+
#[test]
fn fusion_trackpad_uses_each_events_modifiers_and_can_switch_mid_gesture() {
let mut h = crate::scenario::Harness::new();
diff --git a/docs/control-protocol.md b/docs/control-protocol.md
index 3b3f3c7a29..b2dd2342c7 100644
--- a/docs/control-protocol.md
+++ b/docs/control-protocol.md
@@ -355,6 +355,7 @@ One setting per line, sorted by name. A change that adds a setting adds its own
- `nav_bridge_enabled` (default false) and `nav_bridge_port` (default 8765: a device's own app on this computer moves the view, [the navigation bridge](3d-mouse.md#device-apps-the-navigation-bridge))
- `offer_stand_up`
- `orbit_around` (`view_centre` (default: what Pan moves and Fit frames), `origin` (the world origin stays still on screen), `cursor` (the model point under the pointer when the drag began); the older `orbit_cursor` boolean still sets `cursor` when true)
+- `orbit_reverse` (default false: Shift with two-finger scrolling orbits the other way)
- `origin_plane_names` (`xyz` (default) or `top_front_right`: the browser, dialogs and lists call the origin planes Top, Front and Right; their ids, commands and saved designs keep XY, XZ and YZ)
- `pan_reverse_x` (default false: horizontal scrolling pans the other way)
- `pan_reverse_y` (default false: vertical scrolling pans the other way)