mirror of
https://github.com/storytold/photocraft.git
synced 2026-12-02 06:20:48 +01:00
Merge #10755: Support newer recorded Action events
# Conflicts: # crates/engine/src/cmd/artboard_cmds.rs # crates/engine/src/cmd/atn_cmds.rs # crates/engine/src/cmd/atn_cmds/events.rs # crates/engine/src/cmd/atn_cmds/steps_make.rs # crates/engine/tests/it/main.rs # docs/atn.md # docs/development.md # docs/file-format-parity.md
This commit is contained in:
commit
eb3c2044d4
15 files changed
+1778
-27
No files matched your search
@@ -301,22 +301,38 @@ fn new_artboard(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
Ok(json!({"layer": id.0, "rect": [rect.x0, rect.y0, rect.width(), rect.height()]}))
|
||||
}
|
||||
|
||||
/// Convert a plain group at its content bounds; recorded guide IDs are ignored session metadata.
|
||||
fn artboard_from_group(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let cmd = "layer.new.artboardFromGroup";
|
||||
let d = s.active().ok_or(EngineError::NoDocument)?;
|
||||
let id = crate::commands::layer_param(s, p)?;
|
||||
let preset = match p.get("preset") {
|
||||
None => String::new(),
|
||||
Some(value) => value.as_str().ok_or_else(|| bad(cmd, "preset must be text"))?.to_string(),
|
||||
};
|
||||
let apply_background = match p.get("changeBackground") {
|
||||
None | Some(Value::Bool(true)) => true,
|
||||
Some(value) => value.as_i64().and_then(|n| i32::try_from(n).ok()).ok_or_else(|| bad(cmd, "changeBackground must be an integer"))? == 1,
|
||||
};
|
||||
if let Some(guides) = p.get("guideIDs")
|
||||
&& !guides.as_array().is_some_and(|ids| ids.iter().all(|id| id.as_i64().is_some_and(|n| i32::try_from(n).is_ok())))
|
||||
{
|
||||
return Err(bad(cmd, "guideIDs must be a list of integers"));
|
||||
}
|
||||
let canvas = d.doc.bounds();
|
||||
let background = background_param(p, "layer.new.artboardFromGroup")?.unwrap_or_default();
|
||||
let background = if apply_background { background_param(p, cmd)?.unwrap_or_default() } else { ArtboardBackground::White };
|
||||
let rect = s.edit("Artboard from Group", |doc, active| {
|
||||
if !doc.layers.iter().any(|t| t.id == id && t.is_group() && t.artboard().is_none()) {
|
||||
return Err(EngineError::Other("artboards are made from a top-level layer group".into()));
|
||||
}
|
||||
let l = doc.layer_mut(id).ok_or(EngineError::NoLayer(id))?;
|
||||
let rect = crate::layer_multi_cmds::layer_bounds(l).unwrap_or(canvas);
|
||||
set_artboard(l, Artboard { rect, background, preset: String::new() });
|
||||
set_artboard(l, Artboard { rect, background, preset });
|
||||
fit_canvas(doc);
|
||||
*active = Some(id);
|
||||
Ok(rect)
|
||||
})?;
|
||||
crate::layer_multi_cmds::set_selection(s, vec![id], Some(id), Some(id))?;
|
||||
Ok(json!({"layer": id.0, "rect": [rect.x0, rect.y0, rect.width(), rect.height()]}))
|
||||
}
|
||||
|
||||
@@ -697,7 +713,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"layer.new.artboardFromGroup",
|
||||
"Artboard from Group…",
|
||||
&["Layer", "New"],
|
||||
r##"{"layer":id? (a top-level group; default active),"background":…?} → {layer, rect}"##,
|
||||
r##"{"layer":id? (a top-level group; default active),"background":…?,"color":[r,g,b]|"#rrggbb"?,"preset":str? (tag only; does not resize),"guideIDs":[int]? (ignored recording metadata),"changeBackground":int? (1 or absent applies background/color; other integers give white; legacy true = 1)} → {layer, rect}"##,
|
||||
has_plain_group,
|
||||
artboard_from_group
|
||||
),
|
||||
|
||||
@@ -33,6 +33,7 @@ mod events;
|
||||
mod fields;
|
||||
mod files;
|
||||
|
||||
mod steps_artboard;
|
||||
mod steps_channels;
|
||||
mod steps_direct_adjustments;
|
||||
mod steps_distort;
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
const DIFFUSE_MODE: &[(&str, &str)] = &[("Nrml", "normal"), ("DrkO", "darkenOnly"), ("LghO", "lightenOnly"), ("Anst", "anisotropic")];
|
||||
use super::adjustments::{adjustment_by_class, adjustment_steps, levels_from, levels_to, shadows_highlights_from, shadows_highlights_to};
|
||||
use super::descriptors::{class, code, desc, get_bool, get_obj, get_ref, jbool, layer_ref, layer_target, ref_class, trimmed};
|
||||
use super::descriptors::{
|
||||
class, code, desc, get_bool, get_obj, get_ref, jbool, layer_ref, layer_target, path_text, path_value, ref_class, target_ref, trimmed,
|
||||
};
|
||||
use super::fields::{F, Kind, Mapped, fields_from, fields_to, none, step};
|
||||
|
||||
use super::steps_artboard::{artboard_edit_from, artboard_edit_to, artboard_from, artboard_to};
|
||||
use super::steps_channels::{match_color_from, match_color_to, merge_spot_from, merge_spot_to, split_from, split_to, trap_from, trap_to};
|
||||
use super::steps_direct_adjustments::{gradient_from, gradient_to, replace_from, replace_to};
|
||||
use super::steps_distort::{PINCH, POLAR, SPHERIZE, TWIRL, ZIGZAG, keys_from, keys_to, wave_from, wave_to};
|
||||
@@ -24,7 +26,7 @@ use super::steps_layer::{
|
||||
use super::steps_make::{locking_from, locking_to, make_from, make_to, set_from, set_to};
|
||||
use super::steps_other::{DE_INTERLACE, HSB_HSL, bare_from, bare_to, custom_from, custom_to, enums_from, enums_to};
|
||||
use super::tables::{NOISE, OFFSET_FILL, SMART_BLUR_MODE, SMART_BLUR_QUALITY, TRIM};
|
||||
use super::{AtnEvent, D, Descriptor, Id, ReferenceItem, STOP_MESSAGE, Value, json};
|
||||
use super::{AtnEvent, D, Descriptor, Id, Map, ReferenceItem, STOP_MESSAGE, Value, json};
|
||||
|
||||
/// An event: code (empty when Photoshop only has a string name), string name, the panel
|
||||
/// label, the command ids it exports (the first is the one simple events import to), and the
|
||||
@@ -226,6 +228,124 @@ fn spell_check_to(_: &str, p: &Value) -> Option<Descriptor> {
|
||||
Some(desc("null").with("null", spell_check_ref()).with("Usng", D::Descriptor(desc("spellCheck").with("checkAll", D::Boolean(all)))))
|
||||
}
|
||||
|
||||
// Adapter-only transport bit: the reference permits either no target key or the
|
||||
// current-layer target. Save must retain that distinction; native behavior is identical.
|
||||
const NO_TARGET: &str = "_atnNoTarget";
|
||||
|
||||
/// Accept only bare or current-layer targets, retaining their key-presence distinction for save.
|
||||
fn target_params(d: &Descriptor) -> Option<Map<String, Value>> {
|
||||
let mut p = Map::new();
|
||||
if d.items.is_empty() {
|
||||
p.insert(NO_TARGET.into(), Value::Bool(true));
|
||||
} else if d.items != desc("null").with("null", target_ref("Lyr ")).items {
|
||||
return None;
|
||||
}
|
||||
Some(p)
|
||||
}
|
||||
|
||||
/// Restore the bare or explicit current-layer descriptor selected by the private transport bit.
|
||||
fn target_descriptor(p: &Value) -> Option<Descriptor> {
|
||||
match p.get(NO_TARGET) {
|
||||
None => Some(desc("null").with("null", target_ref("Lyr "))),
|
||||
Some(Value::Bool(true)) => Some(desc("null")),
|
||||
Some(_) => None,
|
||||
}
|
||||
}
|
||||
|
||||
// Native-parameter allowlist adapted from #10628; refuse unrepresented options on export.
|
||||
/// Refuse native options that the selected Photoshop form cannot represent.
|
||||
fn params(p: &Value, allowed: &[&str]) -> bool {
|
||||
p.as_object().is_some_and(|p| p.keys().all(|key| allowed.contains(&key.as_str())))
|
||||
}
|
||||
|
||||
/// Import a target-only event, refusing other targets and extra descriptor settings.
|
||||
fn target_only_from(d: &Descriptor, id: &str) -> Mapped {
|
||||
target_params(d).map_or(Mapped::Unsupported { harmless: false }, |p| step(id, Value::Object(p)))
|
||||
}
|
||||
|
||||
/// Export a current-target native step only when no unrepresented options are present.
|
||||
fn target_only_to(_: &str, p: &Value) -> Option<Descriptor> {
|
||||
if !params(p, &[NO_TARGET]) {
|
||||
return None;
|
||||
}
|
||||
target_descriptor(p)
|
||||
}
|
||||
|
||||
const SHAPE_BLUR: &[F] = &[F("Rds ", "radius", Kind::Px)];
|
||||
|
||||
/// Map the radius-only Shape Blur form; keep custom assets or extra keys unsupported.
|
||||
fn shape_blur_from(d: &Descriptor) -> Mapped {
|
||||
let unsupported = Mapped::Unsupported { harmless: false };
|
||||
let Some(p) = fields_from(d, SHAPE_BLUR) else { return unsupported };
|
||||
let p = Value::Object(p);
|
||||
if shape_blur_to("filter.blur.shapeBlur", &p).is_some_and(|expected| d.items == expected.items) { step("filter.blur.shapeBlur", p) } else { unsupported }
|
||||
}
|
||||
|
||||
/// Write an optional finite 5–1000 pixel radius, refusing explicit shapes and other options.
|
||||
fn shape_blur_to(_: &str, p: &Value) -> Option<Descriptor> {
|
||||
if !params(p, &["radius"]) {
|
||||
return None;
|
||||
}
|
||||
if let Some(radius) = p.get("radius") {
|
||||
let radius = radius.as_f64()?;
|
||||
if !radius.is_finite() || !(5.0..=1000.0).contains(&radius) {
|
||||
return None;
|
||||
}
|
||||
}
|
||||
fields_to(p, SHAPE_BLUR, desc("null"))
|
||||
}
|
||||
|
||||
// Recorded Link and Unlink need explicit state: replaying the UI toggle can
|
||||
// perform the opposite operation. Target matching follows #10628's adapter.
|
||||
/// Import Link or Unlink as an explicit operation rather than the state-dependent UI toggle.
|
||||
fn link_from(d: &Descriptor, linked: bool) -> Mapped {
|
||||
let Some(mut p) = target_params(d) else { return Mapped::Unsupported { harmless: false } };
|
||||
p.insert("linked".into(), Value::Bool(linked));
|
||||
step("layer.linkLayers", Value::Object(p))
|
||||
}
|
||||
|
||||
/// Export only the matching explicit link state and supported current-layer target form.
|
||||
fn link_to(p: &Value, linked: bool) -> Option<Descriptor> {
|
||||
if !params(p, &["linked", NO_TARGET]) || p.get("linked") != Some(&Value::Bool(linked)) {
|
||||
return None;
|
||||
}
|
||||
target_descriptor(p)
|
||||
}
|
||||
|
||||
/// Map canonical Smart Object file descriptors, refusing unrepresented paths, targets or keys.
|
||||
fn smart_path_from(d: &Descriptor, id: &str) -> Mapped {
|
||||
let unsupported = Mapped::Unsupported { harmless: false };
|
||||
let key = if id == "layer.smartObjects.convertToLinked" { "Usng" } else { "null" };
|
||||
let Some(path) = d.get(key).and_then(path_text) else { return unsupported };
|
||||
let p = json!({"path": path});
|
||||
let Some(mut expected) = smart_path_to(id, &p) else { return unsupported };
|
||||
if let Some(hint) = d.get("LyrI") {
|
||||
// The reference explicitly omits recording-session IDs on save (#10603,
|
||||
// docs/atn.md:200). They must never become PhotoCraft's playback target.
|
||||
if !matches!(id, "layer.smartObjects.relinkToFile" | "layer.smartObjects.replaceContents") || !matches!(hint, D::Integer(n) if *n > 0) {
|
||||
return unsupported;
|
||||
}
|
||||
expected = expected.with("LyrI", hint.clone());
|
||||
}
|
||||
// Normalize the top-level header as Open/Place do, but refuse unknown keys,
|
||||
// targets and path encodings rather than partly replaying them.
|
||||
if d.items == expected.items { step(id, p) } else { unsupported }
|
||||
}
|
||||
|
||||
/// Export path-only native parameters using the existing Open/Place path encoding.
|
||||
fn smart_path_to(id: &str, p: &Value) -> Option<Descriptor> {
|
||||
let p = p.as_object()?;
|
||||
let path = p.get("path")?.as_str()?;
|
||||
if p.len() != 1 || path.is_empty() || path.contains('\0') {
|
||||
return None;
|
||||
}
|
||||
Some(if id == "layer.smartObjects.convertToLinked" {
|
||||
desc("null").with("null", target_ref("Lyr ")).with("Usng", path_value(path))
|
||||
} else {
|
||||
desc("null").with("null", path_value(path))
|
||||
})
|
||||
}
|
||||
|
||||
/// A clipping mask event: `clipping_from` / `clipping_to` with one command id.
|
||||
macro_rules! clipping_event {
|
||||
($code:literal, $name:literal, $label:literal, $id:literal) => {
|
||||
@@ -240,6 +360,12 @@ macro_rules! selection_event {
|
||||
};
|
||||
}
|
||||
|
||||
macro_rules! target_event {
|
||||
($name:literal, $label:literal, $id:literal) => {
|
||||
Event { code: "", name: $name, label: $label, ids: &[$id], from: |d| target_only_from(d, $id), to: target_only_to }
|
||||
};
|
||||
}
|
||||
|
||||
/// Every Photoshop event PhotoCraft maps. The order matters only for the panel label.
|
||||
pub(super) const EVENTS: &[Event] = &[
|
||||
selection_event!("AddT", "addTo", "Add to Selection", &["select.rect"], |d| super::steps_selection::selection_from(d, "add"), |_, p| {
|
||||
@@ -392,6 +518,7 @@ pub(super) const EVENTS: &[Event] = &[
|
||||
ev!("MtnB", "motionBlur", "Motion Blur", "filter.blur.motionBlur", &[F("Angl", "angle", Kind::Ang), F("Dstn", "distance", Kind::Px)]),
|
||||
ev!("", "boxblur", "Box Blur", "filter.blur.boxBlur", &[F("Rds ", "radius", Kind::Px)]),
|
||||
ev!("", "surfaceBlur", "Surface Blur", "filter.blur.surfaceBlur", &[F("Rds ", "radius", Kind::Px), F("Thsh", "threshold", Kind::Long)]),
|
||||
Event { code: "", name: "shapeBlur", label: "Shape Blur", ids: &["filter.blur.shapeBlur"], from: shape_blur_from, to: shape_blur_to },
|
||||
ev!(
|
||||
"SmrB",
|
||||
"smartBlur",
|
||||
@@ -636,11 +763,39 @@ pub(super) const EVENTS: &[Event] = &[
|
||||
},
|
||||
Event { code: "Dplc", name: "duplicate", label: "Duplicate", ids: &["layer.duplicate", "image.duplicate"], from: duplicate_from, to: duplicate_to },
|
||||
// Layers.
|
||||
target_event!("reverse", "Reverse", "layer.arrange.reverse"),
|
||||
target_event!("selectLinkedLayers", "Select Linked Layers", "layer.selectLinkedLayers"),
|
||||
target_event!("disableLayerStyle", "Clear Layer Style", "layer.layerStyle.clear"),
|
||||
target_event!("rasterizeAll", "Rasterize All Layers", "layer.rasterize.allLayers"),
|
||||
target_event!("addBlankVideoLayer", "New Blank Video Layer", "layer.videoLayers.newBlankVideoLayer"),
|
||||
target_event!("isolateLayers", "Isolate Layers", "select.isolateLayers"),
|
||||
target_event!("textLoadDefaultTypeStyles", "Load Default Type Styles", "type.loadDefaultTypeStyles"),
|
||||
target_event!("textSaveDefaultTypeStyles", "Save Default Type Styles", "type.saveDefaultTypeStyles"),
|
||||
target_event!("recordMeasurements", "Record Measurements", "image.analysis.recordMeasurements"),
|
||||
target_event!("CropPhotosAuto0001", "Crop and Straighten Photos", "file.automate.cropAndStraightenPhotos"),
|
||||
Event {
|
||||
code: "",
|
||||
name: "artboardFromLayerGroupEvent",
|
||||
label: "Artboard from Group",
|
||||
ids: &["layer.new.artboardFromGroup"],
|
||||
from: artboard_from,
|
||||
to: artboard_to,
|
||||
},
|
||||
Event { code: "", name: "editArtboardEvent", label: "Edit Artboard", ids: &["layer.artboard.set"], from: artboard_edit_from, to: artboard_edit_to },
|
||||
Event {
|
||||
code: "",
|
||||
name: "unlinkSelectedLayers",
|
||||
label: "Unlink Layers",
|
||||
ids: &["layer.linkLayers"],
|
||||
from: |d| link_from(d, false),
|
||||
to: |_, p| link_to(p, false),
|
||||
},
|
||||
Event {
|
||||
code: "Mk ",
|
||||
name: "make",
|
||||
label: "Make",
|
||||
ids: &[
|
||||
"type.convertToShape",
|
||||
"layer.new.layer",
|
||||
"layer.new.group",
|
||||
"layer.groupLayers",
|
||||
@@ -755,6 +910,42 @@ pub(super) const EVENTS: &[Event] = &[
|
||||
ev!("", "newPlacedLayer", "Convert to Smart Object", "layer.smartObjects.convertToSmartObject", &[]),
|
||||
ev!("", "placedLayerEditContents", "Edit Contents", "layer.smartObjects.editContents", &[]),
|
||||
ev!("", "updatePlacedLayer", "Update Smart Objects", "layer.smartObjects.updateModifiedContent", &[]),
|
||||
target_event!("placedLayerMakeCopy", "New Smart Object via Copy", "layer.smartObjects.newSmartObjectViaCopy"),
|
||||
target_event!("placedLayerConvertToLayers", "Convert to Layers", "layer.smartObjects.convertToLayers"),
|
||||
target_event!("placedLayerConvertToEmbedded", "Convert to Embedded", "layer.smartObjects.convertToEmbedded"),
|
||||
target_event!("placedLayerUpdateAllModified", "Update All Modified Content", "layer.smartObjects.updateAllModifiedContent"),
|
||||
Event {
|
||||
code: "",
|
||||
name: "placedLayerExportContents",
|
||||
label: "Export Contents",
|
||||
ids: &["layer.smartObjects.exportContents"],
|
||||
from: |d| smart_path_from(d, "layer.smartObjects.exportContents"),
|
||||
to: smart_path_to,
|
||||
},
|
||||
Event {
|
||||
code: "",
|
||||
name: "placedLayerConvertToLinked",
|
||||
label: "Convert to Linked",
|
||||
ids: &["layer.smartObjects.convertToLinked"],
|
||||
from: |d| smart_path_from(d, "layer.smartObjects.convertToLinked"),
|
||||
to: smart_path_to,
|
||||
},
|
||||
Event {
|
||||
code: "",
|
||||
name: "placedLayerRelinkToFile",
|
||||
label: "Relink to File",
|
||||
ids: &["layer.smartObjects.relinkToFile"],
|
||||
from: |d| smart_path_from(d, "layer.smartObjects.relinkToFile"),
|
||||
to: smart_path_to,
|
||||
},
|
||||
Event {
|
||||
code: "",
|
||||
name: "placedLayerReplaceContents",
|
||||
label: "Replace Contents",
|
||||
ids: &["layer.smartObjects.replaceContents"],
|
||||
from: |d| smart_path_from(d, "layer.smartObjects.replaceContents"),
|
||||
to: smart_path_to,
|
||||
},
|
||||
Event { code: "Hd ", name: "hide", label: "Hide", ids: &["layer.hideLayers"], from: |d| visibility_from(d, "layer.hideLayers"), to: visibility_to },
|
||||
Event {
|
||||
code: "Shw ",
|
||||
|
||||
@@ -0,0 +1,160 @@
|
||||
//! Measured Artboard conversion and background-only Properties edits.
|
||||
|
||||
use super::descriptors::{desc, get_num, get_obj, get_text, target_ref, text};
|
||||
use super::fields::{Mapped, none, step};
|
||||
use super::{D, Descriptor, Value, json};
|
||||
|
||||
const FROM_GROUP: &str = "layer.new.artboardFromGroup";
|
||||
const EDIT: &str = "layer.artboard.set";
|
||||
|
||||
/// Keep recorded colors and ignored guide IDs, including an omitted background type.
|
||||
fn settings_from(board: &Descriptor, preset_key: &str) -> Option<Value> {
|
||||
let color = get_obj(board, "Clr ")?;
|
||||
let preset = get_text(board, "artboardPresetName")?;
|
||||
let background = match board.get("artboardBackgroundType") {
|
||||
None | Some(D::Integer(1)) => "white",
|
||||
Some(D::Integer(2)) => "black",
|
||||
Some(D::Integer(3)) => "transparent",
|
||||
Some(D::Integer(4)) => "custom",
|
||||
_ => return None,
|
||||
};
|
||||
let Some(D::List(guides)) = board.get("guideIDs") else { return None };
|
||||
let guides: Vec<i32> = guides.iter().map(|v| if let D::Integer(n) = v { Some(*n) } else { None }).collect::<Option<_>>()?;
|
||||
let recorded: Vec<f64> = ["Rd ", "Grn ", "Bl "].iter().map(|key| get_num(color, key)).collect::<Option<_>>()?;
|
||||
let rgb: Vec<f64> = recorded.iter().map(|n| n / 255.0).collect();
|
||||
let mut p = json!({"background": background, "color": rgb, "guideIDs": guides});
|
||||
if recorded.iter().zip(&rgb).any(|(recorded, native)| *recorded != native * 255.0) {
|
||||
p["recordedColor"] = json!(recorded);
|
||||
}
|
||||
p[preset_key] = preset.into();
|
||||
if board.get("artboardBackgroundType").is_none() {
|
||||
p["backgroundTypeOmitted"] = true.into();
|
||||
}
|
||||
Some(p)
|
||||
}
|
||||
|
||||
/// Rebuild only settings whose native meaning still agrees with the saved wire form.
|
||||
fn settings_to(p: &Value, preset_key: &str) -> Option<Descriptor> {
|
||||
let preset = p.get(preset_key)?.as_str()?;
|
||||
let background = match p.get("background")?.as_str()? {
|
||||
"white" => 1,
|
||||
"black" => 2,
|
||||
"transparent" => 3,
|
||||
"custom" => 4,
|
||||
_ => return None,
|
||||
};
|
||||
let guides = p.get("guideIDs")?.as_array()?.iter().map(|v| Some(D::Integer(i32::try_from(v.as_i64()?).ok()?))).collect::<Option<Vec<_>>>()?;
|
||||
let rgb = p.get("color")?.as_array()?;
|
||||
if rgb.len() != 3 {
|
||||
return None;
|
||||
}
|
||||
let rgb: Vec<f64> = rgb.iter().map(Value::as_f64).collect::<Option<_>>()?;
|
||||
if !rgb.iter().all(|n| n.is_finite() && (0.0..=1.0).contains(n)) {
|
||||
return None;
|
||||
}
|
||||
let recorded = match p.get("recordedColor") {
|
||||
None => rgb.iter().map(|n| n * 255.0).collect(),
|
||||
Some(value) => {
|
||||
let values = value.as_array()?.iter().map(Value::as_f64).collect::<Option<Vec<_>>>()?;
|
||||
if values.len() != 3 || values.iter().zip(&rgb).any(|(wire, native)| !(0.0..=255.0).contains(wire) || wire / 255.0 != *native) {
|
||||
return None;
|
||||
}
|
||||
values
|
||||
}
|
||||
};
|
||||
let color = ["Rd ", "Grn ", "Bl "].into_iter().zip(recorded).fold(desc("RGBC"), |d, (key, n)| d.with(key, D::Double(n)));
|
||||
let board = desc("artboard").with("guideIDs", D::List(guides)).with("artboardPresetName", text(preset)).with("Clr ", D::Descriptor(color));
|
||||
match p.get("backgroundTypeOmitted") {
|
||||
None => Some(board.with("artboardBackgroundType", D::Integer(background))),
|
||||
Some(Value::Bool(true)) if background == 1 => Some(board),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Import target-only conversion or complete recorded settings, preserving flag absence and values.
|
||||
pub(super) fn artboard_from(d: &Descriptor) -> Mapped {
|
||||
let unsupported = Mapped::Unsupported { harmless: false };
|
||||
if d.items == desc("null").with("null", target_ref("Lyr ")).items {
|
||||
return none(FROM_GROUP);
|
||||
}
|
||||
let Some(mut p) = get_obj(d, "artboard").and_then(|b| settings_from(b, "preset")) else { return unsupported };
|
||||
match d.get("changeBackground") {
|
||||
None => {}
|
||||
Some(D::Integer(n)) => p["changeBackground"] = (*n).into(),
|
||||
_ => return unsupported,
|
||||
}
|
||||
if artboard_to(FROM_GROUP, &p).is_some_and(|expected| expected.items == d.items) { step(FROM_GROUP, p) } else { unsupported }
|
||||
}
|
||||
|
||||
/// Fill behavior-neutral metadata for native settings; unknown options must not disappear.
|
||||
pub(super) fn artboard_to(_: &str, p: &Value) -> Option<Descriptor> {
|
||||
let fields = p.as_object()?;
|
||||
let d = desc("null").with("null", target_ref("Lyr "));
|
||||
if fields.is_empty() {
|
||||
return Some(d);
|
||||
}
|
||||
if fields.keys().any(|k| !["background", "color", "recordedColor", "preset", "guideIDs", "changeBackground", "backgroundTypeOmitted"].contains(&k.as_str()))
|
||||
{
|
||||
return None;
|
||||
}
|
||||
let mut settings = p.clone();
|
||||
let fields = settings.as_object_mut()?;
|
||||
if !fields.contains_key("color") && fields.get("background").and_then(Value::as_str) == Some("custom") {
|
||||
fields.insert("background".into(), json!("white"));
|
||||
}
|
||||
let background = if fields.contains_key("color") { "custom" } else { "white" };
|
||||
// Native custom-without-color means white. Other types ignore this last-used color.
|
||||
for (key, value) in [("background", json!(background)), ("color", json!([1.0, 1.0, 1.0])), ("preset", json!("")), ("guideIDs", json!([]))] {
|
||||
fields.entry(key).or_insert(value);
|
||||
}
|
||||
let d = d.with("artboard", D::Descriptor(settings_to(&settings, "preset")?));
|
||||
match p.get("changeBackground") {
|
||||
None => Some(d),
|
||||
// Older native action files used true for the recorded integer 1.
|
||||
Some(Value::Bool(true)) => Some(d.with("changeBackground", D::Integer(1))),
|
||||
Some(value) => Some(d.with("changeBackground", D::Integer(i32::try_from(value.as_i64()?).ok()?))),
|
||||
}
|
||||
}
|
||||
|
||||
/// Background-only edits retain recorded geometry as metadata, never as native resize parameters.
|
||||
pub(super) fn artboard_edit_from(d: &Descriptor) -> Mapped {
|
||||
let unsupported = Mapped::Unsupported { harmless: false };
|
||||
let Some(board) = get_obj(d, "artboard") else { return unsupported };
|
||||
let Some(rect) = get_obj(board, "artboardRect") else { return unsupported };
|
||||
let Some(mut p) = settings_from(board, "recordedPreset") else { return unsupported };
|
||||
let Some(edges) = ["Top ", "Left", "Btom", "Rght"].iter().map(|key| get_num(rect, key)).collect::<Option<Vec<_>>>() else { return unsupported };
|
||||
p["recordedRect"] = json!(edges);
|
||||
p["changeSizes"] = 8.into();
|
||||
p["changeBackground"] = 1.into();
|
||||
if artboard_edit_to(EDIT, &p).is_some_and(|expected| expected.items == d.items) { step(EDIT, p) } else { unsupported }
|
||||
}
|
||||
|
||||
/// Export only the measured background-edit flags and exact recorded rectangle, without quantization.
|
||||
pub(super) fn artboard_edit_to(_: &str, p: &Value) -> Option<Descriptor> {
|
||||
let fields = p.as_object()?;
|
||||
if fields.keys().any(|k| {
|
||||
!["background", "color", "recordedColor", "recordedPreset", "guideIDs", "recordedRect", "changeSizes", "changeBackground", "backgroundTypeOmitted"]
|
||||
.contains(&k.as_str())
|
||||
}) || p.get("changeSizes")?.as_i64()? != 8
|
||||
|| p.get("changeBackground")?.as_i64()? != 1
|
||||
{
|
||||
return None;
|
||||
}
|
||||
let edges = p.get("recordedRect")?.as_array()?;
|
||||
if edges.len() != 4 {
|
||||
return None;
|
||||
}
|
||||
let rect = ["Top ", "Left", "Btom", "Rght"]
|
||||
.into_iter()
|
||||
.zip(edges)
|
||||
.try_fold(desc("classFloatRect"), |d, (key, value)| Some(d.with(key, D::Double(value.as_f64().filter(|v| v.is_finite())?))))?;
|
||||
let mut board = desc("artboard").with("artboardRect", D::Descriptor(rect));
|
||||
board.items.extend(settings_to(p, "recordedPreset")?.items);
|
||||
Some(
|
||||
desc("null")
|
||||
.with("null", target_ref("Lyr "))
|
||||
.with("artboard", D::Descriptor(board))
|
||||
.with("changeSizes", D::Integer(8))
|
||||
.with("changeBackground", D::Integer(1)),
|
||||
)
|
||||
}
|
||||
@@ -172,8 +172,16 @@ fn new_document_from_descriptor(d: &Descriptor) -> Option<Mapped> {
|
||||
/// New Snapshot's From: the full document, the layers merged, or the current layer.
|
||||
const SNAPSHOT_FROM: &[(&str, &str)] = &[("FllD", "fullDocument"), ("MrgL", "mergedLayers"), ("CrnL", "currentLayer")];
|
||||
|
||||
/// Import Make events only when their geometry and options can be represented faithfully.
|
||||
fn type_shape_descriptor() -> Descriptor {
|
||||
desc("null").with("null", class_ref("contentLayer")).with("Usng", target_ref("textLayer"))
|
||||
}
|
||||
|
||||
/// Import Make events only when their geometry and options can be represented faithfully,
|
||||
/// including the exact target-text-to-content-layer references.
|
||||
pub(super) fn make_from(d: &Descriptor) -> Mapped {
|
||||
if d.items == type_shape_descriptor().items {
|
||||
return none("type.convertToShape");
|
||||
}
|
||||
if let Some(mapped) = duplicate_layer_from_descriptor(d) {
|
||||
return mapped;
|
||||
}
|
||||
@@ -300,8 +308,12 @@ fn recorded_percent(opacity: f64) -> f64 {
|
||||
if (level - level.round()).abs() < 1e-6 && (whole * 255.0 / 100.0).round() == level.round() { whole } else { percent }
|
||||
}
|
||||
|
||||
/// Write a creation step, refusing native options the target descriptor cannot carry.
|
||||
/// Write a creation step, refusing native options the target descriptor cannot carry; Type to
|
||||
/// Shape exports only without native options.
|
||||
pub(super) fn make_to(id: &str, p: &Value) -> Option<Descriptor> {
|
||||
if id == "type.convertToShape" {
|
||||
return p.as_object().filter(|p| p.is_empty()).map(|_| type_shape_descriptor());
|
||||
}
|
||||
let with_name = |cls: &str| {
|
||||
let mut u = desc(cls);
|
||||
if let Some(n) = jstr(p, "name") {
|
||||
|
||||
@@ -617,8 +617,33 @@ fn every_mapped_command_exports_and_imports_back() {
|
||||
("layer.duplicate", json!({"layer": "Shadow", "document": "new", "documentName": "Doc"})),
|
||||
("image.duplicate", json!({"mergedOnly": true})),
|
||||
("layer.new.layer", json!({"name": "Ink", "opacity": 0.5, "mode": "Multiply"})),
|
||||
("type.convertToShape", json!({})),
|
||||
("filter.blur.shapeBlur", json!({})),
|
||||
("filter.blur.shapeBlur", json!({"radius": 10})),
|
||||
("layer.new.group", json!({"name": "G"})),
|
||||
("layer.groupLayers", json!({})),
|
||||
("layer.linkLayers", json!({"linked": true})),
|
||||
("layer.linkLayers", json!({"linked": false})),
|
||||
("layer.linkLayers", json!({"linked": true, "_atnNoTarget": true})),
|
||||
("layer.linkLayers", json!({"linked": false, "_atnNoTarget": true})),
|
||||
("layer.arrange.reverse", json!({})),
|
||||
("layer.arrange.reverse", json!({"_atnNoTarget": true})),
|
||||
("layer.selectLinkedLayers", json!({})),
|
||||
("layer.layerStyle.clear", json!({})),
|
||||
("layer.rasterize.allLayers", json!({})),
|
||||
("layer.videoLayers.newBlankVideoLayer", json!({})),
|
||||
("select.isolateLayers", json!({})),
|
||||
("type.loadDefaultTypeStyles", json!({})),
|
||||
("type.saveDefaultTypeStyles", json!({})),
|
||||
("image.analysis.recordMeasurements", json!({})),
|
||||
("file.automate.cropAndStraightenPhotos", json!({})),
|
||||
("file.automate.cropAndStraightenPhotos", json!({"_atnNoTarget": true})),
|
||||
("layer.new.artboardFromGroup", json!({})),
|
||||
("layer.new.artboardFromGroup", json!({"background":"white","color":[1,1,1],"preset":"","guideIDs":[],"changeBackground":1})),
|
||||
(
|
||||
"layer.artboard.set",
|
||||
json!({"background":"custom","color":[0.25,0.5,0.75],"recordedPreset":"","guideIDs":[],"recordedRect":[2,2,6,6],"changeSizes":8,"changeBackground":1}),
|
||||
),
|
||||
("layer.new.layerViaCopy", json!({})),
|
||||
("layer.newFillLayer.solidColor", json!({"color": "#336699"})),
|
||||
("layer.newAdjustmentLayer.hueSaturation", json!({})),
|
||||
@@ -707,6 +732,14 @@ fn every_mapped_command_exports_and_imports_back() {
|
||||
("layer.smartObjects.convertToSmartObject", json!({})),
|
||||
("layer.smartObjects.editContents", json!({})),
|
||||
("layer.smartObjects.updateModifiedContent", json!({})),
|
||||
("layer.smartObjects.newSmartObjectViaCopy", json!({})),
|
||||
("layer.smartObjects.convertToLayers", json!({})),
|
||||
("layer.smartObjects.convertToEmbedded", json!({})),
|
||||
("layer.smartObjects.updateAllModifiedContent", json!({})),
|
||||
("layer.smartObjects.exportContents", json!({"path": "/tmp/contents.png"})),
|
||||
("layer.smartObjects.convertToLinked", json!({"path": "/tmp/linked.png"})),
|
||||
("layer.smartObjects.relinkToFile", json!({"path": "/tmp/relinked.png"})),
|
||||
("layer.smartObjects.replaceContents", json!({"path": "/tmp/replacement.png"})),
|
||||
("paint.bucket", json!({"x": 10, "y": 20, "tolerance": 32, "antiAlias": true, "contiguous": false, "opacity": 100})),
|
||||
("image.imageSize", json!({"percent": 200, "resample": "bicubicAutomatic", "scaleStyles": true})),
|
||||
("file.placeEmbedded", json!({"path": "/tmp/logo.png", "scale": 50})),
|
||||
@@ -860,6 +893,13 @@ fn every_mapped_command_exports_and_imports_back() {
|
||||
Mapped::Unsupported { .. } => panic!("{id} does not import back"),
|
||||
}
|
||||
}
|
||||
// Partial native backgrounds need no recorded preset, guide IDs or last-used color.
|
||||
for (background, imported_background) in [("white", "white"), ("black", "black"), ("transparent", "transparent"), ("custom", "white")] {
|
||||
let item = export_item("layer.new.artboardFromGroup", &json!({"background":background}), "S").unwrap();
|
||||
let Mapped::Steps(steps) = (event_for(&item.event).unwrap().from)(item.descriptor.as_ref().unwrap()) else { panic!("Artboard did not import") };
|
||||
assert_eq!(steps, [("layer.new.artboardFromGroup".into(), json!({"background":imported_background,"color":[1.0,1.0,1.0],"preset":"","guideIDs":[]}))]);
|
||||
assert_eq!(export_item(&steps[0].0, &steps[0].1, "S").unwrap().descriptor, item.descriptor);
|
||||
}
|
||||
// Every command the table claims to export has a case above.
|
||||
let covered: std::collections::BTreeSet<&str> = cases.iter().map(|(id, _)| *id).collect();
|
||||
let mut missing: Vec<&str> = EVENTS.iter().flat_map(|e| e.ids.iter().copied()).filter(|id| !covered.contains(id)).collect();
|
||||
|
||||
@@ -134,9 +134,15 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
s,
|
||||
"vertically"
|
||||
)),
|
||||
spec!("layer.linkLayers", "Link Layers", &["Layer"], None, "{} (toggles: unlinks when the selection is already one link group)", can_link, |s, _| {
|
||||
link_layers(s)
|
||||
}),
|
||||
spec!(
|
||||
"layer.linkLayers",
|
||||
"Link Layers",
|
||||
&["Layer"],
|
||||
None,
|
||||
r#"{"linked":bool?} (omitted: toggle; explicit true links, false unlinks)"#,
|
||||
can_link,
|
||||
link_layers
|
||||
),
|
||||
spec!("layer.mergeLayers", "Merge Layers", &["Layer"], Some("Cmd+E"), "{} (one layer selected: Merge Down)", has_layer, |s, _| merge_layers(s)),
|
||||
spec!(
|
||||
"layer.new.groupFromLayers",
|
||||
|
||||
@@ -3,13 +3,28 @@ use super::{Document, EngineError, Layer, LayerContent, LayerId, PixelFormat, Re
|
||||
|
||||
// ---------- structural commands ----------
|
||||
|
||||
pub(super) fn link_layers(s: &mut Session) -> Result<Value> {
|
||||
/// Set an explicit link state idempotently, or toggle when omitted, with singleton cleanup and Undo.
|
||||
pub(super) fn link_layers(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let requested = match p.get("linked") {
|
||||
None => None,
|
||||
Some(Value::Bool(value)) => Some(*value),
|
||||
Some(_) => return Err(bad("layer.linkLayers", "`linked` must be true or false")),
|
||||
};
|
||||
let sel = selected(s);
|
||||
let linked = s.edit("Link Layers", |doc, _| {
|
||||
let groups: Vec<Option<u64>> = sel.iter().map(|id| doc.layer(*id).and_then(|l| l.link_group)).collect();
|
||||
let doc = &s.active().ok_or(EngineError::NoDocument)?.doc;
|
||||
let groups = sel.iter().map(|id| doc.layer(*id).map(|l| l.link_group).ok_or(EngineError::NoLayer(*id))).collect::<Result<Vec<_>>>()?;
|
||||
let first = groups.first().copied().flatten();
|
||||
let same_group = first.is_some() && groups.iter().all(|group| *group == first);
|
||||
// A recorded Link/Unlink is an operation, not the UI's state-dependent toggle.
|
||||
// An explicit repeat must neither allocate a group nor add an undo entry.
|
||||
let linked_group = same_group && doc.walk().iter().filter(|(_, _, layer)| layer.link_group == first).take(2).count() == 2;
|
||||
if requested == Some(true) && linked_group || requested == Some(false) && groups.iter().all(Option::is_none) {
|
||||
return Ok(json!({"linked": requested == Some(true)}));
|
||||
}
|
||||
let label = if requested == Some(false) { "Unlink Layers" } else { "Link Layers" };
|
||||
let linked = s.edit(label, |doc, _| {
|
||||
// Already one link group (or a single linked layer): unlink, like Photoshop's toggle.
|
||||
let first = groups.first().copied().flatten();
|
||||
let unlink = first.is_some() && groups.iter().all(|g| *g == first);
|
||||
let unlink = requested.map_or(same_group, |linked| !linked) || sel.len() < 2;
|
||||
// A loaded file can store any id up to u64::MAX, so the new id must not be a bare
|
||||
// max + 1 (#961). Unlinking needs no new id at all.
|
||||
let next = if unlink { None } else { Some(doc.unused_link_group().ok_or_else(|| bad("layer.linkLayers", "no free link group id is left"))?) };
|
||||
|
||||
@@ -874,7 +874,9 @@ fn mask_unselected(sel: &Surface, area: Rect, w: usize, h: usize, rgba: &mut [[f
|
||||
true
|
||||
}
|
||||
|
||||
/// Validate the selected layer, then open cropped scan photos without editing the source document.
|
||||
fn crop_and_straighten(s: &mut Session, _p: &Value) -> Result<Value> {
|
||||
crop_ready(s)?;
|
||||
let st = s.active().ok_or(EngineError::NoDocument)?;
|
||||
let doc = st.doc.clone();
|
||||
let fmt = doc.pixel_format();
|
||||
@@ -942,13 +944,18 @@ fn crop_and_straighten(s: &mut Session, _p: &Value) -> Result<Value> {
|
||||
|
||||
// ---------- specs ----------
|
||||
|
||||
/// Photoshop greys Crop and Straighten Photos out for Indexed Color documents.
|
||||
fn not_indexed(s: &Session) -> std::result::Result<(), String> {
|
||||
let st = s.active().ok_or("no document open")?;
|
||||
/// Crop needs a selected, visible, pixel-unlocked layer, including inherited state.
|
||||
fn crop_ready(s: &Session) -> Result<()> {
|
||||
let st = s.active().ok_or(EngineError::NoDocument)?;
|
||||
if st.doc.mode == ColorMode::Indexed {
|
||||
return Err("not available for Indexed Color documents".into());
|
||||
return Err(EngineError::Other("not available for Indexed Color documents".into()));
|
||||
}
|
||||
Ok(())
|
||||
let id = st.active_layer.ok_or_else(|| EngineError::Other("no layer selected".into()))?;
|
||||
let path = st.doc.path_of(id).ok_or(EngineError::NoLayer(id))?;
|
||||
if !st.doc.shown_at(&path) {
|
||||
return Err(EngineError::Other("the selected layer is hidden".into()));
|
||||
}
|
||||
crate::commands::check_pixels_unlocked(&st.doc, id)
|
||||
}
|
||||
|
||||
fn always(_: &Session) -> std::result::Result<(), String> {
|
||||
@@ -983,7 +990,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
menu: &["File", "Automate"],
|
||||
shortcut: None,
|
||||
params: "{} → one new document per photo found on the scan (inside the selection when there is one)",
|
||||
enabled: not_indexed,
|
||||
enabled: |s| crop_ready(s).map_err(|e| e.to_string()),
|
||||
run: crop_and_straighten,
|
||||
journal: true,
|
||||
},
|
||||
|
||||
@@ -160,6 +160,12 @@ impl Session {
|
||||
if spec.id == "layer.smartFilter.deleteFilterMask" && params.get("ifPresent").and_then(Value::as_bool) == Some(true) {
|
||||
return smart_cmds::smart_layer_active(self);
|
||||
}
|
||||
// Recorded Unlink can be repeated on a single, already-unlinked layer.
|
||||
// Keep the menu toggle's two-layer requirement when no state is supplied.
|
||||
if spec.id == "layer.linkLayers" && params.get("linked").and_then(Value::as_bool) == Some(false) {
|
||||
let d = self.active().ok_or_else(|| "no document open".to_string())?;
|
||||
return if d.selected_layers().is_empty() { Err("no layer selected".into()) } else { Ok(()) };
|
||||
}
|
||||
channel_cmds::mask_target_enabled(self, spec.id, params).unwrap_or_else(|| (spec.enabled)(self))
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -4,6 +4,7 @@ mod affinity;
|
||||
mod artboard_export_names;
|
||||
mod atn_crystallize_cell_size;
|
||||
mod atn_direct_adjustments;
|
||||
mod atn_newer_events;
|
||||
mod atn_reference_forms;
|
||||
mod atn_ripple_amount;
|
||||
mod atn_selective_color;
|
||||
|
||||
+91
-5
@@ -18,7 +18,7 @@ layers and documents, newer and older events and files, and a measured reference
|
||||
map yet, with everything needed to implement them without
|
||||
the reference application.
|
||||
|
||||
## Supported events (146)
|
||||
## Supported events (168)
|
||||
|
||||
| Code | String ID | Label | PhotoCraft command(s) |
|
||||
|---|---|---|---|
|
||||
@@ -99,7 +99,7 @@ the reference application.
|
||||
| `CtTL` | cutToLayer | Layer Via Cut | `layer.new.layerViaCut` |
|
||||
| `LnsF` | lensFlare | Lens Flare | `filter.render.lensFlare` |
|
||||
| `Lvls` | levels | Levels | `image.adjustments.levels`, `image.autoTone`, `image.autoContrast` |
|
||||
| `Mk ` | make | Make | `layer.new.layer`, `layer.new.group`, `layer.groupLayers`, `layer.duplicate`, `layer.new.layerViaCopy`, `layer.new.layerViaCut`, `layer.newFillLayer.solidColor`, `layer.newFillLayer.pattern`, `layer.newAdjustmentLayer.levels`, `layer.newAdjustmentLayer.curves`, `layer.newAdjustmentLayer.hueSaturation`, `layer.newAdjustmentLayer.brightnessContrast`, `layer.newAdjustmentLayer.threshold`, `layer.newAdjustmentLayer.posterize`, `layer.newAdjustmentLayer.invert`, `layer.newAdjustmentLayer.colorBalance`, `layer.newAdjustmentLayer.vibrance`, `layer.newAdjustmentLayer.exposure`, `layer.newAdjustmentLayer.photoFilter`, `layer.newAdjustmentLayer.blackWhite`, `layer.newAdjustmentLayer.channelMixer`, `layer.newAdjustmentLayer.selectiveColor`, `layer.newAdjustmentLayer.gradientMap`, `layer.layerMask.revealAll`, `layer.layerMask.hideAll`, `layer.layerMask.revealSelection`, `layer.layerMask.hideSelection`, `file.new`, `file.newFromClipboard`, `history.newSnapshot` |
|
||||
| `Mk ` | make | Make | `layer.new.layer`, `layer.new.group`, `layer.groupLayers`, `layer.duplicate`, `layer.new.layerViaCopy`, `layer.new.layerViaCut`, `layer.newFillLayer.solidColor`, `layer.newFillLayer.pattern`, `layer.newAdjustmentLayer.levels`, `layer.newAdjustmentLayer.curves`, `layer.newAdjustmentLayer.hueSaturation`, `layer.newAdjustmentLayer.brightnessContrast`, `layer.newAdjustmentLayer.threshold`, `layer.newAdjustmentLayer.posterize`, `layer.newAdjustmentLayer.invert`, `layer.newAdjustmentLayer.colorBalance`, `layer.newAdjustmentLayer.vibrance`, `layer.newAdjustmentLayer.exposure`, `layer.newAdjustmentLayer.photoFilter`, `layer.newAdjustmentLayer.blackWhite`, `layer.newAdjustmentLayer.channelMixer`, `layer.newAdjustmentLayer.selectiveColor`, `layer.newAdjustmentLayer.gradientMap`, `layer.layerMask.revealAll`, `layer.layerMask.hideAll`, `layer.layerMask.revealSelection`, `layer.layerMask.hideSelection`, `file.new`, `file.newFromClipboard`, `history.newSnapshot`, `type.convertToShape` |
|
||||
| (string ID only) | animationFramesFromLayers | Make Frames from Layers | |
|
||||
| (string ID only) | matchColor | Match Color | `image.adjustments.matchColor` |
|
||||
| `Mxm ` | maximum | Maximum | `filter.other.maximum` |
|
||||
@@ -168,6 +168,83 @@ the reference application.
|
||||
| (string ID only) | vibrance | Vibrance | `image.adjustments.vibrance` |
|
||||
| `Wave` | wave | Wave | `filter.distort.wave` |
|
||||
| `ZgZg` | zigZag | ZigZag | `filter.distort.zigZag` |
|
||||
| (string ID only) | reverse | Reverse | `layer.arrange.reverse` |
|
||||
| (string ID only) | linkSelectedLayers | Link Layers (toggles, as measured) | `layer.linkLayers` |
|
||||
| (string ID only) | unlinkSelectedLayers | Unlink Layers | `layer.linkLayers {"linked":false}` |
|
||||
| (string ID only) | selectLinkedLayers | Select Linked Layers | `layer.selectLinkedLayers` |
|
||||
| (string ID only) | disableLayerStyle | Clear Layer Style | `layer.layerStyle.clear` |
|
||||
| (string ID only) | placedLayerMakeCopy | New Smart Object via Copy | `layer.smartObjects.newSmartObjectViaCopy` |
|
||||
| (string ID only) | placedLayerConvertToLayers | Convert to Layers | `layer.smartObjects.convertToLayers` |
|
||||
| (string ID only) | placedLayerConvertToEmbedded | Embed Linked | `layer.smartObjects.convertToEmbedded` |
|
||||
| (string ID only) | placedLayerUpdateAllModified | Update All Modified Content | `layer.smartObjects.updateAllModifiedContent` |
|
||||
| (string ID only) | rasterizeAll | Rasterize All Layers | `layer.rasterize.allLayers` |
|
||||
| (string ID only) | addBlankVideoLayer | New Blank Video Layer | `layer.videoLayers.newBlankVideoLayer` |
|
||||
| (string ID only) | isolateLayers | Isolate Layers | `select.isolateLayers` |
|
||||
| (string ID only) | textLoadDefaultTypeStyles | Load Default Type Styles | `type.loadDefaultTypeStyles` |
|
||||
| (string ID only) | textSaveDefaultTypeStyles | Save Default Type Styles | `type.saveDefaultTypeStyles` |
|
||||
| (string ID only) | recordMeasurements | Record Measurements | `image.analysis.recordMeasurements` |
|
||||
| (string ID only) | CropPhotosAuto0001 | Crop and Straighten Photos | `file.automate.cropAndStraightenPhotos` |
|
||||
| (string ID only) | placedLayerExportContents | Export Contents | `layer.smartObjects.exportContents` |
|
||||
| (string ID only) | placedLayerConvertToLinked | Convert to Linked | `layer.smartObjects.convertToLinked` |
|
||||
| (string ID only) | placedLayerRelinkToFile | Relink to File | `layer.smartObjects.relinkToFile` |
|
||||
| (string ID only) | placedLayerReplaceContents | Replace Contents | `layer.smartObjects.replaceContents` |
|
||||
| (string ID only) | shapeBlur | Shape Blur (radius-only form) | `filter.blur.shapeBlur` |
|
||||
| (string ID only) | artboardFromLayerGroupEvent | Artboard from Group | `layer.new.artboardFromGroup` |
|
||||
| (string ID only) | editArtboardEvent | Artboard background color (flags 8/1) | `layer.artboard.set` |
|
||||
|
||||
### Newer event mapping boundaries
|
||||
|
||||
The 23 requested forms in the two **Measured** tables under
|
||||
[Newer events](#newer-events-string-id-only) are mapped. Artboard from Group
|
||||
retains the current-layer target, preset tag, fractional RGB, background type
|
||||
and integer `changeBackground`, including absence. A flag of 1 or absence applies
|
||||
the background; other integers give white. An omitted type defaults to white.
|
||||
Recorded guide IDs are preserved on save and ignored on playback, as measured
|
||||
in [the guide/background reference below](#newer-events-string-id-only).
|
||||
Existing document guides remain unchanged. The preset does not resize the group.
|
||||
|
||||
The additional `editArtboardEvent` maps background-only changes with `changeSizes`
|
||||
8 and `changeBackground` 1. Its rectangle and preset remain recording metadata:
|
||||
they do not move or resize the target artboard. Colors remain in the saved step
|
||||
even for white, black or transparent backgrounds. Other flags, extra settings,
|
||||
unknown targets and forms that cannot reconstruct exactly remain whole kept
|
||||
steps. Native geometry edits without a matching wire form refuse export.
|
||||
|
||||
The sixteen target-only events accept an empty descriptor or the current-layer
|
||||
`null` reference (`Lyr `/`Ordn.Trgt`). Save retains which form was imported.
|
||||
Unknown targets or extra keys stay complete kept steps. Unrepresented native
|
||||
options are refused on export. Playback uses the native command's preconditions
|
||||
and current state. Isolate Layers toggles the panel view; type defaults remain
|
||||
session settings; Record Measurements uses the current measurement configuration.
|
||||
|
||||
Link Layers plays as the toggle the reference application performs (played twice on the same
|
||||
layers it links, then unlinks them; see the measurements below). Unlink is explicit and
|
||||
idempotent: it keeps an already unlinked selection unlinked and clears singleton link groups.
|
||||
Undo restores an edit. Explicit native layer lists cannot be exported as these targeted events.
|
||||
|
||||
The four Smart Object file events use Open/Place's `Pth `/`txtu` path encoding.
|
||||
Export Contents uses `null` for its path; Convert to Linked uses the current-layer
|
||||
`null` reference and `Usng` for its path; Relink and Replace use `null` for the path.
|
||||
A positive integer `LyrI` is a recording-session hint, never a PhotoCraft layer
|
||||
identity, and is omitted on save under the normalization rule below. Undecodable
|
||||
paths or extra keys keep the entire step. File access happens at playback; a
|
||||
missing or unusable file reports the native command's error.
|
||||
|
||||
Convert Type to Shape retains Make's `contentLayer` class reference and `Usng`
|
||||
target `textLayer` reference; it does not export a separate `convertToShape`
|
||||
event. Other Make mappings, including Solid Color and Pattern fills, are unchanged.
|
||||
Shape Blur maps only the measured radius form (`Rds ` pixels, 5–1000; omitted
|
||||
radius uses the native factory value 10). Later dialog forms carrying
|
||||
`customShape` or `keyOriginType` remain kept. Native explicit shape choices cannot
|
||||
be saved as radius-only descriptors; no custom asset lookup or new kernel is added.
|
||||
|
||||
Crop and Straighten Photos executes the native scan operation once, creating one
|
||||
document per photo found inside the selection and leaving the source unchanged.
|
||||
It requires a selected, visible layer with no pixel or full lock, including
|
||||
inherited group state, and remains unavailable for Indexed Color documents.
|
||||
The separate `CropPhotos0001` helper remains a complete kept Photoshop step.
|
||||
Playback stops at that enabled helper before subsequent duplicate/crop steps can
|
||||
run. This covers the parent event, not complete recordings with generated helpers.
|
||||
|
||||
### Settings retained by mapped events
|
||||
|
||||
@@ -314,7 +391,7 @@ Nested values as recorded (example values):
|
||||
|
||||
## Known gaps in mapped events
|
||||
|
||||
A mapped event can still lose a setting. Every mapped event was checked on 2026-11-01: the 5 296 steps of
|
||||
A mapped event can still lose a setting. The original 117-event mapping was checked on 2026-11-01: the 5 296 steps of
|
||||
the `.atn` corpus (sets the reference application recorded) and factory descriptors measured in the
|
||||
reference application went through `actions.load` and `actions.save`, and each saved descriptor was compared
|
||||
with the original. Then every step PhotoCraft saves for the cases in
|
||||
@@ -400,13 +477,16 @@ name form today; the index, ID and ordinal forms load as kept steps.
|
||||
|
||||
## Newer events (string ID only)
|
||||
|
||||
The events the reference application records for the menu items PhotoCraft has that are neither mapped
|
||||
nor in the reference below: 63 candidates from PhotoCraft's menu catalogue, each run in the reference
|
||||
The original survey covered menu events that were neither mapped nor in the reference below:
|
||||
63 candidates from PhotoCraft's menu catalogue, each run in the reference
|
||||
application without a dialog on a document prepared for it (layers, a selection, a smart object, a type
|
||||
layer, a layer style or a group) on 2026-11-01. 27 more menu items record no event of their own (puppet
|
||||
warp and warp splits, combine shapes, scripts such as Load Files into Stack and Statistics, artboard and
|
||||
video export, missing-font commands): they cannot be recorded or play as a script step.
|
||||
|
||||
The two Measured tables remain the recording reference. The mappings and remaining
|
||||
limits added since that survey are listed under [Newer event mapping boundaries](#newer-event-mapping-boundaries).
|
||||
|
||||
**Measured: no settings beyond the target.** A step with these events carries at most `null` (the target
|
||||
layer reference, `Ordn.Trgt`); mapping them needs only the event name.
|
||||
|
||||
@@ -510,6 +590,11 @@ commands record).
|
||||
with more than one layer is refused.
|
||||
- **Load Actions** with a set whose name is already in the panel adds a second set of that name; nothing is replaced.
|
||||
|
||||
- PhotoCraft preserves fractional recorded RGB values exactly. Native actions with partial settings export an empty preset and guide list when absent.
|
||||
An absent native color exports as white: it matches the native custom-color fallback and is visually ignored for white, black and transparent backgrounds.
|
||||
A custom background without a color uses the White variant (type 1); an explicit custom white color keeps type 4.
|
||||
This is canonical export metadata, not a claim about the reference application's remembered color. Imported steps retain their recorded color instead.
|
||||
|
||||
## Measured through dialogs and recordings
|
||||
|
||||
Measured on 2026-11-01 in two ways: by running the event with its dialog and pressing OK (the reference
|
||||
@@ -746,6 +831,7 @@ and string ID, the PhotoCraft command it maps to (or should map to), and every k
|
||||
order it is recorded, with type, unit, factory default and allowed values. The Supported events table says
|
||||
which of them PhotoCraft maps today; for the others an entry has everything needed to implement them. When
|
||||
an event is implemented, add it to that table in the same change.
|
||||
Current support and limits of the newer events are described under [Newer event mapping boundaries](#newer-event-mapping-boundaries).
|
||||
|
||||
### How these values were measured
|
||||
|
||||
|
||||
@@ -643,6 +643,12 @@ the document profile, retains alpha and untouched native pixels, and uses one un
|
||||
A zero tone shift validates its inputs without changing pixels. The existing RGB option keeps
|
||||
its previous behavior. Explicit Lab bounds require a composite pixel-layer target.
|
||||
|
||||
Artboard from Group action settings follow [the measured guide/background behavior](atn.md#newer-events-string-id-only):
|
||||
guide IDs are ignored session metadata, 1 or absent `changeBackground` applies the
|
||||
background, and other integer flags give white. The group's bounds are retained.
|
||||
Background-only `editArtboardEvent` uses the existing Artboard edit command; its
|
||||
recorded rectangle/preset are retained for saving, without resizing the target.
|
||||
|
||||
`crates/psd/tests/it/atn_contract.rs` checks the parser's public API against small, independently
|
||||
encoded version-16 fixtures (the version-12 ones are read by `atn_v12::`) in `crates/psd/tests/fixtures/atn/` (provenance and checksums in
|
||||
its README): `cargo test -p photocraft-psd --test it atn_contract::`.
|
||||
|
||||
@@ -151,6 +151,7 @@ The original reference entry retains its source date and historical totals; curr
|
||||
|
||||
| Date | Change | Summary |
|
||||
|---|---|---|
|
||||
| 2026-11-01 | minor | `.atn`: 23 newer measured forms mapped, including explicit Link/Unlink, Smart Object file operations, Make Type to Shape, radius-only Shape Blur, Artboard from Group and the Crop Photos parent; supported in batch 13; Link Layers keeps the measured toggle. Artboard forms with unmeasured settings and generated Crop helper steps remain kept. |
|
||||
| 2026-11-01 | minor | Recorded direct Gradient Map and Lab-range Replace Color load, play and retain their measured settings on save; unsupported forms remain preserved (part of #10607). |
|
||||
| 2026-11-01 | minor | `.atn`: event reference [atn.md](atn.md): the 117 supported events, and measured keys, defaults, ranges and enum values for 101 events not mapped yet |
|
||||
| 2026-10-31 | minor | `.atn` Group B: four Render events load, play and save; 120 supported and 97 unmapped. Supported-table columns corrected against the event registry; the original 117/101 reference entry remains historical. |
|
||||
|
||||
Reference in new issue
Block a user