mirror of
https://github.com/storytold/photocraft.git
synced 2026-12-02 06:20:48 +01:00
Integration: track t14
This commit is contained in:
commit
e1d2596bd8
53 files changed
+3356
-912
No files matched your search
@@ -796,3 +796,121 @@ fn batch_plays_a_photoshop_actions_file() {
|
||||
assert!(err.contains("Generative Fill"), "{err}");
|
||||
assert!(!o.status.success());
|
||||
}
|
||||
|
||||
/// `photocraft_cli::run` in-process: `(exit code, stdout, stderr)`.
|
||||
fn invoke(args: &[&str]) -> (i32, String, String) {
|
||||
let (mut out, mut err) = (Vec::new(), Vec::new());
|
||||
let args: Vec<String> = args.iter().map(|s| s.to_string()).collect();
|
||||
let code = photocraft_cli::run(&args, &mut out, &mut err);
|
||||
(code, String::from_utf8(out).unwrap(), String::from_utf8(err).unwrap())
|
||||
}
|
||||
|
||||
const SUBCOMMANDS: [&str; 8] = ["convert", "info", "run", "batch", "droplet", "commands", "mcp", "serve"];
|
||||
|
||||
/// Pins top-level dispatch: help goes to stdout (exit 0), no arguments is a usage error on stderr.
|
||||
#[test]
|
||||
fn top_level_help_version_and_no_arguments() {
|
||||
let (code, out, err) = invoke(&[]);
|
||||
assert_eq!((code, out.is_empty(), err.is_empty()), (2, true, false));
|
||||
for help in ["--help", "-h", "help"] {
|
||||
let (code, out, err) = invoke(&[help]);
|
||||
assert_eq!((code, out.is_empty(), err.is_empty()), (0, false, true), "{help}");
|
||||
}
|
||||
for version in ["--version", "version"] {
|
||||
let (code, out, err) = invoke(&[version]);
|
||||
assert_eq!((code, err.as_str()), (0, ""), "{version}");
|
||||
assert!(out.starts_with("photocraft-cli "), "{version}: {out}");
|
||||
}
|
||||
let (code, out, err) = invoke(&["frobnicate"]);
|
||||
assert_eq!((code, out.is_empty()), (2, true));
|
||||
assert!(err.contains("frobnicate"), "{err}");
|
||||
}
|
||||
|
||||
/// `<sub> --help` / `-h` prints help on stdout and returns without running the subcommand
|
||||
/// (`mcp` and `serve` would otherwise block on stdin).
|
||||
#[test]
|
||||
fn every_subcommand_help_returns_on_stdout() {
|
||||
for sub in SUBCOMMANDS {
|
||||
for help in ["--help", "-h"] {
|
||||
let (code, out, err) = invoke(&[sub, help]);
|
||||
assert_eq!((code, out.is_empty(), err.is_empty()), (0, false, true), "{sub} {help}: {err}");
|
||||
// `commands` would also exit 0 with output if it ran; its list names `file.new`, help doesn't.
|
||||
assert!(!out.contains("file.new"), "{sub} {help} ran instead of printing help: {out}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Every subcommand refuses an unknown flag (bare or `=value`) with exit 2, naming it on stderr.
|
||||
#[test]
|
||||
fn every_subcommand_rejects_an_unknown_flag() {
|
||||
for sub in SUBCOMMANDS {
|
||||
for flag in [&["--fromat"][..], &["--fromat=jpg"][..], &["--fromat", "jpg"][..]] {
|
||||
let args: Vec<&str> = [sub].into_iter().chain(flag.iter().copied()).collect();
|
||||
let (code, out, err) = invoke(&args);
|
||||
assert_eq!((code, out.is_empty()), (2, true), "{args:?}: {err}");
|
||||
assert!(err.contains("--fromat"), "{args:?}: {err}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// `--flag=value`, a bare flag given a value, a value flag without one, and repeated flags.
|
||||
#[test]
|
||||
fn flag_value_forms_and_repeats() {
|
||||
let ids = |out: &str| out.lines().filter_map(|l| l.split_whitespace().next()).map(str::to_owned).collect::<Vec<_>>();
|
||||
let (code, eq, err) = invoke(&["commands", "--filter=file.new"]);
|
||||
assert_eq!(code, 0, "{err}");
|
||||
let (_, spaced, _) = invoke(&["commands", "--filter", "file.new"]);
|
||||
assert_eq!(eq, spaced);
|
||||
assert!(ids(&eq).contains(&"file.new".to_string()), "{eq}");
|
||||
// The last of a repeated value flag wins, whichever order they come in.
|
||||
let (code, out, err) = invoke(&["commands", "--filter", "zzz-no-match", "--filter", "file.new"]);
|
||||
assert_eq!(code, 0, "{err}");
|
||||
assert_eq!(out, eq);
|
||||
let (code, out, err) = invoke(&["commands", "--filter", "file.new", "--filter", "zzz-no-match"]);
|
||||
assert_eq!(code, 0, "{err}");
|
||||
assert!(out.is_empty(), "{out}");
|
||||
// A bare flag takes no value; a value flag needs one.
|
||||
let (code, out, err) = invoke(&["commands", "--json=1"]);
|
||||
assert_eq!((code, out.is_empty()), (2, true));
|
||||
assert!(err.contains("--json"), "{err}");
|
||||
let (code, out, err) = invoke(&["commands", "--filter"]);
|
||||
assert_eq!((code, out.is_empty()), (2, true));
|
||||
assert!(err.contains("--filter"), "{err}");
|
||||
}
|
||||
|
||||
/// Each `--params` applies to the `--cmd` before it; a `--cmd` without one gets `{}`; a
|
||||
/// `--params` ahead of every `--cmd` fails naming `--params`.
|
||||
#[test]
|
||||
fn run_pairs_params_with_the_preceding_cmd() {
|
||||
let (code, out, err) = invoke(&[
|
||||
"run",
|
||||
"--new",
|
||||
r#"{"width":8,"height":8}"#,
|
||||
"--cmd",
|
||||
"layer.new.layer",
|
||||
"--params",
|
||||
r#"{"name":"First"}"#,
|
||||
"--cmd",
|
||||
"layer.new.layer",
|
||||
"--cmd",
|
||||
"layer.new.layer",
|
||||
"--params",
|
||||
r#"{"name":"Third"}"#,
|
||||
"--cmd",
|
||||
"document.inspect",
|
||||
]);
|
||||
assert_eq!(code, 0, "{err}");
|
||||
let rows: Vec<Value> = out.lines().map(|l| serde_json::from_str(l).unwrap()).collect();
|
||||
assert_eq!(rows.len(), 4, "{out}");
|
||||
let names: Vec<&str> = rows[3]["result"]["layers"].as_array().unwrap().iter().filter_map(|l| l["name"].as_str()).collect();
|
||||
let count = |n: &str| names.iter().filter(|x| **x == n).count();
|
||||
assert_eq!((count("First"), count("Third")), (1, 1), "each --params applies to its own --cmd only: {names:?}");
|
||||
// Three new layers plus the background; the middle one (no --params) has a default name.
|
||||
assert_eq!(names.len(), 4, "{names:?}");
|
||||
// Layers list top first: Third, the unnamed middle one, First, Background. Pairing --params
|
||||
// with --cmd by position (params[i] -> cmd[i]) would name the middle one Third instead.
|
||||
assert_eq!((names[0], names[2]), ("Third", "First"), "{names:?}");
|
||||
let (code, _, err) = invoke(&["run", "--new", "{}", "--params", "{}", "--cmd", "layer.new.layer"]);
|
||||
assert_ne!(code, 0);
|
||||
assert!(err.contains("--params"), "{err}");
|
||||
}
|
||||
@@ -2221,7 +2221,13 @@ pub(crate) fn composite_with_effects_prepared(
|
||||
let i = ((y - rect.y0) as usize) * rect.width() as usize + (x - rect.x0) as usize;
|
||||
let a = before.px[i];
|
||||
let b = if x >= big.x0 && x < big.x1 && y >= big.y0 && y < big.y1 { work.px[((y - big.y0) as usize) * w + (x - big.x0) as usize] } else { a };
|
||||
backdrop.px[i] = mix_premul(a, b, op);
|
||||
backdrop.px[i] = if layer.blend == BlendMode::Dissolve {
|
||||
// Dissolve applies layer opacity to the completed interior/exterior effect
|
||||
// stack as pixel coverage, not continuous gray interpolation (#3051).
|
||||
if crate::dissolve_noise(x, y) < op { b } else { a }
|
||||
} else {
|
||||
mix_premul(a, b, op)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1900,6 +1900,14 @@ fn composite_layer_plain(layer: &Layer, clipped: &[Layer], backdrop: &mut Buffer
|
||||
// Only `adjusted` has changed; this pixel's original backdrop is still in place.
|
||||
let b = backdrop.px[i];
|
||||
let a = adjusted.px[i];
|
||||
if layer.blend == BlendMode::Dissolve {
|
||||
// An adjustment has no standalone source alpha. Its effective coverage
|
||||
// comes from its own opacity and mask, not a continuous RGB mix (#3050).
|
||||
if dissolve_noise(x, y) < k {
|
||||
backdrop.px[i] = [a[0], a[1], a[2], b[3]];
|
||||
}
|
||||
continue;
|
||||
}
|
||||
let blended = blend::blend_rgb(layer.blend, [b[0], b[1], b[2]], [a[0], a[1], a[2]]);
|
||||
backdrop.px[i] = [b[0] + (blended[0] - b[0]) * k, b[1] + (blended[1] - b[1]) * k, b[2] + (blended[2] - b[2]) * k, b[3]];
|
||||
}
|
||||
@@ -2265,6 +2273,14 @@ fn composite_atop_any(layer: &Layer, base: &mut Buffer, cx: &Ctx) {
|
||||
for (i, p) in base.px.iter_mut().enumerate() {
|
||||
let k = layer.opacity * layer.fill_opacity * mask_k(&mv, i);
|
||||
let a = adjusted.px[i];
|
||||
if layer.blend == BlendMode::Dissolve {
|
||||
let x = rect.x0 + (i % rect.width() as usize) as i32;
|
||||
let y = rect.y0 + (i / rect.width() as usize) as i32;
|
||||
if dissolve_noise(x, y) < k {
|
||||
*p = [a[0], a[1], a[2], p[3]];
|
||||
}
|
||||
continue;
|
||||
}
|
||||
let bl = blend::blend_rgb(layer.blend, [p[0], p[1], p[2]], [a[0], a[1], a[2]]);
|
||||
for c in 0..3 {
|
||||
p[c] += (bl[c] - p[c]) * k;
|
||||
@@ -2311,6 +2327,16 @@ fn composite_atop_any(layer: &Layer, base: &mut Buffer, cx: &Ctx) {
|
||||
continue;
|
||||
}
|
||||
let s = content.px[i];
|
||||
if layer.blend == BlendMode::Dissolve {
|
||||
// Clipping preserves the opaque base's alpha. Dissolve still selects source
|
||||
// pixels by spatial coverage instead of continuously mixing the colours (#3052).
|
||||
let x = rect.x0 + (i as i32 % rect.width() as i32);
|
||||
let y = rect.y0 + (i as i32 / rect.width() as i32);
|
||||
if dissolve_noise(x, y) < s[3] * opacity {
|
||||
*p = [s[0], s[1], s[2], alpha];
|
||||
}
|
||||
continue;
|
||||
}
|
||||
// Blend as if the base were opaque, then keep the base's alpha.
|
||||
let r = blend::composite_gamma(layer.blend, [p[0], p[1], p[2], 1.0], s, opacity, gamma);
|
||||
*p = [r[0], r[1], r[2], alpha];
|
||||
|
||||
@@ -505,6 +505,65 @@ fn clipping_mask_restricts_to_base_alpha() {
|
||||
assert!(close4(px(&d, 6, 1), [1.0; 4]), "outside base: clipped layer hidden");
|
||||
}
|
||||
|
||||
/// #3052 / #4921: clipped Dissolve must apply layer Opacity × Fill as binary coverage,
|
||||
/// restricted to the clipping base's shape.
|
||||
#[test]
|
||||
fn clipped_dissolve_opacity_fill_is_binary_and_preserves_base_shape() {
|
||||
let mut d = doc_white(40, 12);
|
||||
d.layers.push(solid_layer("base", Rect::new(0, 0, 20, 12), [0.0, 0.0, 1.0, 1.0]));
|
||||
let mut clip = solid_layer("clip", d.bounds(), [1.0, 0.0, 0.0, 1.0]);
|
||||
clip.clipped = true;
|
||||
clip.blend = BlendMode::Dissolve;
|
||||
clip.opacity = 0.6;
|
||||
clip.fill_opacity = 0.5;
|
||||
d.layers.push(clip);
|
||||
let mut red = 0;
|
||||
let mut blue = 0;
|
||||
for y in 0..12 {
|
||||
for x in 0..20 {
|
||||
let p = px(&d, x, y);
|
||||
if close4(p, [1.0, 0.0, 0.0, 1.0]) {
|
||||
red += 1;
|
||||
} else {
|
||||
assert!(close4(p, [0.0, 0.0, 1.0, 1.0]), "Dissolve must not interpolate: {p:?} at ({x},{y})");
|
||||
blue += 1;
|
||||
}
|
||||
}
|
||||
assert!(close4(px(&d, 30, y), [1.0; 4]), "outside the base the clip is invisible");
|
||||
}
|
||||
assert!(red > 0 && blue > 0, "Dissolve must expose both source and base: {red}/{blue}");
|
||||
assert!((red as f32 / (red + blue) as f32 - 0.3).abs() < 0.1, "coverage should follow 60% opacity × 50% fill: {red}/{blue}");
|
||||
}
|
||||
|
||||
/// Dissolve noise uses document coordinates, not the region origin; checked across
|
||||
/// negative coordinates, tile boundaries, and all supported RGB sample depths.
|
||||
#[test]
|
||||
fn clipped_dissolve_matches_whole_render_at_offset_regions_and_depths() {
|
||||
for fmt in [PixelFormat::RGBA8, PixelFormat::RGBA16, PixelFormat::RGBA32F] {
|
||||
let mut d = Document::new("coverage", Size::new(32, 18), ColorMode::Rgb, fmt.sample);
|
||||
let bounds = Rect::new(-3, -2, 32, 18);
|
||||
let mut base = Layer::raster("base", fmt);
|
||||
base.surface_mut().unwrap().fill_rect(bounds, &[0.0, 0.0, 1.0, 0.5]);
|
||||
d.layers.push(base);
|
||||
let mut clip = Layer::raster("clip", fmt);
|
||||
clip.surface_mut().unwrap().fill_rect(bounds, &[1.0, 0.0, 0.0, 0.75]);
|
||||
clip.clipped = true;
|
||||
clip.blend = BlendMode::Dissolve;
|
||||
clip.opacity = 0.6;
|
||||
clip.fill_opacity = 0.5;
|
||||
d.layers.push(clip);
|
||||
let whole = render(&d, bounds);
|
||||
for region in [Rect::new(-3, -2, 5, 4), Rect::new(5, 4, 17, 11), Rect::new(17, 11, 32, 18)] {
|
||||
let part = render(&d, region);
|
||||
for y in region.y0..region.y1 {
|
||||
for x in region.x0..region.x1 {
|
||||
assert!(close4(part.get(x, y), whole.get(x, y)), "{fmt:?}: region mismatch at ({x},{y})");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hidden_base_hides_clipping_group() {
|
||||
let mut d = doc_white(4, 4);
|
||||
@@ -3740,3 +3799,105 @@ fn fully_masked_adjustment_tiles_preserve_output_and_skip_tone_work() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn dissolve_adjustment_resolves_opacity_to_binary_coverage() {
|
||||
let mut d = doc_white(16, 16);
|
||||
let mut layer = Layer::new("Invert", LayerContent::Adjustment(Adjustment::Invert));
|
||||
layer.blend = BlendMode::Dissolve;
|
||||
layer.opacity = 0.5;
|
||||
d.layers.push(layer);
|
||||
let pixels = render(&d, d.bounds()).px;
|
||||
let black = pixels.iter().filter(|p| p[0] < 0.01).count();
|
||||
let white = pixels.iter().filter(|p| p[0] > 0.99).count();
|
||||
assert!(black > 0 && white > 0, "Dissolve must select both original and adjusted pixels");
|
||||
assert_eq!(black + white, pixels.len(), "no intermediate gray pixels");
|
||||
d.layers.last_mut().unwrap().blend = BlendMode::Normal;
|
||||
let continuous = render(&d, d.bounds()).px;
|
||||
assert!(continuous.iter().all(|p| (p[0] - 0.5).abs() < E), "Normal remains continuously interpolated");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn clipped_dissolve_fill_matches_opaque_unclipped_coverage() {
|
||||
let mut d = doc_white(16, 16);
|
||||
let mut fill = Layer::new("Black", LayerContent::Fill(Fill::Solid(Color::BLACK)));
|
||||
fill.blend = BlendMode::Dissolve;
|
||||
fill.opacity = 0.5;
|
||||
d.layers.push(fill);
|
||||
let control = render(&d, d.bounds()).px;
|
||||
d.layers.last_mut().unwrap().clipped = true;
|
||||
let clipped = render(&d, d.bounds()).px;
|
||||
assert_eq!(clipped, control, "clipping over a fully opaque base must preserve dissolve pixels");
|
||||
let black = clipped.iter().filter(|p| p[0] < 0.01).count();
|
||||
assert!(black > 0 && black < clipped.len());
|
||||
d.layers.last_mut().unwrap().blend = BlendMode::Normal;
|
||||
let continuous = render(&d, d.bounds()).px;
|
||||
assert!(continuous.iter().all(|p| (p[0] - 0.5).abs() < E));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn dissolve_color_overlay_preserves_binary_layer_coverage() {
|
||||
let mut d = doc_white(16, 16);
|
||||
let mut layer = Layer::new("Black", LayerContent::Fill(Fill::Solid(Color::BLACK)));
|
||||
layer.blend = BlendMode::Dissolve;
|
||||
layer.opacity = 0.5;
|
||||
d.layers.push(layer);
|
||||
let control = render(&d, d.bounds()).px;
|
||||
d.layers
|
||||
.last_mut()
|
||||
.unwrap()
|
||||
.effects
|
||||
.items
|
||||
.push(photocraft_doc::Effect::ColorOverlay { common: photocraft_doc::FxCommon::new(BlendMode::Normal, 1.0), color: Color::BLACK });
|
||||
let styled = render(&d, d.bounds()).px;
|
||||
assert_eq!(styled, control, "an identity overlay should not turn dissolve pixels gray");
|
||||
d.layers.last_mut().unwrap().blend = BlendMode::Normal;
|
||||
let continuous = render(&d, d.bounds()).px;
|
||||
assert!(continuous.iter().all(|p| (p[0] - 0.5).abs() < E));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn clipped_dissolve_adjustment_preserves_alpha_and_document_coverage() {
|
||||
for fmt in [PixelFormat::RGBA8, PixelFormat::RGBA16, PixelFormat::RGBA32F] {
|
||||
let mut d = Document::new("clipped adjustment", Size::new(272, 12), ColorMode::Rgb, fmt.sample);
|
||||
let bounds = Rect::new(-3, -2, 272, 12);
|
||||
let mut base = Layer::raster("base", fmt);
|
||||
base.surface_mut().unwrap().fill_rect(bounds, &[1.0, 1.0, 1.0, 0.5]);
|
||||
d.layers.push(base);
|
||||
let original = render(&d, bounds);
|
||||
let mut adjustment = Layer::new("invert", LayerContent::Adjustment(Adjustment::Invert));
|
||||
adjustment.clipped = true;
|
||||
adjustment.blend = BlendMode::Dissolve;
|
||||
adjustment.opacity = 0.6;
|
||||
adjustment.fill_opacity = 0.5;
|
||||
let mut mask = photocraft_raster::Surface::new(PixelFormat::GRAY8);
|
||||
mask.fill_rect(Rect::new(-3, -2, 260, 12), &[1.0]);
|
||||
adjustment.mask = Some(LayerMask { surface: mask, enabled: true, linked: true, density: 1.0, feather: 0.0 });
|
||||
d.layers.push(adjustment);
|
||||
let whole = render(&d, bounds);
|
||||
let mut changed = 0;
|
||||
for y in bounds.y0..bounds.y1 {
|
||||
for x in bounds.x0..bounds.x1 {
|
||||
let p = whole.get(x, y);
|
||||
let value = if x < 260 && dissolve_noise(x, y) < 0.3 {
|
||||
changed += 1;
|
||||
0.0
|
||||
} else {
|
||||
1.0
|
||||
};
|
||||
assert!(close4(p, [value, value, value, original.get(x, y)[3]]), "{fmt:?} at ({x}, {y}): {p:?}");
|
||||
}
|
||||
}
|
||||
assert!(changed > 0 && changed < whole.px.len());
|
||||
let region = Rect::new(250, 1, 270, 10);
|
||||
let part = render(&d, region);
|
||||
for y in region.y0..region.y1 {
|
||||
for x in region.x0..region.x1 {
|
||||
assert!(close4(part.get(x, y), whole.get(x, y)), "{fmt:?} region at ({x}, {y})");
|
||||
}
|
||||
}
|
||||
d.layers.last_mut().unwrap().blend = BlendMode::Normal;
|
||||
let normal = render(&d, bounds);
|
||||
assert!(normal.px.iter().any(|p| p[0] > 0.01 && p[0] < 0.99), "Normal keeps continuous mixing");
|
||||
}
|
||||
}
|
||||
@@ -389,15 +389,20 @@ pub fn finish_playback(s: &mut Session, recording: Option<(usize, usize)>, actio
|
||||
s.actions.playback_stack.pop();
|
||||
s.actions.playing = s.actions.playing.saturating_sub(1);
|
||||
if let Some((_, idx)) = recording {
|
||||
s.actions.recording = Some((s.journal.len(), idx));
|
||||
let mut params = json!({"action": action.name});
|
||||
if from > 0 {
|
||||
params["from"] = json!(from);
|
||||
}
|
||||
s.journal.push(("actions.play".into(), params));
|
||||
restore_recording(s, idx, &action.name, from);
|
||||
}
|
||||
}
|
||||
|
||||
/// Resume recording into action `idx` and journal the named call that suspended it.
|
||||
pub fn restore_recording(s: &mut Session, idx: usize, action: &str, from: usize) {
|
||||
s.actions.recording = Some((s.journal.len(), idx));
|
||||
let mut params = json!({"action": action});
|
||||
if from > 0 {
|
||||
params["from"] = json!(from);
|
||||
}
|
||||
s.journal.push(("actions.play".into(), params));
|
||||
}
|
||||
|
||||
/// Nested playback returns a structured failure even though the command itself succeeded.
|
||||
/// Promote it to the caller's failed step so no later parent steps run after a child fails.
|
||||
pub fn nested_failure(id: &str, value: &Value) -> Option<String> {
|
||||
|
||||
@@ -1203,8 +1203,18 @@ fn make_from(d: &Descriptor) -> Mapped {
|
||||
if let Some(n) = using.and_then(|u| get_text(u, "Nm ")) {
|
||||
p.insert("name".into(), n.into());
|
||||
}
|
||||
let id = if get_ref(d, "From").is_some() { "layer.groupLayers" } else { "layer.new.group" };
|
||||
step(id, Value::Object(p))
|
||||
match get_ref(d, "From") {
|
||||
// A named source layer stays the source (#7236); a target reference and an
|
||||
// index/id source (our exporter never writes those) keep the old implicit
|
||||
// import: the group lands on the current selection at playback.
|
||||
Some(r) => {
|
||||
if let Some(t) = layer_target(r) {
|
||||
p.extend(t);
|
||||
}
|
||||
step("layer.groupLayers", Value::Object(p))
|
||||
}
|
||||
None => step("layer.new.group", Value::Object(p)),
|
||||
}
|
||||
}
|
||||
_ => Mapped::Unsupported { harmless: false },
|
||||
}
|
||||
@@ -1231,7 +1241,9 @@ fn make_to(id: &str, p: &Value) -> Option<Descriptor> {
|
||||
}
|
||||
"layer.new.group" => desc("null").with("null", class_ref("layerSection")).with("Usng", D::Descriptor(with_name("layerSection"))),
|
||||
"layer.groupLayers" => {
|
||||
desc("null").with("null", class_ref("layerSection")).with("From", target_ref("Lyr ")).with("Usng", D::Descriptor(with_name("layerSection")))
|
||||
// An explicit source layer goes in by name like every other layer reference; a
|
||||
// step without one keeps the target-layer form (#7236).
|
||||
desc("null").with("null", class_ref("layerSection")).with("From", layer_ref(p)).with("Usng", D::Descriptor(with_name("layerSection")))
|
||||
}
|
||||
"layer.new.layerViaCopy" | "layer.new.layerViaCut" => {
|
||||
let mut d = desc("null").with("Nw ", D::Descriptor(desc("Lyr "))).with("Usng", enm("ArSl", "Slct"));
|
||||
@@ -1497,6 +1509,10 @@ fn set_to(id: &str, p: &Value) -> Option<Descriptor> {
|
||||
.with("T ", D::Descriptor(color_desc(hex)?))
|
||||
}
|
||||
"select.rect" => {
|
||||
match jstr(p, "mode") {
|
||||
None | Some("replace") => {}
|
||||
Some(_) => return None,
|
||||
}
|
||||
let (x, y, w, h) = (jnum(p, "x")?, jnum(p, "y")?, jnum(p, "width")?, jnum(p, "height")?);
|
||||
let cls = if jbool(p, "ellipse") == Some(true) { "Elps" } else { "Rctn" };
|
||||
sel(D::Descriptor(desc(cls).with("Top ", px(y)).with("Left", px(x)).with("Btom", px(y + h)).with("Rght", px(x + w))))
|
||||
@@ -1605,7 +1621,11 @@ fn select_to(id: &str, p: &Value) -> Option<Descriptor> {
|
||||
let enumerated = |cls: &str, ty: &str, v: &str| D::Reference(vec![ReferenceItem::Enumerated { class: class(cls), type_id: code(ty), value: code(v) }]);
|
||||
Some(match id {
|
||||
"layer.select" => {
|
||||
let mut d = desc("null").with("null", name_ref("Lyr ", jstr(p, "layer")?));
|
||||
if p.get("occurrence").is_some() {
|
||||
return None;
|
||||
}
|
||||
let name = jstr(p, "name").or_else(|| jstr(p, "layer"))?;
|
||||
let mut d = desc("null").with("null", name_ref("Lyr ", name));
|
||||
match jstr(p, "mode") {
|
||||
None | Some("replace") => {}
|
||||
Some("add") => d = d.with("selectionModifier", enm("selectionModifierType", "addToSelection")),
|
||||
@@ -1783,8 +1803,15 @@ fn transform_from(d: &Descriptor) -> Mapped {
|
||||
// to keep its sub-pixel placement and interpolation.
|
||||
let whole_pixels = ["dx", "dy"].iter().all(|k| p.get(*k).and_then(Value::as_f64).is_none_or(|v| v.fract() == 0.0));
|
||||
let geometry_only = p.keys().all(|k| k == "dx" || k == "dy") && whole_pixels;
|
||||
// The resampling applies to a selection as much as to a layer (#7515).
|
||||
let interpolation = get_enum(d, "Intr").and_then(|i| lookup(INTERPOLATION, &i)).filter(|i| matches!(*i, "bicubic" | "bilinear" | "nearest"));
|
||||
match (ref_class(r).as_deref(), target(r)) {
|
||||
(Some("Chnl"), Target::Property(prop)) if prop == "fsel" => step("select.transformSelection", Value::Object(p)),
|
||||
(Some("Chnl"), Target::Property(prop)) if prop == "fsel" => {
|
||||
if let Some(i) = interpolation {
|
||||
p.insert("interpolation".into(), i.into());
|
||||
}
|
||||
step("select.transformSelection", Value::Object(p))
|
||||
}
|
||||
(Some("Lyr"), _) => {
|
||||
let Some(mut lp) = layer_target(r) else { return unsupported };
|
||||
if geometry_only {
|
||||
@@ -1793,7 +1820,7 @@ fn transform_from(d: &Descriptor) -> Mapped {
|
||||
return step("layer.translate", Value::Object(lp));
|
||||
}
|
||||
lp.extend(p);
|
||||
if let Some(i) = get_enum(d, "Intr").and_then(|i| lookup(INTERPOLATION, &i)).filter(|i| matches!(*i, "bicubic" | "bilinear" | "nearest")) {
|
||||
if let Some(i) = interpolation {
|
||||
lp.insert("interpolation".into(), i.into());
|
||||
}
|
||||
step("edit.transform", Value::Object(lp))
|
||||
@@ -1803,10 +1830,22 @@ fn transform_from(d: &Descriptor) -> Mapped {
|
||||
}
|
||||
|
||||
fn transform_to(id: &str, p: &Value) -> Option<Descriptor> {
|
||||
if p.get("quad").is_some() || p.get("matrix").is_some() || p.get("rect").is_some() {
|
||||
let given = |k: &str| p.get(k).is_some_and(|v| !v.is_null());
|
||||
if ["quad", "corners", "matrix", "rect"].iter().any(|k| given(k)) {
|
||||
return None;
|
||||
}
|
||||
// The descriptor scales and rotates about the centre (`FTcs` average) without skew or warp:
|
||||
// another reference point, a skew or a warp would replay as a different transform (#7516,
|
||||
// #7517, #7518, #7519).
|
||||
let nonzero = |k: &str| p.get(k).is_some_and(|v| !v.is_null() && v.as_f64() != Some(0.0));
|
||||
let off_centre = p.get("reference").is_some_and(|v| !v.is_null() && *v != json!("center"));
|
||||
if nonzero("skewX") || nonzero("skewY") || off_centre || ["warp", "style", "mesh", "grid"].iter().any(|k| given(k)) {
|
||||
return None;
|
||||
}
|
||||
let target = match id {
|
||||
// The `Trnf` descriptor has no field for a mask, Quick Mask or alpha channel target; a
|
||||
// layer reference would transform the layer's pixels instead.
|
||||
"edit.transform" if !pixel_target(p) => return None,
|
||||
"edit.transform" => layer_ref(p),
|
||||
"select.transformSelection" => D::Reference(vec![ReferenceItem::Property { class: class("Chnl"), key: code("fsel") }]),
|
||||
_ => return None,
|
||||
@@ -1892,6 +1931,15 @@ fn apply_image_from(d: &Descriptor) -> Mapped {
|
||||
}
|
||||
|
||||
fn apply_image_to(_: &str, p: &Value) -> Option<Descriptor> {
|
||||
// The optional blending mask has no descriptor mapping: refuse it rather than drop it,
|
||||
// which would widen the edit to the whole layer.
|
||||
let mask_channel = match p.get("mask") {
|
||||
Some(m) => m.get("channel"),
|
||||
None => p.get("maskChannel"),
|
||||
};
|
||||
if mask_channel.is_some_and(|c| !(c.is_null() || c == "none" || c == "")) {
|
||||
return None;
|
||||
}
|
||||
let source = p.get("source").cloned().unwrap_or(json!({}));
|
||||
let channel = jstr(&source, "channel").unwrap_or("composite");
|
||||
let chan = lookup_back(SOURCE_CHANNELS, channel).or_else(|| lookup_back(CHANNELS, channel))?;
|
||||
@@ -2143,6 +2191,20 @@ fn duplicate_to(id: &str, p: &Value) -> Option<Descriptor> {
|
||||
Some(d)
|
||||
}
|
||||
|
||||
/// Only a comp name in the active document is portable across action playback.
|
||||
fn apply_comp_from(d: &Descriptor) -> Mapped {
|
||||
match get_ref(d, "null") {
|
||||
Some([ReferenceItem::Name { class, name }]) if trimmed(&class.class_id) == "compsClass" => {
|
||||
step("layerComp.apply", json!({"comp": name.to_string_lossy()}))
|
||||
}
|
||||
_ => Mapped::Unsupported { harmless: false },
|
||||
}
|
||||
}
|
||||
|
||||
fn apply_comp_to(_: &str, p: &Value) -> Option<Descriptor> {
|
||||
Some(desc("null").with("null", name_ref("compsClass", jstr(p, "comp")?)))
|
||||
}
|
||||
|
||||
fn play_from(d: &Descriptor) -> Mapped {
|
||||
match get_ref(d, "null").map(target) {
|
||||
Some(Target::Name(n)) => step("actions.play", json!({"action": n})),
|
||||
@@ -2628,6 +2690,16 @@ fn shadows_highlights_to(_: &str, p: &Value) -> Option<Descriptor> {
|
||||
}
|
||||
|
||||
fn image_size_to(_: &str, p: &Value) -> Option<Descriptor> {
|
||||
// Resolution only with Resample on imports as keep-print-size; a command without it cannot be told apart.
|
||||
if jnum(p, "resolution").is_some()
|
||||
&& jnum(p, "width").is_none()
|
||||
&& jnum(p, "height").is_none()
|
||||
&& jnum(p, "percent").is_none()
|
||||
&& jstr(p, "resample").is_some_and(|r| r != "none")
|
||||
&& jbool(p, "keepPrintSize") != Some(true)
|
||||
{
|
||||
return None;
|
||||
}
|
||||
let mut d = desc("null");
|
||||
if let Some(pc) = jnum(p, "percent") {
|
||||
d = d.with("Wdth", pct(pc)).with("Hght", pct(pc)).with("CnsP", D::Boolean(true));
|
||||
@@ -3419,6 +3491,7 @@ const EVENTS: &[Event] = &[
|
||||
ev!("save", "save", "Save", "file.save", &[]),
|
||||
ev!("Rvrt", "revert", "Revert", "file.revert", &[]),
|
||||
Event { code: "Ply ", name: "play", label: "Play", ids: &["actions.play"], from: play_from, to: play_to },
|
||||
Event { code: "", name: "applyComp", label: "Apply Layer Comp", ids: &["layerComp.apply"], from: apply_comp_from, to: apply_comp_to },
|
||||
Event { code: "Stop", name: "stop", label: "Stop", ids: &[STOP_MESSAGE], from: stop_from, to: stop_to },
|
||||
];
|
||||
|
||||
|
||||
@@ -66,6 +66,105 @@ fn sample() -> AtnFile {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn layer_comp_apply_imports_plays_and_undoes() {
|
||||
let name = "合成 𠮷";
|
||||
let data = set_of("Comps", vec![("Apply", vec![item("applyComp", "Apply Layer Comp", Some(desc("null").with("null", name_ref("compsClass", name))))])]);
|
||||
for depth in [8, 16, 32] {
|
||||
let mut s = Session::new();
|
||||
let loaded = s.execute("actions.load", json!({"data": data})).unwrap();
|
||||
assert_eq!(loaded["unsupported"], json!([]), "{loaded}");
|
||||
assert_eq!(s.actions.list[0].steps, [("layerComp.apply".into(), json!({"comp": name}))]);
|
||||
|
||||
s.execute("file.new", json!({"width": 8, "height": 8, "depth": depth})).unwrap();
|
||||
s.execute("layerComp.new", json!({"name": "Other"})).unwrap();
|
||||
let before = s.active().unwrap().doc.clone();
|
||||
let played = s.execute("actions.play", json!({"action": "Apply"})).unwrap();
|
||||
assert_eq!(played["ran"], 0, "{played}");
|
||||
assert!(played["failed"]["error"].as_str().unwrap().contains(name), "{played}");
|
||||
assert_eq!(*s.active().unwrap().doc, *before, "a missing comp must not apply another comp");
|
||||
|
||||
let comp = s.execute("layerComp.new", json!({"name": name})).unwrap()["comp"].clone();
|
||||
let layer = s.active().unwrap().active_layer.unwrap();
|
||||
s.execute("layer.setProps", json!({"visible": false})).unwrap();
|
||||
s.execute("layerComp.new", json!({"name": "Hidden"})).unwrap();
|
||||
let played = s.execute("actions.play", json!({"action": "Apply"})).unwrap();
|
||||
assert_eq!(played["ran"], 1, "{played}");
|
||||
assert!(played.get("failed").is_none(), "{played}");
|
||||
assert!(s.active().unwrap().doc.layer(layer).unwrap().visible);
|
||||
assert_eq!(json!(s.active().unwrap().doc.last_applied_comp), comp);
|
||||
assert!(s.undo());
|
||||
assert!(!s.active().unwrap().doc.layer(layer).unwrap().visible);
|
||||
assert!(s.redo());
|
||||
assert!(s.active().unwrap().doc.layer(layer).unwrap().visible);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn layer_comp_apply_round_trips_by_name() {
|
||||
for name in ["Comp 1", "合成 𠮷"] {
|
||||
let descriptor = desc("null").with("null", name_ref("compsClass", name));
|
||||
let data = set_of("Comps", vec![("Apply", vec![item("applyComp", "Apply Layer Comp", Some(descriptor.clone()))])]);
|
||||
let mut s = Session::new();
|
||||
let loaded = s.execute("actions.load", json!({"data": data})).unwrap();
|
||||
assert_eq!(loaded["unsupported"], json!([]), "{loaded}");
|
||||
let saved = s.execute("actions.save", json!({"set": "Comps"})).unwrap();
|
||||
assert_eq!(saved["skipped"], json!([]));
|
||||
let bytes = photocraft_paint::tile::b64_decode(saved["data"].as_str().unwrap()).unwrap();
|
||||
let file = atn::parse(&bytes).unwrap();
|
||||
assert_eq!(file.actions[0].items[0].event, AtnEvent::Name("applyComp".into()));
|
||||
assert_eq!(file.actions[0].items[0].descriptor, Some(descriptor));
|
||||
let mut reloaded = Session::new();
|
||||
reloaded.execute("actions.load", json!({"data": saved["data"]})).unwrap();
|
||||
assert_eq!(reloaded.actions.list, s.actions.list);
|
||||
}
|
||||
// Local comp ids and the default comp cannot be resolved to a portable name at export.
|
||||
for params in [json!({}), json!({"comp": 1}), json!({"comp": null}), json!({"comp": true}), json!({"comp": []})] {
|
||||
assert!(export_item("layerComp.apply", ¶ms, "Comps").is_none(), "{params}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn layer_comp_apply_unknown_references_are_kept_and_stop_playback() {
|
||||
let references = [
|
||||
None,
|
||||
Some(D::Integer(1)),
|
||||
Some(D::Reference(vec![])),
|
||||
Some(name_ref("Lyr ", "Comp 1")),
|
||||
Some(target_ref("compsClass")),
|
||||
Some(class_ref("compsClass")),
|
||||
Some(D::Reference(vec![ReferenceItem::Index { class: class("compsClass"), index: 1 }])),
|
||||
Some(D::Reference(vec![ReferenceItem::Identifier { class: class("compsClass"), id: 1 }])),
|
||||
Some(D::Reference(vec![
|
||||
ReferenceItem::Name { class: class("compsClass"), name: UnicodeString::new_nul("Comp 1") },
|
||||
ReferenceItem::Name { class: class("Dcmn"), name: UnicodeString::new_nul("Other") },
|
||||
])),
|
||||
];
|
||||
let items: Vec<_> =
|
||||
references.into_iter().map(|reference| item("applyComp", "Apply Layer Comp", reference.map(|r| desc("null").with("null", r)))).collect();
|
||||
let data = set_of("Comps", vec![("Unknown", items.clone())]);
|
||||
let mut s = Session::new();
|
||||
let loaded = s.execute("actions.load", json!({"data": data})).unwrap();
|
||||
assert_eq!(loaded["unsupported"].as_array().unwrap().len(), items.len());
|
||||
assert!(s.actions.list[0].steps.iter().all(|(id, _)| id == PHOTOSHOP_STEP));
|
||||
assert!(s.actions.list[0].disabled.is_empty());
|
||||
s.execute("file.new", json!({"width": 8, "height": 8})).unwrap();
|
||||
s.execute("layerComp.new", json!({"name": "Comp 1"})).unwrap();
|
||||
let before = s.active().unwrap().doc.clone();
|
||||
let played = s.execute("actions.play", json!({"action": "Unknown"})).unwrap();
|
||||
assert_eq!(played["ran"], 0, "{played}");
|
||||
assert!(played["failed"]["error"].as_str().unwrap().contains("Apply Layer Comp"), "{played}");
|
||||
assert_eq!(*s.active().unwrap().doc, *before);
|
||||
let saved = s.execute("actions.save", json!({"set": "Comps"})).unwrap();
|
||||
let bytes = photocraft_paint::tile::b64_decode(saved["data"].as_str().unwrap()).unwrap();
|
||||
let file = atn::parse(&bytes).unwrap();
|
||||
assert_eq!(file.actions[0].items.len(), items.len());
|
||||
for (saved, original) in file.actions[0].items.iter().zip(&items) {
|
||||
assert_eq!(saved.event, original.event);
|
||||
assert_eq!(saved.descriptor, original.descriptor);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn load_maps_events_keeps_flags_and_plays() {
|
||||
let mut s = Session::new();
|
||||
@@ -427,6 +526,7 @@ fn every_mapped_command_exports_and_imports_back() {
|
||||
("image.mode.bitmap", json!({"method": "threshold"})),
|
||||
("image.imageSize", json!({"resolution": 1200, "resample": "preserveDetails", "keepPrintSize": true})),
|
||||
("layer.new.layerFromBackground", json!({"ifPresent": true, "select": false})),
|
||||
("layerComp.apply", json!({"comp": "Comp 1"})),
|
||||
];
|
||||
for (id, params) in &cases {
|
||||
let item = export_item(id, params, "S").unwrap_or_else(|| panic!("{id} does not export"));
|
||||
@@ -604,6 +704,16 @@ fn photo_filter_round_trip(params: Value) -> Option<Value> {
|
||||
}
|
||||
}
|
||||
|
||||
/// A `Mk` layerSection step exported to .atn and imported back → (id, params), or None.
|
||||
fn group_round_trip(id: &str, params: &Value) -> Option<(String, Value)> {
|
||||
let item = export_item(id, params, "S")?;
|
||||
let e = event_for(&item.event)?;
|
||||
match (e.from)(item.descriptor.as_ref()?) {
|
||||
Mapped::Steps(steps) => steps.first().map(|(i, p)| (i.clone(), p.clone())),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn photo_filter_preset_only_step_keeps_its_resolved_color() {
|
||||
// #7235: the Photoshop descriptor keeps only a colour (`phfl`/`PhtF` are colour-only; the io
|
||||
@@ -630,6 +740,44 @@ fn photo_filter_preset_only_step_keeps_its_resolved_color() {
|
||||
assert_eq!(back, json!({"density": 25}));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn group_layers_keeps_its_explicit_target_through_atn() {
|
||||
// #7236: a recorded step with an explicit layer groups that layer, not the current
|
||||
// selection. The source goes into the `From` reference by name and comes back the same
|
||||
// way; a step with no source layer keeps the implicit form, imported as before.
|
||||
let (id, p) = group_round_trip("layer.groupLayers", &json!({"layer": "A", "name": "Group"})).unwrap();
|
||||
assert_eq!(id, "layer.groupLayers");
|
||||
assert_eq!(p, json!({"layer": "A", "name": "Group"}));
|
||||
// The implicit form survives unchanged: the reference stays the target layer.
|
||||
let (id, p) = group_round_trip("layer.groupLayers", &json!({"name": "Group"})).unwrap();
|
||||
assert_eq!(id, "layer.groupLayers");
|
||||
assert_eq!(p, json!({"name": "Group"}));
|
||||
let (id, p) = group_round_trip("layer.groupLayers", &json!({})).unwrap();
|
||||
assert_eq!(id, "layer.groupLayers");
|
||||
assert_eq!(p, json!({}));
|
||||
// Group Without Layers: no `From` at all, imported as a plain new group.
|
||||
let (id, p) = group_round_trip("layer.new.group", &json!({"name": "G"})).unwrap();
|
||||
assert_eq!(id, "layer.new.group");
|
||||
assert_eq!(p, json!({"name": "G"}));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn group_layers_from_index_reference_stays_implicit() {
|
||||
// A Photoshop-authored `From` that names nothing portable (a zero-based index) keeps the
|
||||
// old implicit import instead of inventing a wrong explicit target (#7236, edge).
|
||||
let d = desc("null")
|
||||
.with("null", class_ref("layerSection"))
|
||||
.with("From", D::Reference(vec![ReferenceItem::Index { class: class("Lyr "), index: 2 }]))
|
||||
.with("Usng", D::Descriptor(desc("layerSection").with("Nm ", text("Group"))));
|
||||
match make_from(&d) {
|
||||
Mapped::Steps(steps) => {
|
||||
assert_eq!(steps[0].0, "layer.groupLayers");
|
||||
assert_eq!(steps[0].1, json!({"name": "Group"}));
|
||||
}
|
||||
_ => panic!("an index source imports as the implicit form"),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unsupported_shapes_become_photoshop_steps_not_errors() {
|
||||
// Image size in two different percentages, a Paint Bucket click in percent of the canvas, a
|
||||
@@ -1580,6 +1728,36 @@ fn minimum_and_maximum_with_roundness_are_not_exported_as_squareness() {
|
||||
}
|
||||
}
|
||||
|
||||
/// #7515: a Transform Selection's interpolation survives the round trip as a layer transform's
|
||||
/// does. #7516-#7519: a reference point other than the centre, a skew or a warp can't be written,
|
||||
/// so the step is refused instead of replaying as a plain scale.
|
||||
#[test]
|
||||
fn transform_selection_keeps_its_interpolation_and_refuses_what_it_cannot_carry() {
|
||||
let one = |id: &str, p: Value| Action { name: "Probe".into(), steps: vec![(id.into(), p)], ..Default::default() };
|
||||
let p = json!({"dx": 0.7, "dy": 0, "scaleX": 140, "scaleY": 80, "interpolation": "nearest"});
|
||||
let (bytes, skipped) = export("Audit7", &[&one("select.transformSelection", p.clone())], &[], false).unwrap();
|
||||
assert!(skipped.is_empty());
|
||||
let imported = import(&bytes).unwrap();
|
||||
assert_eq!(imported.actions[0].steps, vec![("select.transformSelection".to_string(), p)]);
|
||||
for id in ["select.transformSelection", "edit.transform"] {
|
||||
for p in [
|
||||
json!({"scaleX": 140, "reference": "topLeft"}),
|
||||
json!({"scaleX": 140, "reference": [3, 4]}),
|
||||
json!({"scaleX": 140, "skewX": 12}),
|
||||
json!({"scaleX": 140, "skewY": -5}),
|
||||
json!({"warp": "arc"}),
|
||||
json!({"corners": [[0, 0], [10, 0], [10, 10], [0, 10]]}),
|
||||
] {
|
||||
let err = export("Audit7", &[&one(id, p.clone())], &[], false).unwrap_err();
|
||||
assert!(err.contains("no Photoshop equivalent") && err.contains(&format!("`{id}`")), "{id} {p}: {err}");
|
||||
let (_, skipped) = export("Audit7", &[&one(id, p.clone())], &[], true).unwrap();
|
||||
assert_eq!(skipped, vec![Skipped { action: "Probe".into(), step: 0, id: id.into() }], "{id} {p}");
|
||||
}
|
||||
let carried = json!({"scaleX": 140, "reference": "center", "skewX": 0, "skewY": 0});
|
||||
assert!(export("Audit7", &[&one(id, carried.clone())], &[], false).is_ok(), "{id} {carried}");
|
||||
}
|
||||
}
|
||||
|
||||
/// Photoshop's Close has no document target: a Close of a specific document must not be
|
||||
/// exported as a plain Close, which would close the active document on playback.
|
||||
#[test]
|
||||
@@ -1770,3 +1948,138 @@ fn adjustment_layer_reset_still_resets() {
|
||||
assert_eq!(steps[0], ("layer.setAdjustment".to_string(), json!({})));
|
||||
assert_eq!(steps[1].1, json!({"midtones": [10, 0, 0], "kind": "colorBalance"}));
|
||||
}
|
||||
|
||||
/// A Free Transform recorded against an unlinked mask or an alpha channel must not export as a
|
||||
/// layer transform that moves the layer's pixels on replay (#7195).
|
||||
#[test]
|
||||
fn transform_with_mask_or_channel_target_is_not_exported_as_layer_transform() {
|
||||
for target in [json!("mask"), json!({"channel": 0}), json!("quickMask")] {
|
||||
let a = Action {
|
||||
name: "Probe".into(),
|
||||
steps: vec![("edit.transform".into(), json!({"target": target, "dx": 3, "dy": 2, "scaleX": 100, "interpolation": "nearest"}))],
|
||||
..Default::default()
|
||||
};
|
||||
assert!(export("Targets", &[&a], &[], false).is_err(), "{target} exported");
|
||||
let (_, skipped) = export("Targets", &[&a], &[], true).unwrap();
|
||||
assert_eq!(skipped, vec![Skipped { action: "Probe".into(), step: 0, id: "edit.transform".into() }]);
|
||||
}
|
||||
for params in [
|
||||
json!({"dx": 3, "dy": 2, "scaleX": 50, "interpolation": "nearest"}),
|
||||
json!({"target": "pixels", "dx": 3, "dy": 2, "scaleX": 50, "interpolation": "nearest"}),
|
||||
] {
|
||||
let plain = Action { name: "Plain".into(), steps: vec![("edit.transform".into(), params)], ..Default::default() };
|
||||
let (bytes, skipped) = export("Targets", &[&plain], &[], false).unwrap();
|
||||
assert!(skipped.is_empty());
|
||||
let imported = import(&bytes).unwrap();
|
||||
assert_eq!(imported.actions[0].steps, vec![("edit.transform".to_string(), json!({"dx": 3, "dy": 2, "scaleX": 50, "interpolation": "nearest"}))]);
|
||||
}
|
||||
for form in [json!({"quad": [[0, 0], [1, 0], [1, 1], [0, 1]]}), json!({"matrix": [1, 0, 0, 1, 0, 0]}), json!({"rect": [0, 0, 1, 1]})] {
|
||||
assert!(transform_to("edit.transform", &form).is_none());
|
||||
}
|
||||
}
|
||||
|
||||
/// Apply Image's optional blending mask has no `.atn` mapping: a strict export must refuse the
|
||||
/// step rather than drop the mask and widen the edit to the whole layer.
|
||||
#[test]
|
||||
fn apply_image_with_blending_mask_is_not_exported_without_its_mask() {
|
||||
let source = json!({"layer": "Pixels", "channel": "green", "invert": true});
|
||||
for params in [json!({"source": source, "blending": "normal", "mask": {"channel": 0}}), json!({"source": source, "blending": "normal", "maskChannel": 0})] {
|
||||
let masked = Action { name: "Masked".into(), steps: vec![("image.applyImage".into(), params.clone())], ..Default::default() };
|
||||
assert!(export("Audit5", &[&masked], &[], false).is_err(), "{params}");
|
||||
let (_, skipped) = export("Audit5", &[&masked], &[], true).unwrap();
|
||||
assert_eq!(skipped, vec![Skipped { action: "Masked".into(), step: 0, id: "image.applyImage".into() }]);
|
||||
}
|
||||
for params in [json!({"source": source, "blending": "normal"}), json!({"source": source, "blending": "normal", "mask": {"channel": "none"}})] {
|
||||
let plain = Action { name: "Plain".into(), steps: vec![("image.applyImage".into(), params.clone())], ..Default::default() };
|
||||
let (bytes, skipped) = export("Audit5", &[&plain], &[], false).unwrap();
|
||||
assert!(skipped.is_empty());
|
||||
let imported = import(&bytes).unwrap();
|
||||
assert_eq!(imported.actions[0].steps, vec![("image.applyImage".to_string(), json!({"source": source, "blending": "normal"}))]);
|
||||
}
|
||||
}
|
||||
|
||||
fn image_size_round_trip(params: &Value) -> Option<Value> {
|
||||
let item = export_item("image.imageSize", params, "S")?;
|
||||
let e = event_for(&item.event).unwrap();
|
||||
match (e.from)(item.descriptor.as_ref().unwrap()) {
|
||||
Mapped::Steps(steps) => Some(steps[0].1.clone()),
|
||||
_ => panic!("image size descriptor did not import as steps"),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn image_size_resolution_only_does_not_gain_keep_print_size() {
|
||||
// The .atn cannot tell resolution-only from keepPrintSize:true, so the former must not
|
||||
// export as a descriptor that imports back as keep-print-size.
|
||||
let params = json!({"resolution": 144, "resample": "nearest"});
|
||||
assert_eq!(image_size_round_trip(¶ms), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn image_size_intentional_controls_still_round_trip() {
|
||||
for params in [
|
||||
json!({"resolution": 144.0, "resample": "nearest", "keepPrintSize": true}),
|
||||
json!({"width": 12.0, "height": 10.0, "resolution": 144.0, "resample": "nearest"}),
|
||||
] {
|
||||
assert_eq!(image_size_round_trip(¶ms), Some(params.clone()));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn recorded_layer_select_exports_to_atn() {
|
||||
let mut s = Session::new();
|
||||
s.execute("file.new", json!({"width": 8, "height": 8})).unwrap();
|
||||
let l = s.execute("layer.new.layer", json!({"name": "Wanted"})).unwrap();
|
||||
let wanted_id = l["layer"].as_u64().unwrap();
|
||||
s.execute("actions.record", json!({"name": "SelectWanted"})).unwrap();
|
||||
s.execute("layer.select", json!({"layer": wanted_id})).unwrap();
|
||||
s.execute("actions.stop", json!({})).unwrap();
|
||||
|
||||
let action = s.execute("actions.get", json!({"action": "SelectWanted"})).unwrap();
|
||||
assert_eq!(action["steps"][0], json!(["layer.select", {"name": "Wanted"}]));
|
||||
|
||||
// Strict export should succeed and produce bytes without skipUnsupported
|
||||
let saved = s.execute("actions.save", json!({"action": "SelectWanted"})).unwrap();
|
||||
assert_eq!(saved["steps"], 1);
|
||||
assert_eq!(saved["skipped"], json!([]));
|
||||
|
||||
// When exported with skipUnsupported: true, it shouldn't skip the step either
|
||||
let saved_skip = s.execute("actions.save", json!({"action": "SelectWanted", "skipUnsupported": true})).unwrap();
|
||||
assert_eq!(saved_skip["steps"], 1);
|
||||
assert_eq!(saved_skip["skipped"], json!([]));
|
||||
|
||||
// If an action has an occurrence target (duplicate names), it cannot be represented unambiguously in .atn
|
||||
let bad_action = Action::new("Dup", vec![("layer.select".into(), json!({"name": "Wanted", "occurrence": 1}))]);
|
||||
let err = export("Set", &[&bad_action], &[], false);
|
||||
assert!(err.is_err(), "occurrence without representation must fail strict export");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn select_rect_mode_strict_export_rejects_unrepresentable_modes() {
|
||||
let mut s = Session::new();
|
||||
s.execute("file.new", json!({"width": 8, "height": 8})).unwrap();
|
||||
|
||||
// Default or "replace" mode succeeds
|
||||
s.actions.list.push(Action::new("ReplaceAct", vec![("select.rect".into(), json!({"x": 4, "y": 4, "width": 2, "height": 2, "mode": "replace"}))]));
|
||||
let saved = s.execute("actions.save", json!({"action": "ReplaceAct"})).unwrap();
|
||||
assert_eq!(saved["steps"], 1);
|
||||
|
||||
// "add" mode cannot be silently converted to replace (set) in strict export
|
||||
s.actions.list.push(Action::new("AddAct", vec![("select.rect".into(), json!({"x": 4, "y": 4, "width": 2, "height": 2, "mode": "add"}))]));
|
||||
let before_actions = s.actions.list.clone();
|
||||
let err = s.execute("actions.save", json!({"action": "AddAct"}));
|
||||
assert!(err.is_err(), "strict export must reject select.rect with add mode rather than converting to replace");
|
||||
assert_eq!(s.actions.list, before_actions, "actions list must remain unchanged after rejected save");
|
||||
|
||||
// "subtract" mode cannot be silently converted to replace either
|
||||
s.actions.list.push(Action::new("SubtractAct", vec![("select.rect".into(), json!({"x": 4, "y": 4, "width": 2, "height": 2, "mode": "subtract"}))]));
|
||||
let before_actions_sub = s.actions.list.clone();
|
||||
let err_subtract = s.execute("actions.save", json!({"action": "SubtractAct"}));
|
||||
assert!(err_subtract.is_err(), "strict export must reject select.rect with subtract mode rather than converting to replace");
|
||||
assert_eq!(s.actions.list, before_actions_sub, "actions list must remain unchanged after rejected save");
|
||||
|
||||
// With skipUnsupported: true, unrepresentable modes are reported in skipped
|
||||
let skipped = s.execute("actions.save", json!({"action": "AddAct", "skipUnsupported": true})).unwrap();
|
||||
assert_eq!(skipped["steps"], 0);
|
||||
assert_eq!(skipped["skipped"][0]["id"], "select.rect");
|
||||
}
|
||||
@@ -476,6 +476,28 @@ fn paper(p: &Value, cmd: &str) -> Result<(f64, f64)> {
|
||||
Ok(if p.get("orientation").and_then(Value::as_str) == Some("landscape") { (h.max(w), w.min(h)) } else { (w, h) })
|
||||
}
|
||||
|
||||
/// The driver's printable area (`printable`: [x, y, width, height] pt from the paper's top-left,
|
||||
/// as `file.print.page` reports it), clipped to the paper, with the layout's bottom-left origin.
|
||||
fn printable(p: &Value, (pw, ph): (f64, f64), cmd: &str) -> Result<Option<(f64, f64, f64, f64)>> {
|
||||
let Some(v) = p.get("printable").filter(|v| !v.is_null()) else { return Ok(None) };
|
||||
let r: Option<Vec<f64>> = v.as_array().and_then(|a| a.iter().map(Value::as_f64).collect());
|
||||
let Some([x, y, w, h]) = r.as_deref().and_then(|r| <[f64; 4]>::try_from(r).ok()) else {
|
||||
return Err(bad(cmd, "printable is [x, y, width, height] in points from the paper's top-left"));
|
||||
};
|
||||
// Drivers report their paper a fraction of a point off the named size (842.29 pt for A3's
|
||||
// 841.89), so clip that much; an area that doesn't fit the paper (another paper or
|
||||
// orientation) is refused. 2 pt, as `print_windows` allows between driver and layout.
|
||||
const SLACK: f64 = 2.0;
|
||||
if !(x >= -SLACK && y >= -SLACK && x + w <= pw + SLACK && y + h <= ph + SLACK) {
|
||||
return Err(bad(cmd, "the printable area doesn't fit the paper and orientation"));
|
||||
}
|
||||
let (x0, y0, x1, y1) = (x.max(0.0), y.max(0.0), (x + w).min(pw), (y + h).min(ph));
|
||||
if !(x1 > x0 && y1 > y0) {
|
||||
return Err(bad(cmd, "the printable area is empty"));
|
||||
}
|
||||
Ok(Some((x0, ph - y1, x1 - x0, y1 - y0)))
|
||||
}
|
||||
|
||||
/// Where the image lands on the paper.
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
pub struct PrintLayout {
|
||||
@@ -500,16 +522,37 @@ pub fn layout(doc: &Document, p: &Value, cmd: &str) -> Result<PrintLayout> {
|
||||
center_crop: p.get("centerCropMarks").and_then(Value::as_bool).unwrap_or(false),
|
||||
registration: p.get("registrationMarks").and_then(Value::as_bool).unwrap_or(false),
|
||||
};
|
||||
let margin = if marks.corner_crop || marks.center_crop || marks.registration { 36.0 } else { 18.0 };
|
||||
let has_marks = marks.corner_crop || marks.center_crop || marks.registration;
|
||||
// Scale to Fit Media fits the driver's printable area when it is known (the whole sheet for
|
||||
// borderless paper); marks keep their inset inside it. Without one (CUPS, PDF), the paper
|
||||
// minus a fixed margin.
|
||||
let emulsion_down = p.get("emulsionDown").and_then(Value::as_bool).unwrap_or(false);
|
||||
let fit = p.get("scaleToFit").and_then(Value::as_bool).unwrap_or(false);
|
||||
let scale = if fit {
|
||||
((pw - 2.0 * margin) / iw).min((ph - 2.0 * margin) / ih)
|
||||
} else {
|
||||
p.get("scale").and_then(Value::as_f64).filter(|v| *v > 0.0).unwrap_or(100.0) / 100.0
|
||||
// Only a fitted print reads the area, so a stale one (a replayed action, another paper) can't
|
||||
// fail a print at a manual scale.
|
||||
let area = if fit { printable(p, (pw, ph), cmd)? } else { None };
|
||||
let fit_box = match area {
|
||||
Some((x, y, w, h)) => {
|
||||
// Emulsion Down mirrors the page as it prints: fit the mirror of the printable area,
|
||||
// so the printed image lands inside the real one.
|
||||
let x = if emulsion_down { pw - x - w } else { x };
|
||||
let inset = if has_marks { 36.0 } else { 0.0 };
|
||||
if !(w > 2.0 * inset && h > 2.0 * inset) {
|
||||
return Err(bad(cmd, "the printable area is too small for crop and registration marks"));
|
||||
}
|
||||
(x + inset, y + inset, w - 2.0 * inset, h - 2.0 * inset)
|
||||
}
|
||||
None => {
|
||||
let margin = if has_marks { 36.0 } else { 18.0 };
|
||||
(margin, margin, pw - 2.0 * margin, ph - 2.0 * margin)
|
||||
}
|
||||
};
|
||||
let scale = if fit { (fit_box.2 / iw).min(fit_box.3 / ih) } else { p.get("scale").and_then(Value::as_f64).filter(|v| *v > 0.0).unwrap_or(100.0) / 100.0 };
|
||||
let (w, h) = (iw * scale, ih * scale);
|
||||
let center = p.get("center").and_then(Value::as_bool).unwrap_or(true);
|
||||
let (x, y) = if center {
|
||||
let (x, y) = if center && fit {
|
||||
(fit_box.0 + (fit_box.2 - w) / 2.0, fit_box.1 + (fit_box.3 - h) / 2.0)
|
||||
} else if center {
|
||||
((pw - w) / 2.0, (ph - h) / 2.0)
|
||||
} else {
|
||||
// Top / left in inches from the paper's top-left corner (Photoshop's Position fields).
|
||||
@@ -517,7 +560,6 @@ pub fn layout(doc: &Document, p: &Value, cmd: &str) -> Result<PrintLayout> {
|
||||
let left = p.get("left").and_then(Value::as_f64).unwrap_or(0.0) * 72.0;
|
||||
(left, ph - top - h)
|
||||
};
|
||||
let emulsion_down = p.get("emulsionDown").and_then(Value::as_bool).unwrap_or(false);
|
||||
Ok(PrintLayout { paper: (pw, ph), rect: (x, y, w, h), scale, marks, emulsion_down })
|
||||
}
|
||||
|
||||
@@ -569,7 +611,49 @@ fn do_print(s: &mut Session, p: &Value, cmd: &str) -> Result<Value> {
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
/// True when a print may go to a Windows printer through the driver rather than a PDF spooler.
|
||||
fn native_route(p: &Value, spooler: Option<&Spooler>) -> bool {
|
||||
// A named print server always takes the IPP route and a preferred app spooler takes every
|
||||
// job (the route order in `spool_job`), on Windows too: neither may enter the native path,
|
||||
// which would print on the local default printer instead.
|
||||
let named_server = p.get("printServer").and_then(Value::as_str).is_some_and(|v| !v.is_empty());
|
||||
let skip_native = named_server || spooler.is_some_and(|sp| sp.preferred);
|
||||
let output = p.get("output").and_then(Value::as_str).is_some_and(|v| !v.is_empty());
|
||||
let send = p.get("send").and_then(Value::as_bool).unwrap_or(!output);
|
||||
let dry = p.get("dryRun").and_then(Value::as_bool).unwrap_or(false);
|
||||
cfg!(windows) && !skip_native && send && !dry && !output
|
||||
}
|
||||
|
||||
/// `p` with the driver's printable area, read from the printer itself, so Print One Copy, the
|
||||
/// CLI, control and replayed actions fit the same area as the Print dialog does (#7782). A
|
||||
/// native print never fits an area the caller passed: without the driver's, it has none.
|
||||
fn with_driver_printable(p: &Value) -> Value {
|
||||
let mut out = p.clone();
|
||||
if let Some(o) = out.as_object_mut() {
|
||||
o.remove("printable");
|
||||
if let Some(area) = driver_printable(p) {
|
||||
o.insert("printable".into(), area);
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
fn driver_printable(p: &Value) -> Option<Value> {
|
||||
let printer = printer_name(p).ok()?;
|
||||
let pg = craft_print::rgb::page(&printer, printer_settings(p).ok()?.as_ref()).ok()?;
|
||||
// Only for the paper the driver is set to: a print laid out on another paper keeps the
|
||||
// fixed margin (and `print_windows` refuses it), as before.
|
||||
let (pw, ph) = paper(p, "file.print").ok()?;
|
||||
if (pg.paper.0 - pw).abs() > 2.0 || (pg.paper.1 - ph).abs() > 2.0 {
|
||||
return None;
|
||||
}
|
||||
Some(json!([pg.printable.0, pg.printable.1, pg.printable.2, pg.printable.3]))
|
||||
}
|
||||
|
||||
fn render_and_spool(doc: &Document, p: &Value, cmd: &str, spooler: Option<&Spooler>) -> Result<Value> {
|
||||
let fit = p.get("scaleToFit").and_then(Value::as_bool).unwrap_or(false);
|
||||
let driver = (fit && native_route(p, spooler)).then(|| with_driver_printable(p));
|
||||
let p = driver.as_ref().unwrap_or(p);
|
||||
let PrintLayout { paper: (pw, ph), rect: (x, y, w, h), scale, marks, emulsion_down } = layout(doc, p, cmd)?;
|
||||
let (img, color) = print_image(doc, p, cmd)?;
|
||||
let description = p
|
||||
@@ -587,12 +671,8 @@ fn render_and_spool(doc: &Document, p: &Value, cmd: &str, spooler: Option<&Spool
|
||||
// Sending follows the shared command contract; fuzz tests explicitly request dryRun.
|
||||
// The worker returns its result before repeat settings and hooks are applied once.
|
||||
let handling = p.get("colorHandling").and_then(Value::as_str).unwrap_or("printerManages");
|
||||
// A named print server always takes the IPP route and a preferred app spooler takes every
|
||||
// job (the route order in `spool_job`), on Windows too: neither may enter the native path
|
||||
// below, which would print on the local default printer instead.
|
||||
let named_server = p.get("printServer").and_then(Value::as_str).is_some_and(|v| !v.is_empty());
|
||||
let skip_native = named_server || spooler.is_some_and(|sp| sp.preferred);
|
||||
if cfg!(windows) && !skip_native && send && !dry && output.is_none() && native_rgb_compatible(&page, handling) {
|
||||
let native = native_route(p, spooler);
|
||||
if native && native_rgb_compatible(&page, handling) {
|
||||
require_printing_enabled()?;
|
||||
let printed = print_windows(&page, p, &doc.name, copies)?;
|
||||
return Ok(json!({
|
||||
@@ -600,7 +680,7 @@ fn render_and_spool(doc: &Document, p: &Value, cmd: &str, spooler: Option<&Spool
|
||||
"copies": copies, "command": Value::Null, "sent": true, "spooler": printed, "color": color,
|
||||
}));
|
||||
}
|
||||
if cfg!(windows) && !skip_native && send && !dry && output.is_none() && printer_settings(p)?.is_some() {
|
||||
if native && printer_settings(p)?.is_some() {
|
||||
return Err(other("the selected color profile or page text requires PDF printing. Save as PDF, or clear Print Settings to use PDF printing."));
|
||||
}
|
||||
let pdf = print_pdf(&page);
|
||||
@@ -695,6 +775,9 @@ fn remember_print(s: &mut Session, p: &Value) {
|
||||
o.remove("dryRun");
|
||||
// Output and dry-run choices are not remembered, so a send override must not survive them.
|
||||
o.remove("send");
|
||||
// The driver's printable area belongs to the printer and paper chosen now: the dialog
|
||||
// reads it again, and a later print to PDF or another printer must not inherit it.
|
||||
o.remove("printable");
|
||||
}
|
||||
let kept = remembered.clone();
|
||||
s.prefs.edit(|prefs| {
|
||||
@@ -1098,7 +1181,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
CommandSpec { id: $id, label: $label, menu: $menu, shortcut: $sc, params: $params, enabled: $enabled, journal: true, run: $run }
|
||||
};
|
||||
}
|
||||
const PRINT_PARAMS: &str = r##"{"printerSettings":hex? (Windows driver settings),"printer":name? (default printer),"copies":1..999=1,"paper":"letter|legal|tabloid|a3|a4|a5|4x6|5x7"|[w,h] pt="letter","orientation":"portrait|landscape"="portrait","center":bool=true,"top":in?,"left":in?,"scale":%=100,"scaleToFit":bool=false,"colorHandling":"printerManages|photocraftManages|noColorManagement"="printerManages","printerProfile":profile? (photocraftManages),"intent":"perceptual|relative|saturation|absolute"="relative","bpc":bool=true,"cornerCropMarks":bool,"centerCropMarks":bool,"registrationMarks":bool,"description":bool,"labels":bool,"emulsionDown":bool=false (mirror the page left to right, for sublimation and other transfer printing),"output":pdf path? (print to PDF; then "send" defaults to false),"send":bool?,"printServer":"host[:port]|socket path"? (default: the system's CUPS; a named server is always printed to over IPP),"dryRun":bool=false (render the PDF, report the backend command, don't spool; write a PDF only at an explicit output path)} → {pdf:path|null (null without explicit output), imageRect, command:diagnostic array|null, sent, spooler:where the job went|null, backend:"lp|windows|ipp|portal"|null}"##;
|
||||
const PRINT_PARAMS: &str = r##"{"printerSettings":hex? (Windows driver settings),"printer":name? (default printer),"copies":1..999=1,"paper":"letter|legal|tabloid|a3|a4|a5|4x6|5x7"|[w,h] pt="letter","orientation":"portrait|landscape"="portrait","center":bool=true,"top":in?,"left":in?,"scale":%=100,"scaleToFit":bool=false,"printable":[x,y,w,h] pt? (the driver's printable area from the paper's top-left, as file.print.page reports it; Scale to Fit Media fits it, else the paper minus 18 pt; a native Windows print reads the driver's own instead),"colorHandling":"printerManages|photocraftManages|noColorManagement"="printerManages","printerProfile":profile? (photocraftManages),"intent":"perceptual|relative|saturation|absolute"="relative","bpc":bool=true,"cornerCropMarks":bool,"centerCropMarks":bool,"registrationMarks":bool,"description":bool,"labels":bool,"emulsionDown":bool=false (mirror the page left to right, for sublimation and other transfer printing),"output":pdf path? (print to PDF; then "send" defaults to false),"send":bool?,"printServer":"host[:port]|socket path"? (default: the system's CUPS; a named server is always printed to over IPP),"dryRun":bool=false (render the PDF, report the backend command, don't spool; write a PDF only at an explicit output path)} → {pdf:path|null (null without explicit output), imageRect, command:diagnostic array|null, sent, spooler:where the job went|null, backend:"lp|windows|ipp|portal"|null}"##;
|
||||
|
||||
vec![
|
||||
spec!("file.print", "Print…", &["File"], Some("Cmd+P"), PRINT_PARAMS, native_doc, print),
|
||||
|
||||
@@ -869,3 +869,121 @@ fn windows_pdf_component_is_detected_by_loading_its_dll() {
|
||||
fn the_windows_pdf_check_is_a_no_op_elsewhere() {
|
||||
assert!(require_windows_pdf().is_ok());
|
||||
}
|
||||
|
||||
/// A 500 × 1000 pt document (72 ppi) on A3 (841.89 × 1190.55 pt): its height sets the fit.
|
||||
fn a3_layout(extra: Value) -> Result<PrintLayout> {
|
||||
let mut s = Session::new();
|
||||
s.execute("file.new", json!({"width": 500, "height": 1000, "resolution": 72})).unwrap();
|
||||
let mut p = json!({"paper": "a3", "scaleToFit": true});
|
||||
if let (Some(p), Some(extra)) = (p.as_object_mut(), extra.as_object()) {
|
||||
p.extend(extra.clone());
|
||||
}
|
||||
layout(&s.active().unwrap().doc, &p, "file.print")
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn scale_to_fit_fills_a_borderless_printable_area() {
|
||||
let (pw, ph) = (841.89, 1190.55);
|
||||
// Without a printable area, the fixed 18 pt margin stays (CUPS, PDF).
|
||||
let l = a3_layout(json!({})).unwrap();
|
||||
assert!((l.scale - (ph - 36.0) / 1000.0).abs() < 1e-9, "{l:?}");
|
||||
// Borderless: the driver reports the whole sheet (#7782: a Canon PRO-1000 reports its A3 as
|
||||
// 842.29 × 1191.14 pt), and the image reaches the paper's edges.
|
||||
let l = a3_layout(json!({"printable": [0.0, 0.0, 842.29, 1191.14]})).unwrap();
|
||||
assert!((l.scale - ph / 1000.0).abs() < 1e-9, "{l:?}");
|
||||
let (x, y, w, h) = l.rect;
|
||||
assert!(y.abs() < 1e-9 && (h - ph).abs() < 1e-9 && (x - (pw - w) / 2.0).abs() < 1e-9, "{l:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn scale_to_fit_stays_inside_an_uneven_printable_area() {
|
||||
let (pw, ph) = (841.89, 1190.55);
|
||||
// 17 pt left and right, 14 pt at the top, 48 pt at the bottom (from the top-left, as
|
||||
// `file.print.page` reports it). The layout's rect has its origin at the bottom-left.
|
||||
let l = a3_layout(json!({"printable": [17.0, 14.0, pw - 34.0, ph - 62.0]})).unwrap();
|
||||
assert!((l.scale - (ph - 62.0) / 1000.0).abs() < 1e-9, "{l:?}");
|
||||
let (x, y, w, h) = l.rect;
|
||||
assert!((y - 48.0).abs() < 1e-9 && (y + h - (ph - 14.0)).abs() < 1e-9, "fills the printable height: {l:?}");
|
||||
assert!((x - (pw - w) / 2.0).abs() < 1e-9, "centred between equal side margins: {l:?}");
|
||||
// Crop and registration marks keep their 36 pt inset, inside the printable area.
|
||||
let l = a3_layout(json!({"printable": [17.0, 14.0, pw - 34.0, ph - 62.0], "cornerCropMarks": true})).unwrap();
|
||||
assert!((l.scale - (ph - 62.0 - 72.0) / 1000.0).abs() < 1e-9, "{l:?}");
|
||||
assert!((l.rect.1 - 84.0).abs() < 1e-9, "{l:?}");
|
||||
// Scale to fit off: the printable area changes nothing.
|
||||
let l = a3_layout(json!({"printable": [17.0, 14.0, pw - 34.0, ph - 62.0], "scaleToFit": false})).unwrap();
|
||||
assert_eq!(l, a3_layout(json!({"scaleToFit": false})).unwrap());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_bad_printable_area_is_refused() {
|
||||
let portrait = json!([0.0, 0.0, 842.29, 1191.14]);
|
||||
for bad in [
|
||||
json!([0, 0, 100]),
|
||||
json!([0, 0, 0, 100]),
|
||||
json!([0, 0, 100, -5]),
|
||||
json!("whole"),
|
||||
json!([2000, 0, 100, 100]),
|
||||
json!([0, "oops", 0, 842.29, 1191.14]),
|
||||
json!([0, 0, 842.29, null]),
|
||||
] {
|
||||
assert!(a3_layout(json!({ "printable": bad })).is_err(), "{bad}");
|
||||
}
|
||||
// A portrait sheet's area on a landscape layout is another paper, not a rounding error.
|
||||
assert!(a3_layout(json!({"printable": portrait, "orientation": "landscape"})).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn emulsion_down_fits_the_mirrored_printable_area() {
|
||||
let (pw, ph) = (841.89, 1190.55);
|
||||
// 10 pt on the left, 40 pt on the right of the sheet as the driver sees it. The page is
|
||||
// mirrored as it prints, so the image box (before mirroring) must fit the mirror image.
|
||||
// A wide image, so the printable width sets the fit.
|
||||
let mut s = Session::new();
|
||||
s.execute("file.new", json!({"width": 1000, "height": 500, "resolution": 72})).unwrap();
|
||||
let p = json!({"paper": "a3", "scaleToFit": true, "printable": [10.0, 0.0, pw - 50.0, ph], "emulsionDown": true});
|
||||
let l = layout(&s.active().unwrap().doc, &p, "file.print").unwrap();
|
||||
let (x, _, w, _) = l.rect;
|
||||
let printed = (pw - x - w, pw - x);
|
||||
assert!(printed.0 >= 10.0 - 1e-9 && printed.1 <= pw - 40.0 + 1e-9, "printed at {printed:?}: {l:?}");
|
||||
}
|
||||
|
||||
/// A native print fits only the driver's area: one the caller passed is dropped when the
|
||||
/// driver can't give one for this paper (no such paper here, or no driver at all).
|
||||
#[test]
|
||||
fn a_native_print_drops_a_printable_area_the_driver_did_not_give() {
|
||||
let p = with_driver_printable(&json!({"paper": [500.0, 500.0], "printable": [0.0, 0.0, 100.0, 100.0], "scaleToFit": true}));
|
||||
assert!(p.get("printable").is_none(), "{p}");
|
||||
assert_eq!(p["paper"], json!([500.0, 500.0]));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_print_uses_the_printable_area_but_does_not_remember_it() {
|
||||
let mut s = Session::new();
|
||||
s.execute("file.new", json!({"width": 500, "height": 1000, "resolution": 72})).unwrap();
|
||||
let r = s.execute("file.print", json!({"paper": "a3", "scaleToFit": true, "printable": [0.0, 0.0, 842.29, 1191.14], "dryRun": true})).unwrap();
|
||||
assert!((r["scale"].as_f64().unwrap() - 119.055).abs() < 1e-6, "{r}");
|
||||
// The next print (Print One Copy, or the dialog on another printer or to PDF) reads its own.
|
||||
let last = last_print(&s).unwrap();
|
||||
assert!(last.get("printable").is_none() && last["scaleToFit"] == true, "{last}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_rejected_printable_area_fails_the_print_and_changes_nothing() {
|
||||
let mut s = Session::new();
|
||||
s.execute("file.new", json!({"width": 500, "height": 1000, "resolution": 72})).unwrap();
|
||||
s.execute("file.print", json!({"paper": "a3", "scale": 50, "dryRun": true})).unwrap();
|
||||
let before = (last_print(&s), s.prefs.get().dialogs.get(REMEMBERED).cloned(), s.active().unwrap().doc.clone());
|
||||
for printable in [json!([2000, 0, 100, 100]), json!([0, "oops", 0, 842.29, 1191.14])] {
|
||||
let r = s.execute("file.print", json!({"paper": "a3", "scaleToFit": true, "printable": printable, "dryRun": true}));
|
||||
assert!(r.is_err(), "{printable}: {r:?}");
|
||||
}
|
||||
assert!(before == (last_print(&s), s.prefs.get().dialogs.get(REMEMBERED).cloned(), s.active().unwrap().doc.clone()));
|
||||
// A print at a manual scale doesn't read the area, so a stale one doesn't fail it.
|
||||
let r = s.execute("file.print", json!({"paper": "a3", "scale": 50, "printable": [0.0, 0.0, 842.29, 1191.14], "orientation": "landscape", "dryRun": true}));
|
||||
assert!(r.is_ok(), "{r:?}");
|
||||
// Marks need room only to fit: a small manual scale in a 60 pt-wide area prints.
|
||||
let r = s.execute("file.print", json!({"paper": "a3", "scale": 5, "printable": [0, 0, 60, 1191.14], "cornerCropMarks": true, "dryRun": true}));
|
||||
assert!(r.is_ok(), "{r:?}");
|
||||
let r = s.execute("file.print", json!({"paper": "a3", "scaleToFit": true, "printable": [0, 0, 60, 1191.14], "cornerCropMarks": true, "dryRun": true}));
|
||||
assert!(r.is_err(), "{r:?}");
|
||||
}
|
||||
@@ -935,6 +935,9 @@ fn fs_atop(in: VOut) -> @location(0) vec4<f32> {
|
||||
let base = textureLoad(tex_a, p, 0);
|
||||
if (base.a <= 0.0) { return base; }
|
||||
let s = textureLoad(tex_b, p, 0);
|
||||
if (op.mode == M_DISSOLVE) {
|
||||
return select(base, vec4(s.rgb, base.a), dissolve_noise(doc_px(p)) < s.a * op.opacity);
|
||||
}
|
||||
let r = composite_g(op.mode, vec4(base.rgb, 1.0), s, op.opacity, (op.flags & F_TEXT_GAMMA) != 0u);
|
||||
return vec4(r.rgb, base.a);
|
||||
}
|
||||
@@ -950,6 +953,7 @@ fn fs_adjust(in: VOut) -> @location(0) vec4<f32> {
|
||||
}
|
||||
|
||||
// Mix an adjusted result B back over the original A with blend mode, opacity and mask.
|
||||
// Both ordinary and clipped adjustments use this pass, retaining the original alpha.
|
||||
@fragment
|
||||
fn fs_adjmix(in: VOut) -> @location(0) vec4<f32> {
|
||||
let p = local(in.pos);
|
||||
@@ -957,6 +961,9 @@ fn fs_adjmix(in: VOut) -> @location(0) vec4<f32> {
|
||||
let k = op.opacity * mask_value(doc_px(p));
|
||||
if (k <= 0.0) { return b; }
|
||||
let a = textureLoad(tex_b, p, 0);
|
||||
if (op.mode == M_DISSOLVE) {
|
||||
return select(b, vec4(a.rgb, b.a), dissolve_noise(doc_px(p)) < k);
|
||||
}
|
||||
let bl = blend_rgb(op.mode, b.rgb, a.rgb);
|
||||
return vec4(b.rgb + (bl - b.rgb) * k, b.a);
|
||||
}
|
||||
@@ -1280,7 +1287,14 @@ fn fs_fxmerge(in: VOut) -> @location(0) vec4<f32> {
|
||||
let atop = (op.flags & F_ATOP) != 0u;
|
||||
var before = c;
|
||||
if (atop) { before = vec4(c.rgb, 1.0); }
|
||||
let o = mix_premul(before, w, op.opacity);
|
||||
var o: vec4<f32>;
|
||||
if (op.mode == M_DISSOLVE) {
|
||||
// Match the CPU effects compositor: opacity gates the completed stack, not
|
||||
// its individual colours or alpha. Use document coordinates across chunks.
|
||||
o = select(before, w, dissolve_noise(doc_px(p)) < op.opacity);
|
||||
} else {
|
||||
o = mix_premul(before, w, op.opacity);
|
||||
}
|
||||
if (atop) {
|
||||
if (c.a > 0.0) { return vec4(o.rgb, c.a); }
|
||||
return c;
|
||||
|
||||
@@ -794,6 +794,19 @@ fn groups_masks_and_clipping() {
|
||||
d.layers.extend([base, c1, c2]);
|
||||
check(&mut g, &d, &format!("clipping hidden={hidden}"));
|
||||
}
|
||||
// #3052/#4921: a clipped Dissolve layer retains opacity/fill binary coverage
|
||||
// across the partially covered clipping base; the GPU must match the CPU.
|
||||
for (opacity, fill) in [(0.4, 1.0), (0.8, 0.5)] {
|
||||
let mut d = base_doc(56, 44);
|
||||
let base = noise_layer("base", PixelFormat::RGBA8, Rect::new(5, 6, 48, 40), 45, 0.0);
|
||||
let mut clip = noise_layer("dissolve clip", PixelFormat::RGBA8, d.bounds(), 46, 0.0);
|
||||
clip.clipped = true;
|
||||
clip.blend = BlendMode::Dissolve;
|
||||
clip.opacity = opacity;
|
||||
clip.fill_opacity = fill;
|
||||
d.layers.extend([base, clip]);
|
||||
check(&mut g, &d, "clipped Dissolve opacity/fill CPU/GPU parity");
|
||||
}
|
||||
// Clipped group base (isolated) with a clipped layer.
|
||||
let mut d = base_doc(56, 44);
|
||||
let mut gb = Layer::group("gb", vec![child(18, BlendMode::Normal)]);
|
||||
@@ -2893,3 +2906,60 @@ fn soft_shapes_match_the_cpu() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// An adjustment has no standalone source alpha: its opacity and mask gate binary coverage.
|
||||
#[test]
|
||||
fn dissolve_adjustment_matches_cpu() {
|
||||
let Some(mut g) = gpu() else { return };
|
||||
let mut d = base_doc(64, 48);
|
||||
let mut adjustment = Layer::new("invert", LayerContent::Adjustment(Adjustment::Invert));
|
||||
adjustment.blend = BlendMode::Dissolve;
|
||||
adjustment.opacity = 0.5;
|
||||
adjustment.mask = Some(mask(Rect::new(0, 0, 32, 48), 31, 0.0));
|
||||
d.layers.push(adjustment);
|
||||
check(&mut g, &d, "dissolve adjustment + mask");
|
||||
}
|
||||
|
||||
/// Clipped pixels still use document-positioned noise, without changing the base alpha.
|
||||
#[test]
|
||||
fn dissolve_clipped_layer_matches_cpu() {
|
||||
let Some(mut g) = gpu() else { return };
|
||||
let mut d = base_doc(64, 48);
|
||||
let mut clipped = Layer::new("clipped", LayerContent::Fill(Fill::Solid(Color::BLACK)));
|
||||
clipped.clipped = true;
|
||||
clipped.blend = BlendMode::Dissolve;
|
||||
clipped.opacity = 0.5;
|
||||
d.layers.push(clipped);
|
||||
check(&mut g, &d, "dissolve clipped");
|
||||
}
|
||||
|
||||
/// Layer opacity gates the completed effects stack, instead of fading its pixels.
|
||||
#[test]
|
||||
fn dissolve_effects_stack_matches_cpu() {
|
||||
let Some(mut g) = gpu() else { return };
|
||||
let mut d = base_doc(64, 48);
|
||||
let mut styled = Layer::new("styled", LayerContent::Fill(Fill::Solid(Color::BLACK)));
|
||||
styled.blend = BlendMode::Dissolve;
|
||||
styled.opacity = 0.5;
|
||||
styled.effects.items.push(Effect::ColorOverlay { common: FxCommon::new(BlendMode::Normal, 1.0), color: Color::BLACK });
|
||||
d.layers.push(styled);
|
||||
check(&mut g, &d, "dissolve effects");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn dissolve_clipped_adjustment_matches_cpu() {
|
||||
let Some(mut g) = gpu() else { return };
|
||||
for fmt in [PixelFormat::RGBA8, PixelFormat::RGBA16, PixelFormat::RGBA32F] {
|
||||
let mut d = Document::new("clipped adjustment", Size::new(272, 24), ColorMode::Rgb, fmt.sample);
|
||||
let base = noise_layer("base", fmt, Rect::new(-3, -2, 268, 22), 47, 0.0);
|
||||
let mut adjustment = Layer::new("invert", LayerContent::Adjustment(Adjustment::Invert));
|
||||
adjustment.clipped = true;
|
||||
adjustment.blend = BlendMode::Dissolve;
|
||||
adjustment.opacity = 0.6;
|
||||
adjustment.fill_opacity = 0.5;
|
||||
adjustment.mask = Some(mask(Rect::new(0, 0, 260, 24), 48, 0.0));
|
||||
d.layers.extend([base, adjustment]);
|
||||
check(&mut g, &d, &format!("clipped Dissolve adjustment {fmt:?}"));
|
||||
diff_rect(&mut g, &d, Rect::new(250, 1, 270, 20), "clipped adjustment offset region").unwrap_or_else(|e| panic!("{e}"));
|
||||
}
|
||||
}
|
||||
+10
-3
@@ -25,7 +25,7 @@ Implemented only from public specifications, papers and observation of files:
|
||||
* ITU-T T.81 (ISO 10918-1) Annex H: lossless JPEG, process 14 ("LJ92").
|
||||
* The published description of Canon's CR2 container (header, raw IFD, slice tag 0xC640).
|
||||
* Publicly documented maker-note / private tags (ExifTool's tag tables): Canon ModelID (0x0010),
|
||||
SensorInfo (0x00E0) and ColorData (0x4001), Nikon WB_RBLevels (0x000C) and BlackLevel (0x003D), Sony
|
||||
SensorInfo (0x00E0) and ColorData (0x4001), Nikon WB_RBLevels (0x000C), ColorSpace (0x001E) and BlackLevel (0x003D), Sony
|
||||
BlackLevel (0x7310), WB_RGGBLevels (0x7313), SonyRawFileType (0x7000) and SonyToneCurve
|
||||
(0x7010), the PanasonicRaw IFD0 tags, Olympus ImageProcessing (0x2040) and CameraSettings
|
||||
(0x2020) preview tags, the Fujifilm RAF header and metadata records (RawImageCropTopLeft /
|
||||
@@ -119,7 +119,11 @@ out). One cell in three is held out: the look is used only when it shows the sam
|
||||
the matrix is plausible and the held-out mean CIE76 ΔE drops to at most 85 % of the fallback's.
|
||||
Pass it as `DevelopOptions::camera_look`; `develop` then notes "colour fitted to the camera's
|
||||
embedded JPEG (mean ΔE …)". The crate cannot decode JPEG itself: `photocraft-io` decodes the
|
||||
smallest preview at least 512 pixels long, fits and develops in one go.
|
||||
smallest preview at least 512 pixels long, fits and develops in one go. A preview without an ICC
|
||||
profile is read in the colour space the raw states (`embedded_preview_color_space`): the EXIF
|
||||
ColorSpace (a Sony body set to Adobe RGB writes Uncalibrated with Interoperability "R03"), else a
|
||||
Nikon maker note's ColorSpace (0x001E; Nikon writes no EXIF ColorSpace), sRGB when the file says
|
||||
nothing.
|
||||
Camera Raw's tuned import fits at the default exposure and as-shot white balance first,
|
||||
then applies the user's Exposure, Temperature and Tint to that same rendering.
|
||||
The D5100's measured image area is 4928 × 3264 at (8, 8) in a 4992 × 3280
|
||||
@@ -149,7 +153,10 @@ Raw rendering (quarter size, medians over the frames) the measured profile is 0.
|
||||
luminance with a mean CIE76 ΔE of 1.8; the look fitted to the embedded JPEG would be 0.30 stop and
|
||||
ΔE 6.4, as it follows the camera's picture style instead. The open-time re-develop
|
||||
(`photocraft-io`'s `import_raw_tuned`) and the tone curve its previews use (`tone_curve`) take the
|
||||
same look as the default open, so changing a slider does not change the colour rendering.
|
||||
same look as the default open, so changing a slider does not change the colour rendering. The D4's
|
||||
saturation level was measured on 14-bit files and follows the sample depth (a 12-bit frame is the
|
||||
14-bit one shifted right by two, so its level is a quarter of it): the three public 12-bit D4 files
|
||||
develop within 0.02 stop of their 14-bit twin.
|
||||
|
||||
## Tools
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
use std::time::Instant;
|
||||
|
||||
use photocraft_raw::{Demosaic, DevelopOptions, decode, develop_sensor, dump_structure, embedded_preview, identify};
|
||||
use photocraft_raw::{Demosaic, DevelopOptions, decode, develop_sensor, dump_structure, embedded_preview, embedded_preview_color_space, identify};
|
||||
|
||||
fn main() {
|
||||
let mut args = std::env::args().skip(1);
|
||||
@@ -76,7 +76,13 @@ fn main() {
|
||||
println!("{}", dump_structure(&bytes));
|
||||
}
|
||||
if let Some(p) = embedded_preview(&bytes) {
|
||||
println!(" preview: {}x{} JPEG, {} bytes", p.width, p.height, p.jpeg.len());
|
||||
println!(
|
||||
" preview: {}x{} JPEG, {} bytes, colour space stated by the file: {:?}",
|
||||
p.width,
|
||||
p.height,
|
||||
p.jpeg.len(),
|
||||
embedded_preview_color_space(&bytes)
|
||||
);
|
||||
if let Some(dir) = png.as_ref().filter(|d| std::path::Path::new(d).is_dir()) {
|
||||
let stem = std::path::Path::new(&f).file_stem().map(|s| s.to_string_lossy().into_owned()).unwrap_or_default();
|
||||
let _ = std::fs::write(format!("{dir}/{stem}.preview.jpg"), p.jpeg);
|
||||
|
||||
+57
-16
@@ -11,7 +11,9 @@
|
||||
//! (2 px of optical black on the left, 50 + 8 on the right show as a purple stripe otherwise). The
|
||||
//! data is already black-subtracted (the darkest image pixels reach 0). Green saturates at
|
||||
//! 15546–15672 while red and blue reach 15687–16383, so one level of 15520 makes clipped
|
||||
//! highlights white without shifting the white balance. Matrix, curve and black point copy
|
||||
//! highlights white without shifting the white balance. That level is for 14-bit files: the body
|
||||
//! also writes 12-bit ones, whose samples are the 14-bit values shifted right by two, so the
|
||||
//! level follows the sample depth (`Profile::white_at`). Matrix, curve and black point copy
|
||||
//! Photoshop Camera Raw's default rendering of these files, measured black-box: 29 NEFs opened
|
||||
//! in Photoshop 25.4 against our own linear development of the same data (8 × 8 means, pixels
|
||||
//! clipped in neither). The matrix is our first ForwardMatrix (fitted to the camera's embedded
|
||||
@@ -92,7 +94,10 @@ struct Profile {
|
||||
size: (usize, usize),
|
||||
/// The image area: x, y, width, height.
|
||||
crop: (usize, usize, usize, usize),
|
||||
/// The saturation level, in codes of `white_bits`-bit samples.
|
||||
white: f32,
|
||||
/// The sample depth `white` was measured at.
|
||||
white_bits: u32,
|
||||
/// The black level is known to be 0 (the data is black-subtracted in camera).
|
||||
black_zero: bool,
|
||||
forward: Mat3,
|
||||
@@ -102,12 +107,25 @@ struct Profile {
|
||||
black_point: f32,
|
||||
}
|
||||
|
||||
impl Profile {
|
||||
/// The saturation level for `bits`-bit samples. A body that writes several depths stores the
|
||||
/// lower ones as the deepest value shifted right (a 12-bit D4 sample is the 14-bit sample
|
||||
/// divided by four), so the level scales by the same power of two. At the depth the level was
|
||||
/// measured at it is returned unchanged.
|
||||
fn white_at(&self, bits: u32) -> f32 {
|
||||
let bits = bits.clamp(1, 16);
|
||||
let measured = self.white_bits.clamp(1, 16);
|
||||
if bits >= measured { self.white * f32::from(1u16 << (bits - measured)) } else { self.white / f32::from(1u16 << (measured - bits)) }
|
||||
}
|
||||
}
|
||||
|
||||
const PROFILES: &[Profile] = &[Profile {
|
||||
make: "NIKON CORPORATION",
|
||||
model: "NIKON D4",
|
||||
size: (4992, 3292),
|
||||
crop: (8, 6, 4928, 3280),
|
||||
white: 15520.0,
|
||||
white_bits: 14,
|
||||
black_zero: true,
|
||||
forward: D4_FORWARD,
|
||||
color: D4_COLOR,
|
||||
@@ -148,8 +166,9 @@ const IMAGE_AREAS: &[ImageArea] = &[
|
||||
];
|
||||
|
||||
/// Applies the measured profile of the camera that made `s`, when there is one,
|
||||
/// and its measured image area when the profile is not measured yet.
|
||||
pub(crate) fn apply(s: &mut Sensor) {
|
||||
/// and its measured image area when the profile is not measured yet. `bits` is the depth of
|
||||
/// the stored samples (the profile's saturation level depends on it).
|
||||
pub(crate) fn apply(s: &mut Sensor, bits: u32) {
|
||||
let (Some(make), Some(model)) = (s.make.as_deref(), s.model.as_deref()) else { return };
|
||||
let (make, model) = (make.trim(), model.trim());
|
||||
if let Some(a) = IMAGE_AREAS.iter().find(|a| a.make == make && a.model == model && a.size == (s.width, s.height) && s.crop == s.active) {
|
||||
@@ -164,7 +183,7 @@ pub(crate) fn apply(s: &mut Sensor) {
|
||||
}
|
||||
let (x, y, w, h) = p.crop;
|
||||
s.crop = Rect::new(x, y, w, h);
|
||||
s.white = [p.white; 3];
|
||||
s.white = [p.white_at(bits); 3];
|
||||
if p.black_zero {
|
||||
s.warnings.retain(|w| !w.contains("black level not recorded"));
|
||||
}
|
||||
@@ -217,7 +236,7 @@ mod tests {
|
||||
#[test]
|
||||
fn a_d4_nef_gets_its_crop_levels_matrix_and_curve() {
|
||||
let mut s = nef("NIKON D4", 4992, 3292);
|
||||
apply(&mut s);
|
||||
apply(&mut s, 14);
|
||||
assert_eq!(s.crop, Rect::new(8, 6, 4928, 3280));
|
||||
assert_eq!(s.white, [15520.0; 3]);
|
||||
assert_eq!(s.color.calibrations.len(), 1);
|
||||
@@ -229,6 +248,28 @@ mod tests {
|
||||
assert!(s.color.balanced_to_xyz_d50([0.5, 1.0, 0.7]).is_some());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_d4_white_level_follows_the_sample_depth() {
|
||||
// 14 bits is the depth it was measured at: unchanged.
|
||||
let mut s = nef("NIKON D4", 4992, 3292);
|
||||
apply(&mut s, 14);
|
||||
assert_eq!(s.white, [15520.0; 3]);
|
||||
// A 12-bit sample is the 14-bit one shifted right by two.
|
||||
let mut s = nef("NIKON D4", 4992, 3292);
|
||||
apply(&mut s, 12);
|
||||
assert_eq!(s.white, [3880.0; 3]);
|
||||
// Everything else of the profile is independent of the depth.
|
||||
assert_eq!(s.crop, Rect::new(8, 6, 4928, 3280));
|
||||
assert_eq!(s.tone_curve.len(), D4_TONE.len());
|
||||
assert!(s.warnings.is_empty());
|
||||
// Other depths scale the same way and stay inside their own range; nonsense stays finite.
|
||||
for (bits, white) in [(1, 15520.0 / 8192.0), (8, 15520.0 / 64.0), (13, 7760.0), (16, 62080.0), (0, 15520.0 / 8192.0), (200, 62080.0)] {
|
||||
let mut s = nef("NIKON D4", 4992, 3292);
|
||||
apply(&mut s, bits);
|
||||
assert_eq!(s.white, [white; 3], "{bits} bits");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn d5100_image_area_respects_explicit_crops_and_exact_sensor_size() {
|
||||
let mut s = nef("NIKON D5100", 4992, 3280);
|
||||
@@ -236,7 +277,7 @@ mod tests {
|
||||
s.active = Rect::new(0, 0, 4984, 3280);
|
||||
s.crop = s.active;
|
||||
let wb = s.camera_wb;
|
||||
apply(&mut s);
|
||||
apply(&mut s, 14);
|
||||
assert_eq!(s.crop, Rect::new(8, 8, 4928, 3264));
|
||||
assert_eq!(s.active, Rect::new(0, 0, 4984, 3280));
|
||||
assert_eq!(s.camera_wb, wb);
|
||||
@@ -244,11 +285,11 @@ mod tests {
|
||||
assert_eq!(s.white, [16383.0; 3]);
|
||||
|
||||
s.crop = Rect::new(16, 12, 4800, 3200);
|
||||
apply(&mut s);
|
||||
apply(&mut s, 14);
|
||||
assert_eq!(s.crop, Rect::new(16, 12, 4800, 3200));
|
||||
for (model, w, h) in [("NIKON D5100", 2496, 1640), ("NIKON D5200", 4992, 3280)] {
|
||||
let mut other = nef(model, w, h);
|
||||
apply(&mut other);
|
||||
apply(&mut other, 14);
|
||||
assert_eq!(other.crop, other.active);
|
||||
}
|
||||
}
|
||||
@@ -256,36 +297,36 @@ mod tests {
|
||||
#[test]
|
||||
fn measured_image_areas_crop_the_borders_without_touching_the_rest() {
|
||||
let mut s = nef("NIKON D800E", 7424, 4924);
|
||||
apply(&mut s);
|
||||
apply(&mut s, 14);
|
||||
assert_eq!(s.crop, Rect::new(8, 6, 7360, 4912));
|
||||
// Only the image area is measured: levels, colour and tone stay untouched.
|
||||
assert!(s.color.calibrations.is_empty() && s.tone_curve.is_empty());
|
||||
assert_eq!(s.white, [16383.0; 3]);
|
||||
|
||||
let mut s = sensor("SONY", "ILCE-7", 6048, 4024);
|
||||
apply(&mut s);
|
||||
apply(&mut s, 14);
|
||||
assert_eq!(s.crop, Rect::new(12, 12, 6000, 4000));
|
||||
|
||||
// Another size or model of the same maker is left alone.
|
||||
let mut s = nef("NIKON D800E", 2496, 1646);
|
||||
apply(&mut s);
|
||||
apply(&mut s, 14);
|
||||
assert_eq!(s.crop, Rect::new(0, 0, 2496, 1646));
|
||||
let mut s = nef("NIKON D800", 7424, 4924);
|
||||
apply(&mut s);
|
||||
apply(&mut s, 14);
|
||||
assert_eq!(s.crop, Rect::new(0, 0, 7424, 4924));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn d90_image_area_matches_the_camera_jpeg() {
|
||||
let mut s = nef("NIKON D90", 4352, 2868);
|
||||
apply(&mut s);
|
||||
apply(&mut s, 14);
|
||||
assert_eq!(s.crop, Rect::new(10, 10, 4288, 2848));
|
||||
// Only the image area is measured: levels, colour and tone stay untouched.
|
||||
assert!(s.color.calibrations.is_empty() && s.tone_curve.is_empty());
|
||||
assert_eq!(s.white, [16383.0; 3]);
|
||||
// An explicit crop in the file wins over the measured area.
|
||||
s.crop = Rect::new(0, 0, 4288, 2848);
|
||||
apply(&mut s);
|
||||
apply(&mut s, 14);
|
||||
assert_eq!(s.crop, Rect::new(0, 0, 4288, 2848));
|
||||
}
|
||||
|
||||
@@ -298,7 +339,7 @@ mod tests {
|
||||
calibrations: vec![Calibration { temperature: 6504.0, color_matrix: IDENTITY, forward_matrix: None, camera_calibration: IDENTITY }],
|
||||
..ColorInfo::default()
|
||||
};
|
||||
apply(&mut s);
|
||||
apply(&mut s, 14);
|
||||
assert_eq!(s.color.calibrations.len(), 1);
|
||||
assert_eq!(s.color.calibrations[0].temperature, 6504.0, "the file's own calibration stands");
|
||||
assert!(s.tone_curve.is_empty() && s.black_point == 0.0);
|
||||
@@ -309,7 +350,7 @@ mod tests {
|
||||
fn other_cameras_and_sizes_are_left_alone() {
|
||||
for (model, w, h) in [("NIKON D4S", 4992, 3292), ("NIKON D4", 2496, 1646), ("NIKON D800", 7424, 4924)] {
|
||||
let mut s = nef(model, w, h);
|
||||
apply(&mut s);
|
||||
apply(&mut s, 14);
|
||||
assert_eq!(s.crop, Rect::new(0, 0, w, h), "{model} {w}x{h}");
|
||||
assert!(s.tone_curve.is_empty() && s.color.calibrations.is_empty() && s.white == [16383.0; 3]);
|
||||
assert_eq!(s.warnings.len(), 1);
|
||||
|
||||
+119
-6
@@ -107,18 +107,30 @@ pub enum PreviewColorSpace {
|
||||
AdobeRgb,
|
||||
}
|
||||
|
||||
/// The colour space the raw's EXIF gives for the camera's JPEG rendering, for a preview that declares none itself:
|
||||
/// ColorSpace (0xA001) 1 = sRGB, or Uncalibrated (0xFFFF) with the Interoperability IFD's InteropIndex "R03", the
|
||||
/// DCF option file for Adobe RGB (as a Sony body set to Adobe RGB writes; Exif and DCF specifications). `None` when
|
||||
/// the file doesn't say, and for a DNG, whose EXIF describes the original capture while its previews are the
|
||||
/// converter's. A preview's own ICC profile takes precedence over this.
|
||||
/// Nikon maker note tag ColorSpace: 1 = sRGB, 2 = Adobe RGB (4 = BT.2100, which is not a preview colour space we
|
||||
/// read), from ExifTool's public Nikon tag documentation.
|
||||
const NIKON_COLOR_SPACE: u16 = 0x001E;
|
||||
|
||||
/// The colour space the raw states for the camera's JPEG rendering, for a preview that declares none itself:
|
||||
/// * the EXIF ColorSpace (0xA001) 1 = sRGB, or Uncalibrated (0xFFFF) with the Interoperability IFD's InteropIndex
|
||||
/// "R03", the DCF option file for Adobe RGB (as a Sony body set to Adobe RGB writes; Exif and DCF specifications);
|
||||
/// * else, where the EXIF doesn't decide, a Nikon maker note's ColorSpace (0x001E): Nikon bodies write no EXIF
|
||||
/// ColorSpace, and say Adobe RGB only here.
|
||||
///
|
||||
/// `None` when the file doesn't say, and for a DNG, whose EXIF describes the original capture while its previews
|
||||
/// are the converter's. A preview's own ICC profile takes precedence over this.
|
||||
pub fn embedded_preview_color_space(bytes: &[u8]) -> Option<PreviewColorSpace> {
|
||||
let t = Tiff::new(bytes)?;
|
||||
let ifd0 = t.ifd_at(t.first_ifd, 0)?;
|
||||
if ifd0.has(tag::DNG_VERSION) {
|
||||
return None;
|
||||
}
|
||||
let exif = t.ifd_at(t.tag_uint(&ifd0, tag::EXIF_IFD)? as usize, 0)?;
|
||||
exif_color_space(&t, &ifd0).or_else(|| nikon_color_space(&t))
|
||||
}
|
||||
|
||||
/// The colour space the EXIF IFD gives (see [`embedded_preview_color_space`]).
|
||||
fn exif_color_space(t: &Tiff<'_>, ifd0: &crate::tiff::Ifd) -> Option<PreviewColorSpace> {
|
||||
let exif = t.ifd_at(t.tag_uint(ifd0, tag::EXIF_IFD)? as usize, 0)?;
|
||||
match t.tag_uint(&exif, tag::COLOR_SPACE)? {
|
||||
1 => Some(PreviewColorSpace::Srgb),
|
||||
0xFFFF => {
|
||||
@@ -129,6 +141,16 @@ pub fn embedded_preview_color_space(bytes: &[u8]) -> Option<PreviewColorSpace> {
|
||||
}
|
||||
}
|
||||
|
||||
/// The colour space a Nikon maker note gives.
|
||||
fn nikon_color_space(t: &Tiff<'_>) -> Option<PreviewColorSpace> {
|
||||
let (note, ifd) = crate::tiffep::nikon_maker_note(t, &t.all_ifds())?;
|
||||
match note.tag_uint(&ifd, NIKON_COLOR_SPACE)? {
|
||||
1 => Some(PreviewColorSpace::Srgb),
|
||||
2 => Some(PreviewColorSpace::AdobeRgb),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
@@ -167,4 +189,95 @@ mod tests {
|
||||
assert_eq!(embedded_preview_color_space(junk), None);
|
||||
}
|
||||
}
|
||||
|
||||
/// The maker note's embedded TIFF stream (`ifd` entries, in the given byte order) behind `header`.
|
||||
fn maker_note(header: &[u8], tags: Vec<(u16, Val)>, big_endian: bool) -> Vec<u8> {
|
||||
let mut note = TiffBuilder { big_endian, ..Default::default() };
|
||||
let ifd = note.ifd(tags);
|
||||
note.chain = vec![ifd];
|
||||
let mut maker = header.to_vec();
|
||||
maker.extend(note.build());
|
||||
maker
|
||||
}
|
||||
|
||||
/// A raw whose EXIF IFD holds the entries `exif` makes (it may add directories to the builder) and a maker note.
|
||||
fn raw_with_note(maker: Vec<u8>, exif: impl FnOnce(&mut TiffBuilder) -> Vec<(u16, Val)>, dng: bool) -> Vec<u8> {
|
||||
let mut t = TiffBuilder::default();
|
||||
let mut exif = exif(&mut t);
|
||||
exif.push((tag::MAKER_NOTE, Val::Undefined(maker)));
|
||||
let exif = t.ifd(exif);
|
||||
let mut ifd0 = vec![(tag::MAKE, Val::Ascii("NIKON CORPORATION".into())), (tag::EXIF_IFD, Val::Ifds(vec![exif]))];
|
||||
if dng {
|
||||
ifd0.push((tag::DNG_VERSION, Val::Byte(vec![1, 6, 0, 0])));
|
||||
}
|
||||
t.chain = vec![t.ifd(ifd0)];
|
||||
t.build()
|
||||
}
|
||||
|
||||
const NIKON: &[u8] = b"Nikon\0\x02\x10\0\0";
|
||||
|
||||
/// A Nikon raw whose maker note has ColorSpace `color_space` (when given) and whose EXIF IFD holds `exif`.
|
||||
fn nikon_raw(color_space: Option<u16>, exif: impl FnOnce(&mut TiffBuilder) -> Vec<(u16, Val)>, big_endian: bool) -> Vec<u8> {
|
||||
let tags = color_space.map(|cs| (NIKON_COLOR_SPACE, Val::Short(vec![cs]))).into_iter().chain([(0x0002, Val::Ascii("200".into()))]).collect();
|
||||
raw_with_note(maker_note(NIKON, tags, big_endian), exif, false)
|
||||
}
|
||||
|
||||
/// EXIF entries for a preview in Adobe RGB the way a Sony body writes it: Uncalibrated, Interoperability "R03".
|
||||
fn exif_r03(t: &mut TiffBuilder) -> Vec<(u16, Val)> {
|
||||
let interop = t.ifd(vec![(tag::INTEROP_INDEX, Val::Ascii("R03".into()))]);
|
||||
vec![(tag::COLOR_SPACE, Val::Short(vec![0xFFFF])), (tag::INTEROP_IFD, Val::Ifds(vec![interop]))]
|
||||
}
|
||||
|
||||
/// Nikon bodies write no EXIF ColorSpace; the maker note's ColorSpace (1 sRGB, 2 Adobe RGB) is
|
||||
/// what says their JPEG previews are Adobe RGB.
|
||||
#[test]
|
||||
fn nikon_maker_note_colour_space_of_the_previews() {
|
||||
for big_endian in [false, true] {
|
||||
assert_eq!(embedded_preview_color_space(&nikon_raw(Some(2), |_| vec![], big_endian)), Some(PreviewColorSpace::AdobeRgb), "be {big_endian}");
|
||||
assert_eq!(embedded_preview_color_space(&nikon_raw(Some(1), |_| vec![], big_endian)), Some(PreviewColorSpace::Srgb), "be {big_endian}");
|
||||
}
|
||||
// BT.2100 (4), unknown values, a note without the tag
|
||||
for cs in [Some(4), Some(0), Some(3), Some(0xFFFF), None] {
|
||||
assert_eq!(embedded_preview_color_space(&nikon_raw(cs, |_| vec![], false)), None, "{cs:?}");
|
||||
}
|
||||
}
|
||||
|
||||
/// The EXIF IFD, when it states a colour space, comes before the maker note; when it does not decide, the
|
||||
/// maker note does.
|
||||
#[test]
|
||||
fn exif_colour_space_comes_before_the_nikon_maker_note() {
|
||||
// EXIF says sRGB, the note Adobe RGB: EXIF wins.
|
||||
let raw = nikon_raw(Some(2), |_| vec![(tag::COLOR_SPACE, Val::Short(vec![1]))], false);
|
||||
assert_eq!(embedded_preview_color_space(&raw), Some(PreviewColorSpace::Srgb));
|
||||
// EXIF says Adobe RGB (R03), the note sRGB: EXIF wins.
|
||||
assert_eq!(embedded_preview_color_space(&nikon_raw(Some(1), exif_r03, false)), Some(PreviewColorSpace::AdobeRgb));
|
||||
// EXIF says Uncalibrated without R03, which decides nothing: the note does.
|
||||
let raw = nikon_raw(Some(2), |_| vec![(tag::COLOR_SPACE, Val::Short(vec![0xFFFF]))], false);
|
||||
assert_eq!(embedded_preview_color_space(&raw), Some(PreviewColorSpace::AdobeRgb));
|
||||
}
|
||||
|
||||
/// Only a Nikon maker note is read, and not for a DNG, whose previews are the converter's.
|
||||
#[test]
|
||||
fn only_a_nikon_maker_note_of_a_non_dng_is_read() {
|
||||
let tags = || vec![(NIKON_COLOR_SPACE, Val::Short(vec![2]))];
|
||||
assert_eq!(embedded_preview_color_space(&raw_with_note(maker_note(NIKON, tags(), false), |_| vec![], false)), Some(PreviewColorSpace::AdobeRgb));
|
||||
assert_eq!(embedded_preview_color_space(&raw_with_note(maker_note(NIKON, tags(), false), |_| vec![], true)), None);
|
||||
for header in [&b"OLYMPUS\0II\x03\0"[..], b"SONY DSC \0\0\0", b"Nikon", b""] {
|
||||
assert_eq!(embedded_preview_color_space(&raw_with_note(maker_note(header, tags(), false), |_| vec![], false)), None, "{header:?}");
|
||||
}
|
||||
}
|
||||
|
||||
/// A maker note that is cut short or points outside the file states nothing, and never panics.
|
||||
#[test]
|
||||
fn a_damaged_nikon_maker_note_states_nothing() {
|
||||
let good = maker_note(NIKON, vec![(NIKON_COLOR_SPACE, Val::Short(vec![2]))], false);
|
||||
assert_eq!(embedded_preview_color_space(&raw_with_note(good.clone(), |_| vec![], false)), Some(PreviewColorSpace::AdobeRgb));
|
||||
for len in 0..good.len() {
|
||||
let _ = embedded_preview_color_space(&raw_with_note(good[..len].to_vec(), |_| vec![], false));
|
||||
}
|
||||
// the embedded TIFF's first-IFD offset (bytes 14..18 of the note) points outside the file
|
||||
let mut wild = good.clone();
|
||||
wild[14..18].copy_from_slice(&[0xFF; 4]);
|
||||
assert_eq!(embedded_preview_color_space(&raw_with_note(wild, |_| vec![], false)), None);
|
||||
}
|
||||
}
|
||||
@@ -66,7 +66,7 @@ pub(crate) fn cfa(t: &Tiff, raw: &Ifd, ifds: &[Ifd]) -> Option<Cfa> {
|
||||
|
||||
/// Nikon maker note: "Nikon\0", version, then an embedded TIFF header whose
|
||||
/// offsets are relative to itself.
|
||||
fn nikon_maker_note<'a>(t: &Tiff<'a>, ifds: &[Ifd]) -> Option<(Tiff<'a>, Ifd)> {
|
||||
pub(crate) fn nikon_maker_note<'a>(t: &Tiff<'a>, ifds: &[Ifd]) -> Option<(Tiff<'a>, Ifd)> {
|
||||
let e = ifds.iter().find_map(|i| i.get(tag::MAKER_NOTE).copied())?;
|
||||
let b = t.raw(&e)?;
|
||||
if !b.starts_with(b"Nikon\0") {
|
||||
@@ -254,7 +254,7 @@ pub(crate) fn decode(t: &Tiff, format: RawFormat, limits: &Limits) -> Result<Sen
|
||||
black_point: 0.0,
|
||||
warnings,
|
||||
};
|
||||
crate::cameras::apply(&mut sensor);
|
||||
crate::cameras::apply(&mut sensor, plane.bits);
|
||||
Ok(sensor)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,32 @@
|
||||
//! Truncated and corrupted raw files must fail cleanly, never panic, and
|
||||
//! never allocate beyond the limits.
|
||||
|
||||
use photocraft_raw::testgen::{Cr2Spec, DngSpec, DngStorage, RafPacking, RafSpec, XTRANS, mosaic, mosaic_cfa, orf, rw2, scene, sony_craw, tiff_ep};
|
||||
use photocraft_raw::testgen::{
|
||||
Cr2Spec, DngSpec, DngStorage, RafPacking, RafSpec, Val, XTRANS, mosaic, mosaic_cfa, nef_compressed, orf, rw2, scene, sony_craw, tiff_ep,
|
||||
};
|
||||
use photocraft_raw::*;
|
||||
|
||||
/// 12-bit samples packed little-endian, `w` per row, rows byte-aligned (Nikon's packed NEF layout).
|
||||
fn pack12(values: &[u16], w: usize) -> Vec<u8> {
|
||||
let mut out = Vec::new();
|
||||
for row in values.chunks_exact(w) {
|
||||
let (mut acc, mut have) = (0u32, 0u32);
|
||||
for v in row {
|
||||
acc |= u32::from(*v) << have;
|
||||
have += 12;
|
||||
while have >= 8 {
|
||||
out.push(acc as u8);
|
||||
acc >>= 8;
|
||||
have -= 8;
|
||||
}
|
||||
}
|
||||
if have > 0 {
|
||||
out.push(acc as u8);
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// Losslessly encodes 16-bit RGB as a JPEG XL codestream.
|
||||
fn jxl_rgb16(rgb: &[u16], w: usize, h: usize) -> Vec<u8> {
|
||||
use zune_core::{bit_depth::BitDepth, colorspace::ColorSpace, options::EncoderOptions};
|
||||
@@ -84,6 +107,8 @@ fn samples() -> Vec<Vec<u8>> {
|
||||
.build(),
|
||||
);
|
||||
out.push(tiff_ep("NIKON", w, h, &cfa, [0, 1, 1, 2], 12, vec![]));
|
||||
// A Nikon NEF (packed 12-bit) whose maker note says the previews are Adobe RGB (ColorSpace 0x001E).
|
||||
out.push(nef_compressed(w, h, 12, pack12(&cfa, w), [0, 1, 1, 2], false, vec![(0x0093, Val::Short(vec![6])), (0x001E, Val::Short(vec![2]))]));
|
||||
let codes = mosaic(&scene(64, 6), 64, [0, 1, 1, 2], 256, 1900);
|
||||
out.push(sony_craw(64, 6, &codes, [8000, 10400, 12900, 14100]));
|
||||
out.push(rw2(30, 8, &mosaic(&scene(30, 8), 30, [0, 1, 1, 2], 128, 4095), 12));
|
||||
@@ -126,6 +151,12 @@ fn originals_develop() {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_seed_states_a_maker_note_colour_space() {
|
||||
// The truncation and corruption tests below only exercise the maker-note reader if a seed has one.
|
||||
assert!(samples().iter().any(|b| embedded_preview_color_space(b) == Some(PreviewColorSpace::AdobeRgb)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn every_truncation_fails_cleanly() {
|
||||
for b in samples() {
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
//! The Nikon D4 profile (`cameras.rs`) was measured on 14-bit NEFs. The camera also writes 12-bit
|
||||
//! files (lossless, lossy and uncompressed) whose samples are the 14-bit values shifted right by
|
||||
//! two, so the profile's saturation level must follow the sample depth: a 12-bit D4 frame has to
|
||||
//! develop as bright as the same scene at 14 bits.
|
||||
|
||||
use photocraft_raw::testgen::{Val, tiff_ep};
|
||||
use photocraft_raw::{Demosaic, DevelopOptions, Limits, Rect, WhiteBalance, decode, develop_sensor};
|
||||
|
||||
const WIDTH: usize = 4992;
|
||||
const HEIGHT: usize = 3292;
|
||||
|
||||
/// A synthetic D4 NEF: a smooth ramp, 14-bit values (3000..7000, well below the saturation
|
||||
/// level) stored at `bits`.
|
||||
fn d4_nef(bits: u16) -> Vec<u8> {
|
||||
let shift = 14 - u32::from(bits);
|
||||
let data: Vec<u16> = (0..WIDTH * HEIGHT).map(|i| (3000 + ((i % WIDTH) + 2 * (i / WIDTH)) % 4000) as u16 >> shift).collect();
|
||||
tiff_ep("NIKON CORPORATION", WIDTH, HEIGHT, &data, [0, 1, 1, 2], bits, vec![(272, Val::Ascii("NIKON D4".into()))])
|
||||
}
|
||||
|
||||
/// Mean linear luminance of the developed ProPhoto frame over a small window of the image.
|
||||
fn mean_luminance(bits: u16) -> (f32, f64) {
|
||||
let mut s = decode(&d4_nef(bits), &Limits::default()).expect("a synthetic D4 NEF decodes");
|
||||
let white = s.white[1];
|
||||
// Only a window is developed: the profile is keyed on the full sensor size, the test is not.
|
||||
s.crop = Rect::new(2000, 1000, 64, 64);
|
||||
let opts = DevelopOptions { demosaic: Demosaic::Bilinear, white_balance: WhiteBalance::Multipliers([2.0, 1.0, 1.5]), ..DevelopOptions::default() };
|
||||
let d = develop_sensor(&s, &opts).expect("a synthetic D4 NEF develops");
|
||||
let lin = |v: u16| (f64::from(v) / 65535.0).powf(1.8);
|
||||
let pixels = d.rgb.as_chunks::<3>().0;
|
||||
let y: f64 = pixels.iter().map(|p| 0.2880402 * lin(p[0]) + 0.7118741 * lin(p[1]) + 0.0000857 * lin(p[2])).sum();
|
||||
(white, y / pixels.len() as f64)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_12_bit_d4_nef_develops_as_bright_as_the_same_scene_at_14_bit() {
|
||||
let (white14, y14) = mean_luminance(14);
|
||||
let (white12, y12) = mean_luminance(12);
|
||||
let stops = (y12 / y14).log2();
|
||||
assert!(stops.abs() < 0.2, "12-bit differs from 14-bit by {stops:.2} stops (mean Y {y12:.4} vs {y14:.4})");
|
||||
// The 14-bit level is the measured one, untouched.
|
||||
assert_eq!(white14, 15520.0);
|
||||
// The 12-bit level is the same fraction of the (4095-range) data.
|
||||
assert_eq!(white12, 3880.0);
|
||||
}
|
||||
@@ -95,8 +95,32 @@ pub(crate) fn assign_shortcut(app: &mut PhotocraftApp, name: &str, shortcut: &st
|
||||
/// Replay edits synchronously, with view steps handled by the shell in the same order.
|
||||
/// Engine steps keep the headless action semantics (no dialogs or background jobs).
|
||||
pub(crate) fn play(app: &mut PhotocraftApp, params: &Value) -> Result<Value, String> {
|
||||
let (action, from) = actions_cmds::playback_plan(&app.session, params).map_err(|e| e.to_string())?;
|
||||
let recording = actions_cmds::begin_playback(&mut app.session, &action).map_err(|e| e.to_string())?;
|
||||
play_owned(app, params, None)
|
||||
}
|
||||
|
||||
/// `suspended` is the recording a paused part of the same call took (`RECORD`); it comes
|
||||
/// back, with that named call journaled, only when the whole call ends.
|
||||
fn play_owned(app: &mut PhotocraftApp, params: &Value, suspended: Option<Value>) -> Result<Value, String> {
|
||||
let (action, from) = match actions_cmds::playback_plan(&app.session, params) {
|
||||
Ok(plan) => plan,
|
||||
Err(e) => {
|
||||
restore_recording(app, suspended.as_ref());
|
||||
return Err(e.to_string());
|
||||
}
|
||||
};
|
||||
let recording = match actions_cmds::begin_playback(&mut app.session, &action) {
|
||||
Ok(r) => r,
|
||||
Err(e) => {
|
||||
restore_recording(app, suspended.as_ref());
|
||||
return Err(e.to_string());
|
||||
}
|
||||
};
|
||||
let owner = recording
|
||||
.map(|(_, idx)| {
|
||||
let into = app.session.actions.list.get(idx).map(|a| a.name.clone());
|
||||
json!({"index": idx, "into": into, "action": action.name, "from": from})
|
||||
})
|
||||
.or(suspended);
|
||||
let mut ran = 0u64;
|
||||
let mut failed = None;
|
||||
let mut paused = None;
|
||||
@@ -155,7 +179,18 @@ pub(crate) fn play(app: &mut PhotocraftApp, params: &Value) -> Result<Value, Str
|
||||
}
|
||||
}
|
||||
}
|
||||
actions_cmds::finish_playback(&mut app.session, recording, &action, from);
|
||||
actions_cmds::finish_playback(&mut app.session, None, &action, from);
|
||||
match paused.as_ref().and_then(|p| p.get("dialog")).and_then(Value::as_u64).and_then(|d| app.ui.dialog_mut(d)) {
|
||||
// Paused for a dialog: the call goes on after it, so recording stays suspended.
|
||||
Some(d) if failed.is_none() => match (owner, d.fields.get_mut(RESUME)) {
|
||||
(Some(owner), Some(Value::Object(r))) => {
|
||||
r.insert(RECORD.into(), owner);
|
||||
}
|
||||
// No continuation to carry the recording: the call ends here.
|
||||
(owner, _) => restore_recording(app, owner.as_ref()),
|
||||
},
|
||||
_ => restore_recording(app, owner.as_ref()),
|
||||
}
|
||||
Ok(match (failed, paused) {
|
||||
(Some(f), _) => json!({"action": action.name, "ran": ran, "failed": f}),
|
||||
(None, Some(p)) => json!({"action": action.name, "ran": ran, "paused": p}),
|
||||
@@ -435,21 +470,74 @@ pub fn insert_stop_confirm(app: &mut PhotocraftApp, fields: &serde_json::Map<Str
|
||||
/// The key a paused playback leaves in its dialog's fields: `{action, from}`.
|
||||
pub const RESUME: &str = "__resumeAction";
|
||||
|
||||
/// The recording a paused call suspended, kept in its `RESUME` entry:
|
||||
/// `{index, into, action, from}` (`into` is the name of the action being recorded).
|
||||
/// A step dialog only closes through `dialogs::confirm` (OK, `↩`, automation) or
|
||||
/// `dialogs::cancel` (Cancel, Esc, the close box, automation), which end the call through
|
||||
/// `resume`, `abandoned` or `stopped`, so the recording comes back exactly once.
|
||||
const RECORD: &str = "record";
|
||||
|
||||
/// Resume the recording a paused call suspended and journal that call, once.
|
||||
fn restore_recording(app: &mut PhotocraftApp, owner: Option<&Value>) {
|
||||
let Some(owner) = owner else { return };
|
||||
let (Some(idx), Some(into), Some(name)) = (
|
||||
owner.get("index").and_then(Value::as_u64).and_then(|n| usize::try_from(n).ok()),
|
||||
owner.get("into").and_then(Value::as_str),
|
||||
owner.get("action").and_then(Value::as_str),
|
||||
) else {
|
||||
return;
|
||||
};
|
||||
let from = owner.get("from").and_then(Value::as_u64).and_then(|n| usize::try_from(n).ok()).unwrap_or(0);
|
||||
// `suspended_guard` refuses what would move the recorded action, but another command may
|
||||
// still replace the list: the call goes to the action of that name, never to whatever now
|
||||
// sits at the old index, and is dropped if that action is gone.
|
||||
let list = &app.session.actions.list;
|
||||
let target = if list.get(idx).is_some_and(|a| a.name == into) { Some(idx) } else { list.iter().position(|a| a.name == into) };
|
||||
if let Some(idx) = target
|
||||
&& app.session.actions.recording.is_none()
|
||||
{
|
||||
actions_cmds::restore_recording(&mut app.session, idx, name, from);
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether a step dialog holds a suspended recording.
|
||||
fn suspended(app: &PhotocraftApp) -> bool {
|
||||
app.ui.dialogs.iter().any(|d| d.fields.get(RESUME).and_then(|r| r.get(RECORD)).is_some())
|
||||
}
|
||||
|
||||
/// While a step dialog holds a suspended recording, refuse what would lose its call: a new
|
||||
/// recording (the restore would find recording taken) or deleting/moving actions (the recorded
|
||||
/// action could go away or change place). The engine checks these against `recording`, which
|
||||
/// is `None` then.
|
||||
pub(crate) fn suspended_guard(app: &PhotocraftApp, id: &str) -> Result<(), String> {
|
||||
if matches!(id, "actions.record" | "actions.delete" | "actions.move") && suspended(app) {
|
||||
return Err(tl!("Confirm or cancel the open action step dialog first").into());
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// A step dialog's command failed: the action ends there.
|
||||
pub fn abandoned(app: &mut PhotocraftApp, fields: &serde_json::Map<String, Value>) {
|
||||
restore_recording(app, fields.get(RESUME).and_then(|r| r.get(RECORD)));
|
||||
}
|
||||
|
||||
/// A step dialog confirmed: continue the action after it (`dialogs::confirm` calls this).
|
||||
pub fn resume(app: &mut PhotocraftApp, fields: &serde_json::Map<String, Value>) -> Result<(), String> {
|
||||
let Some(r) = fields.get(RESUME) else { return Ok(()) };
|
||||
let owner = r.get(RECORD).cloned();
|
||||
// The dialog's command may run as a background job; the next step needs its result.
|
||||
if let Some(doc) = app.session.active().map(|d| d.doc.id)
|
||||
&& let Some(job) = app.session.job_on(doc)
|
||||
&& let Err(e) = app.session.wait_job(job.id)
|
||||
{
|
||||
restore_recording(app, owner.as_ref());
|
||||
let template = "Action playback failed: {error}";
|
||||
app.ui.status = crate::i18n::fmt(tl!(template), &[("error", &e.to_string())]);
|
||||
app.ui.status_error = true;
|
||||
return Err(e.to_string());
|
||||
}
|
||||
let params = json!({"action": r.get("action").cloned().unwrap_or(Value::Null), "from": r.get("from").cloned().unwrap_or(Value::Null)});
|
||||
match play(app, ¶ms) {
|
||||
match play_owned(app, ¶ms, owner) {
|
||||
Ok(v) => {
|
||||
report_play(app, &v);
|
||||
Ok(())
|
||||
@@ -466,6 +554,7 @@ pub fn resume(app: &mut PhotocraftApp, fields: &serde_json::Map<String, Value>)
|
||||
/// A step dialog cancelled: the action stops there, as in Photoshop.
|
||||
pub fn stopped(app: &mut PhotocraftApp, fields: &serde_json::Map<String, Value>) {
|
||||
if fields.contains_key(RESUME) {
|
||||
abandoned(app, fields);
|
||||
app.ui.status = tl!("Action playback stopped").to_string();
|
||||
app.ui.status_error = false;
|
||||
}
|
||||
@@ -1688,6 +1777,134 @@ mod tests {
|
||||
assert!(v.get("paused").is_none());
|
||||
}
|
||||
|
||||
/// An 8×6 document, a Child action whose first step (a blur) shows its dialog and whose
|
||||
/// second step adds a "Suffix" layer, and recording into Owner started.
|
||||
fn recording_with_dialog_child() -> PhotocraftApp {
|
||||
let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default());
|
||||
app.run("file.new", json!({"width": 8, "height": 6, "background": "#203040"})).unwrap();
|
||||
let mut child =
|
||||
Action::new("Child", vec![("filter.blur.gaussianBlur".into(), json!({"radius": 1.5})), ("layer.new.layer".into(), json!({"name": "Suffix"}))]);
|
||||
child.dialogs.insert(0);
|
||||
app.session.actions.list.push(child);
|
||||
app.run("actions.record", json!({"name": "Owner"})).unwrap();
|
||||
app
|
||||
}
|
||||
|
||||
fn suffixes(app: &PhotocraftApp) -> usize {
|
||||
app.session.active().unwrap().doc.walk().iter().filter(|(_, _, l)| l.name == "Suffix").count()
|
||||
}
|
||||
|
||||
fn child_call() -> Vec<(String, Value)> {
|
||||
vec![("actions.play".to_string(), json!({"action": "Child"}))]
|
||||
}
|
||||
|
||||
/// Play Child and return the id of its step dialog.
|
||||
fn pause_child(app: &mut PhotocraftApp) -> u64 {
|
||||
let v = play(app, &json!({"action": "Child"})).unwrap();
|
||||
v["paused"]["dialog"].as_u64().unwrap()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_recorded_call_paused_by_a_dialog_records_one_call_and_replays_once() {
|
||||
let mut app = recording_with_dialog_child();
|
||||
let refusal = crate::i18n::t("Confirm or cancel the open action step dialog first").to_string();
|
||||
|
||||
// Confirm: the dialog command and the resumed rest stay inside the one named call.
|
||||
let live = app.session.journal.len();
|
||||
let id = pause_child(&mut app);
|
||||
assert!(app.session.actions.recording.is_none(), "recording stays suspended while the step dialog is open");
|
||||
let names = |app: &PhotocraftApp| app.session.actions.list.iter().map(|a| a.name.clone()).collect::<Vec<_>>();
|
||||
let before = names(&app);
|
||||
assert_eq!(app.run("actions.record", json!({"name": "Intruder"})), Err(refusal.clone()), "no second recording while the call is suspended");
|
||||
assert_eq!(app.run("actions.delete", json!({"action": "Owner"})), Err(refusal.clone()), "the suspended owner can't be deleted");
|
||||
assert_eq!(app.run("actions.move", json!({"action": "Owner", "to": 0})), Err(refusal.clone()), "the suspended owner can't be moved");
|
||||
assert_eq!(names(&app), before, "the refused commands leave the list alone");
|
||||
crate::dialogs::confirm(&mut app, id).unwrap();
|
||||
assert!(app.session.actions.recording.is_some(), "recording comes back when the call completes");
|
||||
app.run("actions.stop", json!({})).unwrap();
|
||||
assert_eq!(app.session.actions.list[1].steps, child_call());
|
||||
assert_eq!(suffixes(&app), 1);
|
||||
|
||||
// Replaying the recording repeats the call once.
|
||||
app.run("file.new", json!({"width": 8, "height": 6})).unwrap();
|
||||
let start = app.session.journal.len();
|
||||
app.automation_input = true;
|
||||
let v = play(&mut app, &json!({"action": "Owner"})).unwrap();
|
||||
app.automation_input = false;
|
||||
assert!(v.get("failed").is_none(), "{v}");
|
||||
assert_eq!(suffixes(&app), 1, "replay creates the suffix once");
|
||||
let edits = |from: usize| -> Vec<(String, Value)> {
|
||||
app.session.journal[from..].iter().filter(|(id, _)| !id.starts_with("actions.") && id != "file.new").cloned().collect()
|
||||
};
|
||||
let expected = vec![("filter.blur.gaussianBlur".to_string(), json!({"radius": 1.5})), ("layer.new.layer".to_string(), json!({"name": "Suffix"}))];
|
||||
assert_eq!(edits(start), expected, "replay journals the blur and the suffix once each, in order");
|
||||
assert_eq!(edits(live), expected[..].iter().chain(&expected).cloned().collect::<Vec<_>>(), "live then replay");
|
||||
|
||||
// Cancel: the call ends at the dialog and is recorded once.
|
||||
app.run("actions.record", json!({"name": "Cancelled"})).unwrap();
|
||||
let id = pause_child(&mut app);
|
||||
crate::dialogs::cancel(&mut app, id).unwrap();
|
||||
assert!(app.session.actions.recording.is_some(), "cancel restores recording");
|
||||
app.run("actions.stop", json!({})).unwrap();
|
||||
assert_eq!(app.session.actions.list[2].steps, child_call());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_failing_step_dialog_command_ends_the_recorded_call_once() {
|
||||
let mut app = recording_with_dialog_child();
|
||||
let id = pause_child(&mut app);
|
||||
assert!(app.session.actions.recording.is_none(), "recording stays suspended while the step dialog is open");
|
||||
app.ui.dialog_mut(id).unwrap().fields.insert("radius".into(), json!("not a radius"));
|
||||
assert!(crate::dialogs::confirm(&mut app, id).is_err(), "the dialog command fails");
|
||||
assert!(app.session.actions.recording.is_some(), "recording comes back when the dialog command fails");
|
||||
assert_eq!(suffixes(&app), 0, "the action stops at the failed step");
|
||||
app.run("actions.stop", json!({})).unwrap();
|
||||
assert_eq!(app.session.actions.list[1].steps, child_call());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_failing_resumed_playback_ends_the_recorded_call_once() {
|
||||
let mut app = recording_with_dialog_child();
|
||||
let id = pause_child(&mut app);
|
||||
// The rest of the call can't be found any more: resuming it fails.
|
||||
app.session.actions.list[0].name = "Renamed".into();
|
||||
assert!(crate::dialogs::confirm(&mut app, id).is_err(), "the resumed playback fails");
|
||||
assert!(app.session.actions.recording.is_some(), "recording comes back when the resumed playback fails");
|
||||
app.run("actions.stop", json!({})).unwrap();
|
||||
assert_eq!(app.session.actions.list[1].steps, child_call());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_suspended_call_is_recorded_into_its_action_after_the_list_changes() {
|
||||
let mut app = recording_with_dialog_child();
|
||||
let id = pause_child(&mut app);
|
||||
// Something else puts an action where Owner was.
|
||||
app.session.actions.list.insert(1, Action::new("Bystander", vec![]));
|
||||
crate::dialogs::confirm(&mut app, id).unwrap();
|
||||
app.run("actions.stop", json!({})).unwrap();
|
||||
assert!(app.session.actions.list[1].steps.is_empty(), "the action now at the old index gets nothing");
|
||||
assert_eq!(app.session.actions.list[2].name, "Owner");
|
||||
assert_eq!(app.session.actions.list[2].steps, child_call());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn escape_on_a_step_dialog_ends_the_recorded_call_once() {
|
||||
let app = recording_with_dialog_child();
|
||||
let mut h = egui_kittest::Harness::builder().with_size(vec2(900.0, 700.0)).build_ui_state(|ui, app| crate::dialogs::show(app, ui.ctx()), app);
|
||||
PhotocraftApp::setup_context(&h.ctx, crate::theme::ThemeKind::ALL[0]);
|
||||
h.run_steps(2);
|
||||
pause_child(h.state_mut());
|
||||
h.run_steps(4);
|
||||
assert!(h.state().session.actions.recording.is_none(), "recording stays suspended while the step dialog is open");
|
||||
h.key_press(egui::Key::Escape);
|
||||
h.run_steps(2);
|
||||
assert!(h.state().ui.dialogs.is_empty(), "Esc closes the step dialog");
|
||||
assert!(h.state().session.actions.recording.is_some(), "Esc restores recording");
|
||||
let app = h.state_mut();
|
||||
app.run("actions.stop", json!({})).unwrap();
|
||||
assert_eq!(app.session.actions.list[1].steps, child_call());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn button_mode_plays_the_clicked_action_and_hides_its_steps() {
|
||||
use egui_kittest::{Harness, kittest::Queryable};
|
||||
|
||||
@@ -4363,10 +4363,20 @@ pub fn canvas_view(app: &mut PhotocraftApp, ui: &mut egui::Ui, idx: usize, rect:
|
||||
app.hover_doc = response.hover_pos().map(|p| xf.to_doc(p));
|
||||
}
|
||||
if primary && app.ui.extras.rulers {
|
||||
let before = app.guide_drag;
|
||||
crate::rulers::draw_rulers(app, ui, full, &xf);
|
||||
// A guide dragged out of a ruler moved after this frame drew it: draw it again where it is.
|
||||
if app.guide_drag != before {
|
||||
ctx.request_repaint();
|
||||
}
|
||||
} else if app.ui.extras.rulers {
|
||||
crate::rulers::paint_rulers(app, ui, full, &xf, &doc);
|
||||
}
|
||||
// After the ruler drags above, so the readout shows where the guide is now, and not after a
|
||||
// release ended the drag.
|
||||
if app.session.active_index() == Some(idx) {
|
||||
crate::rulers::draw_guide_drag_readout(app, &ctx);
|
||||
}
|
||||
crate::rotate_view::overlay(app, &ctx, &painter, &xf, &mut view, &response);
|
||||
if primary {
|
||||
// Tool input can change the stored camera while navigation edits the local view.
|
||||
|
||||
@@ -654,6 +654,7 @@ pub fn confirm(app: &mut PhotocraftApp, id: u64) -> Result<Value, String> {
|
||||
DialogKind::Command => {
|
||||
let Some(cmd) = d.fields.get("__command").and_then(Value::as_str).map(str::to_string) else {
|
||||
app.filter_preview = None;
|
||||
crate::actions::abandoned(app, &d.fields);
|
||||
return Err("dialog has no command".into());
|
||||
};
|
||||
if crate::filter_dialog::needs_displace_map(&cmd, &crate::filter_dialog::params_of(&d.fields)) {
|
||||
@@ -679,6 +680,8 @@ pub fn confirm(app: &mut PhotocraftApp, id: u64) -> Result<Value, String> {
|
||||
crate::filter_dialog::remember(app, &cmd, &d.fields);
|
||||
// A step dialog of a playing action: the action continues after it.
|
||||
crate::actions::resume(app, &d.fields)?;
|
||||
} else {
|
||||
crate::actions::abandoned(app, &d.fields);
|
||||
}
|
||||
result
|
||||
}
|
||||
|
||||
@@ -0,0 +1,383 @@
|
||||
//! The mouse wheel on value fields (#5473, #4061): one step a notch, as the Up/Down keys (×10
|
||||
//! with Shift).
|
||||
//!
|
||||
//! - While a field has keyboard focus, the wheel steps it wherever the pointer is. [`begin_frame`]
|
||||
//! takes the wheel out of the frame's input before anything is laid out, so neither the canvas
|
||||
//! nor a panel scrolls or zooms with it. ⌥/Alt and ⌘/Ctrl + wheel stay the view's.
|
||||
//! - Over a field without focus, the wheel steps it too, but only a gesture that starts over it:
|
||||
//! a panel being scrolled keeps scrolling when a field passes under the pointer. A gesture that
|
||||
//! leaves the field is the view's from then on.
|
||||
|
||||
use egui::{Context, Event, Id, MouseWheelUnit, Rect, Ui, Vec2};
|
||||
|
||||
/// Wheel events this close together (seconds) are one gesture.
|
||||
const GESTURE_GAP: f64 = 0.3;
|
||||
|
||||
/// Who a wheel gesture belongs to.
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
enum Owner {
|
||||
/// It started this frame and no field has taken it yet.
|
||||
New,
|
||||
Field(Id),
|
||||
/// It started where no field took it (a panel, the canvas).
|
||||
Elsewhere,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
struct Gesture {
|
||||
last: f64,
|
||||
owner: Owner,
|
||||
}
|
||||
|
||||
fn gesture_id() -> Id {
|
||||
Id::new("pc-field-wheel-gesture")
|
||||
}
|
||||
|
||||
fn focused_id() -> Id {
|
||||
Id::new("pc-field-wheel-focused")
|
||||
}
|
||||
|
||||
fn taken_id() -> Id {
|
||||
Id::new("pc-field-wheel-taken")
|
||||
}
|
||||
|
||||
/// A wheel event a field takes: plain or Shift, not the view's Alt or Ctrl/Cmd zoom, nor a plain
|
||||
/// sideways scroll (a trackpad swipe pans the view; Shift+wheel can arrive sideways). An event
|
||||
/// with no delta at all counts: macOS starts a trackpad gesture with one, and it is what lets a
|
||||
/// field under the pointer claim the gesture.
|
||||
fn for_field(e: &Event) -> bool {
|
||||
matches!(e, Event::MouseWheel { delta, modifiers, .. }
|
||||
if (delta.y != 0.0 || delta.x == 0.0 || modifiers.shift) && !modifiers.alt && !modifiers.ctrl && !modifiers.command && !modifiers.mac_cmd)
|
||||
}
|
||||
|
||||
/// Before this frame's UI is laid out: hand the wheel to the focused value field, if any, and
|
||||
/// follow which gesture the wheel is in.
|
||||
pub fn begin_frame(ctx: &Context) {
|
||||
ctx.data_mut(|d| d.remove::<Vec<Event>>(taken_id()));
|
||||
// (the field's widget id, its slot id): focus is the widget's, a gesture the slot's.
|
||||
let focused = ctx.data(|d| d.get_temp::<(Id, Id)>(focused_id())).filter(|(id, _)| ctx.memory(|m| m.has_focus(*id)));
|
||||
let (now, wheel) = ctx.input(|i| (i.time, i.events.iter().any(|e| matches!(e, Event::MouseWheel { .. }))));
|
||||
if let Some((_, field)) = focused {
|
||||
let (taken, view_wheel): (Vec<Event>, bool) = ctx.input_mut(|i| {
|
||||
let (taken, rest) = std::mem::take(&mut i.events).into_iter().partition(for_field);
|
||||
i.events = rest;
|
||||
(taken, i.events.iter().any(|e| matches!(e, Event::MouseWheel { .. })))
|
||||
});
|
||||
if wheel {
|
||||
// The latest wheel is the view's when any of it was left to the view (Alt, Ctrl/Cmd).
|
||||
let owner = if view_wheel { Owner::Elsewhere } else { Owner::Field(field) };
|
||||
ctx.data_mut(|d| d.insert_temp(gesture_id(), Gesture { last: now, owner }));
|
||||
}
|
||||
if !taken.is_empty() {
|
||||
ctx.data_mut(|d| d.insert_temp(taken_id(), taken));
|
||||
}
|
||||
// egui spreads each notch over a few frames: the tail of the field's own notches scrolls
|
||||
// nothing, while the view's keeps all of its own.
|
||||
if ctx.data(|d| d.get_temp::<Gesture>(gesture_id())).is_some_and(|g| g.owner == Owner::Field(field)) {
|
||||
ctx.input_mut(|i| i.smooth_scroll_delta = Vec2::ZERO);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if !wheel {
|
||||
return;
|
||||
}
|
||||
let gesture = ctx.data(|d| d.get_temp::<Gesture>(gesture_id()));
|
||||
let owner = match gesture {
|
||||
Some(g) if now - g.last <= GESTURE_GAP => match g.owner {
|
||||
// No field took it when it started.
|
||||
Owner::New => Owner::Elsewhere,
|
||||
owner => owner,
|
||||
},
|
||||
_ => Owner::New,
|
||||
};
|
||||
ctx.data_mut(|d| d.insert_temp(gesture_id(), Gesture { last: now, owner }));
|
||||
}
|
||||
|
||||
/// Record that value field `id` (whose slot is `field`, as given to [`notches`]) has keyboard
|
||||
/// focus this frame, so the wheel is its next frame.
|
||||
pub fn set_focused(ctx: &Context, id: Id, field: Id) {
|
||||
ctx.data_mut(|d| d.insert_temp(focused_id(), (id, field)));
|
||||
}
|
||||
|
||||
/// Wheel notches for the value field `field` in `rect` this frame (up positive, Shift ×10):
|
||||
/// all of the wheel while it is `focused`, else a gesture that started with the pointer over it.
|
||||
pub fn notches(ui: &Ui, field: Id, focused: bool, rect: Rect) -> f32 {
|
||||
let events: Vec<Event> = if focused {
|
||||
ui.data_mut(|d| d.remove_temp::<Vec<Event>>(taken_id())).unwrap_or_default()
|
||||
} else {
|
||||
if !ui.is_enabled() {
|
||||
return 0.0;
|
||||
}
|
||||
let Some(mut g) = ui.data(|d| d.get_temp::<Gesture>(gesture_id())) else { return 0.0 };
|
||||
let (events, wheel): (Vec<Event>, bool) =
|
||||
ui.input(|i| (i.events.iter().filter(|e| for_field(e)).cloned().collect(), i.events.iter().any(|e| matches!(e, Event::MouseWheel { .. }))));
|
||||
// Wheel the field doesn't take (a sideways swipe after a zero-delta start), or any wheel
|
||||
// with the pointer off the field, hands the rest of the gesture to the view: coming back
|
||||
// over the field in the same gesture doesn't step it.
|
||||
if g.owner == Owner::Field(field) && wheel && (events.is_empty() || !ui.rect_contains_pointer(rect)) {
|
||||
g.owner = Owner::Elsewhere;
|
||||
ui.data_mut(|d| d.insert_temp(gesture_id(), g));
|
||||
return 0.0;
|
||||
}
|
||||
if !ui.rect_contains_pointer(rect) {
|
||||
return 0.0;
|
||||
}
|
||||
match g.owner {
|
||||
Owner::New if !events.is_empty() => {
|
||||
g.owner = Owner::Field(field);
|
||||
ui.data_mut(|d| d.insert_temp(gesture_id(), g));
|
||||
}
|
||||
Owner::Field(id) if id == field => {}
|
||||
_ => return 0.0,
|
||||
}
|
||||
// Nothing under the field scrolls with the wheel that steps it, smoothed tail included.
|
||||
ui.ctx().input_mut(|i| i.smooth_scroll_delta = Vec2::ZERO);
|
||||
events
|
||||
};
|
||||
let wheel: Vec<(MouseWheelUnit, Vec2, bool)> = events
|
||||
.iter()
|
||||
.filter_map(|e| match e {
|
||||
Event::MouseWheel { unit, delta, modifiers, .. } if for_field(e) => Some((*unit, *delta, modifiers.shift)),
|
||||
_ => None,
|
||||
})
|
||||
.collect();
|
||||
crate::widgets::count_notches(ui, field.with("wheel-acc"), &wheel, 10.0)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use egui::accesskit::Role;
|
||||
use egui::{Modifiers, Pos2, vec2};
|
||||
use egui_kittest::Harness;
|
||||
use egui_kittest::kittest::Queryable;
|
||||
|
||||
/// The value, the scroll area's vertical offset, whether the field is enabled, and the
|
||||
/// horizontal offset.
|
||||
type State = (f32, f32, bool, f32);
|
||||
|
||||
/// A value field (0–1000) at the top left of a scroll area 100 pt tall, beside and above a
|
||||
/// large filler.
|
||||
fn harness(value: f32) -> Harness<'static, State> {
|
||||
harness_stepping(value, 0.25)
|
||||
}
|
||||
|
||||
/// [`harness`] with each step `step_dt` seconds long.
|
||||
fn harness_stepping(value: f32, step_dt: f32) -> Harness<'static, State> {
|
||||
let mut h = Harness::builder().with_size(vec2(300.0, 200.0)).with_step_dt(step_dt).build_ui_state(
|
||||
|ui, s: &mut State| {
|
||||
super::begin_frame(ui.ctx());
|
||||
let out = egui::ScrollArea::both().max_height(100.0).max_width(200.0).show(ui, |ui| {
|
||||
ui.add_enabled_ui(s.2, |ui| crate::widgets::value_field(ui, &mut s.0, 0.0..=1000.0, "px", 90.0));
|
||||
ui.allocate_space(vec2(1000.0, 1000.0));
|
||||
});
|
||||
s.1 = out.state.offset.y;
|
||||
s.3 = out.state.offset.x;
|
||||
},
|
||||
(value, 0.0, true, 0.0),
|
||||
);
|
||||
h.run();
|
||||
h
|
||||
}
|
||||
|
||||
fn field(h: &Harness<'static, State>) -> egui::Rect {
|
||||
h.get_by_role(Role::SpinButton).rect()
|
||||
}
|
||||
|
||||
/// `lines` wheel lines (up positive) at `at`, then let the gesture end.
|
||||
fn wheel(h: &mut Harness<'static, State>, at: Pos2, lines: f32, modifiers: Modifiers) {
|
||||
h.hover_at(at);
|
||||
h.run_steps(1);
|
||||
h.event(egui::Event::MouseWheel { unit: egui::MouseWheelUnit::Line, delta: vec2(0.0, lines), phase: egui::TouchPhase::Move, modifiers });
|
||||
h.run_steps(4);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_wheel_over_a_field_steps_it_and_scrolls_nothing() {
|
||||
let mut h = harness(100.0);
|
||||
let at = field(&h).center();
|
||||
wheel(&mut h, at, 1.0, Modifiers::NONE);
|
||||
assert_eq!(h.state().0, 101.0);
|
||||
wheel(&mut h, at, -3.0, Modifiers::NONE);
|
||||
assert_eq!(h.state().0, 98.0);
|
||||
wheel(&mut h, at, 1.0, Modifiers::SHIFT);
|
||||
assert_eq!(h.state().0, 108.0, "Shift: ten a notch");
|
||||
assert_eq!(h.state().1, 0.0, "the panel under the field didn't scroll");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_focused_field_takes_the_wheel_wherever_the_pointer_is() {
|
||||
let mut h = harness(100.0);
|
||||
h.get_by_role(Role::SpinButton).click();
|
||||
h.run();
|
||||
let away = field(&h).center() + vec2(0.0, 60.0);
|
||||
wheel(&mut h, away, -2.0, Modifiers::NONE);
|
||||
assert_eq!(h.state().0, 98.0);
|
||||
assert_eq!(h.state().1, 0.0, "the panel under the pointer didn't scroll");
|
||||
assert!(h.get_by_role(Role::SpinButton).is_focused(), "the field keeps focus");
|
||||
// Alt + wheel stays the view's (zoom), not the field's.
|
||||
wheel(&mut h, away, 1.0, Modifiers::ALT);
|
||||
assert_eq!(h.state().0, 98.0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_gesture_that_starts_over_the_panel_keeps_scrolling_it_over_a_field() {
|
||||
let mut h = harness(100.0);
|
||||
let below = field(&h).center() + vec2(0.0, 40.0);
|
||||
h.hover_at(below);
|
||||
h.run_steps(1);
|
||||
let down =
|
||||
|| egui::Event::MouseWheel { unit: egui::MouseWheelUnit::Line, delta: vec2(0.0, -1.0), phase: egui::TouchPhase::Move, modifiers: Modifiers::NONE };
|
||||
h.event(down());
|
||||
h.run_steps(1);
|
||||
// Still the same gesture as the pointer reaches a field.
|
||||
h.hover_at(field(&h).center());
|
||||
h.event(down());
|
||||
h.run_steps(1);
|
||||
assert_eq!(h.state().0, 100.0, "the field passing under the pointer is not stepped");
|
||||
assert!(h.state().1 > 0.0, "the panel scrolled");
|
||||
}
|
||||
|
||||
/// A plain sideways scroll (a trackpad swipe) is the view's, focused or hovered; Shift+wheel
|
||||
/// that the system turned sideways still steps by ten.
|
||||
#[test]
|
||||
fn a_sideways_scroll_steps_a_field_only_with_shift() {
|
||||
for focus in [false, true] {
|
||||
for (m, want) in [(Modifiers::NONE, 100.0), (Modifiers::SHIFT, 110.0)] {
|
||||
let mut h = harness(100.0);
|
||||
if focus {
|
||||
h.get_by_role(Role::SpinButton).click();
|
||||
h.run();
|
||||
}
|
||||
let at = field(&h).center();
|
||||
h.hover_at(at);
|
||||
h.run_steps(1);
|
||||
h.event(egui::Event::MouseWheel { unit: egui::MouseWheelUnit::Line, delta: vec2(1.0, 0.0), phase: egui::TouchPhase::Move, modifiers: m });
|
||||
h.run_steps(4);
|
||||
assert_eq!(h.state().0, want, "focus {focus}, {m:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A trackpad gesture that macOS starts with a zero-delta event, then moves a frame later,
|
||||
/// steps the field under the pointer.
|
||||
#[test]
|
||||
fn a_trackpad_gesture_that_starts_with_no_delta_steps_a_hovered_field() {
|
||||
let mut h = harness(100.0);
|
||||
h.hover_at(field(&h).center());
|
||||
h.run_steps(1);
|
||||
let ev = |phase, y| egui::Event::MouseWheel { unit: egui::MouseWheelUnit::Line, delta: vec2(0.0, y), phase, modifiers: Modifiers::NONE };
|
||||
h.event(ev(egui::TouchPhase::Start, 0.0));
|
||||
h.run_steps(1);
|
||||
h.event(ev(egui::TouchPhase::Move, 2.0));
|
||||
h.run_steps(4);
|
||||
assert_eq!(h.state().0, 102.0);
|
||||
assert_eq!(h.state().1, 0.0, "the panel didn't scroll");
|
||||
}
|
||||
|
||||
/// A trackpad gesture that starts with a zero-delta event over a field, then swipes sideways,
|
||||
/// pans the view and leaves the field alone.
|
||||
#[test]
|
||||
fn a_sideways_swipe_after_a_zero_delta_start_pans_the_view() {
|
||||
let mut h = harness(100.0);
|
||||
h.hover_at(field(&h).center());
|
||||
h.run_steps(1);
|
||||
let ev = |phase, x| egui::Event::MouseWheel { unit: egui::MouseWheelUnit::Line, delta: vec2(x, 0.0), phase, modifiers: Modifiers::NONE };
|
||||
h.event(ev(egui::TouchPhase::Start, 0.0));
|
||||
h.run_steps(1);
|
||||
h.event(ev(egui::TouchPhase::Move, -2.0));
|
||||
h.run_steps(4);
|
||||
assert_eq!(h.state().0, 100.0, "the field was not stepped");
|
||||
assert!(h.state().3 > 0.0, "the panel panned sideways");
|
||||
}
|
||||
|
||||
/// The same swipe with the pointer off the field hands the gesture to the view too: coming
|
||||
/// back over the field in the same gesture doesn't step it.
|
||||
#[test]
|
||||
fn a_sideways_swipe_off_the_field_keeps_the_rest_of_the_gesture_the_views() {
|
||||
// Short frames: moving the pointer takes a frame of its own, and the gesture must not end.
|
||||
let mut h = harness_stepping(100.0, 1.0 / 30.0);
|
||||
h.hover_at(field(&h).center());
|
||||
h.run_steps(1);
|
||||
let ev = |phase, unit, d| egui::Event::MouseWheel { unit, delta: d, phase, modifiers: Modifiers::NONE };
|
||||
h.event(ev(egui::TouchPhase::Start, egui::MouseWheelUnit::Point, vec2(0.0, 0.0)));
|
||||
h.run_steps(1);
|
||||
// A short swipe, so the field stays in view.
|
||||
h.hover_at(field(&h).center() + vec2(0.0, 40.0));
|
||||
h.event(ev(egui::TouchPhase::Move, egui::MouseWheelUnit::Point, vec2(-10.0, 0.0)));
|
||||
h.run_steps(1);
|
||||
h.hover_at(field(&h).center());
|
||||
h.event(ev(egui::TouchPhase::Move, egui::MouseWheelUnit::Line, vec2(0.0, -1.0)));
|
||||
h.run_steps(4);
|
||||
assert_eq!(h.state().0, 100.0, "the field was not stepped");
|
||||
assert!(h.state().1 > 0.0, "the panel scrolled");
|
||||
}
|
||||
|
||||
/// A gesture that steps a field, then wheels on with the pointer off it, is the view's from
|
||||
/// then on: coming back over the field in the same gesture doesn't step it again.
|
||||
#[test]
|
||||
fn a_gesture_that_wheels_off_the_field_does_not_step_it_on_coming_back() {
|
||||
// Short frames: moving the pointer takes a frame of its own, and the gesture must not end.
|
||||
let mut h = harness_stepping(100.0, 1.0 / 30.0);
|
||||
h.hover_at(field(&h).center());
|
||||
h.run_steps(1);
|
||||
// Up, so the panel (already at the top) doesn't move the field.
|
||||
let up =
|
||||
|| egui::Event::MouseWheel { unit: egui::MouseWheelUnit::Line, delta: vec2(0.0, 1.0), phase: egui::TouchPhase::Move, modifiers: Modifiers::NONE };
|
||||
h.event(up());
|
||||
h.run_steps(1);
|
||||
assert_eq!(h.state().0, 101.0);
|
||||
h.hover_at(field(&h).center() + vec2(0.0, 40.0));
|
||||
h.event(up());
|
||||
h.run_steps(1);
|
||||
h.hover_at(field(&h).center());
|
||||
h.event(up());
|
||||
h.run_steps(4);
|
||||
assert_eq!(h.state().0, 101.0, "the field was stepped once, by the start of the gesture");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_disabled_field_ignores_the_wheel() {
|
||||
let mut h = harness(100.0);
|
||||
h.state_mut().2 = false;
|
||||
h.run();
|
||||
let at = field(&h).center();
|
||||
wheel(&mut h, at, 1.0, Modifiers::NONE);
|
||||
assert_eq!(h.state().0, 100.0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn wild_wheel_deltas_leave_a_finite_value_in_range() {
|
||||
// egui itself asserts on a non-finite wheel event in debug builds: `count_notches` is checked
|
||||
// with those below.
|
||||
for lines in [1e30, -1e30, 1e6, -1e6] {
|
||||
for focus in [false, true] {
|
||||
let mut h = harness(100.0);
|
||||
if focus {
|
||||
h.get_by_role(Role::SpinButton).click();
|
||||
h.run();
|
||||
}
|
||||
let at = field(&h).center();
|
||||
wheel(&mut h, at, lines, Modifiers::SHIFT);
|
||||
let v = h.state().0;
|
||||
assert!(v.is_finite() && (0.0..=1000.0).contains(&v), "{lines} (focus {focus}): {v}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn notches_of_nan_or_infinite_deltas_are_none() {
|
||||
use egui::MouseWheelUnit::{Line, Point};
|
||||
let ctx = egui::Context::default();
|
||||
let mut out = ctx.run_ui(Default::default(), |ui| {
|
||||
let id = egui::Id::new("acc");
|
||||
for d in [f32::NAN, f32::INFINITY, f32::NEG_INFINITY] {
|
||||
for unit in [Line, Point] {
|
||||
assert_eq!(crate::widgets::count_notches(ui, id, &[(unit, vec2(0.0, d), false)], 10.0), 0.0, "{d} {unit:?}");
|
||||
// Nothing poisoned is carried over to the next notch.
|
||||
assert_eq!(crate::widgets::count_notches(ui, id, &[(Line, vec2(0.0, 1.0), true)], 10.0), 10.0);
|
||||
}
|
||||
}
|
||||
});
|
||||
out.textures_delta.clear();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
//! #5473 in the app: a focused value field takes the wheel over the canvas, which neither pans
|
||||
//! nor zooms with it.
|
||||
|
||||
use egui::accesskit::Role;
|
||||
use egui::vec2;
|
||||
use egui_kittest::Harness;
|
||||
use egui_kittest::kittest::Queryable;
|
||||
use serde_json::json;
|
||||
|
||||
use crate::PhotocraftApp;
|
||||
use crate::state::Tool;
|
||||
|
||||
fn harness() -> Harness<'static, PhotocraftApp> {
|
||||
let mut h = Harness::builder().with_size(vec2(1440.0, 900.0)).with_max_steps(64).build_eframe(move |cc| {
|
||||
PhotocraftApp::setup_context(&cc.egui_ctx, Default::default());
|
||||
let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default());
|
||||
app.run("file.new", json!({"width": 64, "height": 48})).unwrap();
|
||||
app.ui.tool = Tool::Brush;
|
||||
app
|
||||
});
|
||||
h.run_steps(8);
|
||||
h
|
||||
}
|
||||
|
||||
/// The value field showing `value`: the options bar's Smoothing is the brush's only one at 10.
|
||||
fn field<'a>(h: &'a Harness<'_, PhotocraftApp>, value: &str) -> egui_kittest::Node<'a> {
|
||||
h.query_all_by_role(Role::SpinButton).find(|n| n.value().as_deref() == Some(value)).unwrap()
|
||||
}
|
||||
|
||||
fn wheel(h: &mut Harness<'_, PhotocraftApp>, at: egui::Pos2, lines: f32, modifiers: egui::Modifiers) {
|
||||
h.hover_at(at);
|
||||
h.run_steps(1);
|
||||
h.event(egui::Event::MouseWheel { unit: egui::MouseWheelUnit::Line, delta: vec2(0.0, lines), phase: egui::TouchPhase::Move, modifiers });
|
||||
h.run_steps(6);
|
||||
}
|
||||
|
||||
/// (zoom, centre) of the document's view.
|
||||
fn view(h: &Harness<'_, PhotocraftApp>) -> (f32, [f32; 2]) {
|
||||
let v = &h.state().ui.views[0];
|
||||
(v.zoom, v.center)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_focused_field_takes_the_wheel_over_the_canvas() {
|
||||
let mut h = harness();
|
||||
let canvas = egui::pos2(640.0, 500.0);
|
||||
let before = view(&h);
|
||||
wheel(&mut h, canvas, -1.0, egui::Modifiers::NONE);
|
||||
assert_ne!(view(&h), before, "without a focused field the wheel pans the canvas");
|
||||
let before = view(&h);
|
||||
field(&h, "10").click();
|
||||
h.run();
|
||||
wheel(&mut h, canvas, -2.0, egui::Modifiers::NONE);
|
||||
assert_eq!(view(&h), before, "the canvas neither pans nor zooms");
|
||||
assert!(h.query_all_by_role(Role::SpinButton).any(|n| n.value().as_deref() == Some("8")), "Smoothing stepped from 10 to 8");
|
||||
// ⌥/Alt + wheel is still the view's zoom.
|
||||
wheel(&mut h, canvas, 1.0, egui::Modifiers::ALT);
|
||||
assert_ne!(view(&h).0, before.0, "Alt + wheel zooms");
|
||||
assert!(h.query_all_by_role(Role::SpinButton).any(|n| n.value().as_deref() == Some("8")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_wheel_over_a_field_steps_it_without_a_click() {
|
||||
let mut h = harness();
|
||||
let before = view(&h);
|
||||
let at = field(&h, "10").rect().center();
|
||||
wheel(&mut h, at, 1.0, egui::Modifiers::NONE);
|
||||
assert!(h.query_all_by_role(Role::SpinButton).any(|n| n.value().as_deref() == Some("11")), "Smoothing stepped from 10 to 11");
|
||||
wheel(&mut h, at, 1.0, egui::Modifiers::SHIFT);
|
||||
assert!(h.query_all_by_role(Role::SpinButton).any(|n| n.value().as_deref() == Some("21")), "Shift: ten a notch");
|
||||
assert!(!field(&h, "21").is_focused(), "hovering doesn't put the cursor in the field");
|
||||
assert_eq!(view(&h), before, "the canvas didn't move");
|
||||
}
|
||||
|
||||
/// How far a wheel of `delta` lines with `modifiers` over the canvas moves the view, a Smoothing
|
||||
/// field focused or not, once egui's smoothed scroll has run out. The field isn't stepped.
|
||||
fn canvas_pan(focus: bool, delta: egui::Vec2, modifiers: egui::Modifiers) -> (f32, [f32; 2]) {
|
||||
let mut h = harness();
|
||||
if focus {
|
||||
field(&h, "10").click();
|
||||
h.run();
|
||||
}
|
||||
let canvas = egui::pos2(640.0, 500.0);
|
||||
h.hover_at(canvas);
|
||||
h.run_steps(1);
|
||||
let before = view(&h);
|
||||
h.event(egui::Event::MouseWheel { unit: egui::MouseWheelUnit::Line, delta, phase: egui::TouchPhase::Move, modifiers });
|
||||
h.run_steps(40);
|
||||
assert!(h.query_all_by_role(Role::SpinButton).any(|n| n.value().as_deref() == Some("10")), "focus {focus}: the field wasn't stepped");
|
||||
let after = view(&h);
|
||||
(after.0 / before.0, [after.1[0] - before.1[0], after.1[1] - before.1[1]])
|
||||
}
|
||||
|
||||
/// The wheel a focused field leaves to the view moves it as far as with no field focused: its
|
||||
/// smoothed tail isn't cut off (⌘/Ctrl + wheel, and a plain sideways trackpad swipe).
|
||||
#[test]
|
||||
fn the_view_keeps_its_whole_wheel_while_a_field_is_focused() {
|
||||
for (delta, m) in [(vec2(0.0, -1.0), egui::Modifiers::COMMAND), (vec2(0.0, -1.0), egui::Modifiers::CTRL), (vec2(-1.0, 0.0), egui::Modifiers::NONE)] {
|
||||
let free = canvas_pan(false, delta, m);
|
||||
assert!(free != (1.0, [0.0, 0.0]), "{delta:?} {m:?}: the wheel moves the view");
|
||||
let focused = canvas_pan(true, delta, m);
|
||||
let close = (focused.0 - free.0).abs() < 1e-3 && (0..2).all(|k| (focused.1[k] - free.1[k]).abs() < 0.5);
|
||||
assert!(close, "{delta:?} {m:?}: {focused:?} with a field focused, {free:?} without");
|
||||
}
|
||||
}
|
||||
@@ -817,10 +817,12 @@ fn driver_page(f: &mut Map<String, Value>) {
|
||||
match craft_print::rgb::page(&printer, settings.as_ref()) {
|
||||
Ok(pg) => {
|
||||
f.insert("paper".into(), json!([pg.paper.0, pg.paper.1]));
|
||||
f.insert("printable".into(), json!([pg.printable.0, pg.printable.1, pg.printable.2, pg.printable.3]));
|
||||
f.insert("orientation".into(), json!("portrait"));
|
||||
f.remove("__pageError");
|
||||
}
|
||||
Err(e) => {
|
||||
f.remove("printable");
|
||||
f.insert("__pageError".into(), json!(e.to_string()));
|
||||
}
|
||||
}
|
||||
@@ -936,7 +938,9 @@ fn print_body(app: &mut PhotocraftApp, ui: &mut egui::Ui, f: &mut Map<String, Va
|
||||
f.insert("__driverPageInitialized".into(), json!(true));
|
||||
}
|
||||
} else {
|
||||
// PDF output and previews have no driver page: Scale to Fit Media uses the paper.
|
||||
f.remove("__driverPageInitialized");
|
||||
f.remove("printable");
|
||||
}
|
||||
let p = params(f);
|
||||
let mut browse = false;
|
||||
@@ -1216,8 +1220,20 @@ fn print_body(app: &mut PhotocraftApp, ui: &mut egui::Ui, f: &mut Map<String, Va
|
||||
}
|
||||
}
|
||||
|
||||
/// `file.print`'s params. The driver's printable area only goes with a print to the printer:
|
||||
/// an output path or a preview set in the same frame as the confirm still drops it.
|
||||
fn print_params(f: &Map<String, Value>) -> Value {
|
||||
let mut p = params(f);
|
||||
if (b(f, "dryRun", false) || !s(f, "output", "").is_empty())
|
||||
&& let Some(o) = p.as_object_mut()
|
||||
{
|
||||
o.remove("printable");
|
||||
}
|
||||
p
|
||||
}
|
||||
|
||||
fn print_confirm(app: &mut PhotocraftApp, f: &Map<String, Value>) -> Result<Value, String> {
|
||||
let r = app.run("file.print", params(f))?;
|
||||
let r = app.run("file.print", print_params(f))?;
|
||||
if r["pending"] != json!(true) {
|
||||
print_status(app, &r);
|
||||
}
|
||||
@@ -1527,6 +1543,20 @@ mod tests {
|
||||
assert!(params(f).get("__printers").is_none());
|
||||
}
|
||||
|
||||
/// An output path or a preview typed and confirmed in one frame doesn't take the driver's area.
|
||||
#[test]
|
||||
fn the_printable_area_goes_only_with_a_print_to_the_printer() {
|
||||
let area = json!([0.0, 0.0, 842.29, 1191.14]);
|
||||
let mut f = Map::new();
|
||||
f.insert("printable".into(), area.clone());
|
||||
assert_eq!(print_params(&f)["printable"], area);
|
||||
f.insert("output".into(), json!("/tmp/out.pdf"));
|
||||
assert!(print_params(&f).get("printable").is_none());
|
||||
f.insert("output".into(), json!(""));
|
||||
f.insert("dryRun".into(), json!(true));
|
||||
assert!(print_params(&f).get("printable").is_none());
|
||||
}
|
||||
|
||||
/// #7410: File › Print opens with the settings of the last print, also those remembered from
|
||||
/// an earlier session (the preferences), before anything was printed in this one.
|
||||
#[test]
|
||||
|
||||
@@ -1136,6 +1136,14 @@ impl GpuInfo {
|
||||
let template = "Driver: {driver}";
|
||||
crate::i18n::fmt(tl!(template), &[("driver", &or(&self.driver, "unknown"))])
|
||||
},
|
||||
];
|
||||
// The card's own memory caps the GPU budgets, so it explains a huge canvas falling back
|
||||
// to the CPU. Only discrete cards report one (integrated GPUs share system memory).
|
||||
if let Some(mb) = self.video_memory_mb {
|
||||
let template = "Graphics memory: {size}";
|
||||
v.push(crate::i18n::fmt(tl!(template), &[("size", &crate::chrome_ui::fmt_bytes(mb.saturating_mul(1 << 20)))]));
|
||||
}
|
||||
v.extend([
|
||||
{
|
||||
let template = "GPU backend preference: {backend}";
|
||||
crate::i18n::fmt(tl!(template), &[("backend", &or(&self.preference, "auto"))])
|
||||
@@ -1159,7 +1167,7 @@ impl GpuInfo {
|
||||
};
|
||||
crate::i18n::fmt(tl!(template), &[("renderer", tl!(renderer))])
|
||||
},
|
||||
];
|
||||
]);
|
||||
if let Some(f) = &self.fallback {
|
||||
v.push({
|
||||
let template = "Fallback: {reason}";
|
||||
@@ -2793,6 +2801,19 @@ mod tests {
|
||||
assert_eq!(detect_video_memory(0xdead, 0xbeef), None, "no such adapter");
|
||||
}
|
||||
|
||||
/// System Info names the card's own memory, after the driver, when the card reports one; an
|
||||
/// integrated GPU or an unknown card shows no such line.
|
||||
#[test]
|
||||
fn system_info_shows_the_cards_memory() {
|
||||
let info = GpuInfo { adapter: "Card".into(), driver: "Driver 1".into(), video_memory_mb: Some(8192), ..Default::default() };
|
||||
let lines = info.lines();
|
||||
assert_eq!(lines.get(2).map(String::as_str), Some("Driver: Driver 1"));
|
||||
assert_eq!(lines.get(3).map(String::as_str), Some("Graphics memory: 8.0G"));
|
||||
let none = GpuInfo { video_memory_mb: None, ..info }.lines();
|
||||
assert!(none.iter().all(|l| !l.starts_with("Graphics memory")), "{none:?}");
|
||||
assert_eq!(none.len() + 1, lines.len());
|
||||
}
|
||||
|
||||
/// The Linux reader finds the card by its PCI ids in a `/sys/class/drm`-shaped folder and reads
|
||||
/// amdgpu's VRAM size; a card without one, unreadable ids or a malformed size give nothing.
|
||||
#[test]
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
//! selection tools do their own ⌘ handling in `canvas` (⌘ inside the selection cuts the
|
||||
//! selected pixels, outside it moves the layer, #896), and the Hand, Zoom, Crop, Slice, Path
|
||||
//! Selection, shape, Pen and Type tools keep ⌘ for themselves.
|
||||
//! - With the Hand tool selected, ⌘ (Ctrl off the Mac) is Zoom In while held and ⌥ (with or
|
||||
//! without ⌘) Zoom Out ([`hand_zoom`], #6434).
|
||||
//! - `~` (the backtick key) with the Brush or Pencil: a stroke started while it is held erases,
|
||||
//! with that tool's own brush ([`erase_held`], #3439).
|
||||
//!
|
||||
@@ -118,6 +120,28 @@ fn cmd_move_held(app: &PhotocraftApp, i: &InputState) -> bool {
|
||||
i.modifiers.command && cmd_moves(app.ui.tool) && app.ui.transform.is_none() && app.ui.text_edit.is_none()
|
||||
}
|
||||
|
||||
/// The Hand tool's own modifiers (#6434): ⌘ (Ctrl off the Mac) held is Zoom In, ⌥ (with or
|
||||
/// without ⌘) Zoom Out, as in Photoshop; the Modifier Keys panel's latched keys count. Not while
|
||||
/// Free Transform is open (its box keeps ⌘ for the distort handles), and a modifier pressed during
|
||||
/// a Hand press doesn't turn it into a zoom, release included: only a press made with it held
|
||||
/// zooms (that one is latched by [`for_frame`] until the button comes up). A middle-button pan
|
||||
/// stays a pan whatever is held.
|
||||
fn hand_zoom(app: &PhotocraftApp, i: &InputState) -> Option<Temporary> {
|
||||
let p = &i.pointer;
|
||||
let hand_press = ((p.primary_down() || p.primary_released()) && !p.primary_pressed()) || p.middle_down();
|
||||
if app.ui.tool != Tool::Hand || app.ui.transform.is_some() || hand_press {
|
||||
return None;
|
||||
}
|
||||
let m = crate::workspace_ui::sticky_mods(app, i.modifiers);
|
||||
if m.alt {
|
||||
Some(Temporary::ZoomOut)
|
||||
} else if m.command {
|
||||
Some(Temporary::ZoomIn)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
/// Is `id` a held temporary tool rather than a command?
|
||||
pub fn is_temporary(id: &str) -> bool {
|
||||
photocraft_engine::prefs::TEMPORARY_TOOLS.iter().any(|t| t.0 == id)
|
||||
@@ -160,6 +184,7 @@ pub fn held_tool(app: &PhotocraftApp, ctx: &egui::Context) -> Option<Temporary>
|
||||
let mut best: Option<(u8, Temporary, KeyboardShortcut)> = None;
|
||||
let mut cmd_move = false;
|
||||
let mut alt = false;
|
||||
let mut hand = None;
|
||||
ctx.input(|i| {
|
||||
for t in Temporary::BOUND {
|
||||
if let Some(sc) = binding(app, t)
|
||||
@@ -171,12 +196,13 @@ pub fn held_tool(app: &PhotocraftApp, ctx: &egui::Context) -> Option<Temporary>
|
||||
}
|
||||
cmd_move = cmd_move_held(app, i);
|
||||
alt = i.modifiers.alt;
|
||||
hand = hand_zoom(app, i);
|
||||
});
|
||||
// ⌥ turns a held Zoom In around, as it does the Zoom tool: ⌘⌥Space zooms out (and wins the
|
||||
// tie with ⌥Space), unless ⌥ is part of the Zoom In key itself.
|
||||
let held = best.map(|(_, t, sc)| if t == Temporary::ZoomIn && alt && !sc.modifiers.alt { Temporary::ZoomOut } else { t });
|
||||
// A bound key (⌘Space is Zoom In) wins over ⌘ alone.
|
||||
held.or(cmd_move.then_some(Temporary::Move))
|
||||
held.or(hand).or(cmd_move.then_some(Temporary::Move))
|
||||
}
|
||||
|
||||
/// The binding id of the Brush and Pencil erase key (`prefs::TEMPORARY_TOOLS`).
|
||||
|
||||
@@ -696,7 +696,9 @@ fn cmd_is_not_the_move_tool_for_selection_hand_zoom_pen_shape_or_type_tools() {
|
||||
let mut h = harness(tool);
|
||||
h.event(Event::ModifiersChanged(platform(Modifiers::COMMAND)));
|
||||
h.run_steps(1);
|
||||
assert_eq!(held_tool(h.state(), &h.ctx), None, "{tool:?}");
|
||||
// The Hand's own ⌘ is Zoom In (#6434).
|
||||
let want = (tool == Tool::Hand).then_some(Temporary::ZoomIn);
|
||||
assert_eq!(held_tool(h.state(), &h.ctx), want, "{tool:?}");
|
||||
}
|
||||
for tool in [Tool::Brush, Tool::Eraser, Tool::Gradient, Tool::CloneStamp, Tool::Eyedropper, Tool::MagneticLasso, Tool::QuickSelection] {
|
||||
assert!(cmd_moves(tool), "{tool:?}");
|
||||
@@ -849,3 +851,157 @@ fn a_held_key_keeps_a_pending_crop_and_another_tools_key_commits_it() {
|
||||
assert_eq!(h.state().session.active().unwrap().doc.size, photocraft_doc::Size::new(200, 150));
|
||||
assert_eq!(h.state().ui.crop_rect, None);
|
||||
}
|
||||
|
||||
/// #6434: with the Hand tool selected, ⌘ (Ctrl off the Mac) held is Zoom In and ⌥ (with or
|
||||
/// without ⌘) Zoom Out, as in Photoshop; letting go gives the Hand back.
|
||||
#[test]
|
||||
fn cmd_and_alt_with_the_hand_tool_zoom_in_and_out() {
|
||||
let mut h = harness(Tool::Hand);
|
||||
let z0 = h.state().ui.views[0].zoom;
|
||||
hold_mods(&mut h, Modifiers::COMMAND);
|
||||
assert_eq!(held_tool(h.state(), &h.ctx), Some(Temporary::ZoomIn));
|
||||
click(&mut h, 200.0, 150.0, Modifiers::COMMAND);
|
||||
let z1 = h.state().ui.views[0].zoom;
|
||||
assert!(z1 > z0, "{z0} -> {z1}");
|
||||
hold_mods(&mut h, Modifiers::NONE);
|
||||
assert_eq!(held_tool(h.state(), &h.ctx), None);
|
||||
|
||||
hold_mods(&mut h, Modifiers::ALT);
|
||||
assert_eq!(held_tool(h.state(), &h.ctx), Some(Temporary::ZoomOut));
|
||||
click(&mut h, 200.0, 150.0, Modifiers::ALT);
|
||||
let z2 = h.state().ui.views[0].zoom;
|
||||
assert!(z2 < z1, "{z1} -> {z2}");
|
||||
hold_mods(&mut h, Modifiers::COMMAND | Modifiers::ALT);
|
||||
assert_eq!(held_tool(h.state(), &h.ctx), Some(Temporary::ZoomOut));
|
||||
click(&mut h, 200.0, 150.0, Modifiers::COMMAND | Modifiers::ALT);
|
||||
assert!(h.state().ui.views[0].zoom < z2);
|
||||
hold_mods(&mut h, Modifiers::NONE);
|
||||
assert_eq!(held_tool(h.state(), &h.ctx), None);
|
||||
assert_eq!(h.state().ui.tool, Tool::Hand, "the Hand is still the tool");
|
||||
}
|
||||
|
||||
/// A ⌘-drag with the Hand is the Zoom tool's scrubby zoom, not a pan.
|
||||
#[test]
|
||||
fn cmd_drag_with_the_hand_tool_is_a_scrubby_zoom() {
|
||||
let mut h = harness(Tool::Hand);
|
||||
let z0 = h.state().ui.views[0].zoom;
|
||||
drag_with(&mut h, Modifiers::COMMAND, 200.0, 150.0, 300.0, 150.0);
|
||||
assert!(h.state().ui.views[0].zoom > z0 * 1.5, "{z0} -> {}", h.state().ui.views[0].zoom);
|
||||
assert_eq!(h.state().ui.tool, Tool::Hand);
|
||||
}
|
||||
|
||||
/// ⌘ or ⌥ pressed during a Hand pan doesn't turn the drag into a zoom: the pan goes on.
|
||||
#[test]
|
||||
fn modifiers_pressed_during_a_hand_pan_keep_panning() {
|
||||
for m in [Modifiers::COMMAND, Modifiers::ALT] {
|
||||
let mut h = harness(Tool::Hand);
|
||||
let (z0, c0) = (h.state().ui.views[0].zoom, h.state().ui.views[0].center);
|
||||
press_at(&mut h, 200.0, 150.0);
|
||||
hold_mods(&mut h, m);
|
||||
assert_eq!(held_tool(h.state(), &h.ctx), None, "{m:?}");
|
||||
let p = screen(&h, 200.0, 150.0) + vec2(60.0, 40.0);
|
||||
h.event(Event::PointerMoved(p));
|
||||
h.run_steps(2);
|
||||
button(&mut h, p, false, m);
|
||||
hold_mods(&mut h, Modifiers::NONE);
|
||||
let v = &h.state().ui.views[0];
|
||||
assert_eq!(v.zoom, z0, "{m:?}: no zoom");
|
||||
assert!(v.center[0] < c0[0] - 30.0 && v.center[1] < c0[1] - 20.0, "{m:?}: panned {c0:?} -> {:?}", v.center);
|
||||
}
|
||||
}
|
||||
|
||||
/// A middle-button pan with the Hand selected keeps panning when ⌘ or ⌥ goes down during it.
|
||||
#[test]
|
||||
fn modifiers_pressed_during_a_middle_button_pan_keep_panning() {
|
||||
for m in [Modifiers::COMMAND, Modifiers::ALT] {
|
||||
let mut h = harness(Tool::Hand);
|
||||
let (z0, c0) = (h.state().ui.views[0].zoom, h.state().ui.views[0].center);
|
||||
let p = screen(&h, 200.0, 150.0);
|
||||
h.event(Event::PointerMoved(p));
|
||||
h.run_steps(1);
|
||||
h.event(Event::PointerButton { pos: p, button: PointerButton::Middle, pressed: true, modifiers: Modifiers::NONE });
|
||||
h.run_steps(1);
|
||||
hold_mods(&mut h, m);
|
||||
assert_eq!(held_tool(h.state(), &h.ctx), None, "{m:?}");
|
||||
let q = p + vec2(60.0, 40.0);
|
||||
h.event(Event::PointerMoved(q));
|
||||
h.run_steps(2);
|
||||
h.event(Event::PointerButton { pos: q, button: PointerButton::Middle, pressed: false, modifiers: platform(m) });
|
||||
h.run_steps(1);
|
||||
hold_mods(&mut h, Modifiers::NONE);
|
||||
let v = &h.state().ui.views[0];
|
||||
assert_eq!(v.zoom, z0, "{m:?}: no zoom");
|
||||
assert!(v.center[0] < c0[0] - 30.0 && v.center[1] < c0[1] - 20.0, "{m:?}: panned {c0:?} -> {:?}", v.center);
|
||||
}
|
||||
}
|
||||
|
||||
/// Free Transform keeps ⌘ (its distort handles) while the Hand is selected.
|
||||
#[test]
|
||||
fn cmd_with_the_hand_tool_is_not_a_zoom_during_free_transform() {
|
||||
let mut h = harness(Tool::Hand);
|
||||
with_layer(&mut h);
|
||||
let ctx = h.ctx.clone();
|
||||
crate::menus::invoke(h.state_mut(), &ctx, "edit.freeTransform", json!({})).unwrap();
|
||||
h.run_steps(2);
|
||||
assert!(h.state().ui.transform.is_some());
|
||||
hold_mods(&mut h, Modifiers::COMMAND);
|
||||
assert_eq!(held_tool(h.state(), &h.ctx), None);
|
||||
}
|
||||
|
||||
/// The Modifier Keys panel's latched ⌥ and ⌘ count, for desktops that take Alt+click.
|
||||
#[test]
|
||||
fn latched_modifier_keys_zoom_with_the_hand_tool() {
|
||||
let mut h = harness(Tool::Hand);
|
||||
h.state_mut().ui.shell.sticky_command = true;
|
||||
h.run_steps(1);
|
||||
assert_eq!(held_tool(h.state(), &h.ctx), Some(Temporary::ZoomIn));
|
||||
h.state_mut().ui.shell.sticky_alt = true;
|
||||
h.run_steps(1);
|
||||
assert_eq!(held_tool(h.state(), &h.ctx), Some(Temporary::ZoomOut));
|
||||
h.state_mut().ui.shell = Default::default();
|
||||
h.state_mut().ui.tool = Tool::Brush;
|
||||
h.state_mut().ui.shell.sticky_alt = true;
|
||||
h.run_steps(1);
|
||||
assert_eq!(held_tool(h.state(), &h.ctx), None, "only the Hand's ⌥ zooms");
|
||||
}
|
||||
|
||||
/// A Hand press made without a modifier stays the Hand through its release: ⌘ or ⌥ pressed
|
||||
/// before letting go (without moving past the drag threshold) doesn't zoom on the release.
|
||||
#[test]
|
||||
fn modifiers_pressed_before_a_hand_click_is_released_do_not_zoom() {
|
||||
for m in [Modifiers::COMMAND, Modifiers::ALT] {
|
||||
let mut h = harness(Tool::Hand);
|
||||
let (z0, c0) = (h.state().ui.views[0].zoom, h.state().ui.views[0].center);
|
||||
let p = screen(&h, 200.0, 150.0);
|
||||
h.event(Event::PointerMoved(p));
|
||||
h.run_steps(1);
|
||||
button(&mut h, p, true, Modifiers::NONE);
|
||||
hold_mods(&mut h, m);
|
||||
button(&mut h, p, false, m);
|
||||
h.run_steps(1);
|
||||
let v = &h.state().ui.views[0];
|
||||
assert_eq!((v.zoom, v.center), (z0, c0), "{m:?}: the release didn't zoom");
|
||||
// The modifier still zooms the next click.
|
||||
click(&mut h, 200.0, 150.0, m);
|
||||
assert_ne!(h.state().ui.views[0].zoom, z0, "{m:?}");
|
||||
hold_mods(&mut h, Modifiers::NONE);
|
||||
}
|
||||
}
|
||||
|
||||
/// A click whose press and release arrive in one frame, with ⌘ held, still zooms.
|
||||
#[test]
|
||||
fn a_one_frame_cmd_click_with_the_hand_tool_zooms() {
|
||||
let mut h = harness(Tool::Hand);
|
||||
let z0 = h.state().ui.views[0].zoom;
|
||||
hold_mods(&mut h, Modifiers::COMMAND);
|
||||
let p = screen(&h, 200.0, 150.0);
|
||||
h.event(Event::PointerMoved(p));
|
||||
h.run_steps(1);
|
||||
let m = platform(Modifiers::COMMAND);
|
||||
h.input_mut().events.extend([
|
||||
Event::PointerButton { pos: p, button: PointerButton::Primary, pressed: true, modifiers: m },
|
||||
Event::PointerButton { pos: p, button: PointerButton::Primary, pressed: false, modifiers: m },
|
||||
]);
|
||||
h.run_steps(2);
|
||||
assert!(h.state().ui.views[0].zoom > z0);
|
||||
}
|
||||
@@ -3881,6 +3881,7 @@ navigator Zoom Zvětšení
|
||||
GPU Memory Full Paměť GPU je plná
|
||||
The layers need {needed} of GPU memory and may hold {budget}, so edits that redraw the whole document do it on the CPU. Click to set GPU Memory. Vrstvy potřebují {needed} paměti GPU a mohou zabrat {budget}, takže úpravy, které překreslují celý dokument, to dělají na CPU. Kliknutím nastavíte Paměť GPU.
|
||||
GPU memory budget: {budget} Rozpočet paměti GPU: {budget}
|
||||
Graphics memory: {size} Paměť GPU: {size}
|
||||
This document's layers: {needed} of {budget} for layers Vrstvy tohoto dokumentu: {needed} z {budget} pro vrstvy
|
||||
This document's layers need {needed} but may hold {budget}: whole-document redraws use the CPU Vrstvy tohoto dokumentu potřebují {needed}, ale mohou zabrat {budget}: překreslení celého dokumentu probíhá na CPU
|
||||
GPU Memory (MB, 0 = Automatic) Paměť GPU (MB, 0 = Automaticky)
|
||||
@@ -3910,3 +3911,5 @@ navigator Zoom Zvětšení
|
||||
|
||||
# Graphics Adapter preference (#1885)
|
||||
GPU adapter Adaptér GPU
|
||||
# Actions: a step dialog holds a suspended recording (#7365)
|
||||
Confirm or cancel the open action step dialog first Nejprve potvrďte nebo zrušte otevřený dialog kroku akce
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -3281,6 +3281,7 @@ curves Smooth Glätten
|
||||
GPU Memory Full GPU-Speicher voll
|
||||
The layers need {needed} of GPU memory and may hold {budget}, so edits that redraw the whole document do it on the CPU. Click to set GPU Memory. Die Ebenen brauchen {needed} GPU-Speicher und dürfen {budget} belegen, daher zeichnen Änderungen, die das ganze Dokument neu zeichnen, auf der CPU. Klicken, um den GPU-Speicher einzustellen.
|
||||
GPU memory budget: {budget} GPU-Speicherbudget: {budget}
|
||||
Graphics memory: {size} Grafikspeicher: {size}
|
||||
This document's layers: {needed} of {budget} for layers Ebenen dieses Dokuments: {needed} von {budget} für Ebenen
|
||||
This document's layers need {needed} but may hold {budget}: whole-document redraws use the CPU Die Ebenen dieses Dokuments brauchen {needed}, dürfen aber {budget} belegen: Das ganze Dokument wird auf der CPU neu gezeichnet
|
||||
GPU Memory (MB, 0 = Automatic) GPU-Speicher (MB, 0 = Automatisch)
|
||||
@@ -3308,3 +3309,5 @@ curves Smooth Glätten
|
||||
|
||||
# Graphics Adapter preference (#1885)
|
||||
GPU adapter GPU-Adapter
|
||||
# Actions: a step dialog holds a suspended recording (#7365)
|
||||
Confirm or cancel the open action step dialog first Bestätige oder brich zuerst den offenen Dialog des Aktionsschritts ab
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -3970,6 +3970,7 @@ curves Smooth Εξομάλυνση
|
||||
GPU Memory Full Η μνήμη GPU είναι πλήρης
|
||||
The layers need {needed} of GPU memory and may hold {budget}, so edits that redraw the whole document do it on the CPU. Click to set GPU Memory. Τα επίπεδα χρειάζονται {needed} μνήμης GPU και μπορούν να καταλάβουν {budget}, οπότε οι αλλαγές που ξανασχεδιάζουν όλο το έγγραφο το κάνουν στη CPU. Κάντε κλικ για να ορίσετε τη Μνήμη GPU.
|
||||
GPU memory budget: {budget} Όριο μνήμης GPU: {budget}
|
||||
Graphics memory: {size} Μνήμη γραφικών: {size}
|
||||
This document's layers: {needed} of {budget} for layers Επίπεδα αυτού του εγγράφου: {needed} από {budget} για επίπεδα
|
||||
This document's layers need {needed} but may hold {budget}: whole-document redraws use the CPU Τα επίπεδα αυτού του εγγράφου χρειάζονται {needed} αλλά μπορούν να καταλάβουν {budget}: η επανασχεδίαση όλου του εγγράφου γίνεται στη CPU
|
||||
GPU Memory (MB, 0 = Automatic) Μνήμη GPU (MB, 0 = Αυτόματο)
|
||||
@@ -3999,3 +4000,5 @@ curves Smooth Εξομάλυνση
|
||||
|
||||
# Graphics Adapter preference (#1885)
|
||||
GPU adapter Προσαρμογέας GPU
|
||||
# Actions: a step dialog holds a suspended recording (#7365)
|
||||
Confirm or cancel the open action step dialog first Επιβεβαιώστε ή ακυρώστε πρώτα το ανοιχτό παράθυρο βήματος της ενέργειας
|
||||
|
Can't render this file because it contains an unexpected character in line 1030 and column 18.
|
@@ -4232,6 +4232,7 @@ navigator Zoom Zoom
|
||||
GPU Memory Full Memoria de GPU llena
|
||||
The layers need {needed} of GPU memory and may hold {budget}, so edits that redraw the whole document do it on the CPU. Click to set GPU Memory. Las capas necesitan {needed} de memoria de GPU y pueden ocupar {budget}, así que las ediciones que redibujan todo el documento lo hacen en la CPU. Haga clic para ajustar Memoria de GPU.
|
||||
GPU memory budget: {budget} Presupuesto de memoria de GPU: {budget}
|
||||
Graphics memory: {size} Memoria gráfica: {size}
|
||||
This document's layers: {needed} of {budget} for layers Capas de este documento: {needed} de {budget} para capas
|
||||
This document's layers need {needed} but may hold {budget}: whole-document redraws use the CPU Las capas de este documento necesitan {needed} pero pueden ocupar {budget}: los redibujados de todo el documento usan la CPU
|
||||
GPU Memory (MB, 0 = Automatic) Memoria de GPU (MB, 0 = Automático)
|
||||
@@ -4261,3 +4262,5 @@ navigator Zoom Zoom
|
||||
|
||||
# Graphics Adapter preference (#1885)
|
||||
GPU adapter Adaptador de GPU
|
||||
# Actions: a step dialog holds a suspended recording (#7365)
|
||||
Confirm or cancel the open action step dialog first Confirme o cancele primero el cuadro de diálogo abierto del paso de la acción
|
||||
|
Can't render this file because it contains an unexpected character in line 4 and column 47.
|
@@ -3279,6 +3279,7 @@ curves Smooth Lisser
|
||||
GPU Memory Full Mémoire GPU pleine
|
||||
The layers need {needed} of GPU memory and may hold {budget}, so edits that redraw the whole document do it on the CPU. Click to set GPU Memory. Les calques ont besoin de {needed} de mémoire GPU et peuvent en occuper {budget} : les modifications qui redessinent tout le document le font sur le CPU. Cliquez pour régler Mémoire GPU.
|
||||
GPU memory budget: {budget} Budget de mémoire GPU : {budget}
|
||||
Graphics memory: {size} Mémoire graphique : {size}
|
||||
This document's layers: {needed} of {budget} for layers Calques de ce document : {needed} sur {budget} pour les calques
|
||||
This document's layers need {needed} but may hold {budget}: whole-document redraws use the CPU Les calques de ce document ont besoin de {needed} mais peuvent occuper {budget} : le document entier se redessine sur le CPU
|
||||
GPU Memory (MB, 0 = Automatic) Mémoire GPU (Mo, 0 = Automatique)
|
||||
@@ -3310,3 +3311,5 @@ curves Smooth Lisser
|
||||
|
||||
# Graphics Adapter preference (#1885)
|
||||
GPU adapter Adaptateur GPU
|
||||
# Actions: a step dialog holds a suspended recording (#7365)
|
||||
Confirm or cancel the open action step dialog first Validez ou annulez d’abord la boîte de dialogue ouverte de l’étape de l’action
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -4187,6 +4187,7 @@ cameraRaw Yellow Sárga
|
||||
GPU Memory Full GPU-memória megtelt
|
||||
The layers need {needed} of GPU memory and may hold {budget}, so edits that redraw the whole document do it on the CPU. Click to set GPU Memory. A rétegeknek {needed} GPU-memória kell, és {budget} foglalhatnak, ezért a teljes dokumentumot újrarajzoló szerkesztések a CPU-n futnak. Kattints a GPU-memória beállításához.
|
||||
GPU memory budget: {budget} GPU-memóriakeret: {budget}
|
||||
Graphics memory: {size} Grafikus memória: {size}
|
||||
This document's layers: {needed} of {budget} for layers A dokumentum rétegei: {needed} / {budget} a rétegeknek
|
||||
This document's layers need {needed} but may hold {budget}: whole-document redraws use the CPU A dokumentum rétegeinek {needed} kell, de {budget} foglalhatnak: a teljes dokumentum újrarajzolása a CPU-n fut
|
||||
GPU Memory (MB, 0 = Automatic) GPU-memória (MB, 0 = Automatikus)
|
||||
@@ -4216,3 +4217,5 @@ cameraRaw Yellow Sárga
|
||||
|
||||
# Graphics Adapter preference (#1885)
|
||||
GPU adapter GPU-adapter
|
||||
# Actions: a step dialog holds a suspended recording (#7365)
|
||||
Confirm or cancel the open action step dialog first Előbb hagyd jóvá vagy vond vissza a művelet lépésének nyitott párbeszédablakát
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -3266,6 +3266,7 @@ curves Smooth Haluskan
|
||||
GPU Memory Full Memori GPU Penuh
|
||||
The layers need {needed} of GPU memory and may hold {budget}, so edits that redraw the whole document do it on the CPU. Click to set GPU Memory. Layer membutuhkan {needed} memori GPU dan boleh memakai {budget}, sehingga suntingan yang menggambar ulang seluruh dokumen melakukannya di CPU. Klik untuk mengatur Memori GPU.
|
||||
GPU memory budget: {budget} Anggaran memori GPU: {budget}
|
||||
Graphics memory: {size} Memori grafis: {size}
|
||||
This document's layers: {needed} of {budget} for layers Layer dokumen ini: {needed} dari {budget} untuk layer
|
||||
This document's layers need {needed} but may hold {budget}: whole-document redraws use the CPU Layer dokumen ini membutuhkan {needed} tetapi boleh memakai {budget}: penggambaran ulang seluruh dokumen memakai CPU
|
||||
GPU Memory (MB, 0 = Automatic) Memori GPU (MB, 0 = Otomatis)
|
||||
@@ -3297,3 +3298,5 @@ curves Smooth Haluskan
|
||||
|
||||
# Graphics Adapter preference (#1885)
|
||||
GPU adapter Adaptor GPU
|
||||
# Actions: a step dialog holds a suspended recording (#7365)
|
||||
Confirm or cancel the open action step dialog first Konfirmasi atau batalkan dulu dialog langkah tindakan yang terbuka
|
||||
|
Can't render this file because it contains an unexpected character in line 4 and column 47.
|
@@ -4391,6 +4391,7 @@ shape Appearance Aspetto
|
||||
GPU Memory Full Memoria GPU piena
|
||||
The layers need {needed} of GPU memory and may hold {budget}, so edits that redraw the whole document do it on the CPU. Click to set GPU Memory. I livelli richiedono {needed} di memoria GPU e possono occuparne {budget}, quindi le modifiche che ridisegnano tutto il documento lo fanno sulla CPU. Fai clic per impostare Memoria GPU.
|
||||
GPU memory budget: {budget} Budget di memoria GPU: {budget}
|
||||
Graphics memory: {size} Memoria grafica: {size}
|
||||
This document's layers: {needed} of {budget} for layers Livelli di questo documento: {needed} su {budget} per i livelli
|
||||
This document's layers need {needed} but may hold {budget}: whole-document redraws use the CPU I livelli di questo documento richiedono {needed} ma possono occupare {budget}: i ridisegni dell'intero documento usano la CPU
|
||||
GPU Memory (MB, 0 = Automatic) Memoria GPU (MB, 0 = Automatico)
|
||||
@@ -4416,3 +4417,5 @@ shape Appearance Aspetto
|
||||
|
||||
# Graphics Adapter preference (#1885)
|
||||
GPU adapter Adattatore GPU
|
||||
# Actions: a step dialog holds a suspended recording (#7365)
|
||||
Confirm or cancel the open action step dialog first Conferma o annulla prima la finestra di dialogo aperta del passo dell’azione
|
||||
|
Can't render this file because it contains an unexpected character in line 2659 and column 53.
|
@@ -3946,6 +3946,7 @@ curves Smooth スムーズ
|
||||
GPU Memory Full GPU メモリ不足
|
||||
The layers need {needed} of GPU memory and may hold {budget}, so edits that redraw the whole document do it on the CPU. Click to set GPU Memory. レイヤーには {needed} の GPU メモリが必要ですが、使えるのは {budget} のため、ドキュメント全体を再描画する編集は CPU で行われます。クリックして GPU メモリを設定します。
|
||||
GPU memory budget: {budget} GPU メモリ予算: {budget}
|
||||
Graphics memory: {size} グラフィックメモリ: {size}
|
||||
This document's layers: {needed} of {budget} for layers このドキュメントのレイヤー: レイヤー用 {budget} のうち {needed}
|
||||
This document's layers need {needed} but may hold {budget}: whole-document redraws use the CPU このドキュメントのレイヤーには {needed} が必要ですが、使えるのは {budget} です: ドキュメント全体の再描画は CPU で行われます
|
||||
GPU Memory (MB, 0 = Automatic) GPU メモリ(MB、0 = 自動)
|
||||
@@ -3977,3 +3978,5 @@ curves Smooth スムーズ
|
||||
|
||||
# Graphics Adapter preference (#1885)
|
||||
GPU adapter GPU アダプター
|
||||
# Actions: a step dialog holds a suspended recording (#7365)
|
||||
Confirm or cancel the open action step dialog first 先に開いているアクションのステップのダイアログを確定またはキャンセルしてください
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -3457,6 +3457,7 @@ curves Smooth 매끄럽게
|
||||
GPU Memory Full GPU 메모리 부족
|
||||
The layers need {needed} of GPU memory and may hold {budget}, so edits that redraw the whole document do it on the CPU. Click to set GPU Memory. 레이어에 GPU 메모리 {needed}가 필요하지만 {budget}만 사용할 수 있어 문서 전체를 다시 그리는 편집은 CPU에서 처리됩니다. 클릭하여 GPU 메모리를 설정합니다.
|
||||
GPU memory budget: {budget} GPU 메모리 예산: {budget}
|
||||
Graphics memory: {size} 그래픽 메모리: {size}
|
||||
This document's layers: {needed} of {budget} for layers 이 문서의 레이어: 레이어용 {budget} 중 {needed}
|
||||
This document's layers need {needed} but may hold {budget}: whole-document redraws use the CPU 이 문서의 레이어에 {needed}가 필요하지만 {budget}만 사용할 수 있습니다: 문서 전체 다시 그리기는 CPU를 사용합니다
|
||||
GPU Memory (MB, 0 = Automatic) GPU 메모리(MB, 0 = 자동)
|
||||
@@ -3489,3 +3490,5 @@ curves Smooth 매끄럽게
|
||||
|
||||
# Graphics Adapter preference (#1885)
|
||||
GPU adapter GPU 어댑터
|
||||
# Actions: a step dialog holds a suspended recording (#7365)
|
||||
Confirm or cancel the open action step dialog first 먼저 열려 있는 액션 단계 대화 상자를 확인하거나 취소하세요
|
||||
|
Can't render this file because it contains an unexpected character in line 3173 and column 53.
|
@@ -4030,6 +4030,7 @@ curves Smooth Vloeiend maken
|
||||
GPU Memory Full GPU-geheugen vol
|
||||
The layers need {needed} of GPU memory and may hold {budget}, so edits that redraw the whole document do it on the CPU. Click to set GPU Memory. De lagen hebben {needed} GPU-geheugen nodig en mogen {budget} gebruiken, dus bewerkingen die het hele document opnieuw tekenen doen dat op de CPU. Klik om GPU-geheugen in te stellen.
|
||||
GPU memory budget: {budget} GPU-geheugenbudget: {budget}
|
||||
Graphics memory: {size} Grafisch geheugen: {size}
|
||||
This document's layers: {needed} of {budget} for layers Lagen van dit document: {needed} van {budget} voor lagen
|
||||
This document's layers need {needed} but may hold {budget}: whole-document redraws use the CPU De lagen van dit document hebben {needed} nodig maar mogen {budget} gebruiken: het hele document wordt op de CPU opnieuw getekend
|
||||
GPU Memory (MB, 0 = Automatic) GPU-geheugen (MB, 0 = Automatisch)
|
||||
@@ -4059,3 +4060,5 @@ curves Smooth Vloeiend maken
|
||||
|
||||
# Graphics Adapter preference (#1885)
|
||||
GPU adapter GPU-adapter
|
||||
# Actions: a step dialog holds a suspended recording (#7365)
|
||||
Confirm or cancel the open action step dialog first Bevestig of annuleer eerst het geopende dialoogvenster van de handelingsstap
|
||||
|
Can't render this file because it contains an unexpected character in line 8 and column 34.
|
@@ -3868,6 +3868,7 @@ curves Smooth Wygładź
|
||||
GPU Memory Full Pamięć GPU pełna
|
||||
The layers need {needed} of GPU memory and may hold {budget}, so edits that redraw the whole document do it on the CPU. Click to set GPU Memory. Warstwy potrzebują {needed} pamięci GPU i mogą zająć {budget}, więc edycje, które odświeżają cały dokument, robią to na CPU. Kliknij, aby ustawić Pamięć GPU.
|
||||
GPU memory budget: {budget} Budżet pamięci GPU: {budget}
|
||||
Graphics memory: {size} Pamięć graficzna: {size}
|
||||
This document's layers: {needed} of {budget} for layers Warstwy tego dokumentu: {needed} z {budget} na warstwy
|
||||
This document's layers need {needed} but may hold {budget}: whole-document redraws use the CPU Warstwy tego dokumentu potrzebują {needed}, ale mogą zająć {budget}: odświeżanie całego dokumentu używa CPU
|
||||
GPU Memory (MB, 0 = Automatic) Pamięć GPU (MB, 0 = Automatycznie)
|
||||
@@ -3899,3 +3900,5 @@ curves Smooth Wygładź
|
||||
|
||||
# Graphics Adapter preference (#1885)
|
||||
GPU adapter Karta GPU
|
||||
# Actions: a step dialog holds a suspended recording (#7365)
|
||||
Confirm or cancel the open action step dialog first Najpierw zatwierdź lub anuluj otwarte okno kroku operacji
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -4060,6 +4060,7 @@ layerLabel No Color Sem cor
|
||||
GPU Memory Full Memória da GPU cheia
|
||||
The layers need {needed} of GPU memory and may hold {budget}, so edits that redraw the whole document do it on the CPU. Click to set GPU Memory. As camadas precisam de {needed} de memória da GPU e podem ocupar {budget}, então as edições que redesenham o documento inteiro fazem isso na CPU. Clique para ajustar Memória da GPU.
|
||||
GPU memory budget: {budget} Orçamento de memória da GPU: {budget}
|
||||
Graphics memory: {size} Memória gráfica: {size}
|
||||
This document's layers: {needed} of {budget} for layers Camadas deste documento: {needed} de {budget} para camadas
|
||||
This document's layers need {needed} but may hold {budget}: whole-document redraws use the CPU As camadas deste documento precisam de {needed} mas podem ocupar {budget}: o documento inteiro é redesenhado na CPU
|
||||
GPU Memory (MB, 0 = Automatic) Memória da GPU (MB, 0 = Automático)
|
||||
@@ -4089,3 +4090,5 @@ layerLabel No Color Sem cor
|
||||
|
||||
# Graphics Adapter preference (#1885)
|
||||
GPU adapter Adaptador de GPU
|
||||
# Actions: a step dialog holds a suspended recording (#7365)
|
||||
Confirm or cancel the open action step dialog first Confirme ou cancele primeiro a caixa de diálogo aberta da etapa da ação
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -3245,6 +3245,7 @@ curves Smooth Сгладить
|
||||
GPU Memory Full Память GPU заполнена
|
||||
The layers need {needed} of GPU memory and may hold {budget}, so edits that redraw the whole document do it on the CPU. Click to set GPU Memory. Слоям нужно {needed} памяти GPU, а занимать они могут {budget}, поэтому правки, перерисовывающие весь документ, выполняются на CPU. Нажмите, чтобы задать «Память GPU».
|
||||
GPU memory budget: {budget} Бюджет памяти GPU: {budget}
|
||||
Graphics memory: {size} Видеопамять: {size}
|
||||
This document's layers: {needed} of {budget} for layers Слои этого документа: {needed} из {budget} для слоёв
|
||||
This document's layers need {needed} but may hold {budget}: whole-document redraws use the CPU Слоям этого документа нужно {needed}, но занимать они могут {budget}: весь документ перерисовывается на CPU
|
||||
GPU Memory (MB, 0 = Automatic) Память GPU (МБ, 0 = автоматически)
|
||||
@@ -3277,3 +3278,5 @@ curves Smooth Сгладить
|
||||
|
||||
# Graphics Adapter preference (#1885)
|
||||
GPU adapter Адаптер GPU
|
||||
# Actions: a step dialog holds a suspended recording (#7365)
|
||||
Confirm or cancel the open action step dialog first Сначала подтвердите или отмените открытый диалог шага операции
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -4341,6 +4341,7 @@ shape Appearance Izgled
|
||||
GPU Memory Full GPU memorija je puna
|
||||
The layers need {needed} of GPU memory and may hold {budget}, so edits that redraw the whole document do it on the CPU. Click to set GPU Memory. Slojevima treba {needed} GPU memorije, a smeju da zauzmu {budget}, pa izmene koje ponovo iscrtavaju ceo dokument to rade na CPU-u. Kliknite da podesite GPU memoriju.
|
||||
GPU memory budget: {budget} Budžet GPU memorije: {budget}
|
||||
Graphics memory: {size} Grafička memorija: {size}
|
||||
This document's layers: {needed} of {budget} for layers Slojevi ovog dokumenta: {needed} od {budget} za slojeve
|
||||
This document's layers need {needed} but may hold {budget}: whole-document redraws use the CPU Slojevima ovog dokumenta treba {needed}, a smeju da zauzmu {budget}: ceo dokument se ponovo iscrtava na CPU-u
|
||||
GPU Memory (MB, 0 = Automatic) GPU memorija (MB, 0 = Automatski)
|
||||
@@ -4370,3 +4371,5 @@ shape Appearance Izgled
|
||||
|
||||
# Graphics Adapter preference (#1885)
|
||||
GPU adapter GPU adapter
|
||||
# Actions: a step dialog holds a suspended recording (#7365)
|
||||
Confirm or cancel the open action step dialog first Prvo potvrdite ili otkažite otvoreni dijalog koraka radnje
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
+830
-825
File diff suppressed because it is too large.
Load diff
@@ -3969,6 +3969,7 @@ curves Smooth Згладити
|
||||
GPU Memory Full Пам'ять GPU заповнена
|
||||
The layers need {needed} of GPU memory and may hold {budget}, so edits that redraw the whole document do it on the CPU. Click to set GPU Memory. Шарам потрібно {needed} пам'яті GPU, а займати вони можуть {budget}, тому зміни, що перемальовують увесь документ, виконуються на CPU. Натисніть, щоб задати «Пам'ять GPU».
|
||||
GPU memory budget: {budget} Бюджет пам'яті GPU: {budget}
|
||||
Graphics memory: {size} Відеопам'ять: {size}
|
||||
This document's layers: {needed} of {budget} for layers Шари цього документа: {needed} з {budget} для шарів
|
||||
This document's layers need {needed} but may hold {budget}: whole-document redraws use the CPU Шарам цього документа потрібно {needed}, але займати вони можуть {budget}: увесь документ перемальовується на CPU
|
||||
GPU Memory (MB, 0 = Automatic) Пам'ять GPU (МБ, 0 = автоматично)
|
||||
@@ -4008,3 +4009,5 @@ curves Smooth Згладити
|
||||
|
||||
# Graphics Adapter preference (#1885)
|
||||
GPU adapter Адаптер GPU
|
||||
# Actions: a step dialog holds a suspended recording (#7365)
|
||||
Confirm or cancel the open action step dialog first Спочатку підтвердьте або скасуйте відкритий діалог кроку операції
|
||||
|
Can't render this file because it contains an unexpected character in line 1394 and column 18.
|
@@ -3759,6 +3759,7 @@ curves Smooth Làm mượt
|
||||
GPU Memory Full Bộ nhớ GPU đầy
|
||||
The layers need {needed} of GPU memory and may hold {budget}, so edits that redraw the whole document do it on the CPU. Click to set GPU Memory. Các lớp cần {needed} bộ nhớ GPU và chỉ được dùng {budget}, nên những chỉnh sửa vẽ lại toàn bộ tài liệu sẽ làm trên CPU. Nhấp để đặt Bộ nhớ GPU.
|
||||
GPU memory budget: {budget} Ngân sách bộ nhớ GPU: {budget}
|
||||
Graphics memory: {size} Bộ nhớ đồ họa: {size}
|
||||
This document's layers: {needed} of {budget} for layers Các lớp của tài liệu này: {needed} trên {budget} dành cho lớp
|
||||
This document's layers need {needed} but may hold {budget}: whole-document redraws use the CPU Các lớp của tài liệu này cần {needed} nhưng chỉ được dùng {budget}: vẽ lại toàn bộ tài liệu dùng CPU
|
||||
GPU Memory (MB, 0 = Automatic) Bộ nhớ GPU (MB, 0 = Tự động)
|
||||
@@ -3790,3 +3791,5 @@ curves Smooth Làm mượt
|
||||
|
||||
# Graphics Adapter preference (#1885)
|
||||
GPU adapter Bộ điều hợp GPU
|
||||
# Actions: a step dialog holds a suspended recording (#7365)
|
||||
Confirm or cancel the open action step dialog first Hãy xác nhận hoặc hủy hộp thoại bước hành động đang mở trước
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -2902,6 +2902,7 @@ curves Smooth 平滑
|
||||
GPU Memory Full GPU 内存已满
|
||||
The layers need {needed} of GPU memory and may hold {budget}, so edits that redraw the whole document do it on the CPU. Click to set GPU Memory. 图层需要 {needed} GPU 内存,但只能占用 {budget},因此重绘整个文档的编辑会在 CPU 上进行。点击以设置 GPU 内存。
|
||||
GPU memory budget: {budget} GPU 内存预算:{budget}
|
||||
Graphics memory: {size} 显存:{size}
|
||||
This document's layers: {needed} of {budget} for layers 此文档的图层:图层可用 {budget} 中的 {needed}
|
||||
This document's layers need {needed} but may hold {budget}: whole-document redraws use the CPU 此文档的图层需要 {needed},但只能占用 {budget}:整个文档的重绘使用 CPU
|
||||
GPU Memory (MB, 0 = Automatic) GPU 内存(MB,0 = 自动)
|
||||
@@ -2934,3 +2935,5 @@ curves Smooth 平滑
|
||||
|
||||
# Graphics Adapter preference (#1885)
|
||||
GPU adapter GPU 适配器
|
||||
# Actions: a step dialog holds a suspended recording (#7365)
|
||||
Confirm or cancel the open action step dialog first 请先确认或取消打开的动作步骤对话框
|
||||
|
Can't render this file because it contains an unexpected character in line 2607 and column 53.
|
@@ -2887,6 +2887,7 @@ curves Smooth 平滑
|
||||
GPU Memory Full GPU 記憶體已滿
|
||||
The layers need {needed} of GPU memory and may hold {budget}, so edits that redraw the whole document do it on the CPU. Click to set GPU Memory. 圖層需要 {needed} GPU 記憶體,但只能佔用 {budget},因此重繪整份文件的編輯會在 CPU 上進行。按一下以設定 GPU 記憶體。
|
||||
GPU memory budget: {budget} GPU 記憶體預算:{budget}
|
||||
Graphics memory: {size} 顯示記憶體:{size}
|
||||
This document's layers: {needed} of {budget} for layers 此文件的圖層:圖層可用 {budget} 中的 {needed}
|
||||
This document's layers need {needed} but may hold {budget}: whole-document redraws use the CPU 此文件的圖層需要 {needed},但只能佔用 {budget}:整份文件的重繪使用 CPU
|
||||
GPU Memory (MB, 0 = Automatic) GPU 記憶體(MB,0 = 自動)
|
||||
@@ -2919,3 +2920,5 @@ curves Smooth 平滑
|
||||
|
||||
# Graphics Adapter preference (#1885)
|
||||
GPU adapter GPU 介面卡
|
||||
# Actions: a step dialog holds a suspended recording (#7365)
|
||||
Confirm or cancel the open action step dialog first 請先確認或取消開啟中的動作步驟對話框
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -91,6 +91,7 @@ pub mod eraser_ui;
|
||||
pub mod export_dialog;
|
||||
pub mod eyedropper_ui;
|
||||
pub mod field_tab;
|
||||
pub mod field_wheel;
|
||||
pub mod file_dialog;
|
||||
pub mod file_open;
|
||||
pub mod file_ui;
|
||||
@@ -1232,6 +1233,7 @@ impl PhotocraftApp {
|
||||
return Err(if self.ui.status.is_empty() { tl!("The transform couldn't be applied.").into() } else { self.ui.status.clone() });
|
||||
}
|
||||
}
|
||||
actions::suspended_guard(self, id)?;
|
||||
if let Some(result) = panel_docking::command(self, id, ¶ms) {
|
||||
return result;
|
||||
}
|
||||
@@ -2201,6 +2203,8 @@ impl eframe::App for PhotocraftApp {
|
||||
self.stroke_trace.cpu_prev(frame.info().cpu_usage);
|
||||
// A text field's right-click menu, before any field is drawn (text_field_menu.rs).
|
||||
text_field_menu::show(&ctx);
|
||||
// The wheel goes to a focused value field before the canvas or a panel sees it (#5473).
|
||||
field_wheel::begin_frame(&ctx);
|
||||
// Each painting tool keeps its own brush (#218), so switch the active tool's brush in
|
||||
// before anything this frame reads it (the cursor, the options bar, a stroke).
|
||||
paint_mouse::sync_tool_brush(self);
|
||||
@@ -3077,6 +3081,9 @@ mod blend_dropdown_wheel_tests;
|
||||
#[cfg(test)]
|
||||
mod options_bar_mode_wheel_tests;
|
||||
|
||||
#[cfg(test)]
|
||||
mod field_wheel_app_tests;
|
||||
|
||||
#[cfg(test)]
|
||||
mod dropdown_press_tests;
|
||||
|
||||
|
||||
@@ -213,6 +213,30 @@ pub fn draw_guides(app: &PhotocraftApp, painter: &egui::Painter, xf: &ViewXform,
|
||||
}
|
||||
}
|
||||
|
||||
/// The position readout of a guide being dragged: `X:` for a vertical guide, `Y:` for a horizontal
|
||||
/// one, measured from the ruler zero point in the ruler unit. Pixels keep one decimal, as
|
||||
/// Photoshop's "X: 103.2 px".
|
||||
pub fn guide_drag_readout(app: &PhotocraftApp, d: GuideDrag) -> Option<(&'static str, String)> {
|
||||
let doc = &app.session.active()?.doc;
|
||||
let ur = &app.session.prefs().units_and_rulers;
|
||||
let axis = usize::from(!d.vertical);
|
||||
let px = d.pos - doc.ruler_origin.get(axis).copied().unwrap_or(0.0);
|
||||
let extent = if d.vertical { doc.size.width } else { doc.size.height } as f64;
|
||||
let value = match ur.rulers {
|
||||
Unit::Pixels => photocraft_engine::prefs::fmt_decimals(px, 1),
|
||||
_ => ur.format(px, f64::from(doc.resolution_dpi), extent),
|
||||
};
|
||||
Some((if d.vertical { "X:" } else { "Y:" }, format!("{value} {}", ur.rulers.suffix())))
|
||||
}
|
||||
|
||||
/// Draw [`guide_drag_readout`] beside the pointer while a guide is dragged.
|
||||
pub fn draw_guide_drag_readout(app: &PhotocraftApp, ctx: &egui::Context) {
|
||||
let (Some(d), Some(at)) = (app.guide_drag, ctx.pointer_latest_pos()) else { return };
|
||||
if let Some((label, value)) = guide_drag_readout(app, d) {
|
||||
crate::canvas::draw_value_readout(app, ctx, "guide-drag-readout", at, [label], [value]);
|
||||
}
|
||||
}
|
||||
|
||||
/// Existing guide under a document point (within 4 screen px).
|
||||
pub fn guide_at(app: &PhotocraftApp, x: f64, y: f64) -> Option<(bool, usize)> {
|
||||
// Hidden canvas guides are not interactive: the Move tool must reach the layer below.
|
||||
@@ -737,6 +761,123 @@ mod tests {
|
||||
assert!(h.query_by_label("17").is_some(), "horizontal guide: Y readout");
|
||||
}
|
||||
|
||||
/// A dragged guide shows its position beside the pointer: X for a vertical guide, Y for a
|
||||
/// horizontal one, from the zero point, in the ruler unit (pixels to one decimal).
|
||||
#[test]
|
||||
fn guide_drag_shows_its_position_beside_the_pointer() {
|
||||
use egui_kittest::kittest::Queryable;
|
||||
let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default());
|
||||
app.run("file.new", json!({"width": 200, "height": 100})).unwrap();
|
||||
let v = GuideDrag { vertical: true, index: Some(0), pos: 103.24, press: 50.0 };
|
||||
assert_eq!(guide_drag_readout(&app, v), Some(("X:", "103.2 px".to_owned())));
|
||||
let h = GuideDrag { vertical: false, index: None, pos: 40.0, press: 40.0 };
|
||||
assert_eq!(guide_drag_readout(&app, h), Some(("Y:", "40 px".to_owned())));
|
||||
app.run("view.setRulerOrigin", json!({"x": 3.0, "y": 10.0})).unwrap();
|
||||
assert_eq!(guide_drag_readout(&app, h), Some(("Y:", "30 px".to_owned())), "from the zero point");
|
||||
app.run("view.resetRulerOrigin", json!({})).unwrap();
|
||||
app.run("prefs.set", json!({"path": "unitsAndRulers.rulers", "value": "percent"})).unwrap();
|
||||
assert_eq!(guide_drag_readout(&app, GuideDrag { vertical: true, index: None, pos: 103.0, press: 0.0 }).map(|r| r.0), Some("X:"));
|
||||
app.run("prefs.set", json!({"path": "unitsAndRulers.rulers", "value": "pixels"})).unwrap();
|
||||
|
||||
app.guide_drag = Some(v);
|
||||
let mut h = egui_kittest::Harness::builder().with_size(vec2(300.0, 200.0)).build_ui_state(|ui, app| draw_guide_drag_readout(app, ui.ctx()), app);
|
||||
h.event(egui::Event::PointerMoved(pos2(50.0, 50.0)));
|
||||
h.run_steps(2);
|
||||
assert!(h.query_by_label("X:").is_some() && h.query_by_label("103.2 px").is_some());
|
||||
h.state_mut().guide_drag = None;
|
||||
h.run_steps(2);
|
||||
assert!(h.query_by_label("X:").is_none(), "no readout once the drag ends");
|
||||
}
|
||||
|
||||
type AppHarness = egui_kittest::Harness<'static, PhotocraftApp>;
|
||||
|
||||
/// The real canvas on a 400 × 300 document with a horizontal guide at y = 100, at 100 %,
|
||||
/// with the Move tool and snapping off.
|
||||
fn canvas_harness(rulers: bool) -> AppHarness {
|
||||
let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default());
|
||||
app.run("file.new", json!({"width": 400, "height": 300})).unwrap();
|
||||
app.run("view.newGuide", json!({"orientation": "horizontal", "position": 100})).unwrap();
|
||||
app.sync_views();
|
||||
app.ui.extras.rulers = rulers;
|
||||
app.ui.extras.snap = false;
|
||||
app.ui.tool = crate::state::Tool::Move;
|
||||
let mut h = egui_kittest::Harness::builder().with_size(vec2(800.0, 600.0)).build_ui_state(
|
||||
|ui, app: &mut PhotocraftApp| {
|
||||
if !ui.ctx().fonts(|f| f.families().contains(&egui::FontFamily::Name("medium".into()))) {
|
||||
return;
|
||||
}
|
||||
egui::CentralPanel::default().show(ui, |ui| crate::canvas::document_area(app, ui));
|
||||
},
|
||||
app,
|
||||
);
|
||||
PhotocraftApp::setup_context(&h.ctx, crate::theme::ThemeKind::ALL[0]);
|
||||
h.run_steps(4);
|
||||
let v = &mut h.state_mut().ui.views[0];
|
||||
(v.zoom, v.center, v.fit_pending) = (1.0, [200.0, 150.0], false);
|
||||
h.run_steps(2);
|
||||
h
|
||||
}
|
||||
|
||||
/// Screen point of document point `(x, y)` in [`canvas_harness`].
|
||||
fn canvas_at(h: &AppHarness, x: f32, y: f32) -> Pos2 {
|
||||
let app = h.state();
|
||||
let v = &app.ui.views[0];
|
||||
let rect = content_rect(app, app.last_canvas_rect);
|
||||
ViewXform { rect, zoom: v.zoom, center: v.center, flip: false, rotation: 0.0, aspect: 1.0 }.to_screen(x, y)
|
||||
}
|
||||
|
||||
/// Moving a horizontal guide with the Move tool on the real canvas: `Y:` follows the pointer.
|
||||
#[test]
|
||||
fn moving_a_guide_on_the_canvas_shows_its_y() {
|
||||
use egui_kittest::kittest::Queryable;
|
||||
let mut h = canvas_harness(false);
|
||||
let at = canvas_at;
|
||||
let press = at(&h, 200.0, 100.0);
|
||||
h.event(egui::Event::PointerMoved(press));
|
||||
h.run_steps(1);
|
||||
h.event(egui::Event::PointerButton { pos: press, button: egui::PointerButton::Primary, pressed: true, modifiers: egui::Modifiers::NONE });
|
||||
h.run_steps(1);
|
||||
for y in [110.0, 125.0, 140.0] {
|
||||
h.event(egui::Event::PointerMoved(at(&h, 210.0, y)));
|
||||
h.run_steps(2);
|
||||
}
|
||||
assert!(h.state().guide_drag.is_some_and(|d| !d.vertical), "a horizontal guide is being dragged");
|
||||
assert!(h.query_by_label("Y:").is_some() && h.query_by_label("140 px").is_some(), "Y readout at the guide");
|
||||
assert!(h.query_by_label("X:").is_none());
|
||||
let up = at(&h, 210.0, 140.0);
|
||||
h.event(egui::Event::PointerButton { pos: up, button: egui::PointerButton::Primary, pressed: false, modifiers: egui::Modifiers::NONE });
|
||||
h.run_steps(2);
|
||||
assert_eq!(h.state().session.active().unwrap().doc.guides.horizontal, vec![140.0]);
|
||||
assert!(h.query_by_label("Y:").is_none(), "gone after the drop");
|
||||
}
|
||||
|
||||
/// A guide dragged out of the top ruler: in each frame the readout shows where the guide is
|
||||
/// after that frame's pointer move (the ruler handles the drag after the canvas is drawn), and
|
||||
/// the frame that drops it shows none.
|
||||
#[test]
|
||||
fn ruler_drag_readout_is_current_every_frame() {
|
||||
use egui_kittest::kittest::Queryable;
|
||||
let mut h = canvas_harness(true);
|
||||
let from = pos2(canvas_at(&h, 200.0, 0.0).x, h.state().last_canvas_rect.top() + RULER / 2.0);
|
||||
h.event(egui::Event::PointerMoved(from));
|
||||
h.run_steps(1);
|
||||
h.event(egui::Event::PointerButton { pos: from, button: egui::PointerButton::Primary, pressed: true, modifiers: egui::Modifiers::NONE });
|
||||
h.run_steps(1);
|
||||
for y in [40.0, 60.0, 75.0] {
|
||||
h.event(egui::Event::PointerMoved(canvas_at(&h, 200.0, y)));
|
||||
h.run_steps(1);
|
||||
let pos = h.state().guide_drag.map(|d| d.pos);
|
||||
assert_eq!(pos, Some(f64::from(y)), "the drag follows the pointer");
|
||||
assert!(h.query_by_label(&format!("{y} px")).is_some(), "readout at {y} in the same frame");
|
||||
}
|
||||
let up = canvas_at(&h, 200.0, 75.0);
|
||||
h.event(egui::Event::PointerButton { pos: up, button: egui::PointerButton::Primary, pressed: false, modifiers: egui::Modifiers::NONE });
|
||||
h.run_steps(1);
|
||||
assert!(h.state().guide_drag.is_none());
|
||||
assert!(h.query_by_label("Y:").is_none(), "no readout in the frame that drops the guide");
|
||||
assert!(h.state().session.active().unwrap().doc.guides.horizontal.contains(&75.0), "the guide lands at y = 75");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn percentage_grid_spacing_uses_both_canvas_dimensions() {
|
||||
let mut g = GuidesGridAndSlices { grid_unit: Unit::Percent, gridline_every: 20.0, subdivisions: 2, ..Default::default() };
|
||||
|
||||
@@ -587,7 +587,20 @@ fn value_field_box(
|
||||
// Small ranges (gamma 0.01–9.99, 0–1 centres) need two decimals and a finer drag, like Photoshop.
|
||||
let fine = range.end() - range.start() <= 10.0;
|
||||
let (lo, hi) = (*range.start(), *range.end());
|
||||
let (step, grid) = arrow_step(ui, slot.id, if fine { 0.01 } else { 1.0 });
|
||||
// The field's id is only known once it's drawn: last frame's, saved under `slot` below.
|
||||
let focused = ui.data(|d| d.get_temp::<egui::Id>(slot.id)).filter(|id| ui.memory(|m| m.has_focus(*id)));
|
||||
let unit = if fine { 0.01 } else { 1.0 };
|
||||
let (step, grid) = arrow_step(ui, slot.id, unit);
|
||||
// The wheel steps it as the arrow keys do (#5473), focused or under the pointer.
|
||||
let notches = crate::field_wheel::notches(ui, slot.id, focused.is_some(), rect);
|
||||
if notches != 0.0
|
||||
&& let Some(id) = focused
|
||||
&& ui.data(|d| d.get_temp(id.with("arithmetic"))).unwrap_or(false)
|
||||
{
|
||||
// A typed sum works itself out first, as before an arrow step.
|
||||
ui.memory_mut(|m| m.surrender_focus(id));
|
||||
}
|
||||
let step = step + notches * unit;
|
||||
// new_child (not scope_builder): a scope would move the parent cursor back to the child rect.
|
||||
let mut child = ui.new_child(egui::UiBuilder::new().max_rect(field));
|
||||
let mut resp = {
|
||||
@@ -643,16 +656,26 @@ fn value_field_box(
|
||||
// Round to 4 decimal places, so repeated 0.1 steps don't leave float errors.
|
||||
let v = (v * 1e4).round() / 1e4;
|
||||
// `f32::clamp` panics on a reversed or NaN range, which `DragValue::range` accepts.
|
||||
*value = if lo <= hi { v.clamp(lo, hi) } else { v };
|
||||
// Only take focus back after a typed sum gave it up: re-requesting it while held resets
|
||||
// the field's arrow-key filter next frame, and a held arrow then moves focus away (#5474).
|
||||
if !ui.memory(|m| m.has_focus(resp.id)) {
|
||||
ui.memory_mut(|m| m.request_focus(resp.id));
|
||||
let v = if lo <= hi { v.clamp(lo, hi) } else { v };
|
||||
// A wild wheel delta must not leave infinity in the field.
|
||||
if v.is_finite() {
|
||||
*value = v;
|
||||
}
|
||||
// A wheel step over a field without focus leaves the focus where it is.
|
||||
if focused.is_some() {
|
||||
// Only take focus back after a typed sum gave it up: re-requesting it while held resets
|
||||
// the field's arrow-key filter next frame, and a held arrow then moves focus away (#5474).
|
||||
if !ui.memory(|m| m.has_focus(resp.id)) {
|
||||
ui.memory_mut(|m| m.request_focus(resp.id));
|
||||
}
|
||||
// The text stays selected, as in Photoshop: typing after a step replaces the value.
|
||||
crate::field_tab::select_all(ui.ctx(), resp.id, &if fine { fmt_num2(f64::from(*value)) } else { fmt_num(f64::from(*value)) });
|
||||
}
|
||||
// The text stays selected, as in Photoshop: typing after a step replaces the value.
|
||||
crate::field_tab::select_all(ui.ctx(), resp.id, &if fine { fmt_num2(f64::from(*value)) } else { fmt_num(f64::from(*value)) });
|
||||
resp.mark_changed();
|
||||
}
|
||||
if ui.memory(|m| m.has_focus(resp.id)) {
|
||||
crate::field_wheel::set_focused(ui.ctx(), resp.id, slot.id);
|
||||
}
|
||||
(resp, rect)
|
||||
}
|
||||
|
||||
@@ -989,11 +1012,6 @@ pub(crate) fn wheel_notches_of(ui: &Ui, id: egui::Id, hovered: bool, shift_notch
|
||||
if !hovered {
|
||||
return 0.0;
|
||||
}
|
||||
let acc_id = id.with("wheel-acc");
|
||||
let mut acc: f32 = ui.data(|d| d.get_temp(acc_id)).unwrap_or(0.0);
|
||||
let per_line = ui.ctx().options(|o| o.input_options.line_scroll_speed);
|
||||
let per_line = if per_line.is_finite() && per_line > 0.0 { per_line } else { 40.0 };
|
||||
let mut notches = 0.0;
|
||||
let wheel: Vec<(egui::MouseWheelUnit, Vec2, bool)> = ui.input(|i| {
|
||||
i.events
|
||||
.iter()
|
||||
@@ -1003,7 +1021,17 @@ pub(crate) fn wheel_notches_of(ui: &Ui, id: egui::Id, hovered: bool, shift_notch
|
||||
})
|
||||
.collect()
|
||||
});
|
||||
for (unit, delta, shift) in wheel {
|
||||
count_notches(ui, id.with("wheel-acc"), &wheel, shift_notches)
|
||||
}
|
||||
|
||||
/// Whole notches in `wheel` (unit, delta, Shift held), a notch with Shift counting
|
||||
/// `shift_notches`; fractions carry over in egui memory under `acc_id`.
|
||||
pub(crate) fn count_notches(ui: &Ui, acc_id: egui::Id, wheel: &[(egui::MouseWheelUnit, Vec2, bool)], shift_notches: f32) -> f32 {
|
||||
let mut acc: f32 = ui.data(|d| d.get_temp(acc_id)).unwrap_or(0.0);
|
||||
let per_line = ui.ctx().options(|o| o.input_options.line_scroll_speed);
|
||||
let per_line = if per_line.is_finite() && per_line > 0.0 { per_line } else { 40.0 };
|
||||
let mut notches = 0.0;
|
||||
for &(unit, delta, shift) in wheel {
|
||||
// Some systems turn Shift+wheel into a horizontal scroll.
|
||||
let d = if delta.y != 0.0 { delta.y } else { delta.x };
|
||||
acc += match unit {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# File-format parity
|
||||
|
||||
> **Last reviewed:** 2026-10-12 · **Last updated:** 2026-10-15 · **Change:** minor (Photoshop mixed-order TIFF type geometry, #4758; DDS textures save: uncompressed or BC1–BC3, optional mip chain, DDS Options in Save As (#1327); PSD smart filters: 45 filters (31 more: Blur, Surface Blur, Smart Sharpen, Diffuse, Wind, Offset, Mezzotint, Clouds, Difference Clouds, Fibers, Lens Flare and others) plus Hue/Saturation and Perspective Warp mapped both ways, #6296, #6298, #6300, #6302, #6304, #6314, #6316, #6267, #6268, FILE-215-2; large-file fixtures: a 20 MP layered PSD, a 150-layer layout, a 2 GB PSD and a 4.4 GB PSB generated at test time and round-tripped, FILE-216-2 done, #5107; earlier: PNG `sTER` stereo pairing kept on save, #6063; PDF write one flattened page via Save As / Save a Copy / CLI, #3401; CMYK Invert, Posterize and Threshold on the inks; smart filter masks on PSD open and save; Photoshop-oracle floor 188/258; lossy DNG, compression 34892, decodes with its levels and LinearizationTable applied to the stored 8-bit samples, FILE-215-11; CMYK Hue/Saturation and Color Balance keep the black ink; CMYK Posterize on the stored values, psd-tools oracle floor 242/309; CMYK adjustment layers composite on the document's inks; Photoshop-oracle floor 165/258; CMYK Brightness/Contrast on the inks, CMYK Threshold's luma; modern Brightness/Contrast's brightness curve; Photoshop-oracle floor 151/258; Lab documents composite on their stored L, a, b; Photoshop-oracle floor 152/258; Levels on whole levels at every step with Photoshop's shadow toe; Photoshop-oracle floor 146/258, psd-tools 238/309; 32-bit adjustments unclipped; Photoshop-oracle floor 149/258; mask feathers blur with their exact variance; Threshold splits on Photoshop's luminosity; a pass-through clipping base with an adjustment renders isolated; psd-tools oracle floor 240/309; 16-bit Posterize as Photoshop bins it; psd-tools oracle floor 241/309; Gradient Map luminosity; Photoshop-oracle floor 147/258; PSD: `Mt16`/`Mt32` merged transparency read; palette PNGs open in Indexed Color mode, #4804; earlier: CMYK Invert, Posterize and Threshold on the inks; 16-bit Lab Invert; Photoshop-oracle floor 145/258; `.atn` import maps 112 events; DDS textures open, #1327; DPX read and write, #1049; #2465 fixed: CS2 placed layers with only a `PlLd` block open their contents; Photoshop Actions `.atn` read and write; `.shc` contour files read and write; earlier the same day: indexed BMP palette mode; Save keeps a JPEG's quality and a WebP's encoding) · **Target:** Adobe Photoshop 2026
|
||||
> **Last reviewed:** 2026-10-12 · **Last updated:** 2026-10-17 · **Change:** minor (the Nikon D4 white level follows the sample depth (12 and 14 bit), #5978; Apply Layer Comp action mapping, #7101; earlier: earlier: PDF write one flattened page via Save As / Save a Copy / CLI, #3401; Photoshop mixed-order TIFF type geometry, #4758; DDS textures save: uncompressed or BC1–BC3, optional mip chain, DDS Options in Save As (#1327); PSD smart filters: 45 filters (31 more: Blur, Surface Blur, Smart Sharpen, Diffuse, Wind, Offset, Mezzotint, Clouds, Difference Clouds, Fibers, Lens Flare and others) plus Hue/Saturation and Perspective Warp mapped both ways, #6296, #6298, #6300, #6302, #6304, #6314, #6316, #6267, #6268, FILE-215-2; large-file fixtures: a 20 MP layered PSD, a 150-layer layout, a 2 GB PSD and a 4.4 GB PSB generated at test time and round-tripped, FILE-216-2 done, #5107; earlier: PNG `sTER` stereo pairing kept on save, #6063; PDF write one flattened page via Save As / Save a Copy / CLI, #3401; CMYK Invert, Posterize and Threshold on the inks; smart filter masks on PSD open and save; Photoshop-oracle floor 188/258; lossy DNG, compression 34892, decodes with its levels and LinearizationTable applied to the stored 8-bit samples, FILE-215-11; CMYK Hue/Saturation and Color Balance keep the black ink; CMYK Posterize on the stored values, psd-tools oracle floor 242/309; CMYK adjustment layers composite on the document's inks; Photoshop-oracle floor 165/258; CMYK Brightness/Contrast on the inks, CMYK Threshold's luma; modern Brightness/Contrast's brightness curve; Photoshop-oracle floor 151/258; Lab documents composite on their stored L, a, b; Photoshop-oracle floor 152/258; Levels on whole levels at every step with Photoshop's shadow toe; Photoshop-oracle floor 146/258, psd-tools 238/309; 32-bit adjustments unclipped; Photoshop-oracle floor 149/258; mask feathers blur with their exact variance; Threshold splits on Photoshop's luminosity; a pass-through clipping base with an adjustment renders isolated; psd-tools oracle floor 240/309; 16-bit Posterize as Photoshop bins it; psd-tools oracle floor 241/309; Gradient Map luminosity; Photoshop-oracle floor 147/258; PSD: `Mt16`/`Mt32` merged transparency read; palette PNGs open in Indexed Color mode, #4804; earlier: CMYK Invert, Posterize and Threshold on the inks; 16-bit Lab Invert; Photoshop-oracle floor 145/258; `.atn` import maps 112 events; DDS textures open, #1327; DPX read and write, #1049; #2465 fixed: CS2 placed layers with only a `PlLd` block open their contents; Photoshop Actions `.atn` read and write; `.shc` contour files read and write; earlier the same day: indexed BMP palette mode; Save keeps a JPEG's quality and a WebP's encoding) · **Target:** Adobe Photoshop 2026
|
||||
|
||||
Every format Photoshop 2026 (27.11.0) reads or writes, with PhotoCraft's support, fidelity and
|
||||
tests. Photoshop's list comes from its `Info.plist` `CFBundleDocumentTypes`, the PiPL read/write
|
||||
@@ -66,7 +66,7 @@ supports many more, including CR3).
|
||||
| DNG (incl. LJPEG, lossy JPEG and JPEG XL tiles) | yes | 2026-10-13: lossy DNG (DNG 1.4 compression 34892: 8-bit baseline JPEG tiles or strips, CFA and LinearRaw, partial edge tiles) decodes to the stored samples, which go through LinearizationTable / BlackLevel / WhiteLevel (default 255) like every other depth; `crates/raw/tests/dng.rs` `lossy_jpeg_*` (FILE-215-11, lossy DNG part; no lossy file in the raw corpus yet) |
|
||||
| Canon CR2 | yes | |
|
||||
| Canon CR3 | detected, unsupported | `crates/raw/src/lib.rs:219` |
|
||||
| Nikon NEF/NRW (lossless, lossy) | yes; "lossy after split" no | #50; D5100 and D90 image areas measured (14-bit NEFs); [validation](nikon-nef-development.md) |
|
||||
| Nikon NEF/NRW (lossless, lossy) | yes; "lossy after split" no | #50; D5100 and D90 image areas measured (14-bit NEFs); D4 profile levels follow the sample depth (12 and 14 bit); [validation](nikon-nef-development.md) |
|
||||
| Sony ARW/SR2/SRF (incl. compressed) | yes | |
|
||||
| Panasonic RW2, Pentax PEF | yes | |
|
||||
| Olympus ORF | uncompressed only | |
|
||||
@@ -131,7 +131,7 @@ remaining gaps in #1606 stay tracked with per-sample corpus ceilings.
|
||||
| LUTs `.cube` / `.3dl` / `.look` | R/W (Export Color Lookup) | R/W / R / R | `cms/src/lutfile.rs` |
|
||||
| Keyboard shortcuts `.kys` | R/W | R/W | `engine/src/kys.rs` (`write`: Edit › Keyboard Shortcuts › Export…, rows carry our id; Photoshop reading our files is unverified) |
|
||||
| ICC profiles | R | R | Own CMS |
|
||||
| Actions `.atn` | R/W | R/W | `psd/src/atn.rs` (version 16 sets, exact round trip), `engine/src/atn_cmds.rs` (112 Photoshop events ↔ commands; other steps kept verbatim). Panel menu, CLI `batch --actions set.atn`, `actions.load`/`actions.save`. Photoshop 5-era version 12 files unsupported (AUTO-219-2) |
|
||||
| Actions `.atn` | R/W | R/W | `psd/src/atn.rs` (version 16 sets, exact round trip), `engine/src/atn_cmds.rs` (Photoshop events ↔ commands, including Apply Layer Comp by name, #7101; other steps kept verbatim). Panel menu, CLI `batch --actions set.atn`, `actions.load`/`actions.save`. Photoshop 5-era version 12 files unsupported (AUTO-219-2) |
|
||||
| Styles `.asl` | R/W | no | #1693 |
|
||||
| Contours `.shc` | R/W | R/W | `psd/src/shc.rs`; Contour Editor Load…/Save… (FILE-215-15). No user contour library; not yet checked against a Photoshop-written file |
|
||||
| Custom shapes `.csh`, tool presets `.tpl` | R/W | no | |
|
||||
@@ -142,6 +142,7 @@ remaining gaps in #1606 stay tracked with per-sample corpus ceilings.
|
||||
|
||||
| Date | Change | Summary |
|
||||
|---|---|---|
|
||||
| 2026-10-17 | minor | `.atn`: Apply Layer Comp by name maps to `layerComp.apply` and exports as `applyComp` (#7101) |
|
||||
| 2026-10-15 | minor | PSD smart filters: Clouds, Difference Clouds, Fibers and Lens Flare open as editable filters with their seeds, colours and lens, and save like Photoshop (checked against a Photoshop 27 file); render filters on a smart object work within the object, so a flare sits where Photoshop puts it |
|
||||
| 2026-10-15 | minor | DDS textures save (#1327): uncompressed or BC1/BC2/BC3 (DXT1/3/5) from a clean-room block encoder, optional box-filtered mip chain, legacy header; DDS Options in Save As and Save a Copy, `ddsCompression`/`ddsMipmaps` for scripts, the CLI and MCP |
|
||||
| 2026-10-16 | minor | PSD smart filters: Perspective Warp (`perspectiveWarpTransform`: `vertices`, `warpedVertices`, `quads` of vertex indices, document pixels) opens as `layer.smartObjects.perspectiveWarp`, one plane per quad, and re-renders warped; save writes the original item with only the geometry rewritten, or a new one in Photoshop's layout; inconsistent descriptors stay verbatim (FILE-215-2, #6268) |
|
||||
@@ -158,6 +159,7 @@ remaining gaps in #1606 stay tracked with per-sample corpus ceilings.
|
||||
| 2026-10-15 | minor | PSD guides: image resource 1092 (guides v2) gives guides their own colours on import; 1092 and 1097 (guide GUIDs) are written back only while they still describe the document's guides, so an edit no longer leaves Photoshop a stale second guide list (#5966) |
|
||||
| 2026-10-15 | minor | Bevel & Emboss Gloss Contour › Anti-aliased (`antialiasGloss`) is read and written, set by `glossAntiAlias` and shown in the Layer Style dialog; a PSD whose bevel is edited no longer loses it. Rendering still ignores contour anti-aliasing, as for the other effects' contours |
|
||||
| 2026-10-15 | minor | Stroke › Overprint (`overprint`) is read and written, set by the stroke command's `overprint` and shown in the Layer Style dialog; an edited stroke no longer drops it. Rendering ignores it for now |
|
||||
| 2026-10-14 | minor | Nikon NEF: the D4 profile's saturation level follows the sample depth (15520 at 14 bits, 3880 at 12), so 12-bit D4 files open as bright as their 14-bit twins instead of 2.6 stops darker (#5978) |
|
||||
| 2026-10-14 | minor | PSD smart filter masks: Photoshop stores a smart object's filtered pixels without its filter mask and mixes the unfiltered ones (`FEid`) back in; import now mixes them and export writes them that way, so sf-filter-mask-hard, -gradient and sf-stack-blend-and-mask pass; Photoshop-oracle floor 185 → 188 of 258 |
|
||||
| 2026-10-13 | minor | Lossy DNG (compression 34892) decodes: 8-bit baseline JPEG tiles and strips, CFA and LinearRaw, partial edge tiles; the stored values take the normal levels and LinearizationTable (FILE-215-11, lossy DNG part) |
|
||||
| 2026-10-14 | minor | Corpus floors raised to the measured results of the CMYK, Lab, 32-bit, Levels, Threshold, Posterize, feather and pass-through fixes landed together: Photoshop-authored 165 → 185 of 258, io 146 → 148 of 170, psd-tools 242 → 249 of 309 |
|
||||
|
||||
+18
-1
@@ -1,6 +1,6 @@
|
||||
# Where PhotoCraft falls short of Photoshop
|
||||
|
||||
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-18 · **Change:** minor (G9: Preferences › File Handling › Save in Background takes effect, #6207, 24 of 169 preferences do nothing; G7: Content-Aware Move previews every selection the command takes, coarse then exact, TOOL-213-4 done, #6680; G4: Pattern Stamp and Background Eraser draw live, TOOL-213-7; G9: Animated Zoom pref read: holding the Zoom tool zooms continuously, #6210, prefs that do nothing 25 of 166; G2: a cancelled 24 MP Gaussian Blur job stops in at most 44 ms, P25 under its 200 ms budget in local runs, baseline not re-run, #6205; G1: generated large-file fixtures, a 4.38 GB PSB opens on Windows through io, FILE-216-2 done, #5107; G9: fill and adjustment layers copy and paste whole, #2344; G1: smart filter masks show on PSD open, Photoshop-oracle floor 188/258; G10: DPX read and write, #1049, Cineon read; G1: CMYK Hue/Saturation and Color Balance keep the black ink; G1: CMYK Posterize on the stored values, psd-tools oracle floor 242/309; G1: CMYK adjustment layers composite on the document's inks, Photoshop-oracle floor 165/258; G1: CMYK Brightness/Contrast on the inks, CMYK Threshold's luma; G1: modern Brightness/Contrast's brightness curve matches Photoshop, Photoshop-oracle floor 151/258; G1: Lab documents composite on their stored L, a, b, Photoshop-oracle floor 152/258; G1: Levels on whole levels at every step, Photoshop-oracle floor 146/258, psd-tools 238/309; G1: 32-bit Brightness/Contrast legacy, Channel Mixer, Photo Filter and Black & White tint unclipped as in Photoshop, Photoshop-oracle floor 149/258; G1: mask feathers blur with their exact variance, psd-tools oracle floor 240/309; G1: Threshold splits on Photoshop's luminosity, psd-tools oracle floor 241/309; G1: pass-through clipping base with an adjustment renders isolated, psd-tools oracle floor 240/309; G1: 16-bit Posterize as Photoshop bins it, psd-tools oracle floor 241/309; G1: Gradient Map driven by the W3C luminosity, Photoshop-oracle floor 147/258; G7: Field Blur's on-canvas pins, #3373; G4: Hue Jitter amount track, #3825 partial; G4: minimum field interaction, #3825 partial; G1: CMYK Invert, Posterize and Threshold on the inks, 16-bit Lab Invert; Photoshop-oracle floor 145/258; G11: `.atn` import maps 112 events: Select and Mask, Filter Gallery Spatter, Ripple, Crystallize, Pattern Fill layers, mask targeting, Step Backward, nudges in points, Bitmap mode; G5: Free Transform H/V skew fields; G9: toolbar tool shortcut editing; refreshed against main: G2, G5, G7, G9, G10, G13, G14, G17 items that landed; G10: DPX read and write, #1049; G4: checkbox-only Brush Settings rows; G11: Load/Save Actions `.atn` landed, AUTO-219-2 partial; G5: hold-a-key spring-loaded tools landed, #2672; G1: #2465 fixed; stale missing-tool rows corrected: Color Replacement, Red Eye and Add/Delete Anchor Point are live tools, so only Art History Brush is missing; no estimate changed) · **Target:** Adobe Photoshop 2026
|
||||
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-19 · **Change:** minor (G14: the Nikon D4 white level follows the sample depth, so 12-bit D4 NEFs no longer open 2.6 stops dark, #5978; G14: a Nikon NEF's Adobe RGB preview is read as Adobe RGB (maker-note ColorSpace 0x001E), #5987; Apply Layer Comp action mapping, #7101; G9: Preferences › File Handling › Save in Background takes effect, #6207, 24 of 169 preferences do nothing; G7: Content-Aware Move previews every selection the command takes, coarse then exact, TOOL-213-4 done, #6680; G4: Pattern Stamp and Background Eraser draw live, TOOL-213-7; G9: Animated Zoom pref read: holding the Zoom tool zooms continuously, #6210, prefs that do nothing 25 of 166; G2: a cancelled 24 MP Gaussian Blur job stops in at most 44 ms, P25 under its 200 ms budget in local runs, baseline not re-run, #6205; G1: generated large-file fixtures, a 4.38 GB PSB opens on Windows through io, FILE-216-2 done, #5107; G9: fill and adjustment layers copy and paste whole, #2344; G1: smart filter masks show on PSD open, Photoshop-oracle floor 188/258; G10: DPX read and write, #1049, Cineon read; G1: CMYK Hue/Saturation and Color Balance keep the black ink; G1: CMYK Posterize on the stored values, psd-tools oracle floor 242/309; G1: CMYK adjustment layers composite on the document's inks, Photoshop-oracle floor 165/258; G1: CMYK Brightness/Contrast on the inks, CMYK Threshold's luma; G1: modern Brightness/Contrast's brightness curve matches Photoshop, Photoshop-oracle floor 151/258; G1: Lab documents composite on their stored L, a, b, Photoshop-oracle floor 152/258; G1: Levels on whole levels at every step, Photoshop-oracle floor 146/258, psd-tools 238/309; G1: 32-bit Brightness/Contrast legacy, Channel Mixer, Photo Filter and Black & White tint unclipped as in Photoshop, Photoshop-oracle floor 149/258; G1: mask feathers blur with their exact variance, psd-tools oracle floor 240/309; G1: Threshold splits on Photoshop's luminosity, psd-tools oracle floor 241/309; G1: pass-through clipping base with an adjustment renders isolated, psd-tools oracle floor 240/309; G1: 16-bit Posterize as Photoshop bins it, psd-tools oracle floor 241/309; G1: Gradient Map driven by the W3C luminosity, Photoshop-oracle floor 147/258; G7: Field Blur's on-canvas pins, #3373; G4: Hue Jitter amount track, #3825 partial; G4: minimum field interaction, #3825 partial; G1: CMYK Invert, Posterize and Threshold on the inks, 16-bit Lab Invert; Photoshop-oracle floor 145/258; G11: `.atn` import maps 112 events: Select and Mask, Filter Gallery Spatter, Ripple, Crystallize, Pattern Fill layers, mask targeting, Step Backward, nudges in points, Bitmap mode; G5: Free Transform H/V skew fields; G9: toolbar tool shortcut editing; refreshed against main: G2, G5, G7, G9, G10, G13, G14, G17 items that landed; G10: DPX read and write, #1049; G4: checkbox-only Brush Settings rows; G11: Load/Save Actions `.atn` landed, AUTO-219-2 partial; G5: hold-a-key spring-loaded tools landed, #2672; G1: #2465 fixed; stale missing-tool rows corrected: Color Replacement, Red Eye and Add/Delete Anchor Point are live tools, so only Art History Brush is missing; no estimate changed) · **Target:** Adobe Photoshop 2026
|
||||
|
||||
Every known shortfall against Photoshop 2026 (27.11.0), one entry each, ranked by user impact
|
||||
on the way to beta. This is the work list agents pick from: take the highest-ranked entry that
|
||||
@@ -98,6 +98,10 @@ what an agent can't finish alone.
|
||||
- **Estimate:** 120–200 h.
|
||||
|
||||
### G11. Actions and scripting
|
||||
- **Done 2026-10-17 (#7101):** `.atn` Apply Layer Comp steps with a named `compsClass`
|
||||
reference import as `layerComp.apply` and export to the same Photoshop event. Names resolve
|
||||
in the document being played; missing comps stop playback. Other reference forms stay kept
|
||||
Photoshop steps and are reported as unsupported. AUTO-219-2 remains partial.
|
||||
- **2026-10-13 evidence:** Batch supports [output naming templates](batch-naming.md) using
|
||||
`{name}`, `{serial}` and a captured UTC `{date}`, with a starting serial number. Colliding
|
||||
names remain errors; custom output names cannot replace inputs. AUTO-219-5 stays partial.
|
||||
@@ -137,10 +141,20 @@ what an agent can't finish alone.
|
||||
tuning retains the fitted look and applies user gains afterwards. Three D5100 NEFs
|
||||
establish a guarded 4928 × 3264 image area. This is an estimated rendering, not a
|
||||
measured D5100 colour calibration; [validation](nikon-nef-development.md).
|
||||
- **Progress (2026-10-14):** a Nikon NEF's embedded preview takes its colour space from the
|
||||
maker note's ColorSpace (0x001E: 1 sRGB, 2 Adobe RGB) when the EXIF states none, so the
|
||||
colour fit reads an Adobe RGB preview as Adobe RGB (49 of the 291 public Nikon samples;
|
||||
Nikon writes no EXIF ColorSpace); `crates/raw/src/preview.rs`. A raw's preview-fallback
|
||||
document is still opened untagged.
|
||||
- **Progress (2026-10-13):** the D90's image area (4288 × 2848 at (10, 10) in a
|
||||
4352 × 2868 plane) is measured by aligning the decoded plane with the camera's own
|
||||
JPEG, so a D90 NEF opens on the camera's frame instead of the uncropped sensor plane;
|
||||
`crates/raw/src/cameras.rs` (`IMAGE_AREAS`).
|
||||
- **Progress (2026-10-14):** the measured Nikon D4 profile's saturation level follows the
|
||||
sample depth (15520 at 14 bits, 3880 at 12), so a 12-bit D4 NEF opens as bright as the same
|
||||
scene at 14 bits instead of 2.6 stops darker (#5978). Real CC0 pair, mean linear luminance
|
||||
against the 14-bit file: 12-bit lossy +0.02, uncompressed -0.02, lossless +0.01 stop;
|
||||
14-bit output unchanged (`cameras.rs`, `tests/nikon_d4_depth.rs`).
|
||||
- **Estimate:** 120–200 h.
|
||||
|
||||
### G15. AI and generative features
|
||||
@@ -292,11 +306,14 @@ what an agent can't finish alone.
|
||||
|---|---|---|
|
||||
| 2026-10-15 | minor | G1 / #5972 A1: render only provably constant-RGB `GdFl` noise fills; variable noise synthesis remains open |
|
||||
| 2026-10-18 | minor | G9: with no selection, Copy takes fill and adjustment layers whole and Paste recreates them (#2344); UI-217-23 stays partial (a single pixel layer copies its pixels only); estimate unchanged |
|
||||
| 2026-10-17 | minor | G11: `.atn` Apply Layer Comp imports, plays and exports by comp name (#7101); other reference forms remain unsupported |
|
||||
| 2026-10-15 | minor | G2: a cancelled 24 MP Gaussian Blur job stops within 44 ms max (P25, budget 200 ms; was about 400 ms; local runs, baseline not re-run), the uncancelled job on a locked-transparency layer about 40% faster; #6205 |
|
||||
| 2026-10-15 | minor | G9: Animated Zoom preference takes effect (hold the Zoom tool to zoom continuously, #6210); prefs that do nothing 25 of 166; no estimate changed |
|
||||
| 2026-10-16 | minor | G7: Content-Aware Move's live preview covers every selection the command takes (over 256 × 256: a coarse result solved scaled down, then the exact one); TOOL-213-4 done (#6680) |
|
||||
| 2026-10-15 | minor | G9: Save in Background off saves in the foreground under a modal progress dialog (#6207); preferences that do nothing 25 → 24 of 169 |
|
||||
| 2026-10-14 | minor | G14: the Nikon D4 profile's white level follows the sample depth, so 12-bit D4 NEFs no longer open 2.6 stops dark (#5978); gap remains open |
|
||||
| 2026-10-14 | minor | G1: a PSD smart object's filter mask shows when the file opens (Photoshop stores the filtered pixels unmasked); export stores them that way too; Photoshop-oracle floor 185 → 188 of 258 |
|
||||
| 2026-10-14 | minor | G14: a Nikon NEF's Adobe RGB preview is read as Adobe RGB (maker-note ColorSpace 0x001E); gap remains open |
|
||||
| 2026-10-13 | minor | G14: D90 image area measured (4288 × 2848 at (10, 10)); gap remains open |
|
||||
| 2026-10-14 | minor | Corpus floors raised to the measured results of the CMYK, Lab, 32-bit, Levels, Threshold, Posterize, feather and pass-through fixes landed together: Photoshop-authored 165 → 185 of 258, io 146 → 148 of 170, psd-tools 242 → 249 of 309 |
|
||||
| 2026-10-13 | minor | G1: generated large-file fixtures (20 MP, 150 layers, 2 GB PSD, 4.38 GB PSB) round-trip in io tests/large_files.rs; the 4.38 GB PSB opens on Windows through io (#375 evidence); FILE-216-2 done (#5107) |
|
||||
|
||||
+8
-1
@@ -1,6 +1,6 @@
|
||||
# UI parity: tools, handles, modifiers and feel
|
||||
|
||||
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-21 · **Change:** minor (Animated Zoom: holding the Zoom tool zooms continuously, #6210; shape Density and Feather, TOOL-214-12, #5846; Pen Auto Add/Delete on the path being drawn, #6140; Show Transform Controls frames every selected layer; guide keys and clicks; menu bar from the keyboard, #4988; Crop tool Content-Aware Fill; on-canvas corner radius widgets, TOOL-214-12; Curvature Pen edits the active path; Clip Thumbnails to Layer Bounds; Pen ⇧ 45°; last selected tool restored at launch; Layers panel filter-type dropdown with Kind, Name and Mode, #5048; Free Transform box and marching ants follow the selection, #5297; History: the trash deletes the selected snapshot, rows drag onto the trash, #5324; smart filter reordering by drag; smart object perspective row corrected to done, #426; Free Transform H/V skew fields; toolbar tool shortcuts can be reassigned; ⇧-dragged guides land on ruler ticks; layer and selection keys; tool keys; spring-loaded tool letters; type formatting keys; Pen Auto Add/Delete, #4144; smart filter rows; stale missing-tool rows corrected: Color Replacement, Red Eye and the Add/Delete Anchor Point pair are live toolbar tools, Frame landed; no percentage changed; selection-modifier and ⌥-wheel rows match their tests) · **Target:** Adobe Photoshop 2026
|
||||
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-21 · **Change:** minor (Hand tool ⌘ / ⌥ are Zoom In / Zoom Out while held, #6434; the wheel steps value fields, #5473; Animated Zoom: holding the Zoom tool zooms continuously, #6210; shape Density and Feather, TOOL-214-12, #5846; a dragged guide shows its X or Y beside the pointer, #7680; Pen Auto Add/Delete on the path being drawn, #6140; Show Transform Controls frames every selected layer; guide keys and clicks; menu bar from the keyboard, #4988; Crop tool Content-Aware Fill; on-canvas corner radius widgets, TOOL-214-12; Curvature Pen edits the active path; Clip Thumbnails to Layer Bounds; Pen ⇧ 45°; last selected tool restored at launch; Layers panel filter-type dropdown with Kind, Name and Mode, #5048; Free Transform box and marching ants follow the selection, #5297; History: the trash deletes the selected snapshot, rows drag onto the trash, #5324; smart filter reordering by drag; smart object perspective row corrected to done, #426; Free Transform H/V skew fields; toolbar tool shortcuts can be reassigned; ⇧-dragged guides land on ruler ticks; layer and selection keys; tool keys; spring-loaded tool letters; type formatting keys; Pen Auto Add/Delete, #4144; smart filter rows; stale missing-tool rows corrected: Color Replacement, Red Eye and the Add/Delete Anchor Point pair are live toolbar tools, Frame landed; no percentage changed; selection-modifier and ⌥-wheel rows match their tests) · **Target:** Adobe Photoshop 2026
|
||||
|
||||
How PhotoCraft's direct manipulation compares with Photoshop 2026 (27.11.0): the toolbox, the
|
||||
handles and modifier keys of each gesture, nudging, snapping, numeric precision, navigation,
|
||||
@@ -157,17 +157,21 @@ Triangle and Curvature Pen (minus legacy Rounded Rectangle and Targeted Adjustme
|
||||
| Smart guide distance and spacing labels | missing | |
|
||||
| Ruler units px/in/cm/mm/pt/pica/% | done | |
|
||||
| ⇧-drag a guide out of a ruler: it lands on the nearest ruler tick | done | `rulers.rs` `snap_to_tick` (#3770) |
|
||||
| A dragged guide shows its position beside the pointer (X for vertical, Y for horizontal, in the ruler unit) | done | `rulers.rs` `guide_drag_readout` (#7680) |
|
||||
| Status bar follows the ruler unit | partial | #2602 |
|
||||
| Ruler corner and gaps drawn as Photoshop | partial | #2600, #2601, #2551 |
|
||||
| Guides stored as f64 | missing | `Vec<f32>` (UI-217-20) |
|
||||
| Geometry precision | partial | `geom::Point` f64, paths f64; paint internals mostly f32 |
|
||||
| Numeric fields: arithmetic, scrubby labels | partial | units in expressions and double-click reset missing (UI-217-13) |
|
||||
| Wheel steps a value field, ⇧ ×10: clicked into, wherever the pointer is; not clicked, a gesture that starts over it | partial | `field_wheel.rs` (#5473, #4061). Photoshop: a field takes the wheel once clicked into (shortcut guides, user reports); whether the pointer must stay over it is unconfirmed. Stepping on hover alone is Photopea's, kept deliberately |
|
||||
|
||||
## Navigation
|
||||
|
||||
| Behaviour | Status | Evidence |
|
||||
|---|---|---|
|
||||
| Space = Hand, ⌘Space / ⌘⌥Space = zoom in/out, spring-loaded while held | done | `hold_keys.rs` |
|
||||
| Hand tool: ⌘ held = Zoom In, ⌥ (or ⌘⌥) held = Zoom Out; click steps, drag scrubs | done | `hold_keys.rs` `hand_zoom` (#6434); not during Free Transform or once a pan has started |
|
||||
| Hand tool: ⇧-drag / Scroll All Windows pans every open document; hold H for Bird's Eye View | missing | |
|
||||
| Hold any tool letter for a temporary tool | done | `spring_tools.rs`: held ≥ 300 ms or used on the canvas, release gives the previous tool back; ⇧ never springs (#2672) |
|
||||
| Scrubby zoom | done | `zoom_tool.rs` |
|
||||
| Flick panning | done | `flick_pan.rs` (Preferences › Tools › Enable Flick Panning) |
|
||||
@@ -228,6 +232,9 @@ Paragraph; the rest open as in-app floating windows.
|
||||
|
||||
| Date | Change | Summary |
|
||||
|---|---|---|
|
||||
| 2026-10-19 | minor | A guide being moved or dragged out of a ruler shows an `X:` / `Y:` position readout beside the pointer, from the zero point in the ruler unit (#7680) |
|
||||
| 2026-10-17 | minor | The wheel steps value fields: a focused field takes it wherever the pointer is (the canvas and panels don't scroll), an unfocused one only a gesture that starts over it (#5473, #4061); no percentage changed |
|
||||
| 2026-10-16 | minor | Hand tool ⌘ / ⌥ held are temporary Zoom In / Zoom Out (#6434); Scroll All Windows and Bird's Eye View rows added as missing |
|
||||
| 2026-10-15 | minor | Shape Density and Feather row added as done (TOOL-214-12, #5846) |
|
||||
| 2026-10-13 | minor | Menu bar from the keyboard: Alt / F10 focus, Alt+letter, underlined mnemonics (#4988) |
|
||||
| 2026-10-13 | minor | Layers panel filter row: Kind is a real dropdown with Kind, Name and Mode filters, drivable by `ui.set {layerFilter}` (#5048); row added as partial |
|
||||
|
||||
Reference in new issue
Block a user