PhotoCraft: An open-source, photo editor written by scratch in pure Rust
Actions: Add Layer Mask maps only the target layer's mask
Higgs325848fa1217bcc43
diff --git a/crates/engine/src/atn_cmds.rs b/crates/engine/src/atn_cmds.rsindex 27e673699..5d11943b3 100644--- a/crates/engine/src/atn_cmds.rs+++ b/crates/engine/src/atn_cmds.rs@@ -1028,7 +1028,9 @@ fn make_from(d: &Descriptor) -> Mapped {if let Some(D::Class(c)) = d.get("Nw ")&& trimmed(&c.class_id) == "Chnl"{- let at_mask = get_ref(d, "At ").is_some_and(|r| ref_class(r).as_deref() == Some("Chnl") && matches!(target(r), Target::Ordinal(o) if o == "Msk"));+ // The target layer's mask only: a further item (a `Lyr` by name…) puts it on another layer.+ let at_mask = get_ref(d, "At ")+ .is_some_and(|r| r.len() == 1 && ref_class(r).as_deref() == Some("Chnl") && matches!(target(r), Target::Ordinal(o) if o == "Msk"));return match get_enum(d, "Usng").and_then(|u| lookup(MASK_USING, &u)) {Some(id) if at_mask => none(id),_ => Mapped::Unsupported { harmless: false },diff --git a/crates/engine/src/atn_cmds/tests.rs b/crates/engine/src/atn_cmds/tests.rsindex 78acf6c34..981c4c820 100644--- a/crates/engine/src/atn_cmds/tests.rs+++ b/crates/engine/src/atn_cmds/tests.rs@@ -665,6 +665,18 @@ fn retouching_set_events_map_to_their_commands() {// A legacy PhotoCraft export's `Yllw` yellows still read.let legacy = desc("null").with("ClrC", D::List(vec![D::Descriptor(desc("ClrC").with("Clrs", enm("Clrs", "Yllw")).with("Cyn ", pct(5.0)))]));assert_eq!(selective_from(&legacy), Some(json!({"yellows": [5.0, 0.0, 0.0, 0.0]})));+ // The mask of a named layer is not the target layer's mask: it stays unsupported.+ let other_layer = desc("null")+ .with("Nw ", D::Class(class("Chnl")))+ .with(+ "At ",+ D::Reference(vec![+ ReferenceItem::Enumerated { class: class("Chnl"), type_id: code("Chnl"), value: code("Msk ") },+ ReferenceItem::Name { class: class("Lyr "), name: UnicodeString::new_nul("Other") },+ ]),+ )+ .with("Usng", enm("UsrM", "RvlA"));+ assert!(matches!(make_from(&other_layer), Mapped::Unsupported { harmless: false }));}/// Select and Mask exports as the older `refineSelectionEdge` event, which has no Sample All