SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.
Preferences open over the Home page (#313)
Tobias Breckle250d8a2c0473
diff --git a/crates/ui-egui/src/home.rs b/crates/ui-egui/src/home.rsindex 045c548df4..4bbe6f4b88 100644--- a/crates/ui-egui/src/home.rs+++ b/crates/ui-egui/src/home.rs@@ -605,4 +605,28 @@ mod tests {assert_eq!(app.session.doc.name, "Sample Plate");assert!(!app.session.is_dirty());}++ /// The gear, Ctrl+, and Home's own links open Preferences over Home, not after leaving it.+ #[test]+ fn preferences_and_shortcuts_open_over_home() {+ let mut h = crate::scenario::Harness::new();+ let rev = h.app.session.revision;+ h.app.home.show(rev);+ h.frames(2);+ assert!(h.app.home.open);+ let gear = crate::scenario::handle_at("titlebar:preferences").unwrap();+ h.call("ui.click", serde_json::json!({"x": gear.x, "y": gear.y}));+ assert!(h.app.prefs_window.open && h.app.home.open);+ let shown = |h: &crate::scenario::Harness| {+ h.ctx.memory(|m| m.areas().visible_last_frame(&egui::LayerId::new(egui::Order::Middle, egui::Id::new("sc_prefs"))))+ };+ assert!(shown(&h), "the Preferences window must be drawn on Home");+ h.call("ui.prefs", serde_json::json!({"button": "cancel"}));+ assert!(!shown(&h));++ // Home › Keyboard Shortcuts opens the same window at its page.+ h.app.keymap.open = true;+ h.frames(2);+ assert!(shown(&h) && h.app.prefs_window.section == crate::prefs::PAGE_SHORTCUTS && h.app.home.open);+ }}diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rsindex d2a43804b1..3caa1c5cfe 100644--- a/crates/ui-egui/src/lib.rs+++ b/crates/ui-egui/src/lib.rs@@ -978,6 +978,8 @@ impl SolveApp {if self.home.open {home::show(self, ui);if self.home.open {+ // Preferences and Keyboard Shortcuts open from Home too (its links, the gear, Ctrl+,).+ prefs::show(self, ui.ctx());return;}}