SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.
Invert the curved ViewCube roll arrows (option) (#10483) (#10539)
Dahak Builds9fa3c85c6895
diff --git a/assets/locales/pending/invert-curved-roll-arrows.json b/assets/locales/pending/invert-curved-roll-arrows.jsonnew file mode 100644index 0000000000..869851ed2f--- /dev/null+++ b/assets/locales/pending/invert-curved-roll-arrows.json@@ -0,0 +1,26 @@+{+ "en": {+ "prefs.invert_curved_roll_arrows": "Invert the curved roll arrows",+ "prefs.invert_curved_roll_arrows_note": "The two curved arrows at the cube's corner roll the view within the screen plane. On: the clockwise arrow rolls counterclockwise and the counterclockwise arrow rolls clockwise. Off: each arrow rolls the view the way it curls."+ },+ "ja": {+ "prefs.invert_curved_roll_arrows": "カーブしたロール矢印を反転",+ "prefs.invert_curved_roll_arrows_note": "キューブの隅にある2つのカーブした矢印は、画面内でビューをロールします。オン: 時計回りの矢印が反時計回りに、反時計回りの矢印が時計回りにロールします。オフ: 各矢印は、そのカーブの向きにビューをロールします。"+ },+ "zh": {+ "prefs.invert_curved_roll_arrows": "反转弯曲的翻滚箭头",+ "prefs.invert_curved_roll_arrows_note": "立方体角落的两个弯曲箭头在屏幕平面内翻滚视图。开启:顺时针箭头逆时针翻滚,逆时针箭头顺时针翻滚。关闭:每个箭头按其弯曲方向翻滚视图。"+ },+ "ar": {+ "prefs.invert_curved_roll_arrows": "عكس سهمي التدوير المنحنيين",+ "prefs.invert_curved_roll_arrows_note": "سهما التدوير المنحنيان عند زاوية المكعب يدوران العرض داخل مستوى الشاشة. عند التشغيل: سهم التدوير مع عقارب الساعة يدور عكسها، وسهم العكس يدور معها. عند الإيقاف: يدور كل سهم بالعرض حسب انحنائه."+ },+ "he": {+ "prefs.invert_curved_roll_arrows": "היפוך חצי הגלילה המעוגלים",+ "prefs.invert_curved_roll_arrows_note": "שני החצים המעוגלים בפינת הקובייה מסובבים את התצוגה במישור המסך. פועל: החץ עם כיוון השעון מסובב נגד כיוון השעון, והחץ נגד כיוון השעון מסובב עם כיוון השעון. כבוי: כל חץ מסובב את התצוגה לפי העקום שלו."+ },+ "vi": {+ "prefs.invert_curved_roll_arrows": "Đảo ngược mũi tên cuộn cong",+ "prefs.invert_curved_roll_arrows_note": "Hai mũi tên cong ở góc khối cuộn khung nhìn trong mặt phẳng màn hình. Khi bật: mũi tên theo chiều kim đồng hồ cuộn ngược chiều kim đồng hồ và ngược lại. Khi tắt: mỗi mũi tên cuộn khung nhìn theo chiều cong của nó."+ }+}diff --git a/crates/ui-egui/src/navigation_cube.rs b/crates/ui-egui/src/navigation_cube.rsindex 26ab2e0488..7ab002301f 100644--- a/crates/ui-egui/src/navigation_cube.rs+++ b/crates/ui-egui/src/navigation_cube.rs@@ -162,6 +162,18 @@ fn inverted_arrow(action: &str) -> Option<&'static str> {}}+/// Preferences › Navigation: "Invert the curved roll arrows" (#10483). With it on, the two+/// curved arrows at the cube's corner roll the view the other way within the screen plane: the+/// clockwise arrow rolls counterclockwise and the counterclockwise arrow rolls clockwise. The+/// arrow keeps its curl; the tooltip names the roll actually performed.+fn inverted_roll(action: &str) -> Option<&'static str> {+ match action {+ "clockwise" => Some("counterclockwise"),+ "counterclockwise" => Some("clockwise"),+ _ => None,+ }+}+pub(super) fn show(app: &mut SolveApp, ui: &mut egui::Ui, rect: Rect) {let outer = axis_rect(app, rect);if !outer.is_positive() {@@ -242,6 +254,10 @@ pub(super) fn show(app: &mut SolveApp, ui: &mut egui::Ui, rect: Rect) {("counterclockwise", vec2(42.0, -72.0), vec2(40.0, 20.0), false, "Rotate view counterclockwise 90°"),("clockwise", vec2(72.0, -42.0), vec2(20.0, 40.0), true, "Rotate view clockwise 90°"),] {+ let (action, tooltip) = match app.preferences.invert_curved_roll_arrows.then(|| inverted_roll(action)).flatten() {+ Some(swapped) => (swapped, if swapped == "clockwise" { "Rotate view clockwise 90°" } else { "Rotate view counterclockwise 90°" }),+ None => (action, tooltip),+ };let hovered = control(app, ui, Rect::from_center_size(c + offset * scale, size * scale), action, tooltip);if active {curved_arrow(&painter, c + vec2(42.0, -42.0) * scale, clockwise, hovered, t, scale);@@ -644,6 +660,40 @@ mod tests {assert!((h.app.cam.roll - camera.roll - std::f64::consts::FRAC_PI_2).abs() < 1e-6, "clockwise still rolls clockwise");}+ /// #10483: with Preferences › Navigation "Invert the curved roll arrows" on, the two curved+ /// arrows trade rolls: the clockwise arrow rolls counterclockwise, and the counterclockwise+ /// arrow rolls clockwise.+ #[test]+ fn inverted_curved_arrows_roll_the_other_way() {+ let mut h = crate::scenario::Harness::new();+ h.call("ui.prefs", json!({"navigator_style":"cube", "look_at_anim":false}));+ assert!(!h.app.preferences.invert_curved_roll_arrows, "off by default");+ let roll_at = |h: &mut crate::scenario::Harness, p: egui::Pos2| -> f64 {+ h.call("ui.view", json!({"view":"front"}));+ h.frames(2);+ let camera = h.app.cam;+ h.call("ui.click", json!({"x":p.x,"y":p.y}));+ h.frames(2);+ h.app.cam.roll - camera.roll+ };+ let quarter = std::f64::consts::FRAC_PI_2;+ let turn = std::f64::consts::TAU;+ // The engine keeps roll in [0, τ), so compare quarter-turns modulo a full turn.+ let is_a_quarter_turn = |delta: f64, way: f64| (delta - way).rem_euclid(turn) < 1e-6 || (way - delta).rem_euclid(turn) < 1e-6;+ let top = crate::scenario::handle_at("navigation_cube:control:counterclockwise").unwrap();+ let right = crate::scenario::handle_at("navigation_cube:control:clockwise").unwrap();+ // Off (the default): each arrow rolls the view the way it curls.+ assert!(is_a_quarter_turn(roll_at(&mut h, right), quarter), "off: the clockwise arrow rolls clockwise");+ assert!(is_a_quarter_turn(roll_at(&mut h, top), -quarter), "off: the counterclockwise arrow rolls counterclockwise");+ h.call("ui.prefs", json!({"invert_curved_roll_arrows":true}));+ h.frames(2);+ // On: the same two arrows trade rolls.+ assert!(is_a_quarter_turn(roll_at(&mut h, right), -quarter), "on: the clockwise arrow rolls counterclockwise");+ assert!(is_a_quarter_turn(roll_at(&mut h, top), quarter), "on: the counterclockwise arrow rolls clockwise");+ // The handles name the roll actually performed, and trade places with it.+ assert_eq!(crate::scenario::handle_at("navigation_cube:control:clockwise").unwrap(), top);+ }+#[test]fn cube_navigation_eases_through_intermediate_views_and_can_be_interrupted() {let mut h = crate::scenario::Harness::new();diff --git a/crates/ui-egui/src/prefs.rs b/crates/ui-egui/src/prefs.rsindex a4dcb0a950..bd990f6d9e 100644--- a/crates/ui-egui/src/prefs.rs+++ b/crates/ui-egui/src/prefs.rs@@ -1336,6 +1336,10 @@ preference_settings! {/// Fusion and Inventor (`invert_navigator_arrows`, #10254). Off by default: an arrow rotates/// the cube toward the side it sits on, so the arrow on the left swings the camera left.invert_navigator_arrows: bool = false, PAGE_NAVIGATION;+ /// The view cube's two curved arrows roll the view the other way: the clockwise arrow rolls+ /// counterclockwise and the counterclockwise arrow rolls clockwise (`invert_curved_roll_arrows`,+ /// #10483). Off by default: each arrow rolls the view the way it curls.+ invert_curved_roll_arrows: bool = false, PAGE_NAVIGATION;/// How much of the view the model fills when Home, Fit, an opened design or a navigator/// view change frames it (0.1 to 1; #10091): 1, the default, fills the room between the/// panels, the compass and the navigation bar, as before.@@ -4206,6 +4210,22 @@ mod tests {assert!(!app.preferences.invert_navigator_arrows);}+ /// #10483: the curved-roll invert toggle is off by default, persists, and the Navigation+ /// page's Defaults resets it.+ #[test]+ fn invert_curved_roll_arrows_defaults_off_persists_and_resets() {+ assert!(!Prefs::default().invert_curved_roll_arrows);+ let mut app = SolveApp::new(solidcraft_engine::Session::default(), Default::default());+ assert!(!app.preferences.invert_curved_roll_arrows);+ app.preferences.invert_curved_roll_arrows = true;+ assert_eq!(serde_json::to_value(&app.preferences).unwrap()["invert_curved_roll_arrows"], true);+ let mut restored = SolveApp::new(solidcraft_engine::Session::default(), Default::default());+ restored.load_prefs(&app.prefs());+ assert!(restored.preferences.invert_curved_roll_arrows);+ super::reset_preferences(&mut app.preferences, super::PAGE_NAVIGATION);+ assert!(!app.preferences.invert_curved_roll_arrows);+ }+#[test]fn trackpad_zoom_modifier_roundtrips_and_validates_control_values() {assert_eq!(Prefs::default().trackpad_zoom_modifier, TrackpadZoomModifier::Off);diff --git a/crates/ui-egui/src/prefs/navigation.rs b/crates/ui-egui/src/prefs/navigation.rsindex 070035b5f5..67f97e28cd 100644--- a/crates/ui-egui/src/prefs/navigation.rs+++ b/crates/ui-egui/src/prefs/navigation.rs@@ -200,6 +200,9 @@ pub(super) fn show(app: &mut SolveApp, ui: &mut egui::Ui, t: &Tokens) {let (label, note) = (app.tr("prefs.invert_navigator_arrows").to_owned(), app.tr("prefs.invert_navigator_arrows_note").to_owned());let invert = ui_kit::checkbox(ui, &label, &mut app.preferences.invert_navigator_arrows).on_hover_text(note);crate::scenario::publish_target("prefs:invert_navigator_arrows", invert.rect);+ let (label, note) = (app.tr("prefs.invert_curved_roll_arrows").to_owned(), app.tr("prefs.invert_curved_roll_arrows_note").to_owned());+ let invert = ui_kit::checkbox(ui, &label, &mut app.preferences.invert_curved_roll_arrows).on_hover_text(note);+ crate::scenario::publish_target("prefs:invert_curved_roll_arrows", invert.rect);ui_kit::row(ui, app.tr_label("Middle double-click"), |ui| {let current = MiddleDoubleClick::of(app);ui_kit::settings_control_width(ui, t.form_label_width * 2.0 + t.space_24 * 2.0 + t.space_12, |ui| {