Preferences: reverse vertical pan direction (#5240) (#5454)

* claim: #5240

* Preferences: reverse vertical pan direction (#5240)

Add "Reverse vertical pan direction" beside the horizontal setting in
Preferences > Navigation. pan_reverse_y defaults off, so older settings
files load unchanged, and flips the vertical part of two-finger pan on
every canvas through navigation::handle, independent of the horizontal
setting. Labels in en, ja, zh, de, and ko.

* Reverse vertical pan: strings as a pending locale file, with Arabic, Hebrew and Vietnamese

* Control protocol: pan_reverse_y in the sorted ui.prefs list (#5240)
This commit is contained in:
raykholo
2026-10-28 13:59:38 +00:00
committed by GitHub
parent 27772ddba1
commit 5f90d06452
5 changed files with 61 additions and 0 deletions
@@ -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": "双指垂直滚动向相反方向平移"
}
}
+1
View File
@@ -506,6 +506,7 @@ pub(crate) fn handle(app: &mut SolveApp, ui: &mut egui::Ui, rect: Rect, resp: &e
let 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 {
+24
View File
@@ -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);
+1
View File
@@ -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);
+1
View File
@@ -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))