mirror of
https://github.com/storytold/photocraft.git
synced 2026-12-03 06:31:42 +01:00
Layers: an adjustment layer's name click targets its mask again
Reverts #9703 ("Fix adjustment layer name clicks targeting masks"), which made a click on an adjustment layer's name target the layer's contents instead of its mask. The reference application, measured through scripting (targetChannels): selecting an adjustment layer from another layer targets its mask, as before #9703; a masked pixel layer targets its contents; clicking the content thumbnail still targets the contents. So the behaviour before #9703 was right. The revert applied cleanly. Its test asserting the opposite goes with it; a_new_adjustment_or_fill_layer_shows_its_settings_until_the_mask_thumbnail_is_clicked again expects a row click on a new adjustment layer to target the mask. New test selecting_an_adjustment_layer_from_another_layer_targets_its_mask: for Hue/Saturation and Curves layers, a name click coming from another layer targets the mask (and painting goes to the mask), the content thumbnail targets the contents, and a masked pixel layer's name click targets its contents. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
d91195ba29
commit
3525a1d2bc
2 files changed
+30
-39
No files matched your search
@@ -405,20 +405,19 @@ fn select_row_on_click(app: &mut PhotocraftApp, ui: &egui::Ui, rc: &RowCtx<'_>,
|
||||
let mask = if v.filter { "filter" } else { "layer" };
|
||||
actions.push((photocraft_engine::mask_view_cmds::ID.into(), json!({"layer": l.id.0, "mode": "off", "mask": mask})));
|
||||
}
|
||||
let adjustment = matches!(l.content, LayerContent::Adjustment(_));
|
||||
let fill_mask = matches!(l.content, LayerContent::Fill(_)) && l.mask.is_some();
|
||||
let content_less = matches!(l.content, LayerContent::Adjustment(_) | LayerContent::Fill(_));
|
||||
if on_vector {
|
||||
// The vector mask thumbnail targets the vector mask: the path tools edit it and the
|
||||
// Paths panel selects the layer's path.
|
||||
app.ui.selected_path = Some("layer".into());
|
||||
actions.push(("ui.vectorMaskTarget".into(), json!(true)));
|
||||
} else if on_mask || (fill_mask && !on_thumb) {
|
||||
} else if on_mask || (content_less && l.mask.is_some() && !on_thumb) {
|
||||
if on_mask {
|
||||
// The mask thumbnail also switches Properties to the mask (#3369).
|
||||
app.ui.properties_layer = None;
|
||||
}
|
||||
actions.push(("ui.maskTarget".into(), json!(true)));
|
||||
} else if on_thumb || adjustment || !row.primary {
|
||||
} else if on_thumb || !row.primary {
|
||||
actions.push(("ui.maskTarget".into(), json!(false)));
|
||||
}
|
||||
// ⌥-click the layer thumbnail: fit the layer on screen, as Photoshop does.
|
||||
|
||||
@@ -806,8 +806,7 @@ fn a_new_adjustment_or_fill_layer_shows_its_settings_until_the_mask_thumbnail_is
|
||||
// Clicking the row (not a thumbnail) keeps the settings.
|
||||
let row = h.get_by_label(&layer(&h, id).name).rect().center();
|
||||
click_with(&mut h, row, Modifiers::NONE);
|
||||
assert_eq!(h.state().ui.mask_target, command.starts_with("layer.newFillLayer."));
|
||||
assert!(!h.state().ui.vector_mask_target);
|
||||
assert!(h.state().ui.mask_target);
|
||||
assert!(h.query_all_by_label("Density").next().is_none(), "{command}: a row click keeps the settings");
|
||||
// The mask thumbnail switches Properties to the mask.
|
||||
let r = mask_rect(&h, id, MaskKind::Pixel);
|
||||
@@ -841,39 +840,32 @@ fn a_new_adjustment_layer_brings_properties_to_the_front() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn adjustment_names_target_contents_instead_of_masks() {
|
||||
fn selecting_an_adjustment_layer_from_another_layer_targets_its_mask() {
|
||||
// The reference application: an adjustment layer picked by its name targets its mask; a
|
||||
// masked pixel layer targets its contents; the content thumbnail still targets contents.
|
||||
for command in ["layer.newAdjustmentLayer.hueSaturation", "layer.newAdjustmentLayer.curves"] {
|
||||
for ppp in [1.0, 2.0] {
|
||||
let (mut s, _, other) = session();
|
||||
s.execute(command, json!({})).unwrap();
|
||||
let id = s.active().unwrap().active_layer.unwrap().0;
|
||||
let path = json!({"subpaths": [{"knots": [[20, 10], [120, 10], [120, 90], [20, 90]]}]});
|
||||
s.execute("layer.vectorMask.add", json!({"layer": id, "path": path})).unwrap();
|
||||
let mut h = harness(s, 0, ppp, 360.0);
|
||||
for kind in [MaskKind::Pixel, MaskKind::Vector] {
|
||||
let at = mask_rect(&h, id, kind).center();
|
||||
click_with(&mut h, at, Modifiers::NONE);
|
||||
assert_eq!(h.state().ui.mask_target, kind == MaskKind::Pixel);
|
||||
assert_eq!(h.state().ui.vector_mask_target, kind == MaskKind::Vector);
|
||||
let name = crate::layer_row_ui::recorded(&h.ctx).into_iter().find(|r| r.layer == id).unwrap().name.unwrap().center();
|
||||
click_with(&mut h, name, Modifiers::NONE);
|
||||
assert!(!h.state().ui.mask_target && !h.state().ui.vector_mask_target, "{command} @{ppp}x after {kind:?}");
|
||||
let thumb = crate::layer_row_ui::recorded(&h.ctx).into_iter().find(|r| r.layer == id).unwrap().thumbnail.unwrap();
|
||||
assert!(near(super::brackets(&h.ctx).unwrap(), thumb.expand(3.0)), "the content thumbnail is selected");
|
||||
assert_eq!(h.state().session.active().unwrap().active_layer.unwrap().0, id);
|
||||
}
|
||||
let name = crate::layer_row_ui::recorded(&h.ctx).into_iter().find(|r| r.layer == other).unwrap().name.unwrap().center();
|
||||
click_with(&mut h, name, Modifiers::NONE);
|
||||
let name = crate::layer_row_ui::recorded(&h.ctx).into_iter().find(|r| r.layer == id).unwrap().name.unwrap().center();
|
||||
click_with(&mut h, name, Modifiers::NONE);
|
||||
assert_eq!(h.state().session.active().unwrap().active_layer.unwrap().0, id);
|
||||
assert!(!h.state().ui.mask_target && !h.state().ui.vector_mask_target, "{command} @{ppp}x from another layer");
|
||||
assert_eq!(crate::canvas::paint_target(h.state()), json!("mask"));
|
||||
let content = layer(&h, id).content;
|
||||
h.state_mut().run("edit.fill", json!({"contents": "black"})).unwrap();
|
||||
assert_eq!(layer(&h, id).content, content, "filling must preserve the adjustment or fill content");
|
||||
assert_eq!(layer(&h, id).mask.unwrap().surface.sample_channel(50, 50, 0), 0.0, "Fill edits the mask");
|
||||
assert!(!h.state().ui.mask_target && !h.state().ui.vector_mask_target, "painting leaves the content thumbnail selected");
|
||||
}
|
||||
let (mut s, masked, other) = session();
|
||||
s.execute(command, json!({})).unwrap();
|
||||
let id = s.active().unwrap().active_layer.unwrap().0;
|
||||
let mut h = harness(s, 0, 1.0, 360.0);
|
||||
assert!(layer(&h, id).mask.is_some(), "{command}: the adjustment layer has a mask");
|
||||
let name_of =
|
||||
|h: &Harness<'_, PhotocraftApp>, l: u64| crate::layer_row_ui::recorded(&h.ctx).into_iter().find(|r| r.layer == l).unwrap().name.unwrap().center();
|
||||
let at = name_of(&h, other);
|
||||
click_with(&mut h, at, Modifiers::NONE);
|
||||
let at = name_of(&h, id);
|
||||
click_with(&mut h, at, Modifiers::NONE);
|
||||
assert_eq!(h.state().session.active().unwrap().active_layer.unwrap().0, id);
|
||||
assert!(h.state().ui.mask_target && !h.state().ui.vector_mask_target, "{command}: a name click targets the mask");
|
||||
assert_eq!(crate::canvas::paint_target(h.state()), json!("mask"));
|
||||
// The content thumbnail targets the contents.
|
||||
let thumb = layer_thumb_center(&h, id);
|
||||
click_with(&mut h, thumb, Modifiers::NONE);
|
||||
assert!(!h.state().ui.mask_target, "{command}: the content thumbnail targets contents");
|
||||
// A masked pixel layer picked by its name targets its contents.
|
||||
let at = name_of(&h, masked);
|
||||
click_with(&mut h, at, Modifiers::NONE);
|
||||
assert_eq!(h.state().session.active().unwrap().active_layer.unwrap().0, masked);
|
||||
assert!(!h.state().ui.mask_target && !h.state().ui.vector_mask_target, "{command}: a pixel layer targets its contents");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user