Skip to content

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

Merge PR #6881: Actions: .atn Select Subject, Select and Mask, Color Range, clipping and layer masks, colours map to commands (part of #6745)

aiongg719fb44d4226
diff --cc crates/engine/src/atn_cmds.rs
index 22d373ffd,c13ee321f..5e95245cf
--- a/crates/engine/src/atn_cmds.rs
+++ b/crates/engine/src/atn_cmds.rs
@@@ -713,15 -694,14 +713,17 @@@ fn channel_mixer_to(p: &Value) -> Optio
d = d.with(key, D::Descriptor(desc("ChMx").with("Rd ", pct(v(0))).with("Grn ", pct(v(1))).with("Bl ", pct(v(2))).with("Cnst", pct(v(3)))));
}
}
- Some(d.with("Mnch", D::Boolean(jbool(p, "monochrome").unwrap_or(false))))
+ if let Some(m) = jbool(p, "monochrome") {
+ d = d.with("Mnch", D::Boolean(m));
+ }
+ Some(d)
}
+ /// Photoshop's `Clrs` colour-range enumeration. Yellows is `Ylws` (`Yllw` is the yellow ink
+ /// key); earlier PhotoCraft builds wrote `Yllw`, which import still reads (#6745).
const SELECTIVE_RANGES: &[(&str, &str)] = &[
("Rds", "reds"),
- ("Yllw", "yellows"),
+ ("Ylws", "yellows"),
("Grns", "greens"),
("Cyns", "cyans"),
("Bls", "blues"),
@@@ -3199,20 -3214,25 +3407,35 @@@ const EVENTS: &[Event] = &
ev!("Brdr", "border", "Border", "select.modify.border", &[F("Wdth", "radius", Kind::Px)]),
ev!("Grow", "grow", "Grow", "select.grow", &[F("Tlrn", "tolerance", Kind::Long)]),
ev!("Smlr", "similar", "Similar", "select.similar", &[F("Tlrn", "tolerance", Kind::Long)]),
- ev!("", "refineSelectionEdge", "Select and Mask", "select.refineEdge", REFINE_EDGE),
+ // `refineSelectionEdge` has no Sample All Layers, so a step with it exports as
+ // `smartBrushWorkspace` instead of dropping it.
+ Event {
+ code: "",
+ name: "refineSelectionEdge",
+ label: "Select and Mask",
+ ids: &["select.refineEdge"],
+ from: |d| match fields_from(d, REFINE_EDGE) {
+ Some(m) => step("select.refineEdge", Value::Object(m)),
+ None => Mapped::Unsupported { harmless: false },
+ },
+ to: |_, p| if p.get("sampleAllLayers").is_some() { None } else { fields_to(p, REFINE_EDGE, desc("null")) },
+ },
+ ev!("", "smartBrushWorkspace", "Select and Mask", "select.refineEdge", SMART_BRUSH),
+ ev!("", "autoCutout", "Select Subject", "select.subject", &[F("sampleAllLayers", "sampleAllLayers", Kind::Bool)]),
+ Event { code: "ClrR", name: "colorRange", label: "Color Range", ids: &["select.colorRange"], from: color_range_from, to: color_range_to },
// Edit.
Event { code: "Fl ", name: "fill", label: "Fill", ids: &["edit.fill", "paint.bucket"], from: fill_from, to: fill_to },
- ev!("Strk", "stroke", "Stroke", "edit.stroke", STROKE),
+ Event {
+ code: "Strk",
+ name: "stroke",
+ label: "Stroke",
+ ids: &["edit.stroke"],
+ from: |d| match fields_from(d, STROKE) {
+ Some(m) => step("edit.stroke", Value::Object(m)),
+ None => Mapped::Unsupported { harmless: false },
+ },
+ to: stroke_to,
+ },
ev!("copy", "copyEvent", "Copy", "edit.copy", &[]),
ev!("CpyM", "copyMerged", "Copy Merged", "edit.copyMerged", &[]),
ev!("cut ", "cut", "Cut", "edit.cut", &[]),