PhotoCraft: An open-source, photo editor written by scratch in pure Rust
fix(ui): don't reopen floating Brush Settings on restart (#3570)
Nigel Ihza Firdausyc5a9e7f9b2de
diff --git a/crates/ui-egui/src/dock.rs b/crates/ui-egui/src/dock.rsindex 7d70a72e7..089fb6cd2 100644--- a/crates/ui-egui/src/dock.rs+++ b/crates/ui-egui/src/dock.rs@@ -765,6 +765,10 @@ pub fn restore(app: &mut PhotocraftApp) {}let saved = app.session.prefs().panel_layout.clone();apply(app, &saved);+ // The floating Brush Settings window is transient, not a dock panel: remembering the+ // workspace must not leave it open on a fresh launch, especially with no document.+ // Explicit workspace switches still use `apply` and keep their stored panel visibility.+ app.ui.panels.brush_settings = false;if let Some(ws) = saved.get("workspace").and_then(Value::as_str) {app.ui.workspace = ws.to_string();}diff --git a/crates/ui-egui/src/dock_tests.rs b/crates/ui-egui/src/dock_tests.rsindex dddcce655..b5ade1d58 100644--- a/crates/ui-egui/src/dock_tests.rs+++ b/crates/ui-egui/src/dock_tests.rs@@ -1082,3 +1082,31 @@ fn a_tab_dragged_off_the_strip_moves_the_group_and_locking_stops_reordering() {drag(&mut h, paths.center(), paths.center() + vec2(0.0, 500.0));assert_eq!(h.state().ui.dock.order(), order);}++#[test]+fn brush_settings_window_is_closed_on_restart_but_can_be_reopened() {+ let mut first = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default());+ first.ui.panels.brush_settings = true;+ first.ui.panels.history = true;+ let saved = snapshot(&first);+ first.session.prefs.edit(|p| {+ p.workspace.remember_workspace_changes = true;+ p.panel_layout = saved.clone();+ });+ let persisted = first.session.prefs_to_json();++ let mut session = photocraft_engine::Session::new();+ session.load_prefs_json(&persisted).unwrap();+ let mut next = PhotocraftApp::new(session, crate::Services::default());+ restore(&mut next);+ assert!(!next.ui.panels.brush_settings, "a floating Brush Settings window should not reopen on startup");+ assert!(next.ui.panels.history, "remembered dock panel visibility is preserved");++ let ctx = egui::Context::default();+ crate::menus::invoke(&mut next, &ctx, "window.toggle.brushSettings", json!({})).unwrap();+ assert!(next.ui.panels.brush_settings, "Window > Brush Settings can still open it");++ let mut workspace = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default());+ apply(&mut workspace, &saved);+ assert!(workspace.ui.panels.brush_settings, "switching workspaces still restores their saved layout");+}