Skip to content

PhotoCraft: An open-source, photo editor written by scratch in pure Rust

Workspace layouts no longer save or restore the Layers panel options

abc2cb3f5c65e166f0
diff --git a/crates/ui-egui/src/dock.rs b/crates/ui-egui/src/dock.rs
index 7bcf31063..3945ef728 100644
--- a/crates/ui-egui/src/dock.rs
+++ b/crates/ui-egui/src/dock.rs
@@ -809,7 +809,7 @@ fn resize(layout: &mut DockLayout, heights: &[(Group, f32)], i: usize, dy: f32)
/// What `prefs.panelLayout` holds: the live layout and open panels.
fn snapshot(app: &PhotocraftApp) -> Value {
- json!({"workspace": app.ui.workspace, "panels": app.ui.panels, "dockTabs": app.ui.dock_tabs, "dock": app.ui.dock, "layersPanelOptions": app.ui.layers_panel_options, "timelineOpen": app.ui.timeline.open, "docking": app.ui.docking, "dockingHidden": app.ui.docking_hidden, "dockingCollapsed": app.ui.docking_collapsed})
+ json!({"workspace": app.ui.workspace, "panels": app.ui.panels, "dockTabs": app.ui.dock_tabs, "dock": app.ui.dock, "timelineOpen": app.ui.timeline.open, "docking": app.ui.docking, "dockingHidden": app.ui.docking_hidden, "dockingCollapsed": app.ui.docking_collapsed})
}
/// Remember the layout in the preferences once the user lets go of the mouse (Workspace ›
@@ -861,9 +861,6 @@ pub fn apply(app: &mut PhotocraftApp, v: &Value) {
if let Some(d) = v.get("dock").and_then(|d| serde_json::from_value(d.clone()).ok()) {
app.ui.dock = d;
}
- if let Some(opts) = v.get("layersPanelOptions").and_then(|o| serde_json::from_value(o.clone()).ok()) {
- app.ui.layers_panel_options = opts;
- }
crate::panel_docking::sync_visibility(app);
app.ui.timeline.open = v.get("timelineOpen").and_then(Value::as_bool).unwrap_or(false);
if !app.ui.timeline.open {
diff --git a/crates/ui-egui/src/dock_tests.rs b/crates/ui-egui/src/dock_tests.rs
index f0a64562c..f8b325ed9 100644
--- a/crates/ui-egui/src/dock_tests.rs
+++ b/crates/ui-egui/src/dock_tests.rs
@@ -1148,3 +1148,24 @@ fn brush_settings_window_is_closed_on_restart_but_can_be_reopened() {
apply(&mut workspace, &saved);
assert!(workspace.ui.panels.brush_settings, "switching workspaces still restores their saved layout");
}
+
+/// Layers panel options live in the preferences on their own (like Photoshop's Panel Options),
+/// so a workspace layout neither saves nor restores them.
+#[test]
+fn workspace_layouts_leave_the_layers_panel_options_alone() {
+ let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default());
+ app.ui.layers_panel_options.show_filters = false;
+ crate::layers_panel_ui::persist_options(&mut app);
+ let stored = app.session.prefs().dialogs.get("ui.layersPanelOptions").cloned();
+ assert!(stored.is_some(), "the options are saved in the preferences");
+
+ let mut saved = snapshot(&app);
+ assert!(saved.get("layersPanelOptions").is_none(), "a layout does not carry the options");
+
+ // A layout saved by an earlier build still has the key; it must not win over the preferences.
+ saved["layersPanelOptions"] = json!({"showFilters": true, "thumbnailSize": "large"});
+ apply(&mut app, &saved);
+ assert!(!app.ui.layers_panel_options.show_filters);
+ assert_ne!(app.ui.layers_panel_options.thumbnail_size, crate::state::LayerThumbnailSize::Large);
+ assert_eq!(app.session.prefs().dialogs.get("ui.layersPanelOptions").cloned(), stored);
+}