Skip to content

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

Properties: a new adjustment or fill layer brings Properties to the front (#4028) (#4079)

Marco Arnulfo40427f25dc61
diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs
index 025c19eb7..5e54fd274 100644
--- a/crates/ui-egui/src/lib.rs
+++ b/crates/ui-egui/src/lib.rs
@@ -976,6 +976,16 @@ impl PhotocraftApp {
// as in Photoshop (#3369): clicking the mask thumbnail switches it to the mask.
self.ui.properties_layer = if creates_adjustment_or_fill { self.session.active().and_then(|st| st.active_layer).map(|l| l.0) } else { None };
}
+ if r.is_ok() && creates_adjustment_or_fill {
+ // Properties comes to the front, shown and expanded, so the new layer's settings can
+ // be edited at once, as in Photoshop (#4028). The layer is made whatever happens here.
+ if self.ui.docking.is_some() {
+ let _ = panel_docking::command(self, "window.panel.activate", &json!({"panel": "properties"}));
+ } else {
+ self.ui.dock_tabs.properties = 0;
+ dock::reveal(self, dock::Group::Properties);
+ }
+ }
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/mask_thumbs_ui/tests.rs b/crates/ui-egui/src/mask_thumbs_ui/tests.rs
index f5ec70efb..ad0e70ca8 100644
--- a/crates/ui-egui/src/mask_thumbs_ui/tests.rs
+++ b/crates/ui-egui/src/mask_thumbs_ui/tests.rs
@@ -737,3 +737,22 @@ fn a_new_adjustment_or_fill_layer_shows_its_settings_until_the_mask_thumbnail_is
}
}
}
+
+// #4028: with Adjustments showing in a collapsed Properties group, a new adjustment layer brings
+// Properties to the front and expands it, as in Photoshop, so its settings can be edited at once.
+#[test]
+fn a_new_adjustment_layer_brings_properties_to_the_front() {
+ let mut s = photocraft_engine::Session::new();
+ s.execute("file.new", json!({"width": 200, "height": 100})).unwrap();
+ let mut h = harness(s, 0, 1.0, 290.0);
+ let ctx = h.ctx.clone();
+ let (req, _rx) = crate::control::ControlRequest::new("ui.set", json!({"dockTabs": {"properties": 1}}));
+ crate::control::handle(h.state_mut(), &ctx, &req);
+ h.run_steps(2);
+ assert!(h.state().ui.dock.is_collapsed(crate::dock::Group::Properties));
+ h.state_mut().run("layer.newAdjustmentLayer.curves", json!({})).unwrap();
+ h.run_steps(6);
+ assert_eq!(h.state().ui.dock_tabs.properties, 0, "Properties is the group's tab");
+ assert!(!h.state().ui.dock.is_collapsed(crate::dock::Group::Properties), "the group is expanded");
+ assert!(h.query_all_by_label("Reset to defaults").next().is_some(), "the Curves settings show");
+}
diff --git a/crates/ui-egui/src/panel_docking_tests.rs b/crates/ui-egui/src/panel_docking_tests.rs
index 6980a8a93..657232f04 100644
--- a/crates/ui-egui/src/panel_docking_tests.rs
+++ b/crates/ui-egui/src/panel_docking_tests.rs
@@ -504,6 +504,17 @@ fn explicit_reveal_activates_existing_tab_and_expands_custom_group() {
assert_eq!(app.ui.docking, before);
}
+// #4028: in a custom workspace too, a new adjustment layer brings Properties to the front.
+#[test]
+fn a_new_adjustment_layer_activates_properties_in_a_custom_workspace() {
+ let mut app = app();
+ app.run("window.panel.activate", json!({"panel":"adjustments"})).unwrap();
+ assert!(panel_active(app.ui.docking.as_ref().unwrap(), "adjustments"));
+ app.run("file.new", json!({"width":64,"height":64})).unwrap();
+ app.run("layer.newAdjustmentLayer.curves", json!({})).unwrap();
+ assert!(panel_active(app.ui.docking.as_ref().unwrap(), "properties"));
+}
+
#[test]
fn custom_group_commands_preserve_members_and_workspace_timeline() {
let mut app = app();