Skip to content

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

Merge current main into wheel zoom smoothing option

bherbruckff9653a353ae
diff --cc crates/ui-egui/src/prefs.rs
index 18c35d4a7d,2b4e3d61f8..78b2d56bc0
--- a/crates/ui-egui/src/prefs.rs
+++ b/crates/ui-egui/src/prefs.rs
@@@ -181,9 -181,9 +184,10 @@@ fn defaults(app: &mut SolveApp, page: u
}
1 => {
p.nav = d.nav;
+ p.radial_context_menu = d.radial_context_menu;
p.zoom_reverse = d.zoom_reverse;
p.zoom_to_cursor = d.zoom_to_cursor;
+ p.smooth_wheel_zoom = d.smooth_wheel_zoom;
p.orbit_cursor = d.orbit_cursor;
p.space_mouse_enabled = d.space_mouse_enabled;
p.space_mouse_speed = d.space_mouse_speed;
@@@ -760,28 -761,26 +768,48 @@@ pub fn set(app: &mut SolveApp, p: &serd
mod tests {
use super::*;
+ #[test]
+ fn radial_context_menu_defaults_off_and_follows_preferences_transactions() {
+ assert!(!Prefs::default().radial_context_menu);
+ let old: Prefs = serde_json::from_value(json!({"nav":"solidworks","zoom_reverse":true})).unwrap();
+ assert!(!old.radial_context_menu && old.zoom_reverse && old.nav == "solidworks");
+ let mut h = crate::scenario::Harness::new();
+ h.call("ui.prefs", json!({"open":"Navigation"}));
+ h.step(&json!({"widget":"Radial context menu"})).unwrap();
+ assert!(h.app.preferences.radial_context_menu, "the actual checkbox enables radial menus");
+ let mut restored = SolveApp::new(solvecraft_engine::Session::default(), Default::default());
+ restored.load_prefs(&h.app.prefs());
+ assert!(restored.preferences.radial_context_menu, "enabled preference survives save/load");
+ h.call("ui.prefs", json!({"button":"cancel"}));
+ assert!(!h.app.preferences.radial_context_menu, "Cancel restores the default-off setting");
+ h.call("ui.prefs", json!({"open":"Navigation","radial_context_menu":true}));
+ h.call("ui.prefs", json!({"button":"apply"}));
+ h.call("ui.prefs", json!({"button":"defaults"}));
+ assert!(!h.app.preferences.radial_context_menu, "Navigation defaults disable the ring");
+ h.call("ui.prefs", json!({"button":"cancel"}));
+ assert!(h.app.preferences.radial_context_menu, "Cancel restores the last Apply");
+ }
+
+ #[test]
+ fn wheel_smoothing_persists_and_follows_dialog_buttons() {
+ assert!(serde_json::from_value::<Prefs>(json!({})).unwrap().smooth_wheel_zoom);
+ let mut app = SolveApp::new(solvecraft_engine::Session::default(), Default::default());
+ control(&mut app, &json!({"open":"Navigation", "smooth_wheel_zoom":false})).unwrap();
+ control(&mut app, &json!({"button":"cancel"})).unwrap();
+ assert!(app.preferences.smooth_wheel_zoom);
+ control(&mut app, &json!({"open":"Navigation", "smooth_wheel_zoom":false})).unwrap();
+ control(&mut app, &json!({"button":"apply"})).unwrap();
+ control(&mut app, &json!({"smooth_wheel_zoom":true, "button":"cancel"})).unwrap();
+ assert!(!app.preferences.smooth_wheel_zoom);
+ let mut other = SolveApp::new(solvecraft_engine::Session::default(), Default::default());
+ other.load_prefs(&app.prefs());
+ assert!(!other.preferences.smooth_wheel_zoom);
+ control(&mut app, &json!({"open":"Navigation", "button":"defaults"})).unwrap();
+ assert!(app.preferences.smooth_wheel_zoom);
+ control(&mut app, &json!({"button":"cancel"})).unwrap();
+ assert!(!app.preferences.smooth_wheel_zoom);
+ }
+
#[test]
fn presets_map_the_mouse_and_prefs_round_trip() {
let mut app = SolveApp::new(solvecraft_engine::Session::default(), Default::default());