SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.
Preferences: reverse vertical pan direction (#5240) (#5454)
raykholo5f90d0645251
diff --git a/assets/locales/pending/reverse-vertical-pan.json b/assets/locales/pending/reverse-vertical-pan.jsonnew file mode 100644index 0000000000..21e711a0e1--- /dev/null+++ b/assets/locales/pending/reverse-vertical-pan.json@@ -0,0 +1,34 @@+{+ "en": {+ "ui.reverse_vertical_pan_direction": "Reverse vertical pan direction",+ "ui.reverse_vertical_pan_tip": "Vertical two-finger scrolling pans the other way"+ },+ "ar": {+ "ui.reverse_vertical_pan_direction": "عكس اتجاه التحريك الرأسي",+ "ui.reverse_vertical_pan_tip": "التمرير الرأسي بإصبعين يحرّك العرض في الاتجاه المعاكس"+ },+ "de": {+ "ui.reverse_vertical_pan_direction": "Vertikale Schwenkrichtung umkehren",+ "ui.reverse_vertical_pan_tip": "Vertikales Zwei-Finger-Scrollen schwenkt in die andere Richtung"+ },+ "he": {+ "ui.reverse_vertical_pan_direction": "היפוך כיוון ההזזה האנכית",+ "ui.reverse_vertical_pan_tip": "גלילה אנכית בשתי אצבעות מזיזה בכיוון ההפוך"+ },+ "ja": {+ "ui.reverse_vertical_pan_direction": "垂直パンの方向を反転",+ "ui.reverse_vertical_pan_tip": "垂直方向の2本指スクロールで、反対方向にパンします"+ },+ "ko": {+ "ui.reverse_vertical_pan_direction": "수직 이동 방향 반전",+ "ui.reverse_vertical_pan_tip": "두 손가락 수직 스크롤이 반대 방향으로 이동합니다"+ },+ "vi": {+ "ui.reverse_vertical_pan_direction": "Đảo hướng kéo dọc",+ "ui.reverse_vertical_pan_tip": "Cuộn dọc bằng hai ngón tay sẽ kéo theo hướng ngược lại"+ },+ "zh": {+ "ui.reverse_vertical_pan_direction": "反转垂直平移方向",+ "ui.reverse_vertical_pan_tip": "双指垂直滚动向相反方向平移"+ }+}diff --git a/crates/ui-egui/src/navigation.rs b/crates/ui-egui/src/navigation.rsindex 0a15da455f..5c8c295537 100644--- a/crates/ui-egui/src/navigation.rs+++ b/crates/ui-egui/src/navigation.rs@@ -506,6 +506,7 @@ pub(crate) fn handle(app: &mut SolveApp, ui: &mut egui::Ui, rect: Rect, resp: &elet mut pan =if trackpad_pan { raw.pan + if trackpad_orbit { egui::Vec2::ZERO } else { raw.shift_pan } } else { egui::Vec2::ZERO } + raw.mouse_pan;pan.x *= crate::prefs::pan_sign_x(app);+ pan.y *= crate::prefs::pan_sign_y(app);let scroll = if app.viewport.wheel_zoom_raw_until_idle || (trackpad_pan && app.viewport.trackpad_until_idle) {raw.zoom + if trackpad_pan { 0.0 } else { raw.point_zoom }} else {diff --git a/crates/ui-egui/src/prefs.rs b/crates/ui-egui/src/prefs.rsindex 3180d7c223..81989d3688 100644--- a/crates/ui-egui/src/prefs.rs+++ b/crates/ui-egui/src/prefs.rs@@ -902,6 +902,8 @@ preference_settings! {trackpad_pan: bool = true, PAGE_NAVIGATION;/// Horizontal trackpad and thumb-wheel scrolling pans the view the other way (#2007).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");/// 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}×"));@@ -1582,6 +1584,11 @@ pub fn pan_sign_x(app: &SolveApp) -> f32 {if app.preferences.pan_reverse_x { -1.0 } else { 1.0 }}+/// +1, or −1 when vertical scrolling pans the other way.+pub fn pan_sign_y(app: &SolveApp) -> f32 {+ if app.preferences.pan_reverse_y { -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;@@ -5408,6 +5415,23 @@ mod tests {assert!(other.preferences.pan_reverse_x);}+ #[test]+ fn pan_reverse_y_defaults_off_persists_and_flips_the_sign() {+ assert!(!serde_json::from_value::<Prefs>(json!({})).unwrap().pan_reverse_y);+ let mut app = SolveApp::new(solidcraft_engine::Session::default(), Default::default());+ assert_eq!(pan_sign_y(&app), 1.0);+ set(&mut app, &json!({"pan_reverse_y": true})).unwrap();+ assert_eq!(pan_sign_y(&app), -1.0);+ assert_eq!(pan_sign_x(&app), 1.0);+ set(&mut app, &json!({"pan_reverse_x": true, "pan_reverse_y": false})).unwrap();+ assert_eq!(pan_sign_x(&app), -1.0);+ assert_eq!(pan_sign_y(&app), 1.0);+ set(&mut app, &json!({"pan_reverse_y": true})).unwrap();+ let mut other = SolveApp::new(solidcraft_engine::Session::default(), Default::default());+ other.load_prefs(&app.prefs());+ assert!(other.preferences.pan_reverse_y);+ }+#[test]fn trackpad_pan_defaults_on_persists_and_follows_dialog_buttons() {assert!(serde_json::from_value::<Prefs>(json!({})).unwrap().trackpad_pan);diff --git a/crates/ui-egui/src/prefs/navigation.rs b/crates/ui-egui/src/prefs/navigation.rsindex b174ba871f..d05dc325f1 100644--- a/crates/ui-egui/src/prefs/navigation.rs+++ b/crates/ui-egui/src/prefs/navigation.rs@@ -119,6 +119,7 @@ pub(super) fn show(app: &mut SolveApp, ui: &mut egui::Ui, t: &Tokens) {setting::zoom_to_cursor(app, ui);setting::zoom_reverse(app, ui);setting::pan_reverse_x(app, ui);+ setting::pan_reverse_y(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/docs/control-protocol.md b/docs/control-protocol.mdindex 848d3b5aea..ea5ba01bb2 100644--- a/docs/control-protocol.md+++ b/docs/control-protocol.md@@ -346,6 +346,7 @@ One setting per line, sorted by name. A change that adds a setting adds its own- `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)- `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)- `placement_handles` (default false: handles on the preview of a Rest, Boss or Snap Fit that move it across the model and turn it)- `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_exit_view` (`keep` (default: the view stays where it is when a sketch ends), `previous` (back to the view from before the sketch), `unless_rotated` (back unless the sketch view was turned))