PhotoCraft: An open-source, photo editor written by scratch in pure Rust
Reveal Extras when interactive selection commands succeed
jonathnwxh6bef23a7150b
diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rsindex 5d95f2d66..0697409c2 100644--- a/crates/ui-egui/src/lib.rs+++ b/crates/ui-egui/src/lib.rs@@ -1116,6 +1116,15 @@ impl PhotocraftApp {dock::reveal(self, dock::Group::Properties);}}+ // Making a new selection reveals its outline after View > Extras was hidden (#5597).+ // These interactive selection commands complete inline; a failed command, deselection,+ // or painting inside an existing selection must leave the user's view choice alone.+ if r.is_ok()+ && matches!(id, "select.rect" | "select.lasso" | "select.magicWand" | "select.loadSelection" | "select.loadLuminosity")+ && self.session.active().is_some_and(|st| st.doc.selection.is_some())+ {+ self.ui.view.extras = true;+ }if r.is_ok() && id == "select.toWorkPath" {// Make Work Path selects the new work path in the Paths panel, as in Photoshop.self.ui.selected_path = Some("work".into());diff --git a/crates/ui-egui/src/view_cmds/tests.rs b/crates/ui-egui/src/view_cmds/tests.rsindex c966f516d..299a47d22 100644--- a/crates/ui-egui/src/view_cmds/tests.rs+++ b/crates/ui-egui/src/view_cmds/tests.rs@@ -510,9 +510,14 @@ fn esc_leaves_full_screen_modes_unless_something_else_owns_it() {#[test]fn creating_a_selection_restores_hidden_extras() {let mut hidden = Vec::new();- for (command, params) in- [("select.rect", json!({"x": 10, "y": 10, "width": 20, "height": 20})), ("select.loadSelection", json!({"channel": "transparency"}))]- {+ for (command, params) in [+ ("select.rect", json!({"x": 10, "y": 10, "width": 20, "height": 20})),+ ("select.rect", json!({"x": 10, "y": 10, "width": 20, "height": 20, "ellipse": true})),+ ("select.lasso", json!({"points": [[10,10], [30,10], [20,30]]})),+ ("select.magicWand", json!({"x": 10, "y": 10})),+ ("select.loadSelection", json!({"channel": "transparency"})),+ ("select.loadLuminosity", json!({})),+ ] {let (mut app, ctx) = app_with(1);app.run("edit.fill", json!({"color": "#cc4422"})).unwrap();menu(&mut app, &ctx, "view.extras", json!({})).unwrap();@@ -539,3 +544,15 @@ fn failed_selection_and_unrelated_edits_keep_extras_hidden() {app.run("select.deselect", json!({})).unwrap();assert!(!app.ui.view.extras, "deselecting has no new outline to reveal");}++#[test]+fn new_selection_preserves_individual_show_preferences() {+ let (mut app, ctx) = app_with(1);+ app.ui.view.show.selection_edges = false;+ app.ui.view.show.grid = false;+ menu(&mut app, &ctx, "view.extras", json!({})).unwrap();+ app.run("select.rect", json!({"x": 10, "y": 10, "width": 20, "height": 20})).unwrap();+ assert!(app.ui.view.extras);+ assert!(!app.ui.view.show.selection_edges);+ assert!(!app.ui.view.show.grid);+}