From 74687f3cea8a4edfda5946404af107a8b00cb3cd Mon Sep 17 00:00:00 2001 From: tydude001 Date: Thu, 22 Oct 2026 16:49:46 -0500 Subject: [PATCH 01/81] Single instance: private lock file, the CPU relaunch takes part, no stale instance.json (#3755 review) The three follow-ups from the #3755 review, on current main (with the Flatpak socket transport, #7626): - instance.lock is created 0600 (and the settings folder 0700 when single-instance creates it), and a lock file an earlier version left 0644 is narrowed. Another local user who could open it could hold the lock, and every launch would wait out its hand-off time and start on its own. - The CPU-compatibility relaunch (--safe-gpu with PHOTOCRAFT_GPU_STARTUP_FAILURE) takes part in single-instance. The failed launch has already shut its instance down, so the relaunch becomes the primary, and files opened later land in its window. - shutdown removes instance.json if this process wrote it, before the lock is released, so a later launch never reads an endpoint that has since been freed. A second shutdown (the drop) leaves the next primary's file alone. a_launch_waiting_on_a_closing_instance_takes_over now reads the next primary's endpoint before dropping it, since the drop removes the file. Co-Authored-By: Claude Opus 5.5 --- apps/photocraft/src/main.rs | 4 ++ apps/photocraft/src/single_instance.rs | 64 ++++++++++++++++++-- apps/photocraft/src/single_instance/tests.rs | 51 +++++++++++++++- 3 files changed, 111 insertions(+), 8 deletions(-) diff --git a/apps/photocraft/src/main.rs b/apps/photocraft/src/main.rs index 41d2faedee8..062954a58c0 100644 --- a/apps/photocraft/src/main.rs +++ b/apps/photocraft/src/main.rs @@ -224,6 +224,10 @@ fn claim_single_instance( // launch that sets only `PHOTOCRAFT_PRESENT_MODE` (say) has per-process options too, so it // keeps its own process instead of handing its files over and being ignored. launch_options.extend_from_slice(&single_instance::env_launch_options()); + // The CPU-compatibility relaunch's `--safe-gpu` is not a person's: it takes part. + if !single_instance::safe_gpu_is_launch_option(std::env::var_os("PHOTOCRAFT_GPU_STARTUP_FAILURE").as_deref()) { + launch_options.retain(|option| *option != launch_args::PerProcess::SafeGpu); + } let context = single_instance::LaunchContext { per_user_settings: app_dirs::current().mode == app_dirs::Mode::Platform, new_instance_flag: new_instance, diff --git a/apps/photocraft/src/single_instance.rs b/apps/photocraft/src/single_instance.rs index 4d836adc907..76cb0359925 100644 --- a/apps/photocraft/src/single_instance.rs +++ b/apps/photocraft/src/single_instance.rs @@ -29,9 +29,7 @@ use std::io::{BufReader, Read, Write}; use std::net::{Ipv4Addr, SocketAddr, TcpListener, TcpStream}; #[cfg(unix)] use std::os::unix::net::{UnixListener, UnixStream}; -use std::path::Path; -#[cfg(unix)] -use std::path::PathBuf; +use std::path::{Path, PathBuf}; use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; use std::sync::mpsc::{SyncSender, sync_channel}; use std::sync::{Arc, Mutex, PoisonError}; @@ -181,6 +179,13 @@ fn env_launch_options_from(get: impl Fn(&str) -> Option) -> ENV_LAUNCH_OPTIONS.iter().filter(|(name, _, is_on)| get(name).is_some_and(|v| is_on(&v.to_string_lossy()))).map(|(_, option, _)| *option).collect() } +/// Whether `--safe-gpu` keeps a launch out of single-instance. It does when a person passes it, but +/// not for the CPU-compatibility relaunch (which sets `PHOTOCRAFT_GPU_STARTUP_FAILURE`): that one +/// takes the place of a launch that has already shut its instance down. +pub fn safe_gpu_is_launch_option(gpu_startup_failure: Option<&std::ffi::OsStr>) -> bool { + gpu_startup_failure.is_none() +} + /// Why this launch runs as its own instance, or `None` to take part in single-instance. pub fn skip_reason(c: &LaunchContext) -> Option { if !c.per_user_settings { @@ -210,6 +215,8 @@ pub struct Primary { /// then, so the second call (`Drop`) can't remove the socket the next primary has bound. #[cfg(unix)] socket: Mutex>, + /// Where `instance.json` is, removed on [`Primary::shutdown`]. + dir: PathBuf, } struct Shared { @@ -255,7 +262,13 @@ impl Primary { if let Some(path) = self.socket.lock().unwrap_or_else(PoisonError::into_inner).take() { let _ = std::fs::remove_file(path); } - drop(self.lock.lock().unwrap_or_else(PoisonError::into_inner).take()); + let mut lock = self.lock.lock().unwrap_or_else(PoisonError::into_inner); + if let Some(file) = lock.take() { + // Before the lock goes, so the file can only be ours: a later launch never reads an + // endpoint that has since been freed (or taken by another program). + remove_info(&self.dir); + drop(file); + } } } @@ -324,11 +337,11 @@ pub fn claim_with(dir: &Path, paths: &[String], timing: Timing) -> Launch { /// once a quitting or crashed primary is gone) and then the running primary, wherever /// `instance.json` says it listens. pub fn claim_in(dir: &Path, paths: &[String], timing: Timing, transport: &Transport) -> Launch { - if let Err(e) = std::fs::create_dir_all(dir) { + if let Err(e) = create_private_dir(dir) { return Launch::Standalone(format!("{}: {e}", dir.display())); } let lock_path = dir.join(LOCK_FILE); - let lock = match OpenOptions::new().read(true).write(true).create(true).truncate(false).open(&lock_path) { + let lock = match open_lock(&lock_path) { Ok(lock) => lock, Err(e) => return Launch::Standalone(format!("{}: {e}", lock_path.display())), }; @@ -407,9 +420,39 @@ fn serve(dir: &Path, lock: File, timing: Timing, transport: &Transport) -> Resul shared, #[cfg(unix)] socket: Mutex::new(socket), + dir: dir.to_path_buf(), }) } +/// The settings folder, the user's alone (0700) on Unix when this is the first to create it. +fn create_private_dir(dir: &Path) -> std::io::Result<()> { + let mut builder = std::fs::DirBuilder::new(); + builder.recursive(true); + #[cfg(unix)] + std::os::unix::fs::DirBuilderExt::mode(&mut builder, 0o700); + builder.create(dir) +} + +/// `instance.lock`, the user's alone (0600) on Unix: another local user who could open it could +/// hold the lock, and every launch would then wait out its hand-off time and start on its own. +fn open_lock(path: &Path) -> std::io::Result { + let mut options = OpenOptions::new(); + options.read(true).write(true).create(true).truncate(false); + #[cfg(unix)] + std::os::unix::fs::OpenOptionsExt::mode(&mut options, 0o600); + let lock = options.open(path)?; + // The mode applies only on create: narrow a lock file an earlier version left readable. + #[cfg(unix)] + { + use std::os::unix::fs::PermissionsExt; + let wide = lock.metadata().is_ok_and(|m| m.permissions().mode() & 0o077 != 0); + if wide && let Err(e) = lock.set_permissions(std::fs::Permissions::from_mode(0o600)) { + log::warn!("{}: couldn't make it private: {e}", path.display()); + } + } + Ok(lock) +} + /// The primary's listener on either transport. enum Listener { Tcp(TcpListener), @@ -574,6 +617,15 @@ fn write_info(dir: &Path, endpoint: &Endpoint, token: &str) -> Result<(), String }) } +/// Remove `instance.json` if this process wrote it. +fn remove_info(dir: &Path) { + let path = dir.join(INFO_FILE); + let pid = std::fs::read(&path).ok().and_then(|b| serde_json::from_slice::(&b).ok()).and_then(|v| v.get("pid")?.as_u64()); + if pid == Some(u64::from(std::process::id())) { + let _ = std::fs::remove_file(&path); + } +} + fn read_info(dir: &Path) -> Option<(Endpoint, String)> { let v: Value = serde_json::from_slice(&std::fs::read(dir.join(INFO_FILE)).ok()?).ok()?; let token = v.get("token")?.as_str()?.to_string(); diff --git a/apps/photocraft/src/single_instance/tests.rs b/apps/photocraft/src/single_instance/tests.rs index dc5755719fa..4ba1369459b 100644 --- a/apps/photocraft/src/single_instance/tests.rs +++ b/apps/photocraft/src/single_instance/tests.rs @@ -128,9 +128,10 @@ fn a_launch_waiting_on_a_closing_instance_takes_over() { let waiting = launch(&dir, &["a.psd"], FAST); std::thread::sleep(Duration::from_millis(200)); primary.shutdown(); - assert!(matches!(waiting.join().unwrap(), Launch::Primary(_)), "the waiting launch becomes the primary"); - // After shutdown new connections are refused too. + let Launch::Primary(next) = waiting.join().unwrap() else { panic!("the waiting launch becomes the primary") }; + // After shutdown new connections are refused too. (Read before the drop, which removes the file.) let (endpoint, token) = read_info(&dir).unwrap(); + drop(next); drop(primary); let short = Instant::now() + Duration::from_millis(300); assert!(send(&endpoint, &token, &["b.psd".into()], short).is_err()); @@ -222,6 +223,52 @@ fn the_token_file_is_private_to_the_user() { let _ = std::fs::remove_dir_all(&dir); } +/// Follow-up to #3755, point 1: another local user can't open the lock, so can't hold it. +#[cfg(unix)] +#[test] +fn the_lock_file_and_a_new_settings_folder_are_private_to_the_user() { + use std::os::unix::fs::PermissionsExt; + let mode = |p: &Path| std::fs::metadata(p).unwrap().permissions().mode() & 0o777; + let dir = temp_dir("lock-mode").join("photocraft"); + let first = primary(&dir); + assert_eq!((mode(&dir), mode(&dir.join(LOCK_FILE))), (0o700, 0o600)); + drop(first); + // A lock file an earlier version created 0644 is narrowed on the next start. + std::fs::set_permissions(dir.join(LOCK_FILE), std::fs::Permissions::from_mode(0o644)).unwrap(); + let second = primary(&dir); + assert_eq!(mode(&dir.join(LOCK_FILE)), 0o600); + drop(second); + let _ = std::fs::remove_dir_all(dir.parent().unwrap()); +} + +/// Follow-up to #3755, point 3: a primary that shuts down takes its `instance.json` with it, +/// and a second `shutdown` (the drop) leaves the next primary's alone. +#[test] +fn shutdown_removes_the_instance_file_but_not_the_next_ones() { + let dir = temp_dir("info-cleanup"); + let first = primary(&dir); + assert!(read_info(&dir).is_some()); + first.shutdown(); + assert!(read_info(&dir).is_none(), "no endpoint left behind for a later launch"); + let second = primary(&dir); + let port = port_of(&dir); + drop(first); + assert_eq!(port_of(&dir), port, "the running primary's file stays"); + drop(second); + assert!(read_info(&dir).is_none()); + let _ = std::fs::remove_dir_all(&dir); +} + +/// Follow-up to #3755, point 2: the CPU-compatibility relaunch takes part in single-instance; +/// `--safe-gpu` given by a person still gets its own process. +#[test] +fn the_cpu_relaunch_takes_part_in_single_instance() { + assert!(safe_gpu_is_launch_option(None)); + assert!(!safe_gpu_is_launch_option(Some(std::ffi::OsStr::new("wgpu: no adapter")))); + // The relaunch sets the reason even when it is empty. + assert!(!safe_gpu_is_launch_option(Some(std::ffi::OsStr::new("")))); +} + #[test] fn an_unreachable_instance_falls_back_to_a_standalone_launch() { let dir = temp_dir("unreachable"); From f4125c46c82c026e299de9935b13755e41a7a861 Mon Sep 17 00:00:00 2001 From: tydude001 Date: Fri, 6 Nov 2026 13:40:17 -0600 Subject: [PATCH 02/81] Single instance: test the CPU relaunch's --safe-gpu filtering through skip_reason (#6654 review) The retain that drops the relaunch's own --safe-gpu moves from claim_single_instance to single_instance::without_relaunch_safe_gpu, so a test can run the filtering claim_single_instance applies and hand its result to skip_reason: the relaunch with only --safe-gpu takes part, a person's --safe-gpu keeps its own process, and a relaunch with another option drops only its --safe-gpu. --- apps/photocraft/src/main.rs | 4 +-- apps/photocraft/src/single_instance.rs | 9 ++++++ apps/photocraft/src/single_instance/tests.rs | 30 ++++++++++++++++++++ 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/apps/photocraft/src/main.rs b/apps/photocraft/src/main.rs index 062954a58c0..251c89a1889 100644 --- a/apps/photocraft/src/main.rs +++ b/apps/photocraft/src/main.rs @@ -225,9 +225,7 @@ fn claim_single_instance( // keeps its own process instead of handing its files over and being ignored. launch_options.extend_from_slice(&single_instance::env_launch_options()); // The CPU-compatibility relaunch's `--safe-gpu` is not a person's: it takes part. - if !single_instance::safe_gpu_is_launch_option(std::env::var_os("PHOTOCRAFT_GPU_STARTUP_FAILURE").as_deref()) { - launch_options.retain(|option| *option != launch_args::PerProcess::SafeGpu); - } + let launch_options = single_instance::without_relaunch_safe_gpu(launch_options, std::env::var_os("PHOTOCRAFT_GPU_STARTUP_FAILURE").as_deref()); let context = single_instance::LaunchContext { per_user_settings: app_dirs::current().mode == app_dirs::Mode::Platform, new_instance_flag: new_instance, diff --git a/apps/photocraft/src/single_instance.rs b/apps/photocraft/src/single_instance.rs index 76cb0359925..782b234e2b3 100644 --- a/apps/photocraft/src/single_instance.rs +++ b/apps/photocraft/src/single_instance.rs @@ -186,6 +186,15 @@ pub fn safe_gpu_is_launch_option(gpu_startup_failure: Option<&std::ffi::OsStr>) gpu_startup_failure.is_none() } +/// `options` without the `--safe-gpu` the CPU-compatibility relaunch adds; a person's stays +/// ([`safe_gpu_is_launch_option`]). Every other option is kept. +pub fn without_relaunch_safe_gpu(mut options: Vec, gpu_startup_failure: Option<&std::ffi::OsStr>) -> Vec { + if !safe_gpu_is_launch_option(gpu_startup_failure) { + options.retain(|option| *option != PerProcess::SafeGpu); + } + options +} + /// Why this launch runs as its own instance, or `None` to take part in single-instance. pub fn skip_reason(c: &LaunchContext) -> Option { if !c.per_user_settings { diff --git a/apps/photocraft/src/single_instance/tests.rs b/apps/photocraft/src/single_instance/tests.rs index 4ba1369459b..f608233c5a0 100644 --- a/apps/photocraft/src/single_instance/tests.rs +++ b/apps/photocraft/src/single_instance/tests.rs @@ -269,6 +269,36 @@ fn the_cpu_relaunch_takes_part_in_single_instance() { assert!(!safe_gpu_is_launch_option(Some(std::ffi::OsStr::new("")))); } +/// The filtering `claim_single_instance` applies, through to `skip_reason`: the relaunch's own +/// `--safe-gpu` takes part, a person's stays separate, and the relaunch keeps any other option. +#[test] +fn the_cpu_relaunch_filter_decides_who_takes_part() { + let check = |options: &[PerProcess], failure: Option<&str>| { + let launch_options = without_relaunch_safe_gpu(options.to_vec(), failure.map(std::ffi::OsStr::new)); + let context = LaunchContext { + per_user_settings: true, + new_instance_flag: false, + new_instance_env: None, + control: false, + unreadable_paths: false, + launch_options: &launch_options, + }; + (launch_options.clone(), skip_reason(&context)) + }; + // The CPU relaunch with no other options takes part, whatever its reason says. + for failure in ["wgpu: no adapter", ""] { + assert_eq!(check(&[PerProcess::SafeGpu], Some(failure)), (vec![], None)); + } + // A person's `--safe-gpu` keeps its own process. + let (kept, reason) = check(&[PerProcess::SafeGpu], None); + assert_eq!(kept, [PerProcess::SafeGpu]); + assert!(reason.is_some()); + // The relaunch drops only its own `--safe-gpu`: another option still keeps it separate. + let (kept, reason) = check(&[PerProcess::SafeGpu, PerProcess::GpuAdapterEnv], Some("wgpu: no adapter")); + assert_eq!(kept, [PerProcess::GpuAdapterEnv]); + assert!(reason.is_some()); +} + #[test] fn an_unreachable_instance_falls_back_to_a_standalone_launch() { let dir = temp_dir("unreachable"); From 9882c84dca6ac7fccc9b69ac5ac65829fd80b95d Mon Sep 17 00:00:00 2001 From: Hector Villarreal Date: Fri, 23 Oct 2026 22:59:10 -0600 Subject: [PATCH 03/81] Pencil: a 1 px curve has no holes where it bends (#9003) The 1 px Pencil steps pixel by pixel along each pointer segment, starting from that segment's own columns (or rows). Where the stroke bent, the first step of a segment could land two cells from the last step of the one before, leaving a hole. The walker now fills in the cells between two steps that are not neighbours, so the stroke stays 8-connected as in Photoshop. Straight lines are unchanged. Co-Authored-By: Claude Opus 5.5 --- crates/paint/src/brush_tests.rs | 37 +++++++++++++++++++++++++++++++++ docs/brush-parity.md | 5 +++-- 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/crates/paint/src/brush_tests.rs b/crates/paint/src/brush_tests.rs index 268ca52b95b..a924603b75f 100644 --- a/crates/paint/src/brush_tests.rs +++ b/crates/paint/src/brush_tests.rs @@ -283,6 +283,43 @@ fn pencil_1px_freehand_line_never_breaks_where_it_turns() { assert_eq!(reached.len(), painted.len(), "the line breaks along {path:?}"); } } + +#[test] +fn pencil_1px_curve_has_no_holes() { + // #9003: a curve drawn with the 1 px Pencil broke where it bent. Each segment steps from its + // own column, so a pixel could be skipped between the end of one segment and the next. + let b = BrushSettings { aliased: true, hardness: 1.0, size: 1.0, ..brush() }; + let curves: [Vec; 3] = [ + (0..70).map(|i| StrokePoint::new(6.0 + 0.75 * f64::from(i), 24.0 + 13.0 * (f64::from(i) / 7.0).sin(), 1.0)).collect(), + (0..60).map(|i| StrokePoint::new(30.0 + 20.0 * (f64::from(i) / 9.5).cos(), 24.0 + 14.0 * (f64::from(i) / 9.5).sin(), 1.0)).collect(), + vec![ + StrokePoint::new(4.3, 30.6, 1.0), + StrokePoint::new(9.8, 8.2, 1.0), + StrokePoint::new(15.1, 30.9, 1.0), + StrokePoint::new(27.6, 12.4, 1.0), + StrokePoint::new(33.2, 31.7, 1.0), + ], + ]; + for (k, pts) in curves.iter().enumerate() { + let s = paint(&b, pts, 64, 48); + let painted: std::collections::BTreeSet<(i32, i32)> = + (0..48).flat_map(|y| (0..64).map(move |x| (x, y))).filter(|&(x, y)| s.rgba(x, y)[3] > 0.0).collect(); + let Some(&start) = painted.iter().next() else { panic!("curve {k}: nothing painted") }; + let mut seen = std::collections::BTreeSet::from([start]); + let mut todo = vec![start]; + while let Some((x, y)) = todo.pop() { + for (dx, dy) in [(-1, -1), (0, -1), (1, -1), (-1, 0), (1, 0), (-1, 1), (0, 1), (1, 1)] { + let q = (x + dx, y + dy); + if painted.contains(&q) && seen.insert(q) { + todo.push(q); + } + } + } + let holes: Vec<_> = painted.difference(&seen).collect(); + assert!(holes.is_empty(), "curve {k}: the stroke breaks before {holes:?}"); + } +} + // ---------- spacing ---------- #[test] diff --git a/docs/brush-parity.md b/docs/brush-parity.md index acd93b311ec..0a94baa4a08 100644 --- a/docs/brush-parity.md +++ b/docs/brush-parity.md @@ -1,6 +1,6 @@ # Brush and painting parity -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-07 · **Change:** minor (Angle/Roundness fields left of the Brush Tip Shape widget, labels right-aligned, #3825 partial; the eraser end of the pen switches to the Eraser on Windows with Windows Ink on, #2285; no estimate changed; Art History Brush Opacity on the options bar, #10263; no estimate changed; Shift+right-click menu for every painting tool: Edit Brush… and the tool's own Mode list; Brush Shift+right-click Mode picker and Escape dismissal; Art History Brush row added as partial, 8 of 10 styles, TOOL-213-20, #1610; hard-round built-in presets use 5% spacing to remove stacked-tip outlines and reduce pressure-opacity bands, #8842; Mode for Clone Stamp, Pattern Stamp, History Brush, Healing and Paint Bucket; named, stateful Brush Settings locks and visible keyboard focus; independent Brush Pose tilt-axis overrides; Transfer Wetness/Mix tool applicability; dragged preset tip preview; Hue Jitter amount track; Brush Settings minimum fields follow their Control; checkbox-only rows and non-destructive Smoothing switch; shaped-tip cursor follows the view; Color Replacement is a live toolbar tool; no brush-feel estimate changed; 2026-10-11: Pattern Stamp and Background Eraser draw live, TOOL-213-7) · **Target:** Adobe Photoshop 2026 +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-07 · **Change:** minor (1 px Pencil curves have no holes where they bend, #9003; Angle/Roundness fields left of the Brush Tip Shape widget, labels right-aligned, #3825 partial; the eraser end of the pen switches to the Eraser on Windows with Windows Ink on, #2285; no estimate changed; Art History Brush Opacity on the options bar, #10263; no estimate changed; Shift+right-click menu for every painting tool: Edit Brush… and the tool's own Mode list; Brush Shift+right-click Mode picker and Escape dismissal; Art History Brush row added as partial, 8 of 10 styles, TOOL-213-20, #1610; hard-round built-in presets use 5% spacing to remove stacked-tip outlines and reduce pressure-opacity bands, #8842; Mode for Clone Stamp, Pattern Stamp, History Brush, Healing and Paint Bucket; named, stateful Brush Settings locks and visible keyboard focus; independent Brush Pose tilt-axis overrides; Transfer Wetness/Mix tool applicability; dragged preset tip preview; Hue Jitter amount track; Brush Settings minimum fields follow their Control; checkbox-only rows and non-destructive Smoothing switch; shaped-tip cursor follows the view; Color Replacement is a live toolbar tool; no brush-feel estimate changed; 2026-10-11: Pattern Stamp and Background Eraser draw live, TOOL-213-7) · **Target:** Adobe Photoshop 2026 Painting is where Photoshop users notice differences first, so it gets its own checklist: the brush engine (`crates/paint/src/brush.rs`), the Brush Settings UI @@ -94,7 +94,7 @@ tablets against Photoshop side by side. | Tool | Status | Notes | |---|---|---| -| Brush, Pencil (aliased, Auto Erase), Eraser (Brush/Pencil/Block) | done | Pencil 1 px quality #2139 | +| Brush, Pencil (aliased, Auto Erase), Eraser (Brush/Pencil/Block) | done | Pencil 1 px quality #2139; unbroken curves #9003 | | Mixer Brush (Wet, Load, Mix, Flow, Sample All Layers, Current Brush Load with Load Brush and Clean Brush, automatic Load and Clean) | partial | No live result while dragging, no Alt-click loading (#2247) | | Clone Stamp (mode, opacity, flow, aligned, sample, overlay) | partial | Clone Source W/H link and Alt target cursor (TOOL-213-8) | | Pattern Stamp (mode, aligned, impressionist) | done | | @@ -124,6 +124,7 @@ tablets against Photoshop side by side. | 2026-11-06 | minor | Eraser end of the pen switches to the Eraser on Windows with Windows Ink on (#2285); row stays partial (X11, web); no estimate changed | | 2026-10-30 | minor | Art History Brush Opacity on the options bar, #10263; no estimate changed | | 2026-10-25 | minor | Art History Brush row added as partial (8 of 10 styles, TOOL-213-20, #1610). No brush-feel estimate changed. | +| 2026-10-23 | minor | A 1 px Pencil curve stays 8-connected where it bends: the cells skipped between two segments' pixel steps are filled in (#9003). No brush-feel estimate changed. | | 2026-10-23 | minor | Hard-round built-in presets use 5% spacing (#8842); rendered large-tip outline and pressure-opacity continuity tests cover 8/16/32-bit and 0/49% smoothing. Other presets and user settings retain their spacing; percentages and estimates unchanged. | | 2026-10-14 | minor | Brush Pose tilt overrides are independent end to end (#3825 partial); ABR flags, legacy JSON/commands, presets and three pixel depths covered; no readiness percentage or estimate changed | | 2026-10-13 | minor | Stale "missing tool" row corrected against main: Color Replacement (`paint.colorReplacement`) is a live toolbar tool; no brush-feel estimate changed | From 68f7e579ba48aa58900ce09fe5c8032744753b61 Mon Sep 17 00:00:00 2001 From: Hector Villarreal Date: Fri, 23 Oct 2026 23:22:52 -0600 Subject: [PATCH 04/81] Pencil: bridge only pixel steps, not speed or airbrush steps CodeRabbit finding on #9059 ("Bridge only pixel-grid steps"): the bend bridge ran on every step in pixel-grid mode, so a 1 px Pencil with Spacing off (speed spacing) or airbrush build-up gained dabs those modes leave out on purpose. Only grid_steps' steps are bridged now. New test: pixel_grid_bridges_only_its_own_steps (61 speed steps instead of 21, and 19 airbrush steps instead of 14, without the fix). Co-Authored-By: Claude Opus 5.5 --- crates/paint/src/dynamics.rs | 46 ++++++++++++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 4 deletions(-) diff --git a/crates/paint/src/dynamics.rs b/crates/paint/src/dynamics.rs index b3411b7a0bb..df44df903db 100644 --- a/crates/paint/src/dynamics.rs +++ b/crates/paint/src/dynamics.rs @@ -248,7 +248,8 @@ pub struct PathWalker { /// Pixel-grid stepping for small aliased tips: the dab-centre offset inside a pixel (see /// [`PathWalker::pixel_grid`]). grid: Option, - /// The grid cell of the last pixel-grid step, so the next segment joins it (#8040). + /// The grid cell of the last pixel-grid step, so the next segment joins it (#8040). Only pixel + /// steps set it: speed spacing and airbrush build-up leave their gaps on purpose. cell: Option<(f64, f64)>, } @@ -294,6 +295,7 @@ impl PathWalker { let (dm, dn) = (pm - am, pn - an); let n = (m1 - m0).abs(); if !(n.is_finite() && dn.is_finite()) || n > MAX_GRID_STEPS || dm == 0.0 { + self.cell = None; return false; } let dir = (m1 - m0).signum(); @@ -307,6 +309,7 @@ impl PathWalker { (q.x, q.y) = if steep { (cn, c) } else { (c, cn) }; self.bridge(&q, out); self.emit(q, out); + self.cell = Some((q.x, q.y)); } true } @@ -339,9 +342,6 @@ impl PathWalker { } fn emit(&mut self, point: StrokePoint, out: &mut impl FnMut(StepInput)) { - if let Some(g) = self.grid { - self.cell = Some((grid_cell(point.x, g), grid_cell(point.y, g))); - } let s = StepInput { point, direction: self.dir, initial_direction: self.initial_dir.unwrap_or(self.dir), step: self.step }; self.step += 1; out(s); @@ -363,6 +363,9 @@ impl PathWalker { } } if let Some(f) = self.pending_first.take() { + if let Some(g) = self.grid { + self.cell = Some((grid_cell(f.x, g), grid_cell(f.y, g))); + } self.emit(f, out); } if len > 1e-9 { @@ -1046,3 +1049,38 @@ mod streaming_tests { assert_eq!(dabs.len(), 2_000_001); } } + +#[cfg(test)] +mod grid_bridge_tests { + use super::*; + + fn walk(mut walker: PathWalker, pts: &[StrokePoint]) -> Vec { + let mut steps = Vec::new(); + let mut out = |s: StepInput| steps.push(s.point); + for p in pts { + walker.push(*p, &|_: &StrokePoint| 1.0, &mut out); + } + walker.finish(&mut out); + steps + } + + fn at(x: f64, y: f64, time: f64) -> StrokePoint { + StrokePoint { time, ..StrokePoint::new(x, y, 1.0) } + } + + /// #9059 review: only the pixel steps are bridged. Speed spacing (Spacing off) and airbrush + /// build-up leave out dabs on purpose, and pixel-grid mode must not put them back. + #[test] + fn pixel_grid_bridges_only_its_own_steps() { + // Fast enough that speed-spaced steps land 3 px apart. + let fast = [at(0.0, 0.0, 0.0), at(30.0, 0.0, 80.0), at(30.0, 30.0, 160.0)]; + let speed = walk(PathWalker::new(None).speed_spacing(SPEED_SPACING_MS), &fast); + let speed_grid = walk(PathWalker::new(None).speed_spacing(SPEED_SPACING_MS).pixel_grid(0.5), &fast); + assert_eq!(speed_grid.len(), speed.len(), "speed spacing keeps its gaps"); + // Three airbrush steps on top of the pixel steps, and nothing else. + let seg = [at(0.0, 0.0, 0.0), at(10.0, 0.0, 30.0)]; + let grid = walk(PathWalker::new(None).pixel_grid(0.5), &seg); + let airbrush = walk(PathWalker::new(Some(10.0)).pixel_grid(0.5), &seg); + assert_eq!(airbrush.len(), grid.len() + 3, "airbrush adds only its own steps"); + } +} From 9013edc514aa0c440d0258c34cb20214ec92775a Mon Sep 17 00:00:00 2001 From: Hector Villarreal Date: Fri, 23 Oct 2026 23:25:32 -0600 Subject: [PATCH 05/81] Pencil: a bridged cell blends its neighbours' pressure and time CodeRabbit finding on #9059 ("Interpolate the bridge step's dynamics"): a cell filled in at a bend copied the later step's pressure and time, so pressure dynamics jumped at the bend instead of running across it. The walker keeps its last pixel step and interpolates between the two. New test: a_bridged_cell_blends_its_neighbours_dynamics (the bridged cell repeats the next step's pressure 0.568 and time without the fix). Co-Authored-By: Claude Opus 5.5 --- crates/paint/src/dynamics.rs | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/crates/paint/src/dynamics.rs b/crates/paint/src/dynamics.rs index df44df903db..067c9e2c404 100644 --- a/crates/paint/src/dynamics.rs +++ b/crates/paint/src/dynamics.rs @@ -248,9 +248,9 @@ pub struct PathWalker { /// Pixel-grid stepping for small aliased tips: the dab-centre offset inside a pixel (see /// [`PathWalker::pixel_grid`]). grid: Option, - /// The grid cell of the last pixel-grid step, so the next segment joins it (#8040). Only pixel + /// The last pixel-grid step, on its grid cell, so the next segment joins it (#8040). Only pixel /// steps set it: speed spacing and airbrush build-up leave their gaps on purpose. - cell: Option<(f64, f64)>, + cell: Option, } impl PathWalker { @@ -309,7 +309,7 @@ impl PathWalker { (q.x, q.y) = if steep { (cn, c) } else { (c, cn) }; self.bridge(&q, out); self.emit(q, out); - self.cell = Some((q.x, q.y)); + self.cell = Some(q); } true } @@ -318,11 +318,14 @@ impl PathWalker { /// samples its own line, so where a freehand stroke turns, the last pixel of one segment and /// the first of the next can sit two pixels apart, and the 1 px Pencil line breaks (#8040). fn bridge(&mut self, q: &StrokePoint, out: &mut impl FnMut(StepInput)) { - let Some((mut x, mut y)) = self.cell else { return }; + let Some(last) = self.cell else { return }; + let (mut x, mut y) = (last.x, last.y); + let n = (q.x - x).abs().max((q.y - y).abs()).round(); // Only a turn's small gap: a step cut off by the walker's budget is not filled in. - if (q.x - x).abs().max((q.y - y).abs()) > MAX_BRIDGE { + if n > MAX_BRIDGE { return; } + let mut i = 0.0; while (q.x - x).abs() > 1.5 || (q.y - y).abs() > 1.5 { if (q.x - x).abs() > 0.5 { x += (q.x - x).signum(); @@ -330,7 +333,9 @@ impl PathWalker { if (q.y - y).abs() > 0.5 { y += (q.y - y).signum(); } - self.emit(StrokePoint { x, y, ..*q }, out); + // Pressure, tilt and time run on across the filled-in cells too. + i += 1.0; + self.emit(StrokePoint { x, y, ..lerp_pt(&last, q, i / n) }, out); } } @@ -364,7 +369,7 @@ impl PathWalker { } if let Some(f) = self.pending_first.take() { if let Some(g) = self.grid { - self.cell = Some((grid_cell(f.x, g), grid_cell(f.y, g))); + self.cell = Some(StrokePoint { x: grid_cell(f.x, g), y: grid_cell(f.y, g), ..f }); } self.emit(f, out); } @@ -1083,4 +1088,20 @@ mod grid_bridge_tests { let airbrush = walk(PathWalker::new(Some(10.0)).pixel_grid(0.5), &seg); assert_eq!(airbrush.len(), grid.len() + 3, "airbrush adds only its own steps"); } + + /// #9059 review: a cell filled in at a bend takes the pressure and time between its two + /// neighbours, not the later one's, so pressure dynamics change across it. + #[test] + fn a_bridged_cell_blends_its_neighbours_dynamics() { + // Shallow, then steep: the steep segment's first step lands two cells from the last one. + let bend = [(0.3, 0.6), (10.6, 3.0), (13.0, 14.0)]; + let pts: Vec<_> = bend.iter().enumerate().map(|(i, &(x, y))| StrokePoint { pressure: 0.5 * i as f32, ..at(x, y, 100.0 * i as f64) }).collect(); + let steps = walk(PathWalker::new(None).pixel_grid(0.5), &pts); + let cell = |p: &StrokePoint| (grid_cell(p.x, 0.5), grid_cell(p.y, 0.5)); + for w in steps.windows(2) { + let ((ax, ay), (bx, by)) = (cell(&w[0]), cell(&w[1])); + assert!((bx - ax).abs() <= 1.0 && (by - ay).abs() <= 1.0, "8-connected: {:?} then {:?}", w[0], w[1]); + assert!(w[1].time > w[0].time && w[1].pressure > w[0].pressure, "dynamics run on: {:?} then {:?}", w[0], w[1]); + } + } } From 9ff794f042fea3eddf60b23c11d8ece88df63278 Mon Sep 17 00:00:00 2001 From: Hector Villarreal Date: Fri, 23 Oct 2026 23:38:29 -0600 Subject: [PATCH 06/81] Pencil: a pixel segment after speed spacing doesn't step back CodeRabbit finding on #9059 ("Reset stale grid history before bridging after speed spacing"): with Spacing off, a speed-spaced segment left the last pixel cell from before it, so a following segment without a time interval bridged from there, stepping back and repeating a dab. A speed-spaced segment now clears the grid history. New test: a_pixel_segment_after_speed_spacing_does_not_step_back (steps go 0.5, 2.5, 1.5, 2.5, 3.5, 4.5 without the fix). Co-Authored-By: Claude Opus 5.5 --- crates/paint/src/dynamics.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/crates/paint/src/dynamics.rs b/crates/paint/src/dynamics.rs index 067c9e2c404..ab4ac6d989a 100644 --- a/crates/paint/src/dynamics.rs +++ b/crates/paint/src/dynamics.rs @@ -394,6 +394,8 @@ impl PathWalker { } } Some(iv) => { + // The stroke moves on without pixel steps: a later pixel segment starts afresh. + self.cell = None; self.speed_acc += dt; let max_n = (len / MIN_SPEED_STEP).ceil().max(1.0) as usize; let mut n = 0; @@ -1089,6 +1091,17 @@ mod grid_bridge_tests { assert_eq!(airbrush.len(), grid.len() + 3, "airbrush adds only its own steps"); } + /// #9059 review: a speed-spaced segment moves the stroke on without pixel steps, so a pixel + /// segment after it starts afresh instead of bridging from the cell before it. + #[test] + fn a_pixel_segment_after_speed_spacing_does_not_step_back() { + let pts = [at(0.5, 0.5, 0.0), at(2.5, 0.5, 8.0), at(4.5, 0.5, 8.0)]; + let steps = walk(PathWalker::new(None).speed_spacing(SPEED_SPACING_MS).pixel_grid(0.5), &pts); + let xs: Vec = steps.iter().map(|p| p.x).collect(); + assert!(xs.windows(2).all(|w| w[1] > w[0]), "forward only, each cell once: {xs:?}"); + assert!(steps.windows(2).all(|w| w[1].time >= w[0].time), "time runs on: {steps:?}"); + } + /// #9059 review: a cell filled in at a bend takes the pressure and time between its two /// neighbours, not the later one's, so pressure dynamics change across it. #[test] From a810dafb5cddcbe3e216f94b12c1580f35750a74 Mon Sep 17 00:00:00 2001 From: Hector Villarreal Date: Wed, 11 Nov 2026 08:30:24 -0600 Subject: [PATCH 07/81] #9059: a test per refinement that fails on main, after merging main (tanish2k09's review) Pixel-step-only bridging and "no step back after speed spacing" are one change (the bridge's cell comes from pixel steps only and is dropped by a speed-spaced move), so one test shows it: a_pixel_segment_after_speed_spacing_leaves_its_gap fails on main (a cell is filled in after the last speed step) and passes here. a_bridged_cell_blends_its_neighbours_dynamics fails on main (the filled-in cell takes the later point's pressure and time). The earlier pixel_grid_bridges_only_its_own_steps passes on main as well, so it is dropped. --- crates/paint/src/dynamics.rs | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/crates/paint/src/dynamics.rs b/crates/paint/src/dynamics.rs index 9dfe110157b..9b5df403aab 100644 --- a/crates/paint/src/dynamics.rs +++ b/crates/paint/src/dynamics.rs @@ -1111,30 +1111,18 @@ mod grid_bridge_tests { StrokePoint { time, ..StrokePoint::new(x, y, 1.0) } } - /// #9059 review: only the pixel steps are bridged. Speed spacing (Spacing off) and airbrush - /// build-up leave out dabs on purpose, and pixel-grid mode must not put them back. + /// #9059 review: the bridge joins pixel steps only. Speed spacing leaves its gaps on purpose + /// (Spacing off: faster movement spreads the dabs out), so a pixel segment after one starts + /// afresh instead of filling the gap back in from the cell before it. #[test] - fn pixel_grid_bridges_only_its_own_steps() { - // Fast enough that speed-spaced steps land 3 px apart. - let fast = [at(0.0, 0.0, 0.0), at(30.0, 0.0, 80.0), at(30.0, 30.0, 160.0)]; - let speed = walk(PathWalker::new(None).speed_spacing(SPEED_SPACING_MS), &fast); - let speed_grid = walk(PathWalker::new(None).speed_spacing(SPEED_SPACING_MS).pixel_grid(0.5), &fast); - assert_eq!(speed_grid.len(), speed.len(), "speed spacing keeps its gaps"); - // Three airbrush steps on top of the pixel steps, and nothing else. - let seg = [at(0.0, 0.0, 0.0), at(10.0, 0.0, 30.0)]; - let grid = walk(PathWalker::new(None).pixel_grid(0.5), &seg); - let airbrush = walk(PathWalker::new(Some(10.0)).pixel_grid(0.5), &seg); - assert_eq!(airbrush.len(), grid.len() + 3, "airbrush adds only its own steps"); - } - - /// #9059 review: a speed-spaced segment moves the stroke on without pixel steps, so a pixel - /// segment after it starts afresh instead of bridging from the cell before it. - #[test] - fn a_pixel_segment_after_speed_spacing_does_not_step_back() { - let pts = [at(0.5, 0.5, 0.0), at(2.5, 0.5, 8.0), at(4.5, 0.5, 8.0)]; + fn a_pixel_segment_after_speed_spacing_leaves_its_gap() { + // A fast 8 px move in 60 ms: speed steps about every 1.07 px, the last (at 7.97) half a pixel + // short of the move's end. The segment after it has no timestamps, so it takes pixel steps. + let pts = [at(0.5, 0.5, 0.0), at(8.5, 0.5, 60.0), at(12.5, 0.5, 60.0)]; let steps = walk(PathWalker::new(None).speed_spacing(SPEED_SPACING_MS).pixel_grid(0.5), &pts); let xs: Vec = steps.iter().map(|p| p.x).collect(); - assert!(xs.windows(2).all(|w| w[1] > w[0]), "forward only, each cell once: {xs:?}"); + assert!(xs.iter().all(|x| !(8.0..9.4).contains(x)), "no cell filled in after the last speed step: {xs:?}"); + assert!(xs.windows(2).all(|w| w[1] > w[0]), "forward only: {xs:?}"); assert!(steps.windows(2).all(|w| w[1].time >= w[0].time), "time runs on: {steps:?}"); } From 47e025f7dcff887c5a542ac4ebe5b732e2294cc8 Mon Sep 17 00:00:00 2001 From: RickiNano <81099017+RickiNano@users.noreply.github.com> Date: Mon, 23 Nov 2026 20:04:24 +0100 Subject: [PATCH 08/81] Color Settings: the Settings menu shows the setup names translated (#14229) The 13 setup names went to the menu as plain English. They now go through the translation system, with English as the key; the entry values, the stored `preset` and what OK sends stay the English names. --- .../src/dialogs/filter_dialog/color_settings_presets.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/dialogs/filter_dialog/color_settings_presets.rs b/crates/ui-egui/src/dialogs/filter_dialog/color_settings_presets.rs index c58fce05406..808b4e97747 100644 --- a/crates/ui-egui/src/dialogs/filter_dialog/color_settings_presets.rs +++ b/crates/ui-egui/src/dialogs/filter_dialog/color_settings_presets.rs @@ -42,7 +42,8 @@ pub(super) fn row(label: Label) -> Param { let name = label.clone(); Param::custom(KEY, label, move |ui, fields, _| { let mut entries = Vec::new(); - let named = COLOR_SETTINGS_PRESETS.iter().map(|n| (*n, *n)); + // The labels are translated; the values stay the English names scripts and saved settings use. + let named = COLOR_SETTINGS_PRESETS.iter().map(|n| (*n, tl!(*n))); for (value, label) in [(CUSTOM_SETTINGS, tl!("Custom")), (OTHER, tl!("Other"))].into_iter().chain(named) { if GROUP_STARTS.contains(&value) { entries.push(Entry::separator()); From c7d5a8d4835d4685127d575cb2b1d50b48f016de Mon Sep 17 00:00:00 2001 From: Sergey Yadryshnikov Date: Tue, 27 Oct 2026 16:57:28 +0700 Subject: [PATCH 09/81] fix(layers): Merge Down keeps the lower layer's layer style live Photoshop, observed with reproducible fixtures (PR #8750), keeps the lower layer's style live on the merged layer, where it re-composes over the union of both layers' content. pixels::merge_down replaced the lower layer with a fresh Layer::new, whose effects are empty, so a shadow or glow on the layer below was lost. Bake the pair without the lower layer's style (std::mem::take) and restore it on the merged layer, and render through a Document clone so the bake keeps the document's own Global Light, patterns and ICC profile. --- .../src/cmd/layer_multi_cmds/tests.rs | 74 +++++++++++++++++++ crates/engine-core/src/pixels.rs | 16 ++-- 2 files changed, 85 insertions(+), 5 deletions(-) diff --git a/crates/engine-core/src/cmd/layer_multi_cmds/tests.rs b/crates/engine-core/src/cmd/layer_multi_cmds/tests.rs index c690b0d0aeb..3c27b6eaa69 100644 --- a/crates/engine-core/src/cmd/layer_multi_cmds/tests.rs +++ b/crates/engine-core/src/cmd/layer_multi_cmds/tests.rs @@ -967,6 +967,80 @@ fn merging_keeps_layer_effects_outside_the_pixels() { } } +#[test] +fn merging_down_keeps_the_lower_layers_style_live_on_the_union() { + // Merge Down over a styled layer keeps its style live, as in Photoshop, where it + // re-composes over the merged pixels: the glow that only surrounded the lower layer now + // surrounds the union of both layers' content. + let probe = |s: &Session| { + let d = doc(s); + photocraft_compose::render(d, d.bounds()).get(75, 26) + }; + for depth in [8, 16, 32] { + let mut s = session(depth); + let lower = rect_layer(&mut s, Rect::new(10, 10, 30, 30)); + let upper = rect_layer(&mut s, Rect::new(60, 20, 72, 32)); + s.execute("layer.layerStyle.outerGlow", json!({"layer": lower.0, "blend": "normal", "size": 6, "color": "#000000", "add": true})).unwrap(); + let before = probe(&s); + assert!(before.iter().all(|v| *v > 0.9), "depth {depth}: the glow never reaches the probe before the merge: {before:?}"); + s.execute("layer.mergeDown", json!({"layer": upper.0})).unwrap(); + let merged = doc(&s).layer(lower).unwrap().clone(); + assert!(doc(&s).layer(upper).is_none()); + assert_eq!(merged.effects.items.len(), 1); + assert!(merged.effects.items.iter().all(photocraft_doc::Effect::enabled), "the style stays live on the merged layer"); + let after = probe(&s); + assert!( + after.iter().take(3).zip(&before).all(|(a, b)| *a < *b - 0.03), + "depth {depth}: the glow re-applies to the merged union: {before:?} -> {after:?}" + ); + } +} + +#[test] +fn merging_selected_layers_bakes_the_bottom_layers_style_to_pixels() { + // Observed in Photoshop (fixtures in PR #8750): ⌘E over a selection merges the selected + // layers preserving the visible composite — the bottommost layer's style is baked into + // the merged pixels and no longer carried as a live effect, so it keeps drawing only + // around its own shape and never wraps the upper layers' content. + for depth in [8, 16, 32] { + let mut s = session(depth); + let lower = rect_layer(&mut s, Rect::new(10, 10, 30, 30)); + let upper = rect_layer(&mut s, Rect::new(60, 20, 72, 32)); + s.execute("layer.layerStyle.outerGlow", json!({"layer": lower.0, "blend": "normal", "size": 6, "color": "#000000", "add": true})).unwrap(); + let before = photocraft_compose::render(doc(&s), doc(&s).bounds()); + select_all(&mut s, &[lower, upper]); + let m = LayerId(s.execute("layer.mergeLayers", json!({})).unwrap()["layer"].as_u64().unwrap()); + assert!(doc(&s).layer(m).unwrap().effects.items.is_empty(), "depth {depth}: Merge Layers drops the style"); + let after = photocraft_compose::render(doc(&s), doc(&s).bounds()); + let worst = before.px.iter().zip(&after.px).map(|(a, b)| a.iter().zip(b).map(|(x, y)| (x - y).abs()).fold(0.0f32, f32::max)).fold(0.0f32, f32::max); + assert!(worst <= 1.5 / 255.0, "depth {depth}: Merge Layers preserves the visible composite (off by {worst})"); + } +} + +#[test] +fn merging_down_inside_the_shaped_layer_is_a_pixel_match() { + // With the upper layer fully inside the lower one's shape, the union is the same shape, so + // a correct merge is a pixel-for-pixel match: the style is neither lost, nor applied + // twice, and Global Light follows the document instead of `Document::new` defaults. + for depth in [8, 16, 32] { + let mut s = session(depth); + let lower = rect_layer(&mut s, Rect::new(10, 10, 60, 60)); + let upper = rect_layer(&mut s, Rect::new(25, 25, 45, 45)); + s.edit("light", |doc, _| { + doc.global_light = photocraft_doc::GlobalLight { angle: 20.0, altitude: 40.0 }; + Ok(()) + }) + .unwrap(); + s.execute("layer.layerStyle.dropShadow", json!({"layer": lower.0, "blend": "normal", "useGlobalLight": true, "angle": 120, "distance": 5, "spread": 0, "size": 0, "opacity": 100, "color": "#000000"})).unwrap(); + let before = photocraft_compose::render(doc(&s), doc(&s).bounds()); + s.execute("layer.mergeDown", json!({"layer": upper.0})).unwrap(); + assert!(!doc(&s).layer(lower).unwrap().effects.items.is_empty()); + let after = photocraft_compose::render(doc(&s), doc(&s).bounds()); + let worst = before.px.iter().zip(&after.px).map(|(a, b)| a.iter().zip(b).map(|(x, y)| (x - y).abs()).fold(0.0f32, f32::max)).fold(0.0f32, f32::max); + assert!(worst <= 1.5 / 255.0, "depth {depth}: merge down changed the composite (off by {worst})"); + } +} + #[test] fn merging_a_group_down_preserves_the_composite() { for depth in [8, 16, 32] { diff --git a/crates/engine-core/src/pixels.rs b/crates/engine-core/src/pixels.rs index 0e5572d0d9d..d86b510d688 100644 --- a/crates/engine-core/src/pixels.rs +++ b/crates/engine-core/src/pixels.rs @@ -557,11 +557,14 @@ pub fn remap_surface(s: &Surface, map: impl Fn(i32, i32) -> (i32, i32)) -> Surfa /// Merge `upper` onto `lower` producing a raster layer (Layer → Merge Down). pub fn merge_down(doc: &Document, lower: &Layer, upper: &Layer) -> Layer { let format = doc.pixel_format(); - let stack = vec![lower.clone(), upper.clone()]; - let mut tmp = Document::new("merge", doc.size, format.mode, format.sample); - // The pair is read (and a CMYK one separated again) through the document's own profile. - tmp.icc_profile = doc.icc_profile.clone(); - tmp.layers = stack.into(); + // Photoshop keeps the lower layer's layer style live on the merged layer, where it + // re-applies to the merged pixels: bake the pair without it so it is not applied twice. + let mut bare_lower = lower.clone(); + let style = std::mem::take(&mut bare_lower.effects); + // The pair is rendered with the document's own Global Light, patterns and colour profile, + // and read (and a CMYK one separated again) through that profile. + let mut tmp = doc.clone(); + tmp.layers = vec![bare_lower, upper.clone()].into(); // A Background stays canvas-sized; any other layer keeps the pixels outside the canvas (#5067). let s = if doc.is_background(lower.id) { composite_layers(&tmp, format, None) } else { composite_layers_uncropped(&tmp, format) }; let mut merged = Layer::new(lower.name.clone(), LayerContent::Raster(s)); @@ -576,5 +579,8 @@ pub fn merge_down(doc: &Document, lower: &Layer, upper: &Layer) -> Layer { merged.clipped = lower.clipped && upper.clipped; merged.label = lower.label; merged.link_group = lower.link_group; + // The fill opacity and the masks are in the pixels now; the layer style is kept, live, and + // recomposes over the union of both layers' content. + merged.effects = style; merged } From ab052d12d92b2ff023fb42bcd71b4330e590eb9f Mon Sep 17 00:00:00 2001 From: Sergey Yadryshnikov Date: Tue, 27 Oct 2026 16:57:28 +0700 Subject: [PATCH 10/81] contributors: add yadser (Sergey Yadryshnikov) --- contributors/people.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/contributors/people.toml b/contributors/people.toml index e86ee8a01a1..7cc9c1efece 100644 --- a/contributors/people.toml +++ b/contributors/people.toml @@ -306,6 +306,9 @@ sync_github_name = false real_name = "Jason DeBoever" sync_github_name = true +[people.yadser] +real_name = "Sergey Yadryshnikov" + [people.dylanmtaylor] sync_github_name = true From 40987811397c0549a73399e52f9406e372edf310 Mon Sep 17 00:00:00 2001 From: Sergey Yadryshnikov Date: Tue, 27 Oct 2026 21:10:43 +0700 Subject: [PATCH 11/81] fix(layers): Merge Down drops a zero-fill layer's style with its fill Photoshop, observed with fixtures (thread in PR #8750), drops a zero-fill lower layer's whole contribution at Merge Down: the glow that outlined its invisible shape disappears with the fill and nothing re-appears on the union. Our merge_down kept the style live, so the glow re-planted around the merged union. Keep the style live only when the lower layer's fill opacity is non-zero, with a regression test at 8/16/32-bit. --- .../src/cmd/layer_multi_cmds/tests.rs | 30 +++++++++++++++++++ crates/engine-core/src/pixels.rs | 8 +++-- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/crates/engine-core/src/cmd/layer_multi_cmds/tests.rs b/crates/engine-core/src/cmd/layer_multi_cmds/tests.rs index 3c27b6eaa69..9131c02abea 100644 --- a/crates/engine-core/src/cmd/layer_multi_cmds/tests.rs +++ b/crates/engine-core/src/cmd/layer_multi_cmds/tests.rs @@ -1017,6 +1017,36 @@ fn merging_selected_layers_bakes_the_bottom_layers_style_to_pixels() { } } +#[test] +fn merging_down_drops_the_style_of_a_zero_fill_lower_layer() { + // Photoshop drops a zero-fill lower layer's whole contribution at Merge Down: the fill + // already shows nothing and the style goes with it, so the glow that outlined its shape + // before the merge is gone after it and nothing re-appears on the union (fixtures in + // PR #8750, a Fill-0% layer with Outer Glow and a disjoint upper layer). + let probe = |s: &Session| { + let d = doc(s); + photocraft_compose::render(d, d.bounds()).get(32, 20) + }; + for depth in [8, 16, 32] { + let mut s = session(depth); + let lower = rect_layer(&mut s, Rect::new(10, 10, 30, 30)); + let upper = rect_layer(&mut s, Rect::new(60, 20, 72, 32)); + s.execute("layer.layerStyle.outerGlow", json!({"layer": lower.0, "blend": "normal", "size": 6, "color": "#000000", "add": true})).unwrap(); + s.edit("zero fill", |doc, _| { + doc.layer_mut(lower).unwrap().fill_opacity = 0.0; + Ok(()) + }) + .unwrap(); + let before = probe(&s); + assert!(before.iter().take(3).all(|v| *v < 0.97), "depth {depth}: the glow outlines the invisible shape before the merge: {before:?}"); + s.execute("layer.mergeDown", json!({"layer": upper.0})).unwrap(); + let merged = doc(&s).layer(lower).unwrap().clone(); + assert!(merged.effects.items.is_empty(), "depth {depth}: the zero-fill style is dropped with the fill"); + let after = probe(&s); + assert!(after.iter().take(3).zip(&before).all(|(a, b)| *a > *b + 0.03), "depth {depth}: the glow went with the zero fill: {before:?} -> {after:?}"); + } +} + #[test] fn merging_down_inside_the_shaped_layer_is_a_pixel_match() { // With the upper layer fully inside the lower one's shape, the union is the same shape, so diff --git a/crates/engine-core/src/pixels.rs b/crates/engine-core/src/pixels.rs index d86b510d688..8c1aac39464 100644 --- a/crates/engine-core/src/pixels.rs +++ b/crates/engine-core/src/pixels.rs @@ -580,7 +580,11 @@ pub fn merge_down(doc: &Document, lower: &Layer, upper: &Layer) -> Layer { merged.label = lower.label; merged.link_group = lower.link_group; // The fill opacity and the masks are in the pixels now; the layer style is kept, live, and - // recomposes over the union of both layers' content. - merged.effects = style; + // recomposes over the union of both layers' content. A zero-fill lower layer is the one + // exception: Photoshop drops its whole contribution at Merge Down — the fill shows nothing + // and the style goes with it, so nothing re-appears on the union (fixtures in the PR). + if lower.fill_opacity != 0.0 { + merged.effects = style; + } merged } From 7421674b1b173eeee925f0ab05ada6b846cf78ee Mon Sep 17 00:00:00 2001 From: Sergey Yadryshnikov Date: Tue, 27 Oct 2026 22:01:01 +0700 Subject: [PATCH 12/81] Revert "fix(layers): Merge Down drops a zero-fill layer's style with its fill" This reverts commit cb2c8951bb485742a1c49727c2c51df24d779034. --- .../src/cmd/layer_multi_cmds/tests.rs | 30 ------------------- crates/engine-core/src/pixels.rs | 8 ++--- 2 files changed, 2 insertions(+), 36 deletions(-) diff --git a/crates/engine-core/src/cmd/layer_multi_cmds/tests.rs b/crates/engine-core/src/cmd/layer_multi_cmds/tests.rs index 9131c02abea..3c27b6eaa69 100644 --- a/crates/engine-core/src/cmd/layer_multi_cmds/tests.rs +++ b/crates/engine-core/src/cmd/layer_multi_cmds/tests.rs @@ -1017,36 +1017,6 @@ fn merging_selected_layers_bakes_the_bottom_layers_style_to_pixels() { } } -#[test] -fn merging_down_drops_the_style_of_a_zero_fill_lower_layer() { - // Photoshop drops a zero-fill lower layer's whole contribution at Merge Down: the fill - // already shows nothing and the style goes with it, so the glow that outlined its shape - // before the merge is gone after it and nothing re-appears on the union (fixtures in - // PR #8750, a Fill-0% layer with Outer Glow and a disjoint upper layer). - let probe = |s: &Session| { - let d = doc(s); - photocraft_compose::render(d, d.bounds()).get(32, 20) - }; - for depth in [8, 16, 32] { - let mut s = session(depth); - let lower = rect_layer(&mut s, Rect::new(10, 10, 30, 30)); - let upper = rect_layer(&mut s, Rect::new(60, 20, 72, 32)); - s.execute("layer.layerStyle.outerGlow", json!({"layer": lower.0, "blend": "normal", "size": 6, "color": "#000000", "add": true})).unwrap(); - s.edit("zero fill", |doc, _| { - doc.layer_mut(lower).unwrap().fill_opacity = 0.0; - Ok(()) - }) - .unwrap(); - let before = probe(&s); - assert!(before.iter().take(3).all(|v| *v < 0.97), "depth {depth}: the glow outlines the invisible shape before the merge: {before:?}"); - s.execute("layer.mergeDown", json!({"layer": upper.0})).unwrap(); - let merged = doc(&s).layer(lower).unwrap().clone(); - assert!(merged.effects.items.is_empty(), "depth {depth}: the zero-fill style is dropped with the fill"); - let after = probe(&s); - assert!(after.iter().take(3).zip(&before).all(|(a, b)| *a > *b + 0.03), "depth {depth}: the glow went with the zero fill: {before:?} -> {after:?}"); - } -} - #[test] fn merging_down_inside_the_shaped_layer_is_a_pixel_match() { // With the upper layer fully inside the lower one's shape, the union is the same shape, so diff --git a/crates/engine-core/src/pixels.rs b/crates/engine-core/src/pixels.rs index 8c1aac39464..d86b510d688 100644 --- a/crates/engine-core/src/pixels.rs +++ b/crates/engine-core/src/pixels.rs @@ -580,11 +580,7 @@ pub fn merge_down(doc: &Document, lower: &Layer, upper: &Layer) -> Layer { merged.label = lower.label; merged.link_group = lower.link_group; // The fill opacity and the masks are in the pixels now; the layer style is kept, live, and - // recomposes over the union of both layers' content. A zero-fill lower layer is the one - // exception: Photoshop drops its whole contribution at Merge Down — the fill shows nothing - // and the style goes with it, so nothing re-appears on the union (fixtures in the PR). - if lower.fill_opacity != 0.0 { - merged.effects = style; - } + // recomposes over the union of both layers' content. + merged.effects = style; merged } From 6d340d67c0ed28123d2e614830607052060c86d2 Mon Sep 17 00:00:00 2001 From: Sergey Yadryshnikov Date: Tue, 27 Oct 2026 22:33:59 +0700 Subject: [PATCH 13/81] fix(layers): Merge Down inherits the lower layer's fill opacity MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Photoshop, observed with fixtures (thread in PR #8750), inherits the lower layer's fill opacity onto the merged layer instead of resetting the property: a Fill-0% lower layer merges keeping the union ink in the pixels but invisible, with only its live style — re-rendered around the union — showing. PhotoCraft reset the property to opaque, so the merged raster showed its ink with the glow around the wrong shape. At fill 1.0 inheritance is a no-op, and the existing pixel-match tests cover that path; a new regression test asserts the inherited property, the hidden union ink and the relocated glow at 8/16/32-bit. --- .../src/cmd/layer_multi_cmds/tests.rs | 39 +++++++++++++++++++ crates/engine-core/src/pixels.rs | 4 ++ 2 files changed, 43 insertions(+) diff --git a/crates/engine-core/src/cmd/layer_multi_cmds/tests.rs b/crates/engine-core/src/cmd/layer_multi_cmds/tests.rs index 3c27b6eaa69..5e4b653a871 100644 --- a/crates/engine-core/src/cmd/layer_multi_cmds/tests.rs +++ b/crates/engine-core/src/cmd/layer_multi_cmds/tests.rs @@ -996,6 +996,45 @@ fn merging_down_keeps_the_lower_layers_style_live_on_the_union() { } } +#[test] +fn merging_down_inherits_the_lower_layers_fill_opacity() { + // Photoshop inherits the fill onto the merged layer (fixtures in PR #8750): merging onto a + // Fill-0% lower layer keeps the union ink in the pixels but invisible, and only the live + // style — re-rendered around the union — shows. The property is not reset to opaque. + let ink = |s: &Session| { + let d = doc(s); + photocraft_compose::render(d, d.bounds()).get(66, 26) + }; + let glow = |s: &Session| { + let d = doc(s); + photocraft_compose::render(d, d.bounds()).get(75, 26) + }; + for depth in [8, 16, 32] { + let mut s = session(depth); + let lower = rect_layer(&mut s, Rect::new(10, 10, 30, 30)); + let upper = rect_layer(&mut s, Rect::new(60, 20, 72, 32)); + s.execute("layer.layerStyle.outerGlow", json!({"layer": lower.0, "blend": "normal", "size": 6, "color": "#000000", "add": true})).unwrap(); + s.edit("zero fill", |doc, _| { + doc.layer_mut(lower).unwrap().fill_opacity = 0.0; + Ok(()) + }) + .unwrap(); + let before_ink = ink(&s); + let before_glow = glow(&s); + s.execute("layer.mergeDown", json!({"layer": upper.0})).unwrap(); + let merged = doc(&s).layer(lower).unwrap().clone(); + assert_eq!(merged.fill_opacity, 0.0, "depth {depth}: the fill inherits onto the merged layer"); + assert_eq!(merged.effects.items.len(), 1, "depth {depth}: the style stays live"); + let after_ink = ink(&s); + assert!(after_ink.iter().take(3).all(|v| *v > 0.9), "depth {depth}: the inherited zero fill hides the union ink: {before_ink:?} -> {after_ink:?}"); + let after_glow = glow(&s); + assert!( + after_glow.iter().take(3).zip(&before_glow).all(|(a, b)| *a < *b - 0.03), + "depth {depth}: the glow re-renders around the invisible union: {before_glow:?} -> {after_glow:?}" + ); + } +} + #[test] fn merging_selected_layers_bakes_the_bottom_layers_style_to_pixels() { // Observed in Photoshop (fixtures in PR #8750): ⌘E over a selection merges the selected diff --git a/crates/engine-core/src/pixels.rs b/crates/engine-core/src/pixels.rs index d86b510d688..878da574d22 100644 --- a/crates/engine-core/src/pixels.rs +++ b/crates/engine-core/src/pixels.rs @@ -571,6 +571,10 @@ pub fn merge_down(doc: &Document, lower: &Layer, upper: &Layer) -> Layer { merged.id = lower.id; merged.blend = lower.blend; merged.opacity = 1.0; + // And the fill: Photoshop inherits the lower layer's fill opacity onto the merged layer, + // so a zero-fill layer keeps its ink in the pixels but invisible, with only its style + // visible — instead of resetting the property (observed in the PR fixtures). + merged.fill_opacity = lower.fill_opacity; // Merge Down replaces the lower layer, so keep its editing restrictions. // In particular, a merged Background must remain opaque and position-locked. merged.locks = lower.locks; From 4575d6e1729e4aad188f568302fccba037370820 Mon Sep 17 00:00:00 2001 From: Sergey Yadryshnikov Date: Wed, 18 Nov 2026 21:23:48 +0700 Subject: [PATCH 14/81] test(layers): cover Merge Down fill inheritance at 0, 50 and 100% Photoshop, observed with fixtures (thread in PR #8750), holds one opaque circle and one painted at 50% brush opacity per layer. At Fill 50% the merge bakes the lower circles with the fill already applied, then the inherited fill applies again, so they land on a quarter and an eighth while the upper circles stay at half and a quarter. At Fill 0% the lower ink is empty before the bake and nothing is left in the composite; at Fill 100% the merge changes nothing visible. Painted alpha, not just the layer fill, is what the previous zero-fill test could not see: it probed only the upper shape. The test also checks undo restores both layers, the fill and the composite, at 8/16/32-bit. --- .../src/cmd/layer_multi_cmds/tests.rs | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/crates/engine-core/src/cmd/layer_multi_cmds/tests.rs b/crates/engine-core/src/cmd/layer_multi_cmds/tests.rs index 5e4b653a871..334698b5409 100644 --- a/crates/engine-core/src/cmd/layer_multi_cmds/tests.rs +++ b/crates/engine-core/src/cmd/layer_multi_cmds/tests.rs @@ -1035,6 +1035,69 @@ fn merging_down_inherits_the_lower_layers_fill_opacity() { } } +#[test] +fn merging_down_applies_the_inherited_fill_to_the_baked_ink() { + // Observed in Photoshop (fixtures in PR #8750: each layer holds one opaque circle and one + // painted at 50% brush opacity). Merge Down bakes the visible pixels — with the lower + // layer's Fill already applied — onto the merged layer, and the merged layer inherits that + // same Fill, so the lower content is attenuated twice: at Fill 50% the opaque circle lands + // on a quarter (0.5 × 0.5) and the half-transparent one on an eighth, while the upper + // circles stay at half and a quarter. At Fill 0% the lower ink is already empty when baked + // and the rest leaves the composite through the inherited fill — as in the fixtures, where + // the lower shape and its glow vanish; at Fill 100% the merge changes nothing visible. + let alpha_at = |s: &Session, x: i32, y: i32| { + let d = doc(s); + photocraft_compose::render(d, d.bounds()).get(x, y)[3] + }; + let alphas = |s: &Session| [alpha_at(s, 30, 30), alpha_at(s, 30, 80), alpha_at(s, 130, 30), alpha_at(s, 130, 80)]; + let close = |got: &[f32; 4], want: [f32; 4]| got.iter().zip(&want).all(|(g, w)| (g - w).abs() < 0.01); + let (all, top_only) = (Rect::new(10, 10, 150, 100), Rect::new(110, 10, 150, 100)); + // (Fill, alpha of [lower opaque, lower half, upper opaque, upper half] after the merge, + // the ink baked into the merged layer) + let cases = [(1.0f32, [1.0, 0.5, 1.0, 0.5], all), (0.5, [0.25, 0.125, 0.5, 0.25], all), (0.0, [0.0; 4], top_only)]; + for (fill, after, baked) in cases { + for depth in [8, 16, 32] { + let mut s = Session::new(); + s.execute("file.new", json!({"width": 160, "height": 120, "depth": depth, "background": "transparent"})).unwrap(); + let lower = rect_layer(&mut s, Rect::new(10, 10, 50, 50)); + let upper = rect_layer(&mut s, Rect::new(110, 10, 150, 50)); + let half = |s: &mut Session, id: LayerId, r: Rect| { + s.edit("half", |doc, _| { + doc.layer_mut(id).unwrap().surface_mut().unwrap().fill_rect(r, &[0.0, 0.0, 1.0, 0.5]); + Ok(()) + }) + .unwrap(); + }; + half(&mut s, lower, Rect::new(10, 60, 50, 100)); + half(&mut s, upper, Rect::new(110, 60, 150, 100)); + s.edit("fill", |doc, _| { + doc.layer_mut(lower).unwrap().fill_opacity = fill; + Ok(()) + }) + .unwrap(); + let before = alphas(&s); + assert!( + close(&before, [fill, fill * 0.5, 1.0, 0.5]), + "depth {depth}, fill {fill}: the lower layer's own fill attenuates it once before the merge: {before:?}" + ); + let layers_before = doc(&s).layer_count(); + s.execute("layer.mergeDown", json!({"layer": upper.0})).unwrap(); + let merged = doc(&s).layer(lower).unwrap().clone(); + assert!(doc(&s).layer(upper).is_none(), "depth {depth}, fill {fill}: the upper layer merged down"); + assert_eq!(doc(&s).layer_count(), layers_before - 1, "depth {depth}, fill {fill}: the merge took one layer"); + assert_eq!(merged.fill_opacity, fill, "depth {depth}, fill {fill}: the fill inherits onto the merged layer"); + assert_eq!(layer_bounds(&merged).unwrap(), baked, "depth {depth}, fill {fill}: the merge bakes the visible pixels of both layers"); + let got = alphas(&s); + assert!(close(&got, after), "depth {depth}, fill {fill}: the inherited fill applies to the baked ink again: {got:?}, want {after:?}"); + s.undo(); + assert_eq!(doc(&s).layer_count(), layers_before, "depth {depth}, fill {fill}: undo brings both layers back"); + assert!(doc(&s).layer(upper).is_some(), "depth {depth}, fill {fill}: undo restores the upper layer"); + assert_eq!(doc(&s).layer(lower).unwrap().fill_opacity, fill, "depth {depth}, fill {fill}: undo restores the fill"); + assert!(close(&alphas(&s), before), "depth {depth}, fill {fill}: undo restores the composite"); + } + } +} + #[test] fn merging_selected_layers_bakes_the_bottom_layers_style_to_pixels() { // Observed in Photoshop (fixtures in PR #8750): ⌘E over a selection merges the selected From a94251b616ede3523a07b30351db541016d3e15a Mon Sep 17 00:00:00 2001 From: Dan Date: Tue, 24 Nov 2026 13:56:11 +0000 Subject: [PATCH 15/81] Refresh Filter Gallery thumbnails for each open layer --- crates/ui-egui/src/dialogs/gallery_ui.rs | 25 ++++++-- .../ui-egui/src/dialogs/gallery_ui/tests.rs | 64 +++++++++++++++++++ 2 files changed, 83 insertions(+), 6 deletions(-) diff --git a/crates/ui-egui/src/dialogs/gallery_ui.rs b/crates/ui-egui/src/dialogs/gallery_ui.rs index 79de658bc8e..e7be29e6409 100644 --- a/crates/ui-egui/src/dialogs/gallery_ui.rs +++ b/crates/ui-egui/src/dialogs/gallery_ui.rs @@ -139,12 +139,14 @@ pub(crate) struct PcGallerySource { background: [f32; 4], /// The middle of the layer, about 4× the thumbnail size, sampled down to the thumbnail size. thumb_src: Surface, + /// Keeps the shared thumbnail cache from reusing pictures from an earlier Gallery. + thumb_revision: Revision, catalog: PcCatalog, preview: SharedPicture, } impl PcGallerySource { - fn new(src: Surface, canvas: Rect, target: Value, colours: [[f32; 4]; 2]) -> Self { + fn new(src: Surface, canvas: Rect, target: Value, colours: [[f32; 4]; 2], thumb_revision: Revision) -> Self { let cb = src.content_bounds().intersect(&canvas); let cb = if cb.is_empty() { canvas } else { cb }; let k = ((cb.width() as usize / (THUMB[0] * 4)).min(cb.height() as usize / (THUMB[1] * 4))).max(1) as u32; @@ -152,7 +154,17 @@ impl PcGallerySource { let (cx, cy) = ((cb.x0 + cb.x1) / 2, (cb.y0 + cb.y1) / 2); let thumb_src = sample(&src, Rect::new(cx - tw / 2, cy - th / 2, cx - tw / 2 + tw, cy - th / 2 + th), k); let preview = SharedPicture::new(PixelSize::new(canvas.width().max(1), canvas.height().max(1))); - PcGallerySource { src: Arc::new(src), canvas, target, foreground: colours[0], background: colours[1], thumb_src, catalog: PcCatalog, preview } + PcGallerySource { + src: Arc::new(src), + canvas, + target, + foreground: colours[0], + background: colours[1], + thumb_src, + thumb_revision, + catalog: PcCatalog, + preview, + } } /// The command params for `effects`: what OK runs and what the preview renders. @@ -213,9 +225,9 @@ impl FilterGallerySource for PcGallerySource { } impl ThumbSource for PcGallerySource { - /// The crop and colours are fixed while the gallery is open, so a filter's thumbnail never changes. - fn revision(&self, key: &GalleryThumb, _request: &ThumbRequest) -> Revision { - Revision::of(&key.filter) + /// All filters use the same immutable source, and each filter has its own cache key. + fn revision(&self, _key: &GalleryThumb, _request: &ThumbRequest) -> Revision { + self.thumb_revision } fn render(&self, key: &GalleryThumb, _request: &ThumbRequest) -> ThumbRender { @@ -501,7 +513,8 @@ fn open_on( session.effects = effects; } let size = PixelSize::new(canvas.width().max(1), canvas.height().max(1)); - let source = Arc::new(PcGallerySource::new(src, canvas, target, colours)); + let thumb_revision = Revision::new(app.texture_serials.mint()); + let source = Arc::new(PcGallerySource::new(src, canvas, target, colours, thumb_revision)); let workspace = FilterGalleryWorkspace::new(FilterGalleryOpen::new(size, layer_name, session)); let shared: Arc = source.clone(); diff --git a/crates/ui-egui/src/dialogs/gallery_ui/tests.rs b/crates/ui-egui/src/dialogs/gallery_ui/tests.rs index 78b949c2367..8c2cb18f109 100644 --- a/crates/ui-egui/src/dialogs/gallery_ui/tests.rs +++ b/crates/ui-egui/src/dialogs/gallery_ui/tests.rs @@ -408,3 +408,67 @@ fn glow_color_keeps_exact_floats_until_a_new_pick_and_stores_linear() { }; assert!(near(&recorded(h.state())[..3], &[0.21586, 0.05127, 1.0], 1e-3), "{:?}", recorded(h.state())); } + +type GalleryHarness = egui_kittest::Harness<'static, Box>; + +fn open_gallery(mut app: Box) -> GalleryHarness { + let ctx = app.ctx().clone(); + crate::menus::invoke(&mut app, &ctx, KEY, json!({})).unwrap(); + let mut gallery = egui_kittest::Harness::builder().with_context(ctx).with_size(egui::vec2(1500.0, 950.0)).with_pixels_per_point(1.25).build_ui_state( + |ui, app: &mut Box| { + app.framework.dialogs.run(ui); + }, + app, + ); + gallery.run_steps(4); + gallery +} + +fn painted_thumbnails(gallery: &GalleryHarness) -> Vec<[usize; 2]> { + let output = gallery.output(); + let painted = gallery.ctx.tessellate(output.shapes.clone(), output.pixels_per_point); + let drawn: std::collections::HashSet<_> = painted + .iter() + .filter_map(|item| match &item.primitive { + egui::epaint::Primitive::Mesh(mesh) => Some(mesh.texture_id), + _ => None, + }) + .collect(); + gallery + .ctx + .tex_manager() + .read() + .allocated() + .filter(|(id, meta)| drawn.contains(id) && meta.name.contains("filterGallery.thumbs")) + .map(|(_, meta)| meta.size) + .collect() +} + +#[test] +fn gallery_browser_paints_filter_thumbnails() { + let mut app = app(); + app.run("edit.fill", json!({"color": "#3366cc"})).unwrap(); + let gallery = open_gallery(app); + let artistic = GalleryFilter::ALL.iter().filter(|f| f.category() == GalleryFilter::ColoredPencil.category()).count(); + let thumbs = painted_thumbnails(&gallery); + assert_eq!(thumbs.len(), artistic, "every filter in the open Artistic category is painted"); + assert!(thumbs.iter().all(|size| size[0] > 1 && size[1] > 1)); +} + +#[test] +fn gallery_replaces_blank_thumbnails_when_reopened_on_paint() { + let mut app = app(); + app.run("layer.new.layer", json!({})).unwrap(); + let mut gallery = open_gallery(app); + let blank = painted_thumbnails(&gallery); + assert!(!blank.is_empty() && blank.iter().all(|size| *size == [1, 1]), "the first layer has no pixels"); + let ctx = gallery.ctx.clone(); + ui(gallery.state_mut(), json!({"cancel": true})).unwrap(); + take(gallery.state_mut(), &ctx); + gallery.state_mut().run("edit.fill", json!({"color": "#3366cc"})).unwrap(); + crate::menus::invoke(gallery.state_mut(), &ctx, KEY, json!({})).unwrap(); + gallery.run_steps(4); + let painted = painted_thumbnails(&gallery); + assert_eq!(painted.len(), blank.len(), "every Artistic tile has a picture"); + assert!(painted.iter().all(|size| size[0] > 1 && size[1] > 1), "reopening still paints blank previews: {painted:?}"); +} From 8e5ae69f4b33539303afbb58053da867a10a9913 Mon Sep 17 00:00:00 2001 From: RickiNano <81099017+RickiNano@users.noreply.github.com> Date: Tue, 24 Nov 2026 22:02:49 +0100 Subject: [PATCH 16/81] Color Settings: spell out the setup labels so the translation report lists them (#14229) `tl!(*n)` looked a label up but `cargo xtask i18n-coverage` only collects literal keys, so the 13 setup names never showed as missing rows. `preset_label` now has one literal `tl!` per setup; the menu values, stored `preset` and scripted names stay English. --- .../dialogs/color_settings_presets_tests.rs | 7 ++++++ .../filter_dialog/color_settings_presets.rs | 23 ++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/dialogs/color_settings_presets_tests.rs b/crates/ui-egui/src/dialogs/color_settings_presets_tests.rs index 6453ad76278..5537fdee188 100644 --- a/crates/ui-egui/src/dialogs/color_settings_presets_tests.rs +++ b/crates/ui-egui/src/dialogs/color_settings_presets_tests.rs @@ -270,3 +270,10 @@ fn monitor_color_follows_a_monitor_profile_change() { let c = &app.session.color().settings; assert_eq!((c.preset.as_str(), c.working_rgb.as_str(), c.monitor_profile.as_str()), ("Monitor Color", "display-p3", "display-p3")); } + +#[test] +fn every_setup_has_a_spelled_out_label_that_reads_its_name_in_english() { + for name in COLOR_SETTINGS_PRESETS { + assert_eq!(preset_label(name), Some(name), "a setup missing from `preset_label`, or a misspelled key, shows untranslated"); + } +} diff --git a/crates/ui-egui/src/dialogs/filter_dialog/color_settings_presets.rs b/crates/ui-egui/src/dialogs/filter_dialog/color_settings_presets.rs index 808b4e97747..b6a061e0eb5 100644 --- a/crates/ui-egui/src/dialogs/filter_dialog/color_settings_presets.rs +++ b/crates/ui-egui/src/dialogs/filter_dialog/color_settings_presets.rs @@ -43,7 +43,7 @@ pub(super) fn row(label: Label) -> Param { Param::custom(KEY, label, move |ui, fields, _| { let mut entries = Vec::new(); // The labels are translated; the values stay the English names scripts and saved settings use. - let named = COLOR_SETTINGS_PRESETS.iter().map(|n| (*n, tl!(*n))); + let named = COLOR_SETTINGS_PRESETS.iter().map(|n| (*n, preset_label(n).unwrap_or(n))); for (value, label) in [(CUSTOM_SETTINGS, tl!("Custom")), (OTHER, tl!("Other"))].into_iter().chain(named) { if GROUP_STARTS.contains(&value) { entries.push(Entry::separator()); @@ -58,6 +58,27 @@ pub(super) fn row(label: Label) -> Param { }) } +/// A named setup's translated label, spelled out so `cargo xtask i18n-coverage` lists each one; +/// `None` for a name the menu doesn't have. +fn preset_label(name: &str) -> Option<&'static str> { + Some(match name { + "Europe General Purpose 3" => tl!("Europe General Purpose 3"), + "Europe Prepress 3" => tl!("Europe Prepress 3"), + "Europe Web/Internet 2" => tl!("Europe Web/Internet 2"), + "Monitor Color" => tl!("Monitor Color"), + "Japan Color for Newspaper" => tl!("Japan Color for Newspaper"), + "Japan General Purpose 2" => tl!("Japan General Purpose 2"), + "Japan Magazine Advertisement Color" => tl!("Japan Magazine Advertisement Color"), + "Japan Prepress 2" => tl!("Japan Prepress 2"), + "Japan Web/Internet" => tl!("Japan Web/Internet"), + "North America General Purpose 2" => tl!("North America General Purpose 2"), + "North America Newspaper" => tl!("North America Newspaper"), + "North America Prepress 2" => tl!("North America Prepress 2"), + "North America Web/Internet" => tl!("North America Web/Internet"), + _ => return None, + }) +} + /// After a pass or a set: shows Custom for a name the menu doesn't have, loads a newly picked setup /// (from the menu or `ui.dialog.set`), or shows Custom once a control differs from the values the /// shown setup gave. From 13146f174aa0b9bb0390c0830cbb9e6951ca1215 Mon Sep 17 00:00:00 2001 From: hnoerenberg Date: Wed, 25 Nov 2026 22:02:02 +0100 Subject: [PATCH 17/81] fix(vector): a Ctrl-drag of a curvature draft anchor keeps its handles While a Curvature Pen path is still being drawn, a Ctrl/Cmd-drag of one of its anchors runs the path overlay's Direct Selection on the open draft. The finished drag went back to the Pen through `replace_draft`, which solves a Curvature draft's handles again with `reflow_kept`; a draft drawn from scratch has no kept anchors, so every smooth knot's handles were recomputed and the dragged anchor lost the handles the gesture had moved with it - the curve looked exactly as if no key had been held. The hand-back now knows which route it came from: the move a drag made goes through `replace_draft_as_moved`, which leaves the draft as the gesture left it, while every other edit of the draft (a keyboard nudge, an inserted or removed anchor) and a rebuilt live draft keep today's solve. The solve belongs to the Pen's own click in Curvature mode, which is not a Direct Selection edit. Tests: crates/ui-egui/src/tools/vector_ui/curvature_ctrl_drag_tests.rs. Every expected value is read from the app's own draft before the drag - the drag's own delta and the knots the gesture did not touch - so no expected handle position is written into the file. On main the dragged knot's in handle moved by (-26.5, 100) instead of the drag's (0, 100), and the other four knots moved too; with the change all five tests pass. --- .../ui-egui/src/tools/direct_select/edits.rs | 23 ++- crates/ui-egui/src/tools/vector_ui.rs | 5 +- .../vector_ui/curvature_ctrl_drag_tests.rs | 166 ++++++++++++++++++ crates/ui-egui/src/tools/vector_ui/host.rs | 14 +- 4 files changed, 200 insertions(+), 8 deletions(-) create mode 100644 crates/ui-egui/src/tools/vector_ui/curvature_ctrl_drag_tests.rs diff --git a/crates/ui-egui/src/tools/direct_select/edits.rs b/crates/ui-egui/src/tools/direct_select/edits.rs index be9eb8ba3c9..4e3d27703ea 100644 --- a/crates/ui-egui/src/tools/direct_select/edits.rs +++ b/crates/ui-egui/src/tools/direct_select/edits.rs @@ -90,7 +90,7 @@ pub(crate) fn delete_anchors(app: &mut PhotocraftApp, path: PathRef, anchors: &[ return; } if path == PathRef::Pen { - edit_draft(app, |draft| { + edit_draft(app, false, |draft| { let Some(sub) = draft.subpaths.get_mut(0) else { return false }; order.iter().filter(|[s, _]| *s == 0).fold(false, |changed, [_, k]| sub.remove_knot(*k) || changed) }); @@ -205,7 +205,12 @@ fn moved(x: f64, y: f64) -> bool { fn change_path(app: &mut PhotocraftApp, change: &PathEdit, refs: &[PathRef], tool: Tool, mods: Mods, dragged: bool) { let Some(r) = known(change.path(), refs) else { return }; if r == PathRef::Pen { - edit_draft(app, |path| change.apply(path)); + // A drag of an anchor of the path being drawn (⌘/Ctrl with a pen tool, or the Direct Selection tool): the + // anchor moves with its handles and the Curvature Pen takes the draft as the gesture left it, instead of + // solving the curve again under the move (#12757). An arrow-key nudge of the draft, which is no pointer + // gesture, and every other edit of it keep today's solve. + let dragged_move = dragged && matches!(change, PathEdit::MoveAnchors { .. }); + edit_draft(app, dragged_move, |path| change.apply(path)); return; } // The Convert Point tool names its steps as the reference does; the Pen's ⌥ and Direct @@ -323,7 +328,7 @@ fn add_and_move(app: &mut PhotocraftApp, r: PathRef, prefix: &str, segment: Knot /// The Insert key: an anchor in the middle of the segment leaving `knot`. fn insert(app: &mut PhotocraftApp, r: PathRef, knot: KnotRef, t: f64) { if r == PathRef::Pen { - edit_draft(app, |path| path.subpaths.get_mut(knot.subpath).and_then(|sub| sub.insert_at(knot.knot, t)).is_some()); + edit_draft(app, false, |path| path.subpaths.get_mut(knot.subpath).and_then(|sub| sub.insert_at(knot.knot, t)).is_some()); return; } command(app, r, "path.addAnchor", json!({"subpath": knot.subpath, "knot": knot.knot, "t": t})); @@ -407,15 +412,21 @@ pub(crate) fn command(app: &mut PhotocraftApp, r: PathRef, id: &str, params: Val } } -/// Edits the pen draft as a path of its own key and hands the result back to the pen. -fn edit_draft(app: &mut PhotocraftApp, edit: impl FnOnce(&mut EditPath) -> bool) { +/// Edits the pen draft as a path of its own key and hands the result back to the pen. `moved` is the ⌘/Ctrl-drag +/// of an anchor: the Pen takes the draft as the gesture left it, and a Curvature Pen draft is not solved again +/// under it (#12757). Every other edit of the draft keeps the solve. +fn edit_draft(app: &mut PhotocraftApp, moved: bool, edit: impl FnOnce(&mut EditPath) -> bool) { let Some(draft) = app.ui.pen.as_ref().map(|pen| pen.draft.clone()) else { return }; let mut path = EditPath::new(PathRef::Pen.key(), vec![draft]).copies(false); if !edit(&mut path) { return; } if let Some(draft) = path.subpaths.into_iter().next() { - crate::vector_ui::replace_draft(app, &draft); + if moved { + crate::vector_ui::replace_draft_as_moved(app, &draft); + } else { + crate::vector_ui::replace_draft(app, &draft); + } } } diff --git a/crates/ui-egui/src/tools/vector_ui.rs b/crates/ui-egui/src/tools/vector_ui.rs index 254fcaa0085..3fe7485435d 100644 --- a/crates/ui-egui/src/tools/vector_ui.rs +++ b/crates/ui-egui/src/tools/vector_ui.rs @@ -54,7 +54,7 @@ pub(crate) use shapes::{create_geometry, kind_of, tool_history_name}; use crate::shape_paint_ui::PaintChange; #[cfg(test)] pub(crate) use host::remove_last; -pub(crate) use host::{VectorTools, replace_draft}; +pub(crate) use host::{VectorTools, replace_draft, replace_draft_as_moved}; #[cfg(test)] pub(crate) use path_ops::delete_key_deletes_work_path; #[cfg(test)] @@ -221,6 +221,9 @@ mod ellipse_path_menus_tests; #[cfg(test)] mod curvature_delete_key_tests; +#[cfg(test)] +mod curvature_ctrl_drag_tests; + #[cfg(test)] mod shape_properties_tests; diff --git a/crates/ui-egui/src/tools/vector_ui/curvature_ctrl_drag_tests.rs b/crates/ui-egui/src/tools/vector_ui/curvature_ctrl_drag_tests.rs new file mode 100644 index 00000000000..c991e20101d --- /dev/null +++ b/crates/ui-egui/src/tools/vector_ui/curvature_ctrl_drag_tests.rs @@ -0,0 +1,166 @@ +//! #12757: with the Curvature Pen and a path still being drawn, ⌘/Ctrl-dragging one of its anchors moves that +//! anchor with its handles and leaves every other knot exactly as it was: the move does not solve the curve again. +//! Every value expected here is read from the app's own draft before the gesture and compared with what the +//! gesture made of it (the drag's own delta, and the knots it did not touch), so this file states no handle +//! position of its own. + +use egui::Modifiers; +use serde_json::json; + +use crate::PhotocraftApp; +use crate::canvas::testing; +use crate::state::Tool; + +/// The five anchors of the path under test, at 100 % zoom on an 800 x 600 document. +const ANCHORS: [[f64; 2]; 5] = [[100.0, 300.0], [250.0, 150.0], [400.0, 300.0], [550.0, 150.0], [700.0, 300.0]]; +/// The middle anchor: the one the gesture drags. +const DRAGGED: usize = 2; +/// Where the drag lets go, so the drag's own delta is (0, 100). +const RELEASE: [f64; 2] = [400.0, 400.0]; +/// The anchor the path carries on from after the drag, well clear of every anchor drawn and inside the document. +const NEXT: [f64; 2] = [780.0, 420.0]; + +/// The Curvature Pen in Path mode, the five anchors clicked, and the path still being drawn. +fn drawing() -> Box { + let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default()); + app.session.execute("file.new", json!({"width": 800, "height": 600, "background": "white"})).unwrap(); + app.sync_views(); + app.run("layer.new.layer", json!({"name": "Red"})).unwrap(); + app.ui.tool = Tool::CurvaturePen; + app.ui.tool_options.vector_mode = craft::draw::ui::VectorMode::Path; + for at in ANCHORS { + testing::click(&mut app, at, Modifiers::NONE); + } + assert_eq!(draft(&app).len(), ANCHORS.len(), "the five anchors are the draft being drawn"); + app +} + +/// The same path finished with Esc: no draft, the Work Path holds it. +fn finished() -> Box { + let mut app = drawing(); + testing::key(&mut app, egui::Key::Escape, Modifiers::NONE); + assert!(app.ui.pen.is_none(), "Esc ended the path"); + app +} + +/// The draft's knots as anchor, in handle and out handle. +fn draft(app: &PhotocraftApp) -> Vec<[[f64; 2]; 3]> { + app.ui.pen.as_ref().expect("the path is still being drawn").triples() +} + +/// The Work Path's knots the same way. +fn work(app: &PhotocraftApp) -> Vec<[[f64; 2]; 3]> { + let path = app.session.active().unwrap().doc.work_path.clone().expect("the finished path is the Work Path"); + path.subpaths[0].knots.iter().map(|k| [[k.anchor.x, k.anchor.y], [k.in_ctrl.x, k.in_ctrl.y], [k.out_ctrl.x, k.out_ctrl.y]]).collect() +} + +/// How far `after` is from `before`. +fn delta(before: [f64; 2], after: [f64; 2]) -> [f64; 2] { + [after[0] - before[0], after[1] - before[1]] +} + +/// Are two points the same to within a thousandth of a pixel? The pointer's travel is measured through the view, so +/// the drag's delta is only that exact. +fn same(a: [f64; 2], b: [f64; 2]) -> bool { + (a[0] - b[0]).abs() < 1e-3 && (a[1] - b[1]).abs() < 1e-3 +} + +fn drag(app: &mut PhotocraftApp, from: [f64; 2], to: [f64; 2], mods: Modifiers) { + testing::press(app, from, mods); + let mid = [(from[0] + to[0]) / 2.0, (from[1] + to[1]) / 2.0]; + testing::move_to(app, mid, mods); + testing::move_to(app, to, mods); + testing::release(app, to, mods); + // Let go of the keys: a frame keeps the modifiers of the last event, and the Pen's pass reads them to decide + // whether ⌘ still makes the pointer Direct Selection. + testing::modifiers(app, Modifiers::NONE); +} + +fn steps(app: &PhotocraftApp) -> usize { + app.session.active().unwrap().history.entries().len() +} + +/// The dragged anchor went to the point the pointer let go, and every other knot of `after` is `before`'s. +fn assert_only_the_dragged_anchor_moved(before: &[[[f64; 2]; 3]], after: &[[[f64; 2]; 3]]) -> [f64; 2] { + let by = delta(before[DRAGGED][0], after[DRAGGED][0]); + assert!(same(by, [RELEASE[0] - ANCHORS[DRAGGED][0], RELEASE[1] - ANCHORS[DRAGGED][1]]), "the anchor followed the pointer to {RELEASE:?}, moved {by:?}"); + for side in 1..3 { + let handle = delta(before[DRAGGED][side], after[DRAGGED][side]); + assert!(same(handle, by), "handle {side} of the dragged knot moved with it by {by:?}, not {handle:?}"); + } + for k in 0..ANCHORS.len() { + if k == DRAGGED { + continue; + } + assert_eq!(after[k], before[k], "knot {k} is exactly what it was: the move solved the curve again"); + } + by +} + +#[test] +fn a_ctrl_drag_of_a_draft_anchor_moves_it_with_its_handles_and_leaves_the_curve_solved_as_it_was() { + let mut app = drawing(); + let before = draft(&app); + drag(&mut app, ANCHORS[DRAGGED], RELEASE, Modifiers::COMMAND); + assert_only_the_dragged_anchor_moved(&before, &draft(&app)); +} + +#[test] +fn a_ctrl_drag_of_a_draft_anchor_adds_no_step_while_the_path_is_a_draft() { + // The Curvature Pen writes its path only at the finish, and its step names are #12752's: the drag is an edit of + // the draft, so it neither adds a step of its own nor writes the document. + let mut app = drawing(); + let (before, path) = (steps(&app), app.session.active().unwrap().doc.work_path.clone()); + drag(&mut app, ANCHORS[DRAGGED], RELEASE, Modifiers::COMMAND); + assert_eq!(steps(&app), before, "the drag of a draft is no step yet"); + assert_eq!(app.session.active().unwrap().doc.work_path, path, "and wrote nothing to the document"); + testing::key(&mut app, egui::Key::Enter, Modifiers::NONE); + assert_eq!(steps(&app), before + 1, "the finish is still the one step it is today"); +} + +#[test] +fn a_plain_drag_of_a_draft_anchor_still_solves_the_whole_curve() { + let mut app = drawing(); + let before = draft(&app); + drag(&mut app, ANCHORS[DRAGGED], RELEASE, Modifiers::NONE); + let after = draft(&app); + assert!(same(after[DRAGGED][0], RELEASE), "the Pen's own drag put the anchor at the release point"); + for k in [DRAGGED - 1, DRAGGED + 1] { + assert_ne!(after[k], before[k], "the neighbouring knot {k} was solved again under the drag"); + } + // The draft is exactly the solve of its own anchors: solving it again changes nothing. + let mut again = app.ui.pen.as_ref().expect("still drawing").draft.clone(); + again.reflow(); + for (k, knot) in again.knots.iter().enumerate() { + let solved = [[knot.anchor.x, knot.anchor.y], [knot.in_ctrl.x, knot.in_ctrl.y], [knot.out_ctrl.x, knot.out_ctrl.y]]; + for side in 0..3 { + assert!(same(after[k][side], solved[side]), "a plain drag left knot {k} part {side} off its own solve"); + } + } +} + +#[test] +fn a_ctrl_drag_of_a_finished_path_moves_the_anchor_with_its_handles_in_one_step() { + let mut app = finished(); + let (before, n) = (work(&app), steps(&app)); + drag(&mut app, ANCHORS[DRAGGED], RELEASE, Modifiers::COMMAND); + assert_only_the_dragged_anchor_moved(&before, &work(&app)); + assert_eq!(steps(&app), n + 1, "the whole drag is one step"); + assert_eq!(app.session.active().unwrap().history.undo_label(), Some("Drag Anchor Point"), "and that step is named as the finished-path drag is today"); +} + +#[test] +fn drawing_on_from_the_last_anchor_keeps_the_moved_anchor_where_the_drag_put_it() { + // The next click of the Curvature Pen solves the handles of the knots it has again, and whether it keeps the + // handles a ⌘/Ctrl-drag gave the moved anchor is one of the cases the issue marks not measured: it stays as it + // is today, so only the anchor's place is pinned here. + let mut app = drawing(); + let before = draft(&app); + drag(&mut app, ANCHORS[DRAGGED], RELEASE, Modifiers::COMMAND); + let moved = draft(&app); + testing::click(&mut app, NEXT, Modifiers::NONE); + let after = draft(&app); + assert_eq!(after.len(), ANCHORS.len() + 1, "the click added the next anchor"); + assert_eq!(after[DRAGGED][0], moved[DRAGGED][0], "the moved anchor stayed where the drag put it"); + assert_eq!(after[DRAGGED + 1][0], before[DRAGGED + 1][0], "and the last anchor did not move"); +} diff --git a/crates/ui-egui/src/tools/vector_ui/host.rs b/crates/ui-egui/src/tools/vector_ui/host.rs index 23c7ad6c5d9..c70f8896a05 100644 --- a/crates/ui-egui/src/tools/vector_ui/host.rs +++ b/crates/ui-egui/src/tools/vector_ui/host.rs @@ -250,9 +250,21 @@ pub(crate) fn remove_last(app: &mut PhotocraftApp) -> bool { /// Pen draft keeps following its anchors. `false` with no draft or while a press is down. Called between passes: a call /// inside a run would reach the stand-in tools the run left in the app. pub(crate) fn replace_draft(app: &mut PhotocraftApp, draft: &EditSubpath) -> bool { + replace_draft_handback(app, draft, true) +} + +/// `replace_draft` for the anchor a ⌘/Ctrl-drag moved: the draft goes back as the gesture left it, so moving one +/// anchor of a Curvature Pen draft does not solve the rest of the curve again (#12757). +pub(crate) fn replace_draft_as_moved(app: &mut PhotocraftApp, draft: &EditSubpath) -> bool { + replace_draft_handback(app, draft, false) +} + +/// The draft hand-back of both routes: `solve` re-solves a Curvature Pen draft's handles, as an edit that changes +/// which anchors there are (or a path the Pen carried on) needs. +fn replace_draft_handback(app: &mut PhotocraftApp, draft: &EditSubpath, solve: bool) -> bool { let Some(pen) = app.ui.pen.as_mut() else { return false }; let mut next = draft.clone(); - if pen.curvature { + if pen.curvature && solve { next.reflow_kept(pen.kept); } pen.draft = next.clone(); From 7522225fb8f7eb96d275137c69155e47ae540904 Mon Sep 17 00:00:00 2001 From: RickiNano <81099017+RickiNano@users.noreply.github.com> Date: Thu, 26 Nov 2026 12:41:00 +0100 Subject: [PATCH 18/81] Content-Aware Fill: the Custom sampling alert shows an info icon (#16693) Choosing Custom in the Content-Aware Fill workspace opens its alert through a new alerts::info_once, alert_once with the catalog's info icon beside the message. The other "Don't show again" alerts keep their look. --- crates/ui-egui/src/dialogs/alerts.rs | 18 +++++++++++++++- .../src/dialogs/caf_ui/custom_alert_tests.rs | 21 +++++++++++++++++++ .../ui-egui/src/dialogs/caf_ui/lifecycle.rs | 2 +- 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/dialogs/alerts.rs b/crates/ui-egui/src/dialogs/alerts.rs index 84d84a50dac..e2ea6055626 100644 --- a/crates/ui-egui/src/dialogs/alerts.rs +++ b/crates/ui-egui/src/dialogs/alerts.rs @@ -6,12 +6,13 @@ //! [`open_prompt`] (a second open is refused, not replaced) and tags its prompt with its own type. //! [`prompt_tagged`] and [`prompt_tag`] find the open prompt by that tag. +use craft::behavior::IconId; use craft::ui::dialog::{Alert, DialogId, HostedAlert, PromptAnswer, PromptChoice, StackDialog, StandardPrompt}; use serde_json::{Value, json}; use crate::PhotocraftApp; -/// The tag of an alert opened by [`alert_once`]: the dialog preference its "Don't show again" box sets. +/// The tag of an alert opened by [`alert_once`] or [`info_once`]: the dialog preference its "Don't show again" box sets. pub(crate) struct AlertOnce { pref: &'static str, } @@ -56,6 +57,21 @@ pub fn dismissed(app: &PhotocraftApp, pref: &str) -> bool { app.session.prefs().dialogs.get(pref).and_then(|v| v.get("skip")).and_then(Value::as_bool) == Some(true) } +/// [`alert_once`] with the catalog's info icon beside the message, as the reference shows for the +/// Content-Aware Fill workspace's Custom sampling alert (#16693). The other alerts keep their look. +pub fn info_once(app: &mut PhotocraftApp, message: impl Into, pref: &'static str) -> Option { + if dismissed(app, pref) { + return None; + } + let prompt = StandardPrompt::custom(message.into()) + .title(TITLE) + .icon(IconId::new("info")) + .button(PromptChoice::Proceed, tl!("OK").to_owned()) + .dont_show_again() + .tag(AlertOnce { pref }); + open_prompt(app, prompt).ok().or_else(|| prompt_tagged::(app)) +} + /// Keeps "Don't show again" for the question remembered as `pref`, with the other dialog preferences. pub fn remember_skip(app: &mut PhotocraftApp, pref: &str) { remember_skip_or(app, pref, tl!("The preference could not be saved: {error}")); diff --git a/crates/ui-egui/src/dialogs/caf_ui/custom_alert_tests.rs b/crates/ui-egui/src/dialogs/caf_ui/custom_alert_tests.rs index d66740c1eb1..f49ca5010b9 100644 --- a/crates/ui-egui/src/dialogs/caf_ui/custom_alert_tests.rs +++ b/crates/ui-egui/src/dialogs/caf_ui/custom_alert_tests.rs @@ -2,7 +2,9 @@ //! reference's info alert, "Use the Sampling Brush Tool to add to the sampling area in order to //! fill the selected region.", with "Don't show again" and OK, once per choice. OK closes it and the //! Sampling Brush adds. With "Don't show again" ticked it stays closed. Other choices show nothing. +//! #16693: the alert shows an info icon beside its text. +use egui::accesskit::Role; use egui_kittest::kittest::Queryable; use serde_json::{Value, json}; @@ -94,6 +96,25 @@ fn choosing_custom_shows_the_alert_once_and_ok_leaves_the_brush_adding() { assert_eq!((d["settings"]["sampling"].as_str(), d["brushMode"].as_str()), (Some("custom"), Some("add"))); } +#[test] +fn the_alert_shows_an_icon_beside_its_text() { + let mut app = app(); + open(&mut app).unwrap(); + choose(&mut app, "custom"); + let mut h = egui_kittest::Harness::builder() + .with_size(egui::vec2(1440.0, 900.0)) + .with_max_steps(16) + .with_context(app.ctx().clone()) + .build_ui_state(|ui, app: &mut Box| crate::dialogs::run(app, ui), app); + PhotocraftApp::setup_context(&h.ctx, Default::default()); + h.run_steps(4); + let title = h.get_by_role_and_label(Role::Heading, "PhotoCraft").rect(); + let message = h.get_by_label_contains(CUSTOM_SAMPLING_ALERT).rect(); + // The prompt draws the icon unnamed, so it shows in the layout: the title starts at the content's start, the + // message after the icon on its row. + assert!(message.left() > title.left() + 8.0, "the message starts after the icon: {message:?} vs title {title:?}"); +} + #[test] fn each_choice_of_custom_shows_it() { let mut app = app(); diff --git a/crates/ui-egui/src/dialogs/caf_ui/lifecycle.rs b/crates/ui-egui/src/dialogs/caf_ui/lifecycle.rs index 36e538eec6e..697998787f3 100644 --- a/crates/ui-egui/src/dialogs/caf_ui/lifecycle.rs +++ b/crates/ui-egui/src/dialogs/caf_ui/lifecycle.rs @@ -252,7 +252,7 @@ pub(crate) fn take(app: &mut PhotocraftApp, ctx: &egui::Context) { } if custom_chosen { - let _ = crate::dialogs::alerts::alert_once(app, tl!(CUSTOM_SAMPLING_ALERT), CUSTOM_SAMPLING_PREF); + let _ = crate::dialogs::alerts::info_once(app, tl!(CUSTOM_SAMPLING_ALERT), CUSTOM_SAMPLING_PREF); } } From 282ac1e70707df8bd243df1035fed25a810bf042 Mon Sep 17 00:00:00 2001 From: qvest-ssels <214787280+qvest-ssels@users.noreply.github.com> Date: Thu, 26 Nov 2026 16:36:38 +0100 Subject: [PATCH 19/81] Sharpen: sharpen a layer's transparency too, keeping the colour With Protect Detail off, local_sharpen now applies the colour channels' unsharp-mask step to alpha as well, clamped to 0..1, instead of copying it through. Colour is blurred premultiplied, so a one-colour layer keeps its colour and only alpha moves; opaque-next-to-transparent and opaque layers are unchanged. Protect Detail on, 16- and 32-bit layers and Lock transparent pixels keep their alpha, as the issue leaves them unmeasured. The exact reference values need #12939's 8-neighbour kernel. Part of #12940. --- crates/algo/src/retouch.rs | 9 +- crates/algo/tests/it/retouch_sharpen_exact.rs | 2 +- .../engine-paint/src/cmd/retouch_cmds/dab.rs | 11 +- .../cmd/retouch_cmds/sharpen_alpha_tests.rs | 157 ++++++++++++++++++ 4 files changed, 175 insertions(+), 4 deletions(-) create mode 100644 crates/engine-paint/src/cmd/retouch_cmds/sharpen_alpha_tests.rs diff --git a/crates/algo/src/retouch.rs b/crates/algo/src/retouch.rs index 69ed15194c7..a523b770865 100644 --- a/crates/algo/src/retouch.rs +++ b/crates/algo/src/retouch.rs @@ -301,7 +301,12 @@ const PROTECT_DETAIL_LIMIT: f32 = 6.0 / 255.0; /// low halo a few pixels wide, and each difference is soft-limited to `L` = 6 levels: /// `v + amount·d·L/(L + |d|)`. Fine detail is sharpened about as much as without it, while a /// strong edge or a lone bright pixel moves by less than `L` per pass instead of overshooting. -/// Uniform areas stay exactly as they are. Alpha is left unchanged. +/// Uniform areas stay exactly as they are. +/// +/// Without `protect_detail`, alpha is sharpened by the same rule as colour and clamped to 0..1 +/// (#12940): a semi-transparent edge gets crisper while the colour stays, since the colour is +/// blurred premultiplied. An opaque pixel next to a transparent one stays as it is, because the +/// clamp holds both at their limits. With `protect_detail`, alpha is left unchanged (not measured). #[allow(clippy::too_many_arguments)] pub fn local_sharpen( data: &[f32], @@ -332,7 +337,7 @@ pub fn local_sharpen( for c in 0..ch { let v = data[i + c]; if Some(c) == alpha { - dst[o + c] = v; + dst[o + c] = if protect_detail { v } else { (v + amount * (v - blur_row[o + c])).clamp(0.0, 1.0) }; continue; } let d = v - blur_row[o + c]; diff --git a/crates/algo/tests/it/retouch_sharpen_exact.rs b/crates/algo/tests/it/retouch_sharpen_exact.rs index 499b60d6ac3..c5a3d8448b1 100644 --- a/crates/algo/tests/it/retouch_sharpen_exact.rs +++ b/crates/algo/tests/it/retouch_sharpen_exact.rs @@ -62,7 +62,7 @@ fn scalar_local_sharpen( for c in 0..ch { let v = data[i + c]; if Some(c) == alpha { - out[o + c] = v; + out[o + c] = if protect_detail { v } else { (v + amount * (v - blur[o + c])).clamp(0.0, 1.0) }; continue; } let d = v - blur[o + c]; diff --git a/crates/engine-paint/src/cmd/retouch_cmds/dab.rs b/crates/engine-paint/src/cmd/retouch_cmds/dab.rs index 11dc337871f..9b6c4f4a2f5 100644 --- a/crates/engine-paint/src/cmd/retouch_cmds/dab.rs +++ b/crates/engine-paint/src/cmd/retouch_cmds/dab.rs @@ -316,6 +316,9 @@ impl DabTool { } Self::Focus { sharpen, strength, protect, sigma } => { let a = alpha_index(&fmt); + // Sharpen sharpens alpha too (#12940), measured at 8 bits only: 16- and 32-bit + // layers keep their alpha as before. + let keep_alpha = if sharpen && fmt.sample != SampleType::U8 { a } else { None }; let mut shares = ProtectDetailShares::default(); Box::new(move |work, fp| { let r = fp.rect.intersect(&work.rect); @@ -348,7 +351,9 @@ impl DabTool { let i = (x - wx0) as usize * n; let px = &mut line[i..i + n]; for c in 0..n { - px[c] += (out[o + c] - px[c]) * k; + if Some(c) != keep_alpha { + px[c] += (out[o + c] - px[c]) * k; + } } } }); @@ -828,3 +833,7 @@ mod smudge_refuses_indexed_tests; #[cfg(test)] #[path = "smudge_mode_tests.rs"] mod smudge_mode_tests; + +#[cfg(test)] +#[path = "sharpen_alpha_tests.rs"] +mod sharpen_alpha_tests; diff --git a/crates/engine-paint/src/cmd/retouch_cmds/sharpen_alpha_tests.rs b/crates/engine-paint/src/cmd/retouch_cmds/sharpen_alpha_tests.rs new file mode 100644 index 00000000000..b8c06644106 --- /dev/null +++ b/crates/engine-paint/src/cmd/retouch_cmds/sharpen_alpha_tests.rs @@ -0,0 +1,157 @@ +//! #12940: with Protect Detail off, the Sharpen tool sharpens a layer's transparency by the same +//! rule as its colour, and keeps the colour. The reference test layer is (200,40,40) at alpha 64 +//! for x 300..399 and alpha 191 for x 400..499, y 300..349, clicked once at 400,320 with a 40 px +//! hard tip at Strength 100 %. +//! +//! The reference's exact alpha (40 at x 399, 215 at x 400, x 398 and 401 unchanged) comes from the +//! 8-neighbour kernel of #12939; until that lands, alpha follows today's colour kernel. + +use serde_json::json; + +use super::*; + +const RED: [f32; 3] = [200.0 / 255.0, 40.0 / 255.0, 40.0 / 255.0]; + +/// An 800 × 600 RGB document of `depth` whose active layer is `f(x, y)` (straight RGBA, 0..1). +fn doc(depth: u64, transparent: bool, f: impl Fn(i32, i32) -> [f32; 4]) -> Session { + let mut s = crate::session(); + let mut p = json!({"width": 800, "height": 600, "depth": depth, "mode": "rgb"}); + if transparent { + p["background"] = json!("transparent"); + } + s.execute("file.new", p).unwrap(); + s.edit("setup", |doc, active| { + let b = doc.bounds(); + let surf = doc.layer_mut(active.unwrap()).unwrap().surface_mut().unwrap(); + let fmt = surf.format(); + let mut data = Vec::new(); + for y in b.y0..b.y1 { + for x in b.x0..b.x1 { + data.extend(photocraft_raster::from_rgba(&fmt, f(x, y))); + } + } + surf.write_region(b, &data); + Ok(()) + }) + .unwrap(); + s +} + +/// The reference layer: red at alpha 64 | 191, transparent elsewhere. +fn steps(depth: u64) -> Session { + doc(depth, true, |x, y| { + let a = match (x, y) { + (300..=399, 300..=349) => 64.0, + (400..=499, 300..=349) => 191.0, + _ => 0.0, + }; + [RED[0], RED[1], RED[2], a / 255.0] + }) +} + +fn click(s: &mut Session, at: [i32; 2], extra: Value) { + let mut p = json!({"points": [at], "size": 40, "hardness": 100, "strength": 100, "protectDetail": false}); + for (k, v) in extra.as_object().unwrap() { + p[k] = v.clone(); + } + s.execute("paint.sharpen", p).unwrap(); +} + +/// The active layer's pixel as 8-bit RGBA. +fn px(s: &Session, x: i32, y: i32) -> [i32; 4] { + let d = s.active().unwrap(); + d.doc.layer(d.active_layer.unwrap()).unwrap().surface().unwrap().rgba(x, y).map(|v| (v * 255.0).round() as i32) +} + +fn row(s: &Session, xs: std::ops::Range, y: i32) -> Vec<[i32; 4]> { + xs.map(|x| px(s, x, y)).collect() +} + +#[test] +fn a_click_sharpens_the_alpha_boundary_and_keeps_the_colour() { + let mut s = steps(8); + click(&mut s, [400, 320], json!({})); + let got = row(&s, 397..403, 320); + for p in &got { + assert!((p[0] - 200).abs() <= 1 && (p[1] - 40).abs() <= 1 && (p[2] - 40).abs() <= 1, "colour must stay 200,40,40: {got:?}"); + } + let alpha: Vec = got.iter().map(|p| p[3]).collect(); + // The low side goes down and the high side up, as with colour (the reference: 64 · 64 · 40 · + // 215 · 191 · 191 with #12939's kernel). Pinned from today's sigma-1 kernel. + assert!(alpha[2] < 64 && alpha[3] > 191, "alpha boundary not sharpened: {alpha:?}"); + assert_eq!(alpha, PINNED_ALPHA, "alpha x 397..402"); +} + +/// Alpha at x 397..402 after the reference click, with today's kernel. +const PINNED_ALPHA: [i32; 6] = [63, 57, 26, 229, 198, 192]; + +#[test] +fn opaque_next_to_transparent_stays_as_it_is() { + // A red square on an otherwise empty layer; a click on its left edge. + let mut s = doc(8, true, |x, y| { + let a = if (100..200).contains(&x) && (100..200).contains(&y) { 1.0 } else { 0.0 }; + [RED[0], RED[1], RED[2], a] + }); + let before = row(&s, 80..120, 150); + click(&mut s, [100, 150], json!({})); + let after = row(&s, 80..120, 150); + for (b, a) in before.iter().zip(&after) { + assert_eq!(b[3], a[3], "alpha changed: {before:?} -> {after:?}"); + if b[3] == 255 { + assert_eq!(b, a, "an opaque pixel changed: {before:?} -> {after:?}"); + } + } +} + +#[test] +fn an_opaque_layer_keeps_todays_result() { + // The epic's grey 96 | 160 step on the Background: pinned from main 038d035110. + let mut s = doc(8, false, |x, _| { + let g = if x < 400 { 96.0 } else { 160.0 } / 255.0; + [g, g, g, 1.0] + }); + click(&mut s, [400, 320], json!({})); + let grey: Vec = row(&s, 396..404, 320).iter().map(|p| p[0]).collect(); + assert_eq!(grey, [96, 96, 92, 77, 179, 164, 160, 160]); +} + +#[test] +fn lock_transparent_pixels_keeps_the_alpha() { + let mut s = steps(8); + s.execute("layer.setProps", json!({"locks": {"transparency": true}})).unwrap(); + let before = row(&s, 390..410, 320); + click(&mut s, [400, 320], json!({})); + let after = row(&s, 390..410, 320); + assert_eq!(before.iter().map(|p| p[3]).collect::>(), after.iter().map(|p| p[3]).collect::>()); +} + +#[test] +fn protect_detail_keeps_the_alpha() { + // Protect Detail on across a semi-transparent boundary was not measured: alpha stays. + let mut s = steps(8); + let before = row(&s, 390..410, 320); + click(&mut s, [400, 320], json!({"protectDetail": true})); + let after = row(&s, 390..410, 320); + assert_eq!(before.iter().map(|p| p[3]).collect::>(), after.iter().map(|p| p[3]).collect::>()); +} + +#[test] +fn sixteen_and_32_bit_keep_the_alpha() { + // Alpha at 16 and 32 bit was not measured: it stays as it was. + for depth in [16, 32] { + let mut s = steps(depth); + let before = row(&s, 390..410, 320); + click(&mut s, [400, 320], json!({})); + let after = row(&s, 390..410, 320); + assert_eq!(before.iter().map(|p| p[3]).collect::>(), after.iter().map(|p| p[3]).collect::>(), "{depth}-bit"); + } +} + +#[test] +fn blur_is_unchanged() { + // Blur already blurred alpha; this change is Sharpen's alone. + let mut s = steps(16); + s.execute("paint.blur", json!({"points": [[400, 320]], "size": 40, "hardness": 100, "strength": 100})).unwrap(); + let alpha: Vec = row(&s, 397..403, 320).iter().map(|p| p[3]).collect(); + assert!(alpha[2] > 64 && alpha[3] < 191, "16-bit Blur still blurs alpha: {alpha:?}"); +} From 6dbbd6383e409386169ecc09899bedba8b789e73 Mon Sep 17 00:00:00 2001 From: tydude001 <291262504+tydude001@users.noreply.github.com> Date: Thu, 26 Nov 2026 14:51:09 -0600 Subject: [PATCH 20/81] Single instance: docs for the CPU relaunch, instance.json cleanup and the 0600 lock (#6654 review) docs/development.md's single-instance paragraph now says that the CPU-compatibility relaunch's own --safe-gpu doesn't keep it out of single-instance, that the primary removes its instance.json (while it still names this process) before freeing the lock, and that instance.lock is 0600 on Unix (the settings folder 0700 when single-instance creates it). Docs only. cargo xtask ci (Fedora 44 toolbox, x86_64): fmt, clippy, layers, scorecard, panic_hunt, doctest and wasm pass. In test, three tests fail in crates this branch doesn't change: photocraft-automation's dropping_a_waited_command_cancels_its_job and photocraft-gpu's a_refresh_that_submits_several_times_is_one_measurement (both also failed on main 2ff8f419c), and photocraft-ui-egui's opening_a_document_changes_state_not_structure, which fails in 2 of 3 full runs of that binary and passes on its own. --- docs/development.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/development.md b/docs/development.md index 18a7610ee08..901bf817d6e 100644 --- a/docs/development.md +++ b/docs/development.md @@ -134,7 +134,7 @@ CRAFT_FONTS_DIR="$PWD/../craft-fonts" cargo test --workspace # runs the Japa ## One instance per user -On Windows and Linux the first PhotoCraft holds an exclusive lock on `instance.lock` in the config directory and listens on a loopback port named in `instance.json` (with a fresh 256-bit token; the file is 0600 on Unix). Inside a Flatpak it listens on a Unix socket instead, `$XDG_RUNTIME_DIR/app//instance.sock` (0600), because Flatpak isolates each sandbox's network namespace, loopback included, unless the app is granted `--share=network`, while that runtime directory is shared by all sandboxes of the app (#1540); the lock, token and protocol are the same. A later launch hands its file arguments there and exits, so files opened from Explorer or a file manager become tabs in the running window (#3708). The primary answers `ok` only once its UI has taken the files; a launch that gets anything else (the primary is starting, hung or closing) keeps retrying the lock for up to 10 s, becoming the primary itself once the old one lets go, and then starts a separate instance, so a file is never acknowledged and lost. When the event loop ends (and before the CPU-compatibility relaunch) the primary refuses new files and frees the lock. It applies only with the per-user settings folder: a portable copy (`PhotoCraftData` beside the executable) or `PHOTOCRAFT_CONFIG_DIR` may be shared between users, so those launches run separately. So do `--new-instance` (or `PHOTOCRAFT_NEW_INSTANCE=1`), every `--control` launch, and launches given a per-process option (`--safe-gpu`, `--present-mode`, `--frame-latency`, `--stroke-trace`, `--in-window-menus`, `--automation-*-root`). A `cargo run` while an installed PhotoCraft is running forwards to it: pass `--new-instance` or set `PHOTOCRAFT_CONFIG_DIR`. macOS gets the same behaviour from LaunchServices (`apple_events.rs`). On native Wayland the running window can't bring itself forward (that takes the launcher's `XDG_ACTIVATION_TOKEN`, and winit 0.30 can't activate an existing window with one), so it asks for attention instead and the taskbar highlights it; X11, XWayland and Windows bring it to the front. Code: `apps/photocraft/src/single_instance.rs`. +On Windows and Linux the first PhotoCraft holds an exclusive lock on `instance.lock` in the config directory (0600 on Unix, narrowed on the next start if an earlier version left it readable; the directory is 0700 when single-instance creates it) and listens on a loopback port named in `instance.json` (with a fresh 256-bit token; the file is 0600 on Unix). Inside a Flatpak it listens on a Unix socket instead, `$XDG_RUNTIME_DIR/app//instance.sock` (0600), because Flatpak isolates each sandbox's network namespace, loopback included, unless the app is granted `--share=network`, while that runtime directory is shared by all sandboxes of the app (#1540); the lock, token and protocol are the same. A later launch hands its file arguments there and exits, so files opened from Explorer or a file manager become tabs in the running window (#3708). The primary answers `ok` only once its UI has taken the files; a launch that gets anything else (the primary is starting, hung or closing) keeps retrying the lock for up to 10 s, becoming the primary itself once the old one lets go, and then starts a separate instance, so a file is never acknowledged and lost. When the event loop ends (and before the CPU-compatibility relaunch) the primary refuses new files, removes its `instance.json` (only while it still names this process) and then frees the lock. It applies only with the per-user settings folder: a portable copy (`PhotoCraftData` beside the executable) or `PHOTOCRAFT_CONFIG_DIR` may be shared between users, so those launches run separately. So do `--new-instance` (or `PHOTOCRAFT_NEW_INSTANCE=1`), every `--control` launch, and launches given a per-process option (`--safe-gpu`, `--present-mode`, `--frame-latency`, `--stroke-trace`, `--in-window-menus`, `--automation-*-root`). The CPU-compatibility relaunch is the exception: the `--safe-gpu` it adds itself (it also sets `PHOTOCRAFT_GPU_STARTUP_FAILURE`) doesn't count, so the relaunch takes over as the primary from the launch that failed; a `--safe-gpu` a person passes still runs separately. A `cargo run` while an installed PhotoCraft is running forwards to it: pass `--new-instance` or set `PHOTOCRAFT_CONFIG_DIR`. macOS gets the same behaviour from LaunchServices (`apple_events.rs`). On native Wayland the running window can't bring itself forward (that takes the launcher's `XDG_ACTIVATION_TOKEN`, and winit 0.30 can't activate an existing window with one), so it asks for attention instead and the taskbar highlights it; X11, XWayland and Windows bring it to the front. Code: `apps/photocraft/src/single_instance.rs`. ## Graphics startup and device loss From c559f1c9002dc077b70c1d8435ed8fb814539e76 Mon Sep 17 00:00:00 2001 From: Maciej Malinowski <231036771+webglobecontact-ui@users.noreply.github.com> Date: Sun, 18 Oct 2026 01:12:57 +0200 Subject: [PATCH 21/81] Contributors: add Maciej Malinowski --- contributors/people.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/contributors/people.toml b/contributors/people.toml index e86ee8a01a1..e55cd0f8924 100644 --- a/contributors/people.toml +++ b/contributors/people.toml @@ -358,3 +358,6 @@ sync_github_name = true [people.MMexicann] display_name = "mexicann" + +[people.webglobepl] +real_name = "Maciej Malinowski" From 4033c515a7b4e3bd206488c689a71414998859b7 Mon Sep 17 00:00:00 2001 From: "WebGlobe.pl" Date: Thu, 19 Nov 2026 10:20:44 +0100 Subject: [PATCH 22/81] Export As: test that a panorama previews without transparent bands Since #15449 the dialog is craft-libs' Export As, whose preview paints the transparency checkerboard under the picture only, so a wide export no longer shows checkered bands above and below it. This test keeps it that way on PhotoCraft's side: the texture the dialog shows has the export's proportions (2172 x 724 previews at 3:1), and an opaque image previews fully opaque, with no transparent padding a square preview would add. --- .../src/dialogs/export_dialog/tests.rs | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/crates/ui-egui/src/dialogs/export_dialog/tests.rs b/crates/ui-egui/src/dialogs/export_dialog/tests.rs index 7adebfc1113..599fd127cf8 100644 --- a/crates/ui-egui/src/dialogs/export_dialog/tests.rs +++ b/crates/ui-egui/src/dialogs/export_dialog/tests.rs @@ -1099,3 +1099,29 @@ fn profile_and_metadata_follow_the_existing_exporter() { assert!(kept.windows(b"secret".len()).any(|w| w == b"secret")); assert_eq!(doc, before); } + +/// A panorama's preview is the exported picture alone: the texture Export As shows has the export's +/// proportions, and an opaque image previews opaque. A preview padded to a square would read as +/// transparent bands above and below a wide image, as if the exported file had them. +#[test] +fn a_panorama_previews_at_its_own_proportions_with_no_transparent_bands() { + let mut h = harness(export_app(2172, 724)); + super::open(h.state_mut()).unwrap(); + settle_preview(&mut h); + let [w, h_px] = h.state().export_open.as_ref().expect("Export As is open").texture.as_ref().expect("the preview is shown").size(); + assert!(w > h_px, "the preview is wider than tall: {w} × {h_px}"); + let ratio = w as f64 / h_px as f64; + assert!((ratio - 3.0).abs() < 0.02, "the preview keeps 2172 × 724's proportions: {w} × {h_px}"); + + let doc = Document::with_background( + "panorama", + photocraft_doc::Size::new(2172, 724), + photocraft_doc::ColorMode::Rgb, + photocraft_doc::SampleType::U8, + photocraft_doc::Color::WHITE, + ); + let f = Map::from_iter([("format".into(), json!("jpg")), ("scale".into(), json!(100))]); + let pixels = super::preview_pixels(&default_preview_proxy(&doc, &f).unwrap(), None); + assert_eq!(pixels.rgba.len(), pixels.width * pixels.height * 4); + assert!(pixels.rgba.chunks_exact(4).all(|px| px[3] == 255), "every preview pixel of an opaque image is opaque"); +} From 7ff04a0c0f97a8566aa49a8faedaae81ed7c8e79 Mon Sep 17 00:00:00 2001 From: hnoerenberg Date: Fri, 27 Nov 2026 13:27:31 +0100 Subject: [PATCH 23/81] fix(color): an untagged document is shown in the working space Edit > Color Settings' working RGB had no effect on a document without an embedded profile: composite_profile reads document_profile, whose fallback is the mode's built-in default (sRGB), and the canvas display cache keyed an untagged document with profile hash 0, so changing the working space did not even refresh an open document. ColorState now reads the untagged fallback from Color Settings for the two modes the ticket measures, and the display cache key carries the working space while a document is untagged. Convert to Profile (with and without dither), Image > Mode, the mismatch dialog's "convert to working" answer and Profile Info start from the same profile, so what the canvas shows and what a conversion writes agree. Tagged documents, and CMYK, Lab, Bitmap, Duotone, Indexed and Multichannel documents, resolve as they did. Tests: crates/engine-core/src/color_settings_untagged_display_tests.rs, ten tests; seven failed before the fix and all ten pass after it. The three that already passed pin the tagged-document, CMYK and command-reply guards. Fixes #14224 --- crates/engine-core/src/cmd/color_cmds.rs | 92 ++++- .../src/cmd/color_cmds/profile_dither.rs | 15 +- .../color_settings_untagged_display_tests.rs | 318 ++++++++++++++++++ crates/engine-core/src/display_color.rs | 41 ++- 4 files changed, 439 insertions(+), 27 deletions(-) create mode 100644 crates/engine-core/src/color_settings_untagged_display_tests.rs diff --git a/crates/engine-core/src/cmd/color_cmds.rs b/crates/engine-core/src/cmd/color_cmds.rs index 11e74ac6725..684fb9213e8 100644 --- a/crates/engine-core/src/cmd/color_cmds.rs +++ b/crates/engine-core/src/cmd/color_cmds.rs @@ -3,8 +3,10 @@ //! Colors / Gamut Warning) and the display transform the canvas applies. //! //! Document space: `Document::icc_profile` holds the document's ICC bytes (kept byte-exact -//! from PSD resource 1039 / PNG iCCP / JPEG APP2 / TIFF). `None` means untagged: the working -//! profile of the mode is assumed (sRGB, sGray, the built-in coated CMYK, Lab D50). +//! from PSD resource 1039 / PNG iCCP / JPEG APP2 / TIFF). `None` means untagged: RGB and gray +//! documents are then taken in the working space of Color Settings ([`ColorState::working`], +//! sRGB and the default working gray unless the settings say otherwise, #14224), the other modes +//! in the mode's built-in default (the built-in coated CMYK, Lab D50). //! //! Compositing stays in document space for RGB and gray documents. CMYK and Lab documents are //! composited in sRGB after a per-layer conversion with the built-in profiles (see @@ -111,7 +113,8 @@ impl Policy { /// Edit › Color Settings: working spaces, colour management policies and conversion options. /// Honoured when files are opened ([`ColorExt::open_document`](crate::color_cmds::ColorExt::open_document)), by Image › Mode conversions -/// and by "working" profile specs (Convert to Profile, Proof Setup). +/// and by "working" profile specs (Convert to Profile, Proof Setup). An untagged RGB or Grayscale +/// document is taken in the working space as well, on screen and in conversions (#14224). #[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize)] #[serde(default, rename_all = "camelCase", remote = "Self")] pub struct ColorSettings { @@ -468,6 +471,45 @@ impl ColorState { } } + /// The profile an untagged document is taken in: Color Settings' working space for the two + /// modes #14224 measures, otherwise the mode's built-in default, as [`working_profile`] gives. + pub fn untagged_profile(&self, doc: &Document) -> Arc { + match doc.mode { + ColorMode::Rgb | ColorMode::Grayscale => self.working(doc.mode), + _ => working_profile(doc.mode), + } + } + + /// The document's profile as this session sees it: [`document_profile`], except that an + /// untagged RGB or Grayscale document falls back to Color Settings' working space instead of + /// the mode's built-in default (#14224). A tagged document, and every other mode, resolve + /// exactly as the free function does. + pub fn document_profile(&self, doc: &Document) -> Arc { + embedded_profile(doc).unwrap_or_else(|| self.untagged_profile(doc)) + } + + /// [`composite_profile`] as this session sees it: an untagged document's composite is + /// described by the working space it is shown in (#14224). + pub fn composite_profile(&self, doc: &Document) -> Arc { + match mode_space(doc.mode) { + ColorSpace::Rgb => self.document_profile(doc), + ColorSpace::Gray => { + let p = self.document_profile(doc); + // sGray is a TRC profile, so its RGB view always exists; sRGB is the last resort. + p.gray_as_rgb().or_else(|| Builtin::SGray.profile().gray_as_rgb()).map(Arc::new).unwrap_or_else(|| Arc::new(Builtin::Srgb.profile().clone())) + } + _ => Arc::new(Builtin::Srgb.profile().clone()), + } + } + + /// The working-space spec Color Settings holds for `mode`, with the intent that spec is + /// validated against: the cheap stand-in for [`Self::working`] in the display cache key, + /// which runs on every frame and would otherwise clone the profile's tables (or read its + /// `.icc` file) each time (#14224). + pub fn working_space_spec(&self, mode: ColorMode) -> Option<&str> { + self.settings.working_spec(mode_space(mode)) + } + /// Apply the colour management policy to a document being opened. Returns what happened /// (`action`: kept|converted|discarded|assigned|untagged) and whether to ask the user. /// @@ -776,6 +818,11 @@ pub fn profile_from_bytes(bytes: &Arc>) -> std::result::Result Option> { + doc.icc_profile.as_ref().and_then(|b| profile_from_bytes(b).ok()).filter(|p| p.color_space == mode_space(doc.mode)) +} + /// The document's profile: its embedded profile when it parses and matches the mode, /// otherwise the mode's working profile. pub fn document_profile(doc: &Document) -> Arc { @@ -1059,13 +1106,23 @@ fn paint_colors(p: &mut FxPaint, cc: &mut dyn FnMut(&mut Color)) { /// converted. A Duotone document going to a colour space starts from its ink colours /// ([`ink_duotone`]). The document is tagged with `dst`. pub fn convert_document(doc: &mut Document, dst: &Profile, intent: Intent, bpc: bool) -> Result<()> { + let untagged = working_profile(doc.mode); + convert_document_from(doc, &untagged, dst, intent, bpc) +} + +/// [`convert_document`] with the profile an untagged document is taken in given explicitly: for a +/// session that is Color Settings' working space, which the free function cannot know (#14224). +/// Only that fallback changes: a document with a usable embedded profile converts from it, read +/// after [`ink_duotone`] has turned a Duotone one into sRGB, exactly as [`convert_document`] does. +pub fn convert_document_from(doc: &mut Document, untagged: &Profile, dst: &Profile, intent: Intent, bpc: bool) -> Result<()> { let to_mode = space_mode(dst.color_space).ok_or_else(|| EngineError::Other(format!("cannot convert to a {:?} profile", dst.color_space)))?; if to_mode != ColorMode::Grayscale { ink_duotone(doc); } - let src = document_profile(doc); + let embedded = embedded_profile(doc); + let src: &Profile = embedded.as_deref().unwrap_or(untagged); let from_mode = doc.pixel_format().mode; - let t = Transform::new(&src, dst, intent, bpc).map_err(cms_err)?; + let t = Transform::new(src, dst, intent, bpc).map_err(cms_err)?; let fmt = PixelFormat::new(to_mode, doc.depth, true); crate::image_cmds::for_each_surface(&mut doc.layers, false, &mut |surf, _| { let f = PixelFormat { alpha: surf.format().alpha, ..fmt }; @@ -1192,6 +1249,9 @@ pub fn convert_mode(s: &mut Session, mode: ColorMode, p: &Value) -> Result Result Result { // or doesn't fit the mode is still replaced. let doc = &s.active().ok_or(EngineError::NoDocument)?.doc; let measured = matches!(doc.mode, ColorMode::Rgb | ColorMode::Cmyk | ColorMode::Grayscale | ColorMode::Lab); - let embedded = doc.icc_profile.as_ref().and_then(|b| profile_from_bytes(b).ok()).filter(|p| p.color_space == mode_space(doc.mode)); + let embedded = embedded_profile(doc); let same = measured && embedded.is_some_and(|p| p.same_colors(&dst)); + // The fallback for an untagged document is Color Settings' working space, the space it is + // shown in (#14224); a tagged document keeps the embedded profile, as `document_profile` picks. + let untagged = s.color().untagged_profile(doc); if same && !flatten && !rasterize { return Ok(json!({ "profile": dst.description, "mode": format!("{:?}", doc.mode), "intent": intent.id(), "bpc": bpc, "converted": false })); } @@ -1391,9 +1454,9 @@ fn convert_to_profile(s: &mut Session, p: &Value) -> Result { doc.icc_profile = Some(dst.to_bytes()); Ok(()) } else if dither { - profile_dither::convert(doc, &dst, intent, bpc) + profile_dither::convert(doc, &untagged, &dst, intent, bpc) } else { - convert_document(doc, &dst, intent, bpc) + convert_document_from(doc, &untagged, &dst, intent, bpc) } })?; let d = &s.active().ok_or(EngineError::NoDocument)?.doc; @@ -1410,7 +1473,7 @@ fn profile_info(s: &mut Session, p: &Value) -> Result { Some(profile_json(&prof)) } None => doc.as_deref().map(|d| { - let mut j = profile_json(&document_profile(d)); + let mut j = profile_json(&s.color().document_profile(d)); j["embedded"] = json!(d.icc_profile.is_some()); j }), @@ -1603,7 +1666,10 @@ fn profile_mismatch(s: &mut Session, p: &Value) -> Result { "convert" | "convertToWorking" => { let dst = s.color().working(mode); let (intent, bpc) = (s.color().settings.intent(), s.color().settings.bpc); - s.edit("Convert to Working RGB", |doc, _| convert_document(doc, &dst, intent, bpc))?; + // An untagged document answers this dialog in its working space, not in the built-in + // default (#14224); a tagged one keeps its embedded profile. + let untagged = s.color().untagged_profile(&s.active().ok_or(EngineError::NoDocument)?.doc); + s.edit("Convert to Working RGB", |doc, _| convert_document_from(doc, &untagged, &dst, intent, bpc))?; Ok(json!({"action": "converted", "profile": dst.description})) } "discard" | "off" => { @@ -1996,6 +2062,10 @@ mod assign_profile_enabled_modes_tests; #[path = "../color_settings_presets_tests.rs"] mod color_settings_presets_tests; +#[cfg(test)] +#[path = "../color_settings_untagged_display_tests.rs"] +mod color_settings_untagged_display_tests; + #[cfg(test)] mod settings_tests { use super::*; diff --git a/crates/engine-core/src/cmd/color_cmds/profile_dither.rs b/crates/engine-core/src/cmd/color_cmds/profile_dither.rs index 82874d27fe6..f849a19945d 100644 --- a/crates/engine-core/src/cmd/color_cmds/profile_dither.rs +++ b/crates/engine-core/src/cmd/color_cmds/profile_dither.rs @@ -7,8 +7,8 @@ use photocraft_raster::Tile; use rayon::prelude::*; use super::{ - ColorMode, Document, EngineError, Intent, PixelFormat, Profile, Result, SampleType, Surface, Transform, cms_err, convert_color, convert_document, - convert_layer_colors, convert_style_colors, convert_surface, document_profile, space_mode, + ColorMode, Document, EngineError, Intent, PixelFormat, Profile, Result, SampleType, Surface, Transform, cms_err, convert_color, convert_document_from, + convert_layer_colors, convert_style_colors, convert_surface, embedded_profile, space_mode, }; const TILE_PIXELS: u128 = (TILE_SIZE * TILE_SIZE) as u128; @@ -149,14 +149,17 @@ fn dither_tile(s: &Surface, out: &Surface, t: &Transform, bounds: Rect, c: TileC } /// Preserve ordinary conversion outside opt-in U8, admitting the whole dither edit first. -pub(super) fn convert(doc: &mut Document, dst: &Profile, intent: Intent, bpc: bool) -> Result<()> { - let src = document_profile(doc); +/// `untagged` is the profile an untagged document is taken in: Color Settings' working space, +/// which only the session knows (#14224); a tagged document still converts from its embedded one. +pub(super) fn convert(doc: &mut Document, untagged: &Profile, dst: &Profile, intent: Intent, bpc: bool) -> Result<()> { + let embedded = embedded_profile(doc); + let src: &Profile = embedded.as_deref().unwrap_or(untagged); if doc.depth != SampleType::U8 || src.to_bytes() == dst.to_bytes() || doc.mode == ColorMode::Duotone { - return convert_document(doc, dst, intent, bpc); + return convert_document_from(doc, untagged, dst, intent, bpc); } let to_mode = space_mode(dst.color_space).ok_or_else(|| EngineError::Other(format!("cannot convert to a {:?} profile", dst.color_space)))?; let from = doc.pixel_format().mode; - let t = Transform::new(&src, dst, intent, bpc).map_err(cms_err)?; + let t = Transform::new(src, dst, intent, bpc).map_err(cms_err)?; let format = PixelFormat::new(to_mode, doc.depth, true); let bounds = doc.bounds(); if doc.size.width > i32::MAX as u32 || doc.size.height > i32::MAX as u32 { diff --git a/crates/engine-core/src/color_settings_untagged_display_tests.rs b/crates/engine-core/src/color_settings_untagged_display_tests.rs new file mode 100644 index 00000000000..5053485b5dd --- /dev/null +++ b/crates/engine-core/src/color_settings_untagged_display_tests.rs @@ -0,0 +1,318 @@ +//! #14224: an untagged document is displayed in the working space of Edit > Color Settings, not +//! always in the mode's built-in default, and a change of that space refreshes an open document. +//! +//! The checks are relative: what the canvas must show is the transform our own engine builds for +//! the profile Color Settings names ([`ColorState::working`]) to the monitor the session resolves, +//! evaluated in this file. The reference application's absolute numbers for ProPhoto working RGB +//! are its profile's tables, so they are reported rather than asserted here. +//! +//! Untagged documents only: a tagged one keeps its embedded profile, and CMYK keeps today's +//! display (the issue leaves it unmeasured). + +use super::*; +use photocraft_doc::Size; +use photocraft_geom::Rect; + +use crate::display_color::{DISPLAY_BPC, DISPLAY_INTENT}; + +/// Tolerance of the CPU canvas path against the transform evaluated here (8-bit quantisation plus +/// table evaluation), as in `display_color/tests.rs`. +const TOL: f32 = 2.0; + +/// An untagged RGB document: one 4x4 block per entry of `values`, in columns. +fn untagged_rgb(values: &[[f32; 3]], depth: SampleType) -> Document { + let fmt = PixelFormat::new(ColorMode::Rgb, depth, true); + let mut d = Document::new("t", Size::new(values.len() as u32 * 4, 4), ColorMode::Rgb, depth); + let mut surf = Surface::new(fmt); + for (i, v) in values.iter().enumerate() { + let x = i as i32 * 4; + surf.fill_rect(Rect::new(x, 0, x + 4, 4), &[v[0], v[1], v[2], 1.0]); + } + d.layers.push(Layer::new("pixels", LayerContent::Raster(surf))); + d +} + +/// An RGB document tagged with `tag`. +fn tagged_rgb(tag: &Profile, v: [f32; 3]) -> Document { + let mut d = Document::with_background("t", Size::new(8, 8), ColorMode::Rgb, SampleType::U8, Color::rgb(v[0], v[1], v[2])); + d.icc_profile = Some(tag.to_bytes()); + d +} + +/// An untagged Grayscale document. +fn untagged_gray(v: f32) -> Document { + Document::with_background("g", Size::new(8, 8), ColorMode::Grayscale, SampleType::U8, Color::gray(v)) +} + +/// A two-layer untagged CMYK document, so the composite goes through the compositor. +fn untagged_cmyk(ink: [f32; 4]) -> Document { + let fmt = PixelFormat::new(ColorMode::Cmyk, SampleType::U8, true); + let mut d = Document::new("c", Size::new(8, 8), ColorMode::Cmyk, SampleType::U8); + let mut surf = Surface::new(fmt); + surf.fill_rect(Rect::new(0, 0, 8, 8), &[ink[0], ink[1], ink[2], ink[3], 1.0]); + d.layers.push(Layer::new("ink", LayerContent::Raster(surf))); + d.layers.push(Layer::new("empty", LayerContent::Raster(Surface::new(fmt)))); + d +} + +/// What the CPU canvas shows in the middle of column `i` of `d`, in 8-bit codes. +fn shown(s: &Session, d: &Document, i: usize) -> [f32; 3] { + let buf = photocraft_compose::flatten(d); + let img = s.color().canvas_display(d).unwrap().to_rgba8(&buf); + let x = (i as u32 * 4 + 2).min(d.size.width - 1); + let y = d.size.height / 2; + let k = (y as usize * d.size.width as usize + x as usize) * 4; + [0, 1, 2].map(|c| img.pixels[k + c] as f32) +} + +/// The transform our engine builds from `src` to the session's monitor, evaluated at `v`: what the +/// canvas has to show. Returns 8-bit codes. +fn shown_want(s: &Session, src: &Profile, v: &[f32]) -> [f32; 3] { + let monitor = s.color().monitor(); + let t = Transform::new(src, &monitor, DISPLAY_INTENT, DISPLAY_BPC).unwrap(); + let mut out = [0.0f32; 16]; + t.eval(v, &mut out).unwrap(); + let n = t.outputs(); + [0, 1, 2].map(|c| out[if n == 1 { 0 } else { c }].clamp(0.0, 1.0) * 255.0) +} + +fn close(a: [f32; 3], b: [f32; 3], tol: f32) -> bool { + (0..3).all(|i| (a[i] - b[i]).abs() <= tol) +} + +fn far(a: [f32; 3], b: [f32; 3], d: f32) -> bool { + (0..3).any(|i| (a[i] - b[i]).abs() >= d) +} + +fn raw_codes(v: &[f32]) -> [f32; 3] { + [0, 1, 2].map(|c| v[c] * 255.0) +} + +/// The document's description as `edit.profileInfo` reports it. +fn reported(s: &mut Session) -> Value { + s.execute("edit.profileInfo", json!({})).unwrap()["profile"].clone() +} + +#[test] +fn an_untagged_rgb_document_is_displayed_in_the_working_space() { + let mut s = crate::session(); + // The ticket's fixture: 200,30,30 and 30,60,200, profile removed. + let values = [[200.0 / 255.0, 30.0 / 255.0, 30.0 / 255.0], [30.0 / 255.0, 60.0 / 255.0, 200.0 / 255.0]]; + let d = untagged_rgb(&values, SampleType::U8); + // Unchanged with the default settings: sRGB working RGB means the values go to the screen. + let first = s.color().canvas_display(&d).unwrap(); + assert_eq!(first.source.description, Builtin::Srgb.profile().description, "the default working space is sRGB"); + assert!(first.is_identity(), "sRGB on an sRGB monitor still costs nothing"); + s.execute("edit.colorSettings", json!({"workingRgb": "prophoto-compat"})).unwrap(); + let working = s.color().working(ColorMode::Rgb); + assert_eq!(working.description, Builtin::ProPhotoCompat.profile().description, "the setting resolved"); + let cd = s.color().canvas_display(&d).unwrap(); + assert_eq!(cd.source.description, working.description, "an untagged document is shown in Color Settings' working RGB"); + for (i, v) in values.iter().enumerate() { + let got = shown(&s, &d, i); + let want = shown_want(&s, &working, v); + assert!(close(got, want, TOL), "column {i}: canvas {got:?} vs the working space's transform {want:?}"); + assert!(far(got, raw_codes(v), 8.0), "column {i} is still shown as its raw values: {got:?}"); + } + // The reference application's measured numbers for this fixture, tolerance 2 as the ticket + // states them: they match what our own ProPhoto-compatible profile computes. + assert!(close(shown(&s, &d, 0), [255.0, 0.0, 34.0], 2.0), "200,30,30: {:?}", shown(&s, &d, 0)); + assert!(close(shown(&s, &d, 1), [0.0, 82.0, 223.0], 2.0), "30,60,200: {:?}", shown(&s, &d, 1)); +} + +#[test] +fn changing_the_working_space_refreshes_an_open_untagged_document() { + let mut s = crate::session(); + let v = [0.8, 0.12, 0.12]; + let d = untagged_rgb(&[v], SampleType::U8); + let before = s.color().canvas_display(&d).unwrap(); + let signature = s.color().display_signature(&d); + s.execute("edit.colorSettings", json!({"workingRgb": "adobe-rgb-compat"})).unwrap(); + let after = s.color().canvas_display(&d).unwrap(); + assert_eq!(after.source.description, s.color().working(ColorMode::Rgb).description); + assert!(!Arc::ptr_eq(&before, &after), "the display cache handed back the entry made for the old working space"); + assert_ne!(before.key, after.key, "the cache entry and its signature have to move with the working space"); + assert_ne!(signature, s.color().display_signature(&d), "the canvas reloads the document without reopening it"); + assert_eq!(before.monitor.content_hash(), after.monitor.content_hash(), "only the working space moved"); + assert!(close(shown(&s, &d, 0), shown_want(&s, &after.source, &v), TOL), "{:?}", shown(&s, &d, 0)); + // Back to the default: the same entry as before, so the key follows the setting and not a counter. + s.execute("edit.colorSettings", json!({"workingRgb": "srgb"})).unwrap(); + let back = s.color().canvas_display(&d).unwrap(); + assert!(back.is_identity()); + assert_eq!(back.key, before.key, "the same settings give the same display"); +} + +#[test] +fn an_untagged_document_stays_untagged_and_keeps_its_pixels() { + let mut s = crate::session(); + let v = [200.0 / 255.0, 30.0 / 255.0, 30.0 / 255.0]; + s.open_document(untagged_rgb(&[v], SampleType::U8), None); + let before = reported(&mut s); + assert_eq!(before["embedded"], json!(false)); + let sample = |s: &Session| s.active().unwrap().doc.layers[0].surface().unwrap().pixel(1, 1); + let pixels = sample(&s); + s.execute("edit.colorSettings", json!({"workingRgb": "prophoto-compat"})).unwrap(); + let after = reported(&mut s); + assert_eq!(after["embedded"], json!(false), "the working space is not written into the document"); + assert_eq!(after["description"], Builtin::ProPhotoCompat.profile().description, "the document is taken in the working space"); + assert_eq!(sample(&s), pixels, "only the interpretation changes, not the stored samples"); + let d = &s.active().unwrap().doc; + assert!(close(shown(&s, d, 0), shown_want(&s, &s.color().working(ColorMode::Rgb), &v), TOL), "{:?}", shown(&s, d, 0)); +} + +#[test] +fn a_tagged_document_keeps_its_embedded_profile() { + let mut s = crate::session(); + let v = [0.4, 0.6, 0.2]; + for tag in [Builtin::Srgb, Builtin::AdobeRgbCompat, Builtin::DisplayP3] { + let d = tagged_rgb(tag.profile(), v); + let before = s.color().canvas_display(&d).unwrap(); + s.execute("edit.colorSettings", json!({"workingRgb": "prophoto-compat"})).unwrap(); + let cd = s.color().canvas_display(&d).unwrap(); + assert_eq!(cd.source.content_hash(), tag.profile().content_hash(), "{} was replaced by the working space", tag.description()); + assert_eq!(cd.key, before.key, "a tagged document's display does not move with the setting"); + assert!(close(shown(&s, &d, 0), shown_want(&s, tag.profile(), &v), TOL), "{}: {:?}", tag.description(), shown(&s, &d, 0)); + s.execute("edit.colorSettings", json!({"workingRgb": "srgb"})).unwrap(); + } + // The command read-back of a tagged document is its own profile. + s.open_document(tagged_rgb(Builtin::AdobeRgbCompat.profile(), v), None); + s.execute("edit.colorSettings", json!({"workingRgb": "prophoto-compat"})).unwrap(); + let info = reported(&mut s); + assert_eq!(info["embedded"], json!(true)); + assert_eq!(info["description"], Builtin::AdobeRgbCompat.profile().description); +} + +#[test] +fn an_untagged_grayscale_document_follows_the_working_gray() { + let mut s = crate::session(); + let d = untagged_gray(0.3); + let first = s.color().canvas_display(&d).unwrap(); + // The default working Gray is the built-in default, so nothing moves without a setting. + assert_eq!(first.source.content_hash(), working_profile(ColorMode::Grayscale).gray_as_rgb().unwrap().content_hash()); + s.execute("edit.colorSettings", json!({"workingGray": "gray-gamma-2.2"})).unwrap(); + let working = s.color().working(ColorMode::Grayscale); + assert_eq!(working.description, Builtin::GrayGamma22.profile().description, "the setting resolved"); + let cd = s.color().canvas_display(&d).unwrap(); + assert_eq!(cd.source.content_hash(), working.gray_as_rgb().unwrap().content_hash(), "an untagged gray document is shown in the working Gray"); + assert_ne!(cd.key, first.key, "and its display cache entry re-keys"); + assert!(close(shown(&s, &d, 0), shown_want(&s, &cd.source, &[0.3, 0.3, 0.3]), TOL), "{:?}", shown(&s, &d, 0)); +} + +#[test] +fn an_untagged_cmyk_document_keeps_todays_display() { + let mut s = crate::session(); + let ink = [0.1, 0.6, 0.7, 0.05]; + let d = untagged_cmyk(ink); + let before = shown(&s, &d, 0); + let entry = s.color().canvas_display(&d).unwrap(); + s.execute("edit.colorSettings", json!({"workingCmyk": "coated-fogra39"})).unwrap(); + let cd = s.color().canvas_display(&d).unwrap(); + assert_eq!(cd.source.description, Builtin::Srgb.profile().description, "CMYK is not measured and keeps its sRGB composite"); + assert_eq!(cd.key, entry.key, "the working CMYK does not re-key an untagged CMYK document"); + assert!(close(shown(&s, &d, 0), before, 0.6), "its inks are still read through the built-in coated profile: {before:?} -> {:?}", shown(&s, &d, 0)); + // And the profile it is taken in stays the mode's built-in default even though the setting + // now names another one: only RGB and Grayscale follow Color Settings here. + assert_ne!(s.color().working(ColorMode::Cmyk).content_hash(), working_profile(ColorMode::Cmyk).content_hash(), "the setting really moved"); + assert_eq!( + s.color().document_profile(&d).content_hash(), + working_profile(ColorMode::Cmyk).content_hash(), + "an untagged CMYK document keeps the mode default" + ); +} + +#[test] +fn the_same_rule_holds_at_every_depth() { + let mut s = crate::session(); + let v = [0.8, 0.12, 0.12]; + s.execute("edit.colorSettings", json!({"workingRgb": "prophoto-compat"})).unwrap(); + let working = s.color().working(ColorMode::Rgb); + for depth in [SampleType::U8, SampleType::U16, SampleType::F32] { + let d = untagged_rgb(&[v], depth); + let cd = s.color().canvas_display(&d).unwrap(); + assert_eq!(cd.source.description, working.description, "{depth:?}"); + let got = shown(&s, &d, 0); + let want = shown_want(&s, &working, &v); + let tol = if depth == SampleType::U8 { TOL } else { 1.0 }; + assert!(close(got, want, tol), "{depth:?}: {got:?} vs {want:?}"); + } +} + +#[test] +fn a_conversion_starts_from_the_working_space() { + let mut s = crate::session(); + let v = [200.0 / 255.0, 30.0 / 255.0, 30.0 / 255.0]; + let filled = [v[0], v[1], v[2], 1.0]; + s.open_document(untagged_rgb(&[v], SampleType::U8), None); + s.execute("edit.colorSettings", json!({"workingRgb": "prophoto-compat"})).unwrap(); + let working = s.color().working(ColorMode::Rgb); + let srgb = Builtin::Srgb.profile().clone(); + // What Convert to Profile has to write: the working space's own transform of the stored + // samples, clamped the way the sample write clamps them (this colour is outside sRGB). + let clamp3 = |o: &[f32; 16]| [o[0].clamp(0.0, 1.0), o[1].clamp(0.0, 1.0), o[2].clamp(0.0, 1.0)]; + let mut out = [0.0f32; 16]; + Transform::new(&working, &srgb, Intent::RelativeColorimetric, false).unwrap().eval(&v, &mut out).unwrap(); + let want = clamp3(&out); + let mut built_in = [0.0f32; 16]; + let default = working_profile(ColorMode::Rgb); + Transform::new(&default, &srgb, Intent::RelativeColorimetric, false).unwrap().eval(&v, &mut built_in).unwrap(); + assert!( + want.iter().zip(clamp3(&built_in).iter()).any(|(a, b)| (a - b).abs() > 8.0 / 255.0), + "the fixture must tell the working space apart from the built-in default: {want:?} vs {built_in:?}" + ); + for dither in [false, true] { + let r = s.execute("edit.convertToProfile", json!({"profile": "srgb", "intent": "relative", "bpc": false, "dither": dither})).unwrap(); + assert_eq!(r["converted"], json!(true), "dither {dither}"); + let px = s.active().unwrap().doc.layers[0].surface().unwrap().pixel(1, 1); + assert!((0..3).all(|c| (px[c] - want[c]).abs() <= 2.0 / 255.0), "dither {dither}: {px:?} vs the working space's own conversion {want:?}"); + assert_eq!(reported(&mut s)["description"], srgb.description, "tagged with the destination"); + // Back to the untagged start for the second round. + s.execute("edit.assignProfile", json!({"profile": "none"})).unwrap(); + s.edit("reset", |doc, _| { + doc.layers[0].surface_mut().unwrap().fill_rect(Rect::new(0, 0, 4, 4), &filled); + Ok(()) + }) + .unwrap(); + } +} + +#[test] +fn a_mode_change_starts_from_the_working_space() { + let mut s = crate::session(); + let v = [0.8, 0.12, 0.12]; + s.open_document(untagged_rgb(&[v], SampleType::U8), None); + s.execute("edit.colorSettings", json!({"workingRgb": "prophoto-compat", "workingGray": "gray-gamma-2.2"})).unwrap(); + let src = s.color().working(ColorMode::Rgb); + let dst = s.color().working(ColorMode::Grayscale); + let t = Transform::new(&src, &dst, Intent::RelativeColorimetric, false).unwrap(); + let from_built_in = { + let built_in = working_profile(ColorMode::Rgb); + Transform::new(&built_in, &dst, Intent::RelativeColorimetric, false).unwrap() + }; + let mut out = [0.0f32; 16]; + let mut other = [0.0f32; 16]; + t.eval(&v, &mut out).unwrap(); + from_built_in.eval(&v, &mut other).unwrap(); + assert!((out[0] - other[0]).abs() > 1.0 / 255.0, "the fixture must tell the two sources apart: {out:?} vs {other:?}"); + s.execute("image.mode.grayscale", json!({"intent": "relative", "bpc": false})).unwrap(); + let px = s.active().unwrap().doc.layers[0].surface().unwrap().pixel(1, 1); + assert!((px[0] - out[0]).abs() <= 2.0 / 255.0, "the mode change read the built-in default, not the working RGB: {px:?} vs {out:?}"); +} + +#[test] +fn the_profile_commands_answer_the_same_for_a_tagged_document() { + let mut replies = Vec::new(); + for working in ["srgb", "prophoto-compat"] { + let mut s = crate::session(); + s.open_document(tagged_rgb(Builtin::AdobeRgbCompat.profile(), [0.4, 0.6, 0.2]), None); + s.execute("edit.colorSettings", json!({"workingRgb": working})).unwrap(); + replies.push(json!({ + "info": reported(&mut s), + "assign": s.execute("edit.assignProfile", json!({"profile": "display-p3"})).unwrap(), + "info_after_assign": reported(&mut s), + "convert": s.execute("edit.convertToProfile", json!({"profile": "srgb", "intent": "relative", "bpc": false})).unwrap(), + "mode": s.execute("image.mode.grayscale", json!({"intent": "relative", "bpc": false})).unwrap(), + "info_after_mode": reported(&mut s), + })); + } + assert_eq!(replies[0], replies[1], "a tagged document's replies must not depend on the working space"); +} diff --git a/crates/engine-core/src/display_color.rs b/crates/engine-core/src/display_color.rs index b0d5b65b554..de10d463c13 100644 --- a/crates/engine-core/src/display_color.rs +++ b/crates/engine-core/src/display_color.rs @@ -2,9 +2,10 @@ //! monitor profile, on the GPU canvas (matrix/shaper or display 3D LUT) and the CPU canvas //! (an 8-bit transform of the composite). //! -//! * The composite is in [`composite_profile`] (the document profile for RGB, its gray curve as +//! * The composite is in `composite_profile` (the document profile for RGB, its gray curve as //! RGB for gray documents, sRGB for CMYK — read through the document's CMYK profile, see -//! `photocraft_color::convert::CmykSpace` — and Lab). +//! `photocraft_color::convert::CmykSpace` — and Lab). An untagged document has no profile of +//! its own, and an untagged RGB or gray one is taken in Color Settings' working space (#14224). //! * Linear composites (EXR/HDR, linear profiles) are stored in the 8-bit canvas texture //! sRGB-encoded ([`CanvasDisplay::encode_srgb`]) so shadows keep their precision; the display //! source profile is then the same primaries with the sRGB curve. @@ -14,19 +15,21 @@ //! * When the source and the monitor match (sRGB documents on an sRGB display, the common //! case) the transform is the identity and nothing is applied on either path. //! -//! Results are cached per (document profile, mode, monitor profile); the rendering intent is -//! relative colorimetric with black point compensation, as for Photoshop's monitor display. +//! Results are cached per (document profile, mode, monitor profile) — plus the working space while +//! the document is untagged, so a Color Settings change re-keys it (#14224); the rendering intent +//! is relative colorimetric with black point compensation, as for Photoshop's monitor display. use std::borrow::Cow; use std::collections::HashMap; use std::sync::{Arc, Mutex, OnceLock}; use craft_cms::{Builtin, ColorSpace, Curve, Intent, Profile, Transform}; +use photocraft_color::ColorMode; use photocraft_compose::Buffer; use photocraft_doc::Document; use photocraft_raster::Rgba8Image; -use crate::color_cmds::{ColorState, composite_profile, mode_space, profile_from_bytes, resolve_profile}; +use crate::color_cmds::{ColorState, mode_space, profile_from_bytes, resolve_profile}; use crate::{EngineError, Result}; /// Display intent and black point compensation of the monitor transform. @@ -261,11 +264,15 @@ struct MonitorEntry { status: MonitorStatus, } +/// The canvas display cache key: colour space, document profile, monitor profile, and while the +/// document is untagged the Color Settings working space it is shown in (#14224). +type CanvasKey = (ColorSpace, u64, u64, Option); + /// Caches of [`ColorState`] for the display (monitor profiles per display, per-document displays). #[derive(Default)] pub struct DisplayCaches { monitor: Mutex, MonitorEntry>>, - canvas: Mutex>>, + canvas: Mutex>>, } impl ColorState { @@ -407,16 +414,30 @@ impl ColorState { } /// How the canvas shows `doc` on `display` (cached per document profile, mode and monitor - /// profile). + /// profile; for an untagged document also per Color Settings' working space, which is the + /// profile it is shown in). pub fn canvas_display_for(&self, doc: &Document, display: Option) -> Result> { let space = mode_space(doc.mode); - let doc_hash = doc.icc_profile.as_ref().and_then(|b| profile_from_bytes(b).ok()).filter(|p| p.color_space == space).map_or(0, |p| p.content_hash()); + let embedded = crate::color_cmds::embedded_profile(doc); + // An untagged RGB or Grayscale document is displayed in Color Settings' working space + // (#14224), so the setting joins its key: the profile hash 0 that an untagged document + // used before did not move when the working space did, and an open document kept the + // display it was first shown with. The setting is hashed rather than the profile it + // resolves to, because this runs on every frame and `working` would clone the profile's + // tables (or read its `.icc` file) each time. Every other mode keeps the built-in default + // and stays keyed 0. + let working = if embedded.is_none() && matches!(doc.mode, ColorMode::Rgb | ColorMode::Grayscale) { + Some(hash_of((self.working_space_spec(doc.mode), self.settings.intent().id()))) + } else { + None + }; + let doc_hash = embedded.map_or(0, |p| p.content_hash()); let monitor = self.monitor_for(display); - let key = (space, doc_hash, monitor.content_hash()); + let key: CanvasKey = (space, doc_hash, monitor.content_hash(), working); if let Some(d) = self.display.canvas.lock().unwrap_or_else(|e| e.into_inner()).get(&key) { return Ok(d.clone()); } - let composite = composite_profile(doc); + let composite = self.composite_profile(doc); let encode_srgb = is_linear_rgb(&composite); let source = if encode_srgb { Arc::new(srgb_curve_twin(&composite)) } else { composite }; let transform = if source.content_hash() == monitor.content_hash() { From a6359b1d716c6f3d688c44e53af1405f7f32d34b Mon Sep 17 00:00:00 2001 From: hnoerenberg Date: Fri, 27 Nov 2026 15:21:06 +0100 Subject: [PATCH 24/81] fix(color): the session's space reaches the places that move content in The first commit on this item switched the display path and the four colour commands, but left call sites that hold a Session resolving an untagged document through the free document_profile / composite_profile. A layer copied, cloned or unpacked into an untagged document therefore landed as raw numbers while the same canvas showed it in Color Settings' working space; the gamut mask, Color Range > Out of Gamut, Replace Color's Lab bounds, the Indexed matte colour, the mismatch dialog's "convert to working" answer and the Indexed to RGB reply carried the same split. They now read the session's profile, each with a test that was red against the previous head. --- .../cmd/adjust_cmds/replace_color_range.rs | 9 +- crates/engine-core/src/cmd/color_cmds.rs | 35 +++++- crates/engine-core/src/cmd/layer_copy_cmds.rs | 8 +- crates/engine-core/src/cmd/mode_cmds.rs | 4 +- crates/engine-core/src/cmd/selection_cmds.rs | 5 +- .../engine-core/src/cmd/smart_cmds/unpack.rs | 5 +- .../color_settings_untagged_display_tests.rs | 107 +++++++++++++++++- crates/engine-paint/src/cmd/retouch_cmds.rs | 3 + .../src/cmd/retouch_cmds/clone_sampling.rs | 6 +- .../untagged_working_space_tests.rs | 43 +++++++ crates/ui-egui/src/dialogs/color_range_ui.rs | 2 +- 11 files changed, 206 insertions(+), 21 deletions(-) create mode 100644 crates/engine-paint/src/cmd/retouch_cmds/untagged_working_space_tests.rs diff --git a/crates/engine-core/src/cmd/adjust_cmds/replace_color_range.rs b/crates/engine-core/src/cmd/adjust_cmds/replace_color_range.rs index 7191078c796..65ed998121e 100644 --- a/crates/engine-core/src/cmd/adjust_cmds/replace_color_range.rs +++ b/crates/engine-core/src/cmd/adjust_cmds/replace_color_range.rs @@ -7,6 +7,7 @@ use photocraft_raster::Surface; use serde_json::Value; use super::{bad, num}; +use crate::color_cmds::ColorExt; use crate::{EngineError, Result, Session}; const CMD: &str = "image.adjustments.replaceColor"; @@ -107,8 +108,12 @@ pub(super) fn apply(s: &mut Session, p: &Value) -> Result> { if format.mode != st.doc.mode { return Err(bad(CMD, "pixel layout does not match the document profile")); } - let transform = craft_cms::cached(&crate::color_cmds::document_profile(&st.doc), Builtin::LabD50.profile(), TransformOptions::default()) - .map_err(|e| bad(CMD, format!("Lab colour transform: {e}")))?; + // The layer's samples live in the space the session shows the document in, so an untagged + // document is read in its working space here too (#14224): Lab bounds that Replace Color works + // in, and the Gamut Warning marks, agree. + let source = s.color().document_profile(&st.doc); + let transform = + craft_cms::cached(&source, Builtin::LabD50.profile(), TransformOptions::default()).map_err(|e| bad(CMD, format!("Lab colour transform: {e}")))?; if transform.inputs() != format.mode.color_channels() || transform.outputs() != 3 || format.channels() != transform.inputs() + usize::from(format.alpha) { return Err(bad(CMD, "unsupported Lab colour-transform layout")); } diff --git a/crates/engine-core/src/cmd/color_cmds.rs b/crates/engine-core/src/cmd/color_cmds.rs index 684fb9213e8..e27569c1f89 100644 --- a/crates/engine-core/src/cmd/color_cmds.rs +++ b/crates/engine-core/src/cmd/color_cmds.rs @@ -510,6 +510,13 @@ impl ColorState { self.settings.working_spec(mode_space(mode)) } + /// [`gamut_mask`] as this session sees `doc`: the composite is judged in the profile the canvas + /// shows it in, so the Gamut Warning count and Color Range › Out of Gamut agree with the pixels + /// the canvas marks (#14224). + pub fn gamut_mask(&self, doc: &Document, setup: &ProofSetup, threshold: f32) -> Result<(Vec, usize)> { + gamut_mask_against(doc, &self.composite_profile(doc), setup, threshold) + } + /// Apply the colour management policy to a document being opened. Returns what happened /// (`action`: kept|converted|discarded|assigned|untagged) and whether to ask the user. /// @@ -591,7 +598,7 @@ impl ColorState { } let working = self.working(doc.mode); let policy = self.settings.policy(doc.mode); - let embedded = doc.icc_profile.as_ref().and_then(|b| profile_from_bytes(b).ok()).filter(|p| p.color_space == space); + let embedded = embedded_profile(doc); match embedded { Some(emb) => { let linear_hdr = @@ -621,7 +628,13 @@ impl ColorState { pub fn resolve_open(&self, doc: &mut Document, action: &str) -> Result<()> { match action { "preserve" | "useEmbedded" => Ok(()), - "convert" | "convertToWorking" => convert_document(doc, &self.working(doc.mode), self.settings.intent(), self.settings.bpc), + // An untagged document already lives in the working space, so converting it to that + // space keeps its samples and only tags it (#14224); a tagged one converts from its + // embedded profile as before. + "convert" | "convertToWorking" => { + let untagged = self.untagged_profile(doc); + convert_document_from(doc, &untagged, &self.working(doc.mode), self.settings.intent(), self.settings.bpc) + } "discard" | "off" => { doc.icc_profile = None; Ok(()) @@ -1235,7 +1248,10 @@ pub fn convert_mode(s: &mut Session, mode: ColorMode, p: &Value) -> Result s.color().resolve(spec, Some(doc), Some(mode))?, - None if preserve_indexed_rgb => document_profile(doc), + // Indexed → RGB keeps its samples and its ICC bytes, so the space of the document that + // results is its embedded profile, or the working space of Color Settings when it carries + // none - the same space the canvas shows it in (#14224). + None if preserve_indexed_rgb => embedded_profile(doc).unwrap_or_else(|| s.color().working(ColorMode::Rgb)), None => s.color().working(mode), }; if space_mode(dst.color_space) @@ -1268,9 +1284,16 @@ pub fn convert_mode(s: &mut Session, mode: ColorMode, p: &Value) -> Result Result<(Vec, usize)> { - let check = GamutCheck::new(&composite_profile(doc), &setup.profile, threshold).map_err(cms_err)?; + gamut_mask_against(doc, &composite_profile(doc), setup, threshold) +} + +fn gamut_mask_against(doc: &Document, source: &Profile, setup: &ProofSetup, threshold: f32) -> Result<(Vec, usize)> { + let check = GamutCheck::new(source, &setup.profile, threshold).map_err(cms_err)?; let buf = photocraft_compose::flatten(doc); let mut mask = vec![0u8; buf.px.len()]; let count = check.mask_rgba(&buf.px, &mut mask).map_err(cms_err)?; @@ -1522,7 +1545,7 @@ fn gamut_warning(s: &mut Session, p: &Value) -> Result { if let Some(spec) = p.get("profile").and_then(Value::as_str) { setup.profile = resolve_profile(spec, Some(&doc), Some(ColorMode::Cmyk))?; } - let (_, count) = gamut_mask(&doc, &setup, threshold)?; + let (_, count) = s.color().gamut_mask(&doc, &setup, threshold)?; let total = doc.size.width as usize * doc.size.height as usize; Ok(json!({ "on": on, "profile": setup.profile.description, "threshold": threshold, "outOfGamut": count, "fraction": count as f64 / total.max(1) as f64 })) } diff --git a/crates/engine-core/src/cmd/layer_copy_cmds.rs b/crates/engine-core/src/cmd/layer_copy_cmds.rs index 176518f937b..e1c9883270b 100644 --- a/crates/engine-core/src/cmd/layer_copy_cmds.rs +++ b/crates/engine-core/src/cmd/layer_copy_cmds.rs @@ -112,8 +112,12 @@ pub(crate) fn adapt_copies(s: &Session, copies: &mut Document, dest: &Document) } } if (copies.mode, &copies.icc_profile) != (dest.mode, &dest.icc_profile) { - let profile = crate::color_cmds::document_profile(dest); - crate::color_cmds::convert_document(copies, &profile, s.color().settings.intent(), s.color().settings.bpc)?; + // Both sides are read as the session reads them: an untagged document, source or + // destination, is taken in its working space (#14224), so the copies keep their look on + // the destination's canvas instead of landing as raw numbers. + let untagged = s.color().untagged_profile(&copies); + let profile = s.color().document_profile(dest); + crate::color_cmds::convert_document_from(copies, &untagged, &profile, s.color().settings.intent(), s.color().settings.bpc)?; } if copies.depth != dest.depth { crate::image_cmds::for_each_surface(&mut copies.layers, true, &mut |surf, _| { diff --git a/crates/engine-core/src/cmd/mode_cmds.rs b/crates/engine-core/src/cmd/mode_cmds.rs index 64c074d1dd8..5dc7c71d06c 100644 --- a/crates/engine-core/src/cmd/mode_cmds.rs +++ b/crates/engine-core/src/cmd/mode_cmds.rs @@ -357,7 +357,9 @@ fn parse_dither(s: &str) -> Option { /// grayscale output is a scalar sample replicated into the flattened RGB view. fn working_matte_color(s: &Session, doc: &Document, color: [f32; 4]) -> Result<[f32; 3]> { let destination = match crate::color_cmds::mode_space(doc.mode) { - ColorSpace::Rgb | ColorSpace::Gray => crate::color_cmds::document_profile(doc), + // An untagged RGB or Grayscale document is taken in Color Settings' working space (#14224), + // which is where the tool colour above already lives. + ColorSpace::Rgb | ColorSpace::Gray => s.color().document_profile(doc), // CMYK and Lab flatten through the compositor's sRGB view on the pinned main path. _ => crate::color_cmds::composite_profile(doc), }; diff --git a/crates/engine-core/src/cmd/selection_cmds.rs b/crates/engine-core/src/cmd/selection_cmds.rs index 388a8e6f641..d173edc50dc 100644 --- a/crates/engine-core/src/cmd/selection_cmds.rs +++ b/crates/engine-core/src/cmd/selection_cmds.rs @@ -425,10 +425,11 @@ fn color_range(s: &mut Session, p: &Value) -> Result { } "outOfGamut" => { // Pixels the current proof setup (View › Proof Setup) can't reproduce, as the gamut - // warning shows them: judged on the composite. + // warning shows them: judged on the composite, in the space the canvas shows it in + // (#14224), so the selection marks the same pixels the warning marks. let d = s.active().ok_or(EngineError::NoDocument)?; let pv = s.color().proof(d.doc.id); - let (m, _) = crate::color_cmds::gamut_mask(&d.doc, &pv.setup, pv.gamut_threshold)?; + let (m, _) = s.color().gamut_mask(&d.doc, &pv.setup, pv.gamut_threshold)?; (d.doc.bounds(), m.iter().map(|v| f32::from(*v) / 255.0).collect()) } other => { diff --git a/crates/engine-core/src/cmd/smart_cmds/unpack.rs b/crates/engine-core/src/cmd/smart_cmds/unpack.rs index a0bc6c2e737..a472286c6bb 100644 --- a/crates/engine-core/src/cmd/smart_cmds/unpack.rs +++ b/crates/engine-core/src/cmd/smart_cmds/unpack.rs @@ -25,7 +25,10 @@ fn contents(s: &Session, doc: &Document, sm: &SmartObject, intent: Intent, bpc: let mut src = decode_source(&name, &bytes)?; let mode = doc.pixel_format().mode; if src.pixel_format().mode != mode || src.icc_profile != doc.icc_profile { - crate::color_cmds::convert_document(&mut src, &crate::color_cmds::document_profile(doc), intent, bpc)?; + // An untagged document is taken in its working space (#14224): the contents are re-encoded + // into that space so they keep their look once they are layers on this canvas. + let destination = s.color().document_profile(doc); + crate::color_cmds::convert_document(&mut src, &destination, intent, bpc)?; if src.pixel_format().mode != mode { return Err(other(format!("can't convert the smart object's contents to the document's {:?} mode", doc.mode))); } diff --git a/crates/engine-core/src/color_settings_untagged_display_tests.rs b/crates/engine-core/src/color_settings_untagged_display_tests.rs index 5053485b5dd..7760508dc50 100644 --- a/crates/engine-core/src/color_settings_untagged_display_tests.rs +++ b/crates/engine-core/src/color_settings_untagged_display_tests.rs @@ -106,6 +106,8 @@ fn an_untagged_rgb_document_is_displayed_in_the_working_space() { s.execute("edit.colorSettings", json!({"workingRgb": "prophoto-compat"})).unwrap(); let working = s.color().working(ColorMode::Rgb); assert_eq!(working.description, Builtin::ProPhotoCompat.profile().description, "the setting resolved"); + // The monitor side of the comparison: with no platform profile the canvas is shown on sRGB. + assert_eq!(s.color().monitor().description, Builtin::Srgb.profile().description, "the test monitor"); let cd = s.color().canvas_display(&d).unwrap(); assert_eq!(cd.source.description, working.description, "an untagged document is shown in Color Settings' working RGB"); for (i, v) in values.iter().enumerate() { @@ -114,10 +116,6 @@ fn an_untagged_rgb_document_is_displayed_in_the_working_space() { assert!(close(got, want, TOL), "column {i}: canvas {got:?} vs the working space's transform {want:?}"); assert!(far(got, raw_codes(v), 8.0), "column {i} is still shown as its raw values: {got:?}"); } - // The reference application's measured numbers for this fixture, tolerance 2 as the ticket - // states them: they match what our own ProPhoto-compatible profile computes. - assert!(close(shown(&s, &d, 0), [255.0, 0.0, 34.0], 2.0), "200,30,30: {:?}", shown(&s, &d, 0)); - assert!(close(shown(&s, &d, 1), [0.0, 82.0, 223.0], 2.0), "30,60,200: {:?}", shown(&s, &d, 1)); } #[test] @@ -298,6 +296,107 @@ fn a_mode_change_starts_from_the_working_space() { assert!((px[0] - out[0]).abs() <= 2.0 / 255.0, "the mode change read the built-in default, not the working RGB: {px:?} vs {out:?}"); } +#[test] +fn a_layer_copied_into_an_untagged_document_lands_in_its_space() { + let mut s = crate::session(); + // A: untagged, opened under the default settings so nothing is assigned to it on the way in. + s.open_document(untagged_rgb(&[[0.5, 0.5, 0.5]], SampleType::U8), None); + // B: the same shape tagged sRGB, with a saturated block. + let v = [0.9f32, 0.2, 0.2]; + s.open_document(tagged_rgb(Builtin::Srgb.profile(), v), None); + s.execute("edit.colorSettings", json!({"workingRgb": "prophoto-compat"})).unwrap(); + let block = s.active().unwrap().active_layer.unwrap(); + let r = s.execute("layer.copyToDocument", json!({"document": 0, "source": 1, "layers": [block.0]})).unwrap(); + let id = photocraft_doc::LayerId(r["layers"][0].as_u64().unwrap()); + let a = &s.documents()[0].doc; + assert!(a.icc_profile.is_none(), "the destination is still untagged"); + let px = a.layer(id).unwrap().surface().unwrap().pixel(1, 1); + // It has to keep its look, so it is re-encoded into the space A is shown in. + let mut out = [0.0f32; 16]; + let working = s.color().working(ColorMode::Rgb); + Transform::new(Builtin::Srgb.profile(), &working, s.color().settings.intent(), s.color().settings.bpc).unwrap().eval(&v, &mut out).unwrap(); + let want = [out[0], out[1], out[2]]; + assert!((0..3).all(|c| (px[c] - want[c]).abs() <= 2.0 / 255.0), "the pasted block landed as {px:?}, not in the space A is shown in ({want:?})"); + assert!((0..3).any(|c| (px[c] - v[c]).abs() > 8.0 / 255.0), "the fixture must tell a raw copy apart from a re-encoded one: {px:?} vs {v:?}"); +} + +#[test] +fn the_gamut_count_is_judged_in_the_space_the_canvas_marks_in() { + let mut s = crate::session(); + // Six colours that straddle the coated-CMYK gamut: read as sRGB some of them are inside it, + // read as ProPhoto the same samples are far outside. + let colours = [[0.95f32, 0.05, 0.05], [0.8, 0.3, 0.3], [0.6, 0.1, 0.1], [0.3, 0.85, 0.3], [0.1, 0.4, 0.9], [0.45, 0.45, 0.95]]; + s.open_document(untagged_rgb(&colours, SampleType::U8), None); + s.execute("edit.colorSettings", json!({"workingRgb": "prophoto-compat"})).unwrap(); + s.execute("view.proofSetup", json!({"profile": "coated-cmyk", "intent": "perceptual"})).unwrap(); + let doc = s.active().unwrap().doc.clone(); + let setup = s.color().proof(doc.id).setup.clone(); + let buf = photocraft_compose::flatten(&doc); + let count_with = |src: &Profile| { + let check = GamutCheck::new(src, &setup.profile, 4.0).unwrap(); + let mut mask = vec![0u8; buf.px.len()]; + let count = check.mask_rgba(&buf.px, &mut mask).unwrap(); + (mask, count) + }; + // The canvas marks its out-of-gamut pixels through the display source; that is the count the + // Gamut Warning command and Color Range > Out of Gamut have to agree with. + let want = count_with(&s.color().composite_profile(&doc)); + let built_in = count_with(&composite_profile(&doc)); + assert_ne!(want.1, built_in.1, "the fixture must tell the two spaces apart: {want:?} vs {built_in:?}"); + let warning = s.execute("view.gamutWarning", json!({"on": true, "threshold": 4.0})).unwrap(); + assert_eq!(warning["outOfGamut"].as_u64().unwrap() as usize, want.1, "Gamut Warning judged another space than the canvas"); + // Color Range › Out of Gamut has to mark exactly those pixels. + s.execute("select.colorRange", json!({"select": "outOfGamut"})).unwrap(); + let with = s.active().unwrap().doc.clone(); + let selection = with.selection.clone().expect("the selection was set"); + let width = with.size.width as usize; + let marked = |surface: &photocraft_raster::Surface| -> Vec { + (0..with.size.width as usize / 4).map(|i| (surface.pixel(i as i32 * 4 + 2, 2)[0] > 0.5) as usize).collect() + }; + let marks = marked(&selection); + let columns: Vec = (0..width / 4).map(|i| usize::from(want.0[2 * width + i * 4 + 2] == 255)).collect(); + assert_eq!(marks, columns, "Color Range > Out of Gamut marks other pixels than the warning counts"); +} + +#[test] +fn converting_an_untagged_document_to_working_leaves_its_samples() { + let mut s = crate::session(); + let v = [0.9f32, 0.2, 0.2]; + s.execute("edit.colorSettings", json!({"workingRgb": "prophoto-compat"})).unwrap(); + // The answer to the "missing profile" prompt for a document that is not open yet. + let mut d = untagged_rgb(&[v], SampleType::U8); + s.color().resolve_open(&mut d, "convert").unwrap(); + let tagged = profile_from_bytes(d.icc_profile.as_ref().expect("tagged by the answer")).unwrap(); + assert_eq!(tagged.description, s.color().working(ColorMode::Rgb).description, "tagged with the working space"); + let px = d.layers[0].surface().unwrap().pixel(1, 1); + assert!((0..3).all(|c| (px[c] - v[c]).abs() <= 2.0 / 255.0), "the answer read the document in the built-in default and moved its pixels: {px:?} vs {v:?}"); + // The command path agrees: an untagged document answers the same way once it is open. + s.open_document(untagged_rgb(&[v], SampleType::U8), None); + let r = s.execute("color.profileMismatch", json!({"action": "convertToWorking"})).unwrap(); + assert_eq!(r["action"], json!("converted")); + let px = s.active().unwrap().doc.layers[0].surface().unwrap().pixel(1, 1); + assert!((0..3).all(|c| (px[c] - v[c]).abs() <= 2.0 / 255.0), "the open document's answer moved its pixels: {px:?}"); + let info = reported(&mut s); + assert_eq!(info["embedded"], json!(true)); + assert_eq!(info["description"], s.color().working(ColorMode::Rgb).description); +} + +#[test] +fn an_untagged_indexed_document_follows_the_mode_default_until_it_becomes_rgb() { + let mut s = crate::session(); + s.execute("file.new", json!({"width": 8, "height": 8, "background": "#ff0000"})).unwrap(); + s.execute("edit.colorSettings", json!({"workingRgb": "prophoto-compat"})).unwrap(); + s.execute("image.mode.indexedColor", json!({"palette": "exact", "forced": "none", "colors": 8})).unwrap(); + // Indexed is not one of the two modes the item measures: it keeps the mode's built-in default. + let indexed = working_profile(ColorMode::Indexed); + assert_eq!(reported(&mut s)["description"], indexed.description, "an Indexed document is not switched"); + // Image > Mode > RGB without a profile keeps the stored samples; the document that results is + // untagged RGB, so the reply and Profile Info have to name the same space. + let r = s.execute("image.mode.rgb", json!({})).unwrap(); + assert_eq!(r["profile"], s.color().working(ColorMode::Rgb).description, "the reply names the space the result is taken in"); + assert_eq!(reported(&mut s)["description"], s.color().working(ColorMode::Rgb).description, "and Profile Info agrees"); +} + #[test] fn the_profile_commands_answer_the_same_for_a_tagged_document() { let mut replies = Vec::new(); diff --git a/crates/engine-paint/src/cmd/retouch_cmds.rs b/crates/engine-paint/src/cmd/retouch_cmds.rs index 6ecb8398f47..1487546f3b8 100644 --- a/crates/engine-paint/src/cmd/retouch_cmds.rs +++ b/crates/engine-paint/src/cmd/retouch_cmds.rs @@ -458,6 +458,9 @@ mod tests; #[cfg(test)] mod clone_source_layer_tests; +#[cfg(test)] +mod untagged_working_space_tests; + #[cfg(test)] mod patch_history_names_tests; diff --git a/crates/engine-paint/src/cmd/retouch_cmds/clone_sampling.rs b/crates/engine-paint/src/cmd/retouch_cmds/clone_sampling.rs index a134d9f1901..83b7014b4ae 100644 --- a/crates/engine-paint/src/cmd/retouch_cmds/clone_sampling.rs +++ b/crates/engine-paint/src/cmd/retouch_cmds/clone_sampling.rs @@ -238,9 +238,11 @@ fn resolve_source(s: &Session, p: &Value, cmd: &str, source: Option Result>> { - let source = if which == SampleLayers::Current { crate::color_cmds::document_profile(doc) } else { crate::color_cmds::composite_profile(doc) }; + // Both documents are read as the session reads them: an untagged one is taken in its working + // space (#14224), so a stamp cloned across documents keeps the look it has on its own canvas. + let source = if which == SampleLayers::Current { s.color().document_profile(doc) } else { s.color().composite_profile(doc) }; let target = s.active().ok_or(EngineError::NoDocument)?; - let destination = crate::color_cmds::document_profile(&target.doc); + let destination = s.color().document_profile(&target.doc); let inputs = if which == SampleLayers::Current { doc.mode.color_channels() } else { 3 }; if source.channels() != inputs || destination.channels() != target.doc.mode.color_channels() { return Err(bad(cmd, "cross-document cloning does not support this color model")); diff --git a/crates/engine-paint/src/cmd/retouch_cmds/untagged_working_space_tests.rs b/crates/engine-paint/src/cmd/retouch_cmds/untagged_working_space_tests.rs new file mode 100644 index 00000000000..50770ed1a79 --- /dev/null +++ b/crates/engine-paint/src/cmd/retouch_cmds/untagged_working_space_tests.rs @@ -0,0 +1,43 @@ +//! #14224: cloning from another document into an untagged one lands in the space that document is +//! shown in, not in the mode's built-in default. + +use super::*; +use crate::color_cmds::ColorExt; +use craft_cms::{Builtin, Transform}; +use photocraft_color::ColorMode; + +/// Cross-document Clone Stamp over a flat sRGB block, into an untagged RGB document whose working +/// RGB is ProPhoto-compatible. The stamp keeps its look, so its samples are re-encoded into the +/// space the destination is displayed in. +#[test] +fn a_cloned_block_lands_in_the_working_space_of_the_untagged_destination() { + let mut s = crate::session(); + let filled = [0.9f32, 0.2, 0.2, 1.0]; + s.execute("file.new", json!({"width": 64, "height": 64})).unwrap(); + s.execute("edit.assignProfile", json!({"profile": "srgb"})).unwrap(); + s.edit("block", |doc, active| { + doc.layer_mut(active.unwrap()).unwrap().surface_mut().unwrap().fill_rect(Rect::new(0, 0, 64, 64), &filled); + Ok(()) + }) + .unwrap(); + s.execute("cloneSource.set", json!({"source": [16, 16]})).unwrap(); + // Opened under the default settings, so the document stays untagged. + s.execute("file.new", json!({"width": 64, "height": 64})).unwrap(); + s.execute("layer.new.layer", json!({})).unwrap(); + s.execute("edit.colorSettings", json!({"workingRgb": "prophoto-compat"})).unwrap(); + let dst = s.active().unwrap().doc.clone(); + assert!(dst.icc_profile.is_none(), "the destination document is untagged"); + + s.execute("paint.cloneStamp", json!({"points": [[48, 48]], "size": 8, "hardness": 100})).unwrap(); + let st = s.active().unwrap(); + let got = st.doc.layer(st.active_layer.unwrap()).unwrap().surface().unwrap().read_region(Rect::new(48, 48, 49, 49)); + + let mut out = [0.0f32; 16]; + let working = s.color().working(ColorMode::Rgb); + Transform::new(Builtin::Srgb.profile(), &working, s.color().settings.intent(), s.color().settings.bpc).unwrap().eval(&filled[..3], &mut out).unwrap(); + let want = [out[0], out[1], out[2]]; + assert!((0..3).any(|c| (got[c] - filled[c]).abs() > 8.0 / 255.0), "the fixture must tell the two spaces apart: the stamp kept the source samples {got:?}"); + for c in 0..3 { + assert!((got[c] - want[c]).abs() < 0.01, "the stamp landed at {:?}, not in the destination's space {want:?}", &got[..3]); + } +} diff --git a/crates/ui-egui/src/dialogs/color_range_ui.rs b/crates/ui-egui/src/dialogs/color_range_ui.rs index a308d0a0515..765554fdae2 100644 --- a/crates/ui-egui/src/dialogs/color_range_ui.rs +++ b/crates/ui-egui/src/dialogs/color_range_ui.rs @@ -257,7 +257,7 @@ fn proxy_mask(app: &PhotocraftApp, proxy: &Document, k: u32, params: &Value) -> } if params.get("select").and_then(Value::as_str) == Some("outOfGamut") { let pv = app.session.color().proof(proxy.id); - let (m, _) = photocraft_engine::color_cmds::gamut_mask(proxy, &pv.setup, pv.gamut_threshold).map_err(|e| e.to_string())?; + let (m, _) = app.session.color().gamut_mask(proxy, &pv.setup, pv.gamut_threshold).map_err(|e| e.to_string())?; let invert = params.get("invert").and_then(Value::as_bool).unwrap_or(false); let mut mask: Vec = m.iter().map(|v| f32::from(*v) / 255.0).map(|v| if invert { 1.0 - v } else { v }).collect(); scope_preview(proxy, params, &mut mask); From f8cf07d0400375ae1dbd36a8bccb447a9800daa6 Mon Sep 17 00:00:00 2001 From: hnoerenberg Date: Fri, 27 Nov 2026 15:50:22 +0100 Subject: [PATCH 25/81] fix(color): drop a needless borrow at the copy path's fallback clippy::needless_borrow on untagged_profile(copies): copies is already a reference, so taking a reference to it only asks the compiler to deref it again. --- crates/engine-core/src/cmd/layer_copy_cmds.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/engine-core/src/cmd/layer_copy_cmds.rs b/crates/engine-core/src/cmd/layer_copy_cmds.rs index e1c9883270b..d12548a8a5e 100644 --- a/crates/engine-core/src/cmd/layer_copy_cmds.rs +++ b/crates/engine-core/src/cmd/layer_copy_cmds.rs @@ -115,7 +115,7 @@ pub(crate) fn adapt_copies(s: &Session, copies: &mut Document, dest: &Document) // Both sides are read as the session reads them: an untagged document, source or // destination, is taken in its working space (#14224), so the copies keep their look on // the destination's canvas instead of landing as raw numbers. - let untagged = s.color().untagged_profile(&copies); + let untagged = s.color().untagged_profile(copies); let profile = s.color().document_profile(dest); crate::color_cmds::convert_document_from(copies, &untagged, &profile, s.color().settings.intent(), s.color().settings.bpc)?; } From 5f595905169202be9ae4f5b1ea8a4e35848c650e Mon Sep 17 00:00:00 2001 From: hnoerenberg Date: Fri, 27 Nov 2026 16:03:01 +0100 Subject: [PATCH 26/81] fix(color): Color Range's sampled colours judge in the space the canvas shows The Lab box the sampled-colour rows compare against was built through the free composite_profile, so for an untagged document it stayed in the mode's built-in default while the same picture on the canvas was read in Color Settings' working space: the same two sampled colours marked the same columns no matter what the setting said. The new pin runs that box over a ramp of columns and fails when the marks do not move. --- crates/engine-core/src/cmd/selection_cmds.rs | 6 ++++-- .../color_settings_untagged_display_tests.rs | 21 +++++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/crates/engine-core/src/cmd/selection_cmds.rs b/crates/engine-core/src/cmd/selection_cmds.rs index d173edc50dc..c5338d76749 100644 --- a/crates/engine-core/src/cmd/selection_cmds.rs +++ b/crates/engine-core/src/cmd/selection_cmds.rs @@ -170,10 +170,12 @@ fn parse_color(p: &Value) -> [f32; 3] { } } -/// Composite RGB (the compositor's output profile for the document) → CIE Lab D50. +/// Composite RGB (the profile the session shows the document's composite in) → CIE Lab D50. fn lab_transform(s: &Session) -> Result> { let d = s.active().ok_or(EngineError::NoDocument)?; - let src = crate::color_cmds::composite_profile(&d.doc); + // An untagged document's composite is the working space (#14224), so the hue rows and the + // sampled colours select what the canvas actually shows. + let src = s.color().composite_profile(&d.doc); craft_cms::cached(&src, craft_cms::Builtin::LabD50.profile(), craft_cms::TransformOptions::default()) .map_err(|e| EngineError::Other(format!("colour management: {e}"))) } diff --git a/crates/engine-core/src/color_settings_untagged_display_tests.rs b/crates/engine-core/src/color_settings_untagged_display_tests.rs index 7760508dc50..d674af69544 100644 --- a/crates/engine-core/src/color_settings_untagged_display_tests.rs +++ b/crates/engine-core/src/color_settings_untagged_display_tests.rs @@ -397,6 +397,27 @@ fn an_untagged_indexed_document_follows_the_mode_default_until_it_becomes_rgb() assert_eq!(reported(&mut s)["description"], s.color().working(ColorMode::Rgb).description, "and Profile Info agrees"); } +#[test] +fn colour_range_judges_sampled_colours_in_the_space_the_canvas_shows() { + let mut s = crate::session(); + // A box spanned by two sampled colours and a ramp of columns across it. Membership is decided in + // Lab, through the profile the composite is read in, so once the working space moves the box has + // to move with the picture: with the ramp below one column drops out going from sRGB to + // ProPhoto, and none of this changes at the default setting. + let columns: Vec<[f32; 3]> = (0..8).map(|i| [0.55 + 0.03 * i as f32, 0.45 - 0.03 * i as f32, 0.45 - 0.02 * i as f32]).collect(); + s.open_document(untagged_rgb(&columns, SampleType::U8), None); + let marked = |s: &mut Session| -> Vec { + s.execute("select.colorRange", json!({"select": "sampledColors", "colors": ["#cc4d4d", "#996666"], "fuzziness": 40})).unwrap(); + let doc = s.active().unwrap().doc.clone(); + let selection = doc.selection.clone().expect("a selection was set"); + (0..columns.len()).filter(|i| selection.pixel(*i as i32 * 4 + 2, 2)[0] > 0.5).collect() + }; + let as_built_in = marked(&mut s); + s.execute("edit.colorSettings", json!({"workingRgb": "prophoto-compat"})).unwrap(); + let as_working = marked(&mut s); + assert_ne!(as_built_in, as_working, "the sampled colour box marked the same columns whatever the working space: {as_built_in:?} vs {as_working:?}"); +} + #[test] fn the_profile_commands_answer_the_same_for_a_tagged_document() { let mut replies = Vec::new(); From dfc29bc257d738f03ccee14dd3bb38ef72cc7445 Mon Sep 17 00:00:00 2001 From: hnoerenberg Date: Fri, 27 Nov 2026 16:48:26 +0100 Subject: [PATCH 27/81] test(color): Replace Color judges its Lab bounds in the space the canvas shows The pin draws a Lab cube around one column of the gamut fixture through the profile the session reads the layer in, and asks the command to shift what that cube encloses: the column moves in a session whose working space is ProPhoto-compatible and stays where it is at the default setting. Without the session profile at the call site the cube misses the column it was drawn around. --- .../color_settings_untagged_display_tests.rs | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/crates/engine-core/src/color_settings_untagged_display_tests.rs b/crates/engine-core/src/color_settings_untagged_display_tests.rs index d674af69544..2a619aaa7f0 100644 --- a/crates/engine-core/src/color_settings_untagged_display_tests.rs +++ b/crates/engine-core/src/color_settings_untagged_display_tests.rs @@ -418,6 +418,48 @@ fn colour_range_judges_sampled_colours_in_the_space_the_canvas_shows() { assert_ne!(as_built_in, as_working, "the sampled colour box marked the same columns whatever the working space: {as_built_in:?} vs {as_working:?}"); } +#[test] +fn replace_color_judges_its_lab_bounds_in_the_space_the_canvas_shows() { + // A Lab cube drawn around one column of the gamut fixture through the profile this session reads + // the layer in. The same device numbers sit far away when they are read in the mode's built-in + // default, so the cube has to catch that column here and miss it in a session at the default. + let columns = [[0.95f32, 0.05, 0.05], [0.8f32, 0.3, 0.3], [0.6f32, 0.1, 0.1], [0.3, 0.85, 0.3], [0.1, 0.4, 0.9], [0.45, 0.45, 0.95]]; + let column = 1usize; + let lab_in = |profile: &Profile, v: [f32; 3]| -> [f32; 3] { + let t = craft_cms::cached(profile, Builtin::LabD50.profile(), craft_cms::TransformOptions::default()).unwrap(); + let mut out = [0.0f32; 16]; + t.eval(&v, &mut out).unwrap(); + [out[0] * 100.0, out[1] * 255.0 - 128.0, out[2] * 255.0 - 128.0] + }; + let mut s = crate::session(); + s.open_document(untagged_rgb(&columns, SampleType::U8), None); + s.execute("edit.colorSettings", json!({"workingRgb": "prophoto-compat"})).unwrap(); + let doc = s.active().unwrap().doc.clone(); + let centre = lab_in(&s.color().document_profile(&doc), columns[column]); + let elsewhere = lab_in(&document_profile(&doc), columns[column]); + assert!((0..3).any(|c| (centre[c] - elsewhere[c]).abs() > 10.0), "the fixture must tell the two readings apart: {centre:?} vs {elsewhere:?}"); + let cube = json!({ + "labMinimum": [centre[0] - 4.0, centre[1] - 4.0, centre[2] - 4.0], + "labMaximum": [centre[0] + 4.0, centre[1] + 4.0, centre[2] + 4.0], + "fuzziness": 0, + "saturation": -60, + }); + let shifted = |s: &Session| -> bool { + // The layer makes a Lab round trip whether it is inside the cube or not, which moves single + // codes here and there; only the desaturation is a real change. + let surf = s.active().unwrap().doc.layers[0].surface().unwrap(); + let got = raw_codes(&surf.pixel(column as i32 * 4 + 2, 2)); + let stored = raw_codes(&columns[column]); + (0..3).any(|c| (got[c] - stored[c]).abs() > 8.0) + }; + s.execute("image.adjustments.replaceColor", cube.clone()).unwrap(); + assert!(shifted(&s), "the cube drawn in this session's own space missed the column it was drawn around: {centre:?}"); + let mut plain = crate::session(); + plain.open_document(untagged_rgb(&columns, SampleType::U8), None); + plain.execute("image.adjustments.replaceColor", cube).unwrap(); + assert!(!shifted(&plain), "the same cube also caught the column read in the built-in default: {centre:?} vs {elsewhere:?}"); +} + #[test] fn the_profile_commands_answer_the_same_for_a_tagged_document() { let mut replies = Vec::new(); From 7c645e5266e36f6a674ca8d28a5c904028e32742 Mon Sep 17 00:00:00 2001 From: hnoerenberg Date: Fri, 27 Nov 2026 20:17:06 +0100 Subject: [PATCH 28/81] fix(color): the Color Range preview key carries the working space The Out of Gamut mask and the sampled-colour box are judged in the space the session shows the document in (#14224), but the key the dialog caches its preview picture under never named that setting: switch working RGB with the dialog open and the stale mask stayed on screen. query_key now hashes the working space specs rather than the resolved profiles, because it runs several times per frame. --- crates/ui-egui/src/dialogs/color_range_ui.rs | 8 +++++ .../src/dialogs/color_range_ui/tests.rs | 33 +++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/crates/ui-egui/src/dialogs/color_range_ui.rs b/crates/ui-egui/src/dialogs/color_range_ui.rs index 765554fdae2..6dd88a45e51 100644 --- a/crates/ui-egui/src/dialogs/color_range_ui.rs +++ b/crates/ui-egui/src/dialogs/color_range_ui.rs @@ -205,6 +205,14 @@ fn query_key(app: &PhotocraftApp, params: &Value) -> u64 { (setup.profile.content_hash(), setup.intent, setup.bpc, setup.simulate_paper, setup.kind).hash(&mut key); (proof.enabled, proof.gamut_warning, proof.gamut_threshold.to_bits()).hash(&mut key); } + // Both fast paths judge colour in the space the session shows the document in (#14224): the + // sampled-colour box runs through the document's profile, and so does the gamut mask, which for + // an untagged RGB or Grayscale document is Color Settings' working space. Hash the setting + // rather than the resolved profile, for the same reason as the proof setup above. + let color = app.session.color(); + for mode in [photocraft_doc::ColorMode::Rgb, photocraft_doc::ColorMode::Grayscale] { + color.working_space_spec(mode).hash(&mut key); + } key.finish().max(1) } diff --git a/crates/ui-egui/src/dialogs/color_range_ui/tests.rs b/crates/ui-egui/src/dialogs/color_range_ui/tests.rs index 26ef41cf446..e94d26ef0c8 100644 --- a/crates/ui-egui/src/dialogs/color_range_ui/tests.rs +++ b/crates/ui-egui/src/dialogs/color_range_ui/tests.rs @@ -130,6 +130,39 @@ fn preview_cache_refreshes_after_foreground_and_proof_changes() { assert_ne!(query_key(&app, &p), query_key(&app, &json!({"select": "outOfGamut", "invert": true}))); } +/// An untagged RGB strip whose colours straddle coated CMYK: read as sRGB some of them are inside +/// it, read as ProPhoto the same numbers are far outside. +fn untagged_strip_session() -> photocraft_engine::Session { + let colours = [[0.95f32, 0.05, 0.05], [0.8, 0.3, 0.3], [0.6, 0.1, 0.1], [0.3, 0.85, 0.3], [0.1, 0.4, 0.9], [0.45, 0.45, 0.95]]; + let mut doc = Document::with_background("strip", Size::new(24, 4), ColorMode::Rgb, SampleType::U8, Color::WHITE); + { + let bg = doc.layers[0].surface_mut().unwrap(); + for (i, c) in colours.iter().enumerate() { + bg.fill_rect(GRect::new(i as i32 * 4, 0, i as i32 * 4 + 4, 4), &[c[0], c[1], c[2], 1.0]); + } + } + let mut s = photocraft_engine::Session::new(); + s.add_document(doc, None); + s +} + +/// #14224: both fast preview paths judge colour in the space the session shows the document in, so +/// Color Settings' working space belongs in the key the cached picture is kept under - otherwise the +/// dialog keeps showing the old Out of Gamut mask after the setting moves. +#[test] +fn preview_cache_refreshes_after_a_working_space_change() { + let mut app = PhotocraftApp::new(untagged_strip_session(), crate::Services::default()); + app.run("view.proofSetup", json!({"profile": "coated-cmyk", "intent": "perceptual"})).unwrap(); + let p = json!({"select": "outOfGamut"}); + let doc = app.session.active().unwrap().doc.clone(); + let before = proxy_mask(&app, &doc, 1, &p).unwrap(); + let key_before = query_key(&app, &p); + app.run("edit.colorSettings", json!({"workingRgb": "prophoto-compat"})).unwrap(); + let after = proxy_mask(&app, &doc, 1, &p).unwrap(); + assert_ne!(before, after, "the preview marks the same pixels whatever the working space of an untagged document"); + assert_ne!(key_before, query_key(&app, &p), "and the cache key holds onto the picture the setting has made stale"); +} + #[test] fn eyedropper_hover_reuses_preview_textures_without_sampling() { let mut app = app_with_doc(); From 0bcd52f1fae5bba389ba2146ffdda587df901571 Mon Sep 17 00:00:00 2001 From: yoriswind Date: Fri, 27 Nov 2026 13:59:56 -0800 Subject: [PATCH 29/81] Honor the PDF export profile-embedding option --- crates/io/src/lib.rs | 2 +- crates/io/src/pdf.rs | 14 +++++++- crates/io/src/pdf/tests.rs | 65 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+), 2 deletions(-) diff --git a/crates/io/src/lib.rs b/crates/io/src/lib.rs index b8791076908..a2716ddf8ee 100644 --- a/crates/io/src/lib.rs +++ b/crates/io/src/lib.rs @@ -1240,7 +1240,7 @@ fn export_stages_with_renderer( } if ext == "pdf" { let xmp = if opts.xmp == XmpEmbed::All { doc.metadata.xmp.as_deref() } else { None }; - let mut res = pdf::export_with(doc, opts.pdf_spot_plates, xmp, ctl)?; + let mut res = pdf::export_with_icc(doc, opts.pdf_spot_plates, xmp, opts.encode.embed_icc, ctl)?; if let Some(r) = renderer { res.warnings.push("PDF export uses CPU compositor; GPU rendering applies to flat formats".into()); res.warnings.extend(r.drain_diagnostics()); diff --git a/crates/io/src/pdf.rs b/crates/io/src/pdf.rs index a8dc29edc52..7813f5a6be5 100644 --- a/crates/io/src/pdf.rs +++ b/crates/io/src/pdf.rs @@ -176,6 +176,18 @@ pub fn export(doc: &Document, spot_plates: bool, ctl: &photocraft_raster::Interr /// PDF writer; /// without plates it is written as it is, and nothing when there is none. pub fn export_with(doc: &Document, spot_plates: bool, doc_xmp: Option<&str>, ctl: &photocraft_raster::Interrupt) -> std::result::Result { + export_with_icc(doc, spot_plates, doc_xmp, true, ctl) +} + +/// [`export_with`] with control over embedding the document profile in the page images. +/// The document's profile remains available to the compositor even when it is not embedded. +pub(crate) fn export_with_icc( + doc: &Document, + spot_plates: bool, + doc_xmp: Option<&str>, + embed_icc: bool, + ctl: &photocraft_raster::Interrupt, +) -> std::result::Result { ctl.check().map_err(|_| IoError::Cancelled)?; let (w, h) = (usize::try_from(doc.size.width).unwrap_or(0), usize::try_from(doc.size.height).unwrap_or(0)); if w == 0 || h == 0 { @@ -203,7 +215,7 @@ pub fn export_with(doc: &Document, spot_plates: bool, doc_xmp: Option<&str>, ctl let dpi = f64::from(doc.resolution_dpi.max(1.0)); let paper = if doc.mode == ColorMode::Cmyk { 0.0 } else { 1.0 }; let to8 = |v: f32| (v.clamp(0.0, 1.0) * 255.0).round() as u8; - let icc = doc.icc_profile.as_ref().map(|p| p.to_vec()); + let icc = doc.icc_profile.as_ref().filter(|_| embed_icc).map(|p| p.to_vec()); let plate_count = if spot_plates { plate_channels(doc).count() } else { 0 }; // Straight alpha, composited here over paper: white in RGB/Gray (1 = full light), zero ink // in CMYK (0 = paper). diff --git a/crates/io/src/pdf/tests.rs b/crates/io/src/pdf/tests.rs index b3844d993e9..dda728638bf 100644 --- a/crates/io/src/pdf/tests.rs +++ b/crates/io/src/pdf/tests.rs @@ -202,6 +202,71 @@ fn an_embedded_profile_travels_as_iccbased() { assert_eq!(stream_after(&out.bytes, "/N 3 /Alternate"), vec![1, 2, 3, 4, 5, 6, 7, 8], "the profile bytes survive"); } +#[test] +fn the_export_profile_flag_changes_tagging_without_changing_samples_or_the_document() { + use craft_cms::Builtin; + + for (mode, profile, device) in [ + (ColorMode::Rgb, Builtin::DisplayP3, "DeviceRGB"), + (ColorMode::Grayscale, Builtin::SGray, "DeviceGray"), + (ColorMode::Cmyk, Builtin::CoatedCmyk, "DeviceCMYK"), + ] { + let mut d = doc(mode); + let profile = profile.profile().to_bytes(); + d.icc_profile = Some(profile.clone()); + let rect = Rect::new(0, 0, 4, 2); + let before = photocraft_compose::composite_to_surface(&d, rect, d.pixel_format(), None).read_region(rect); + let mut off = crate::ExportOptions::default(); + off.encode.embed_icc = false; + let tagged = crate::export(&d, "out.pdf", &crate::ExportOptions::default()).unwrap(); + let untagged = crate::export(&d, "out.pdf", &off).unwrap(); + + assert!(has(&tagged.bytes, "[/ICCBased "), "{mode:?} image uses its profile"); + let marker = format!("/N {} /Alternate", d.pixel_format().channels() - 1); + assert_eq!(stream_after(&tagged.bytes, &marker), *profile, "the document's exact profile"); + assert!(!has(&untagged.bytes, "/ICCBased"), "OFF writes no profile reference"); + assert!(!has(&untagged.bytes, "/Alternate"), "OFF writes no profile object"); + assert!(has(&untagged.bytes, &format!("/ColorSpace /{device}")), "OFF uses the matching device space"); + assert_eq!( + stream_after(&tagged.bytes, "/Subtype /Image"), + stream_after(&untagged.bytes, "/Subtype /Image"), + "embedding must not convert the samples" + ); + assert_eq!(d.icc_profile.as_deref(), Some(profile.as_ref()), "the source profile remains"); + assert_eq!(photocraft_compose::composite_to_surface(&d, rect, d.pixel_format(), None).read_region(rect), before, "source samples remain"); + assert_eq!(d.layers.len(), 1); + assert_eq!(d.layers[0].name, "Paper"); + } +} + +#[test] +fn the_export_profile_flag_applies_to_every_artboard_without_changing_plates() { + let mut d = artboard_doc(&["Front", "Back"]); + let profile = craft_cms::Builtin::DisplayP3.profile().to_bytes(); + d.icc_profile = Some(profile.clone()); + d.channels.push(spot("Varnish", photocraft_color::Color::WHITE, &[0.0, 0.0, 1.0, 0.5, 0.0, 0.0, 1.0, 0.5])); + let mut off = crate::ExportOptions::default(); + off.encode.embed_icc = false; + let tagged = crate::export(&d, "out.pdf", &crate::ExportOptions::default()).unwrap(); + let untagged = crate::export(&d, "out.pdf", &off).unwrap(); + let on_pdf = lopdf::Document::load_mem(&tagged.bytes).unwrap(); + let off_pdf = lopdf::Document::load_mem(&untagged.bytes).unwrap(); + assert_eq!(on_pdf.get_pages().len(), 2); + assert_eq!(off_pdf.get_pages().len(), 2); + assert_eq!(tagged.bytes.windows(11).filter(|w| *w == b"[/ICCBased ").count(), 2, "every composite is tagged"); + assert!(!has(&untagged.bytes, "/ICCBased")); + assert!(!has(&untagged.bytes, "/Alternate")); + assert_eq!(untagged.bytes.windows(22).filter(|w| *w == b"/ColorSpace /DeviceRGB").count(), 2, "every composite uses device RGB"); + for (on, off) in on_pdf.get_pages().values().zip(off_pdf.get_pages().values()) { + assert_eq!(page_image(&on_pdf, *on), page_image(&off_pdf, *off), "the artboard samples remain"); + assert_eq!(page_xobject(&on_pdf, *on, b"Sp0"), page_xobject(&off_pdf, *off, b"Sp0"), "spot density remains"); + } + assert_eq!(xmp_of(&tagged.bytes), xmp_of(&untagged.bytes), "spot descriptions remain"); + assert_eq!(d.icc_profile.as_deref(), Some(profile.as_ref())); + assert_eq!(d.layers.len(), 2); + assert_eq!(d.channels[0].surface.read_region(Rect::new(0, 0, 4, 2)), vec![0.0, 0.0, 1.0, 0.5, 0.0, 0.0, 1.0, 0.5]); +} + #[test] fn other_modes_are_refused_with_an_actionable_error() { let d = doc(ColorMode::Lab); From f373bcb07b217c51e19e72f74d3b44bf0d0867af Mon Sep 17 00:00:00 2001 From: yoriswind Date: Fri, 27 Nov 2026 14:07:15 -0800 Subject: [PATCH 30/81] Apply PDF profile test formatting --- crates/io/src/pdf/tests.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/crates/io/src/pdf/tests.rs b/crates/io/src/pdf/tests.rs index dda728638bf..412b05bd28b 100644 --- a/crates/io/src/pdf/tests.rs +++ b/crates/io/src/pdf/tests.rs @@ -227,11 +227,7 @@ fn the_export_profile_flag_changes_tagging_without_changing_samples_or_the_docum assert!(!has(&untagged.bytes, "/ICCBased"), "OFF writes no profile reference"); assert!(!has(&untagged.bytes, "/Alternate"), "OFF writes no profile object"); assert!(has(&untagged.bytes, &format!("/ColorSpace /{device}")), "OFF uses the matching device space"); - assert_eq!( - stream_after(&tagged.bytes, "/Subtype /Image"), - stream_after(&untagged.bytes, "/Subtype /Image"), - "embedding must not convert the samples" - ); + assert_eq!(stream_after(&tagged.bytes, "/Subtype /Image"), stream_after(&untagged.bytes, "/Subtype /Image"), "embedding must not convert the samples"); assert_eq!(d.icc_profile.as_deref(), Some(profile.as_ref()), "the source profile remains"); assert_eq!(photocraft_compose::composite_to_surface(&d, rect, d.pixel_format(), None).read_region(rect), before, "source samples remain"); assert_eq!(d.layers.len(), 1); From 5409efbd67feb239509b85b7d60a39b00e966aaa Mon Sep 17 00:00:00 2001 From: qvest-ssels <214787280+qvest-ssels@users.noreply.github.com> Date: Sun, 29 Nov 2026 00:31:06 +0100 Subject: [PATCH 31/81] Data Sets as Files: ask whether to export the remaining sets when a replacement image is missing (#13767) A data set whose Pixel Replacement image does not exist ended the whole export with an error. The form now asks, naming the set, whether to export the remaining sets: Yes leaves the set out and goes on, No stops with the files written so far. A missing image in the last set keeps the error. The command takes missingImage (error, the default; skip; stop) and start, and its result lists the skipped sets and the set a stop ended at, so agents get the same choice without a prompt. --- crates/automation/src/headless.rs | 17 +- crates/engine-core/src/cmd/variables_cmds.rs | 105 ++++++++-- crates/engine-core/src/lib.rs | 5 +- crates/ui-egui/src/dialogs.rs | 5 + .../export_data_sets_missing_image_tests.rs | 198 ++++++++++++++++++ crates/ui-egui/src/lib.rs | 2 + crates/ui-egui/src/menus/view_cmds/dialogs.rs | 83 ++++++++ 7 files changed, 400 insertions(+), 15 deletions(-) create mode 100644 crates/ui-egui/src/export_data_sets_missing_image_tests.rs diff --git a/crates/automation/src/headless.rs b/crates/automation/src/headless.rs index 34455d56222..8ec269bb4b1 100644 --- a/crates/automation/src/headless.rs +++ b/crates/automation/src/headless.rs @@ -334,10 +334,23 @@ impl Headless { _ => return Err(AutomationError::BadRequest("automation filesystem access is not granted: write authority is absent".into())), }; let mut outputs = workspace.export_sequence(dir)?; - let written = photocraft_engine::export_data_sets_with(&this.session, params, |name, bytes| { + let report = photocraft_engine::export_data_sets_report_with(&this.session, params, |name, bytes| { outputs.write(name, bytes).map_err(|e| photocraft_engine::EngineError::Other(e.to_string())) }); - exported(dir, written, &mut outputs) + // The sets a missing replacement image left out or stopped at, as the command says (#13767). + let (written, report) = match report { + Ok(report) => (Ok(report.files.clone()), Some(report)), + Err(error) => (Err(error), None), + }; + let mut result = exported(dir, written, &mut outputs)?; + if let Some(report) = report { + let full = report.json(Vec::new()); + result["skipped"] = full["skipped"].clone(); + if let Some(stopped) = full.get("stopped") { + result["stopped"] = stopped.clone(); + } + } + Ok(result) }) } diff --git a/crates/engine-core/src/cmd/variables_cmds.rs b/crates/engine-core/src/cmd/variables_cmds.rs index 4fe4c3fccc5..ee3059fa6b0 100644 --- a/crates/engine-core/src/cmd/variables_cmds.rs +++ b/crates/engine-core/src/cmd/variables_cmds.rs @@ -465,22 +465,65 @@ fn split_csv(line: &str, delim: u8) -> Vec { } /// Apply each data set in turn and export the flattened document, restoring the original after. -/// `{dir, format?("png"), dataSets?[names]}` → `{files:[…],count}`. +/// `{dir, format?("png"), dataSets?[names], missingImage?, start?}` → `{files:[…],count,skipped,stopped?}`. fn export_as_files(s: &mut Session, p: &Value) -> Result { let dir = p.get("dir").and_then(Value::as_str).ok_or_else(|| bad("file.export.dataSetsAsFiles", "need `dir`"))?.to_string(); // The directory appears only once the batch has been planned, as it always did, so a batch // rejected for colliding names still leaves no directory behind. let mut made_dir = false; - let names = export_data_sets_with(s, p, |name, bytes| { + let report = export_data_sets_report_with(s, p, |name, bytes| { if !made_dir { std::fs::create_dir_all(&dir).map_err(|e| EngineError::Other(format!("mkdir `{dir}`: {e}")))?; made_dir = true; } crate::file_cmds::write_file(&format!("{dir}/{name}"), bytes) })?; - let files: Vec = names.iter().map(|name| format!("{dir}/{name}")).collect(); - let count = files.len(); - Ok(json!({"files": files, "count": count})) + let files: Vec = report.files.iter().map(|name| format!("{dir}/{name}")).collect(); + Ok(report.json(files)) +} + +/// What a data-set export with a `missingImage` mode does when a set's Pixel Replacement image +/// does not exist (#13767). +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +enum MissingImage { + /// The export ends with the missing-file error; the files written before it stay (the default). + Error, + /// The set is left out, listed in `skipped`, and the export goes on. + Skip, + /// The export ends without an error at that set; the result names it in `stopped`. + Stop, +} + +/// The data set a `missingImage: "stop"` export stopped at: its name, its 0-based position in the +/// batch (the `start` that resumes after it is `index + 1`), how many sets come after it and the +/// missing-file error it would have ended with. +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct StoppedDataSet { + pub name: String, + pub index: usize, + pub remaining: usize, + pub error: String, +} + +/// What a data-set export did: the filenames written, in order, the sets left out for a missing +/// replacement image (`missingImage: "skip"`) and the set a `"stop"` export stopped at. +#[derive(Clone, Debug, Default, PartialEq, Eq)] +pub struct DataSetsExportReport { + pub files: Vec, + pub skipped: Vec, + pub stopped: Option, +} + +impl DataSetsExportReport { + /// The command's result, with `files` as the caller names them (joined to its folder). + pub fn json(&self, files: Vec) -> Value { + let count = files.len(); + let mut out = json!({"files": files, "count": count, "skipped": self.skipped}); + if let Some(stop) = &self.stopped { + out["stopped"] = json!({"name": stop.name, "index": stop.index, "remaining": stop.remaining, "error": stop.error}); + } + out + } } /// The bodies of `file.export.dataSetsAsFiles`, streamed to `write` as a single-component @@ -488,8 +531,30 @@ fn export_as_files(s: &mut Session, p: &Value) -> Result { /// so colliding names are rejected before any file is written, and automation writes exactly /// these bytes beneath its write root (#3216) — the two paths cannot drift. Returns the /// filenames written, in order. -pub fn export_data_sets_with(s: &Session, p: &Value, mut write: impl FnMut(&str, &[u8]) -> Result<()>) -> Result> { +pub fn export_data_sets_with(s: &Session, p: &Value, write: impl FnMut(&str, &[u8]) -> Result<()>) -> Result> { + export_data_sets_report_with(s, p, write).map(|report| report.files) +} + +/// [`export_data_sets_with`] that also says which sets a missing replacement image left out or +/// stopped at (`missingImage`, #13767). `start` resumes a batch at that 0-based position: the +/// sets before it are not written, and `{index}` keeps counting from the first set. +pub fn export_data_sets_report_with(s: &Session, p: &Value, mut write: impl FnMut(&str, &[u8]) -> Result<()>) -> Result { let format = p.get("format").and_then(Value::as_str).unwrap_or("png"); + let missing = match p.get("missingImage") { + None | Some(Value::Null) => MissingImage::Error, + Some(v) => match v.as_str() { + Some("error") => MissingImage::Error, + Some("skip") => MissingImage::Skip, + Some("stop") => MissingImage::Stop, + _ => return Err(bad("file.export.dataSetsAsFiles", "`missingImage` must be \"error\", \"skip\" or \"stop\"")), + }, + }; + let start = match p.get("start") { + None | Some(Value::Null) => 0, + Some(v) => { + v.as_u64().and_then(|n| usize::try_from(n).ok()).ok_or_else(|| bad("file.export.dataSetsAsFiles", "`start` must be a whole number from 0"))? + } + }; let st = s.active().ok_or(EngineError::NoDocument)?; let original = st.doc.clone(); let vars = original.variables.clone(); @@ -498,6 +563,9 @@ pub fn export_data_sets_with(s: &Session, p: &Value, mut write: impl FnMut(&str, if sets.is_empty() { return Err(bad("file.export.dataSetsAsFiles", "no data sets to export")); } + if start >= sets.len() { + return Err(bad("file.export.dataSetsAsFiles", format!("`start` {start} is past the last of {} data sets", sets.len()))); + } // Judge every image path before anything is written, as Apply Data Set does. for set in &sets { authorize_pixel_paths(s, set)?; @@ -538,17 +606,30 @@ pub fn export_data_sets_with(s: &Session, p: &Value, mut write: impl FnMut(&str, } names.push(name); } - let mut written = Vec::new(); - for (set, name) in sets.iter().zip(&names) { + let mut report = DataSetsExportReport::default(); + for (n, (set, name)) in sets.iter().zip(&names).enumerate().skip(start) { let mut doc = (*original).clone(); - apply_to_doc(&mut doc, &vars, set)?; + match apply_to_doc(&mut doc, &vars, set) { + Ok(()) => {} + // Only a replacement file that does not exist: one that can't be read or decoded is + // still an error in every mode. + Err(EngineError::Other(m)) if missing != MissingImage::Error && m.starts_with(DATA_SET_FILE_MISSING) => { + if missing == MissingImage::Skip { + report.skipped.push(set.name.clone()); + continue; + } + report.stopped = Some(StoppedDataSet { name: set.name.clone(), index: n, remaining: sets.len() - n - 1, error: m }); + break; + } + Err(e) => return Err(e), + } // An untrusted session's PSD export embeds no file a linked smart object names. let opts = photocraft_io::ExportOptions { read_linked_files: s.authorize.is_none(), ..Default::default() }; let bytes = photocraft_io::export(&doc, format, &opts).map(|r| r.bytes).map_err(|e| EngineError::Other(format!("export `{}`: {e}", set.name)))?; write(name, &bytes)?; - written.push(name.clone()); + report.files.push(name.clone()); } - Ok(written) + Ok(report) } fn list(s: &mut Session) -> Result { @@ -612,7 +693,7 @@ pub fn specs() -> Vec { "file.export.dataSetsAsFiles", "Data Sets as Files…", &["File", "Export"], - "{dir, format?:png, dataSets?[names], naming?:\"{name}|{index}|{document}\"} → {files,count}: apply each data set and export the flattened document; colliding filenames are rejected before writing (include {index} to disambiguate)", + "{dir, format?:png, dataSets?[names], naming?:\"{name}|{index}|{document}\", missingImage?:error|skip|stop, start?:n} → {files,count,skipped,stopped?:{name,index,remaining,error}}: apply each data set and export the flattened document; colliding filenames are rejected before writing (include {index} to disambiguate). A set whose Pixel Replacement image does not exist ends the export with an error (missingImage error, the default), is left out and listed in `skipped` (skip), or ends the export without an error, named in `stopped` (stop); `start` resumes at that 0-based set, keeping {index}", has_data_sets, |s, p| export_as_files(s, p) ), diff --git a/crates/engine-core/src/lib.rs b/crates/engine-core/src/lib.rs index c58ebac5ae7..e063e016fb2 100644 --- a/crates/engine-core/src/lib.rs +++ b/crates/engine-core/src/lib.rs @@ -55,7 +55,10 @@ pub mod shortcut_sets; mod slots; pub mod snap; mod state; -pub use variables_cmds::{DATA_SET_FILE_MISSING, DATA_SET_LAYER_LOCKED, data_set_preview, export_data_sets_with, import_data_sets_text}; +pub use variables_cmds::{ + DATA_SET_FILE_MISSING, DATA_SET_LAYER_LOCKED, DataSetsExportReport, StoppedDataSet, data_set_preview, export_data_sets_report_with, export_data_sets_with, + import_data_sets_text, +}; pub use video_cmds::render_video_with; use std::sync::Arc; diff --git a/crates/ui-egui/src/dialogs.rs b/crates/ui-egui/src/dialogs.rs index 62884471a45..4fda8e47948 100644 --- a/crates/ui-egui/src/dialogs.rs +++ b/crates/ui-egui/src/dialogs.rs @@ -138,6 +138,10 @@ pub(crate) mod params { ..ParamFamily::new(|key| key == "file.automate.batch", filter_dialog::run) }, ParamFamily { document: Some(file_info_document), ..ParamFamily::new(|key| key == "file.fileInfo", run_file_info) }, + ParamFamily { + cancel: Some(filter_dialog::cancel), + ..ParamFamily::new(|key| key == crate::view_cmds::dialogs::DATA_SETS, crate::view_cmds::dialogs::data_sets_run) + }, ParamFamily { cancel: Some(filter_dialog::cancel), ..ParamFamily::new(crate::view_cmds::dialogs::is_form, filter_dialog::run) }, crate::prefs_ui::PRESETS_FAMILY, crate::swatches_ui::SWATCH_NAME_FAMILY, @@ -449,6 +453,7 @@ pub(crate) const PROMPTS: &[PromptRow] = &[ preset_group_prompt::answer, open_prompt::answer_prompt, alerts::answer, + crate::view_cmds::dialogs::data_sets_answer, crate::jobs_ui::answer, crate::gpu_status::answer, crate::actions::library::answer, diff --git a/crates/ui-egui/src/export_data_sets_missing_image_tests.rs b/crates/ui-egui/src/export_data_sets_missing_image_tests.rs new file mode 100644 index 00000000000..9085ee0464a --- /dev/null +++ b/crates/ui-egui/src/export_data_sets_missing_image_tests.rs @@ -0,0 +1,198 @@ +//! #13767: File › Export › Data Sets as Files with a data set whose Pixel Replacement image is +//! missing. The form asks, naming the set, whether to export the remaining sets: Yes leaves that +//! set out and goes on (asking again at the next missing image), No stops with the files written +//! so far. A missing image in the last set keeps today's error (not measured). Agents get the same +//! choice without a prompt through the command's `missingImage` and `start` parameters, and the +//! result lists the sets left out (`skipped`) or stopped at (`stopped`). +use crate::PhotocraftApp; +use craft::ui::dialog::{DialogId, StandardPrompt}; +use serde_json::{Value, json}; +use std::path::{Path, PathBuf}; + +const EXPORT: &str = "file.export.dataSetsAsFiles"; + +/// A fresh scratch folder for one test, holding `ok.png` (a real image) and an `out` folder to come. +fn scratch(name: &str) -> PathBuf { + let dir = std::env::temp_dir().join(format!("pc-13767-{}-{name}", std::process::id())); + let _ = std::fs::remove_dir_all(&dir); + std::fs::create_dir_all(&dir).unwrap(); + let mut s = photocraft_engine::Session::new(); + s.execute("file.new", json!({"width": 4, "height": 4})).unwrap(); + let png = photocraft_io::export(&s.active().unwrap().doc, "png", &Default::default()).unwrap().bytes; + std::fs::write(dir.join("ok.png"), png).unwrap(); + dir +} + +/// A document whose raster layer `photo` is bound to a Pixel Replacement variable, with one data +/// set per entry of `images` ("Data Set 1", …): `true` names `ok.png`, `false` a file that is not there. +fn app(dir: &Path, images: &[bool]) -> (Box, egui::Context) { + let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), Default::default()); + app.run("file.new", json!({"width": 16, "height": 16})).unwrap(); + app.run("layer.new.layer", json!({"name": "photo"})).unwrap(); + let layer = app.session.active().unwrap().active_layer.unwrap().0; + app.run("image.variables.define", json!({"defs": [{"name": "photo", "layer": layer, "type": "pixelReplacement"}]})).unwrap(); + let sets: Vec = images + .iter() + .enumerate() + .map(|(i, ok)| { + let file = if *ok { dir.join("ok.png") } else { dir.join(format!("missing-{}.png", i + 1)) }; + json!({"name": format!("Data Set {}", i + 1), "values": [{"variable": "photo", "kind": "pixels", "value": file}]}) + }) + .collect(); + app.run("image.variables.dataSets", json!({"dataSets": sets})).unwrap(); + app.sync_views(); + let ctx = app.ctx().clone(); + (app, ctx) +} + +/// The files in `dir`, by name, sorted. +fn files(dir: &Path) -> Vec { + let mut names: Vec = std::fs::read_dir(dir).map(|r| r.map(|e| e.unwrap().file_name().to_string_lossy().into_owned()).collect()).unwrap_or_default(); + names.sort(); + names +} + +/// Opens the form through the menu and confirms it with `out` as the destination. +fn export_from_form(app: &mut PhotocraftApp, ctx: &egui::Context, out: &Path) { + let reply = crate::menus::invoke(app, ctx, EXPORT, json!({})).unwrap(); + let want = reply["dialog"].as_str().unwrap().to_owned(); + let dialog = app.framework.dialogs.open_dialogs().into_iter().map(|d| d.id).find(|d| d.value().to_string() == want).unwrap(); + app.framework.dialogs.set_json_field(ctx, dialog, "dir", json!(out)).unwrap(); + crate::dialogs::confirm(app, ctx, dialog).unwrap(); +} + +/// The open missing-image question and its message. +fn question(app: &PhotocraftApp) -> Option<(DialogId, String)> { + let id = crate::dialogs::alerts::prompt_tagged::(app)?; + let prompt = app.framework.dialogs.get::()?; + let host = app.framework.host(); + let buttons: Vec = prompt.shown_buttons(host).into_iter().map(|(_, label)| label).collect(); + Some((id, format!("{} | {} | {}", prompt.shown_title(host), prompt.shown_message(host), buttons.join(" / ")))) +} + +fn answer(app: &mut PhotocraftApp, ctx: &egui::Context, id: DialogId, yes: bool) { + if !yes { + app.framework.dialogs.set_json_field(ctx, id, "choice", json!("cancel")).unwrap(); + } + crate::dialogs::confirm(app, ctx, id).unwrap(); +} + +#[test] +fn the_form_asks_yes_no_naming_the_set_and_yes_exports_the_others() { + let dir = scratch("yes"); + let out = dir.join("out"); + let (mut app, ctx) = app(&dir, &[true, false, true]); + export_from_form(&mut app, &ctx, &out); + + let (id, message) = question(&app).expect("a missing image asks"); + assert!(message.contains("Data Set 2"), "{message}"); + assert_eq!(files(&out), ["Data_Set_1.png"], "the sets before it are written before the question"); + assert!(message.ends_with("| Yes / No"), "Yes and No: {message}"); + + answer(&mut app, &ctx, id, true); + assert!(question(&app).is_none()); + assert_eq!(files(&out), ["Data_Set_1.png", "Data_Set_3.png"], "Yes leaves set 2 out and writes set 3"); + assert!(app.ui.status.contains("Data Set 2") && !app.ui.status_error, "the status lists the skipped set: {}", app.ui.status); + let _ = std::fs::remove_dir_all(dir); +} + +#[test] +fn no_stops_with_the_files_written_so_far() { + let dir = scratch("no"); + let out = dir.join("out"); + let (mut app, ctx) = app(&dir, &[true, false, true]); + export_from_form(&mut app, &ctx, &out); + let (id, _) = question(&app).unwrap(); + answer(&mut app, &ctx, id, false); + assert!(question(&app).is_none()); + assert_eq!(files(&out), ["Data_Set_1.png"], "No writes nothing more"); + let _ = std::fs::remove_dir_all(dir); +} + +#[test] +fn several_missing_images_in_a_row_ask_once_each_in_every_combination() { + for (answers, want) in + [(vec![true, true], vec!["Data_Set_1.png", "Data_Set_4.png"]), (vec![true, false], vec!["Data_Set_1.png"]), (vec![false], vec!["Data_Set_1.png"])] + { + let dir = scratch(&format!("row-{answers:?}").replace([' ', ',', '[', ']'], "")); + let out = dir.join("out"); + let (mut app, ctx) = app(&dir, &[true, false, false, true]); + export_from_form(&mut app, &ctx, &out); + let mut asked = Vec::new(); + for yes in &answers { + let (id, message) = question(&app).expect("asked"); + asked.push(message); + answer(&mut app, &ctx, id, *yes); + } + assert!(question(&app).is_none(), "{answers:?}: no further question"); + assert_eq!(files(&out), want, "{answers:?}"); + assert!(asked[0].contains("Data Set 2"), "{asked:?}"); + if let Some(second) = asked.get(1) { + assert!(second.contains("Data Set 3"), "{asked:?}"); + } + let _ = std::fs::remove_dir_all(dir); + } +} + +#[test] +fn a_missing_image_in_the_last_set_keeps_todays_error() { + let dir = scratch("last"); + let out = dir.join("out"); + let (mut app, ctx) = app(&dir, &[true, false]); + export_from_form(&mut app, &ctx, &out); + assert!(question(&app).is_none(), "not measured: no question for the last set"); + assert_eq!(files(&out), ["Data_Set_1.png"]); + let _ = std::fs::remove_dir_all(dir); +} + +#[test] +fn the_command_reports_skipped_and_stopped_sets_without_a_prompt() { + let dir = scratch("cmd"); + let (mut app, _) = app(&dir, &[true, false, true]); + let out = |n: &str| dir.join(n).to_string_lossy().into_owned(); + + // Default: today's error, after Data Set 1. + let e = app.run(EXPORT, json!({"dir": out("error")})).unwrap_err(); + assert!(e.starts_with(photocraft_engine::DATA_SET_FILE_MISSING), "{e}"); + assert_eq!(files(&dir.join("error")), ["Data_Set_1.png"]); + + let r = app.run(EXPORT, json!({"dir": out("skip"), "missingImage": "skip"})).unwrap(); + assert_eq!(r["skipped"], json!(["Data Set 2"])); + assert_eq!(r["count"], json!(2)); + assert!(r.get("stopped").is_none()); + assert_eq!(files(&dir.join("skip")), ["Data_Set_1.png", "Data_Set_3.png"]); + + let r = app.run(EXPORT, json!({"dir": out("stop"), "missingImage": "stop", "naming": "{index}"})).unwrap(); + assert_eq!(r["stopped"]["name"], json!("Data Set 2")); + assert_eq!(r["stopped"]["index"], json!(1)); + assert_eq!(r["stopped"]["remaining"], json!(1)); + assert!(r["stopped"]["error"].as_str().unwrap().starts_with(photocraft_engine::DATA_SET_FILE_MISSING)); + assert_eq!(r["skipped"], json!([])); + assert_eq!(files(&dir.join("stop")), ["001.png"]); + + // `start` resumes after the stop and keeps the numbering of the whole batch. + let r = app.run(EXPORT, json!({"dir": out("stop"), "missingImage": "stop", "naming": "{index}", "start": 2})).unwrap(); + assert_eq!(r["count"], json!(1)); + assert_eq!(files(&dir.join("stop")), ["001.png", "003.png"]); + let _ = std::fs::remove_dir_all(dir); +} + +#[test] +fn bad_missing_image_and_start_params_are_errors_not_panics() { + let dir = scratch("bad"); + let (mut app, _) = app(&dir, &[true, false]); + let out = dir.join("out").to_string_lossy().into_owned(); + for params in [ + json!({"dir": out, "missingImage": "maybe"}), + json!({"dir": out, "missingImage": 3}), + json!({"dir": out, "start": 2}), + json!({"dir": out, "start": -1}), + json!({"dir": out, "start": 1.5}), + json!({"dir": out, "start": "1"}), + json!({"dir": out, "start": u64::MAX}), + ] { + assert!(app.run(EXPORT, params.clone()).is_err(), "{params}"); + } + assert!(files(&dir.join("out")).is_empty(), "a refused batch writes nothing"); + let _ = std::fs::remove_dir_all(dir); +} diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index 7e6cc44d0c4..499201db99d 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -1080,6 +1080,8 @@ mod artboards_to_pdf_reverse_tests; #[cfg(test)] mod browse_field_tests; #[cfg(test)] +mod export_data_sets_missing_image_tests; +#[cfg(test)] mod export_quality_tests; #[cfg(test)] mod select_and_mask_button_tests; diff --git a/crates/ui-egui/src/menus/view_cmds/dialogs.rs b/crates/ui-egui/src/menus/view_cmds/dialogs.rs index 9a81a77de55..38a6eedd406 100644 --- a/crates/ui-egui/src/menus/view_cmds/dialogs.rs +++ b/crates/ui-egui/src/menus/view_cmds/dialogs.rs @@ -1076,6 +1076,89 @@ pub(crate) fn batch_check(app: &mut PhotocraftApp, result: &ParamResult) -> Resu Err(Label::from(message)) } +/// File › Export › Data Sets as Files (#13767). +pub(crate) const DATA_SETS: &str = "file.export.dataSetsAsFiles"; + +/// The Data Sets as Files form's OK: runs the export with `missingImage: "stop"`, so a data set +/// whose replacement image is missing asks whether to export the remaining sets. +pub(crate) fn data_sets_run(app: &mut PhotocraftApp, ctx: &egui::Context, mut result: ParamResult) { + result.fields.set("missingImage", FieldValue::Text("stop".into())); + let doc = app.session.active().map(|st| st.doc.id); + let params = crate::dialogs::filter_dialog::command_params(DATA_SETS, &result.fields); + match crate::dialogs::filter_dialog::run_command(app, ctx, DATA_SETS, result) { + Ok(reply) => data_sets_went_on(app, doc, params, Vec::new(), &reply), + Err(error) => crate::notices::error(app, error), + } +} + +/// The question a missing replacement image asks: the document, the export's parameters, the set +/// it stopped at and where the batch resumes, and the sets skipped so far. +pub(crate) struct DataSetsMissingImage { + pub(crate) doc: Option, + pub(crate) params: Value, + pub(crate) name: String, + pub(crate) resume: usize, + pub(crate) skipped: Vec, +} + +/// After one run of the export: a set it stopped at asks Yes / No, unless it was the last set +/// (not measured: today's error stands). A finished export lists the sets skipped in the status bar. +fn data_sets_went_on(app: &mut PhotocraftApp, doc: Option, params: Value, skipped: Vec, reply: &Value) { + let Some(stopped) = reply.get("stopped").filter(|s| s.is_object()) else { + if !skipped.is_empty() { + app.ui.status = crate::i18n::fmt(tl!("Data sets not exported (replacement file not found): {names}"), &[("names", &skipped.join(", "))]); + app.ui.status_error = false; + } + return; + }; + let name = stopped.get("name").and_then(Value::as_str).unwrap_or_default().to_owned(); + let index = stopped.get("index").and_then(Value::as_u64).and_then(|n| usize::try_from(n).ok()); + let remaining = stopped.get("remaining").and_then(Value::as_u64).unwrap_or(0); + let (Some(index), true) = (index, remaining > 0) else { + let error = stopped.get("error").and_then(Value::as_str).unwrap_or(photocraft_engine::DATA_SET_FILE_MISSING).to_owned(); + crate::notices::error(app, error); + return; + }; + let message = crate::i18n::fmt(tl!("“{name}” was not exported: its replacement file was not found. Export the remaining data sets?"), &[("name", &name)]); + let tag = DataSetsMissingImage { doc, params, name, resume: index.saturating_add(1), skipped }; + let prompt = craft::ui::dialog::StandardPrompt::custom(message) + .title(tl!("Data Sets as Files")) + .icon(craft::behavior::IconId::new("info")) + .button(craft::ui::dialog::PromptChoice::Proceed, tl!("Yes")) + .button(craft::ui::dialog::PromptChoice::Cancel, tl!("No")) + .tag(tag); + if crate::dialogs::alerts::open_prompt(app, prompt).is_err() { + crate::dialogs::alerts::report_error(app, tl!("Data Sets as Files stopped: another question is open")); + } +} + +/// The `PROMPTS` entry of the missing-image question: Yes skips that set and exports the rest +/// (asking again at the next missing image), No stops with the files written so far. +pub(crate) fn data_sets_answer(app: &mut PhotocraftApp, _ctx: &egui::Context, answer: &mut craft::ui::dialog::PromptAnswer) -> bool { + let Some(mut pending) = answer.take_tag::() else { return false }; + pending.skipped.push(pending.name.clone()); + if answer.choice != craft::ui::dialog::PromptChoice::Proceed { + app.ui.status = crate::i18n::fmt(tl!("Data Sets as Files stopped at “{name}”"), &[("name", &pending.name)]); + app.ui.status_error = false; + return true; + } + let mut params = pending.params.clone(); + if let Some(map) = params.as_object_mut() { + map.insert("start".into(), json!(pending.resume)); + map.insert("missingImage".into(), json!("stop")); + } + let run = |app: &mut PhotocraftApp| app.run(DATA_SETS, params.clone()); + let outcome = match pending.doc { + Some(doc) => app.with_document(doc, run), + None => run(app), + }; + match outcome { + Ok(reply) => data_sets_went_on(app, pending.doc, pending.params, pending.skipped, &reply), + Err(error) => crate::notices::error(app, error), + } + true +} + #[cfg(test)] #[path = "batch_ok_validation_tests.rs"] mod batch_ok_validation_tests; From 9183e68b3a4a154d5eacf07a170fe016dfbd248d Mon Sep 17 00:00:00 2001 From: qvest-ssels <214787280+qvest-ssels@users.noreply.github.com> Date: Sun, 29 Nov 2026 01:08:13 +0100 Subject: [PATCH 32/81] Data Sets as Files: list skipped sets only when a set was left out An export without a missing image keeps its old result shape. --- crates/automation/src/headless.rs | 7 ++++--- crates/engine-core/src/cmd/variables_cmds.rs | 10 +++++++--- .../src/export_data_sets_missing_image_tests.rs | 2 +- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/crates/automation/src/headless.rs b/crates/automation/src/headless.rs index 8ec269bb4b1..a7193312765 100644 --- a/crates/automation/src/headless.rs +++ b/crates/automation/src/headless.rs @@ -345,9 +345,10 @@ impl Headless { let mut result = exported(dir, written, &mut outputs)?; if let Some(report) = report { let full = report.json(Vec::new()); - result["skipped"] = full["skipped"].clone(); - if let Some(stopped) = full.get("stopped") { - result["stopped"] = stopped.clone(); + for key in ["skipped", "stopped"] { + if let Some(value) = full.get(key) { + result[key] = value.clone(); + } } } Ok(result) diff --git a/crates/engine-core/src/cmd/variables_cmds.rs b/crates/engine-core/src/cmd/variables_cmds.rs index ee3059fa6b0..40f9019f1dd 100644 --- a/crates/engine-core/src/cmd/variables_cmds.rs +++ b/crates/engine-core/src/cmd/variables_cmds.rs @@ -465,7 +465,7 @@ fn split_csv(line: &str, delim: u8) -> Vec { } /// Apply each data set in turn and export the flattened document, restoring the original after. -/// `{dir, format?("png"), dataSets?[names], missingImage?, start?}` → `{files:[…],count,skipped,stopped?}`. +/// `{dir, format?("png"), dataSets?[names], missingImage?, start?}` → `{files:[…],count,skipped?,stopped?}`. fn export_as_files(s: &mut Session, p: &Value) -> Result { let dir = p.get("dir").and_then(Value::as_str).ok_or_else(|| bad("file.export.dataSetsAsFiles", "need `dir`"))?.to_string(); // The directory appears only once the batch has been planned, as it always did, so a batch @@ -518,7 +518,11 @@ impl DataSetsExportReport { /// The command's result, with `files` as the caller names them (joined to its folder). pub fn json(&self, files: Vec) -> Value { let count = files.len(); - let mut out = json!({"files": files, "count": count, "skipped": self.skipped}); + let mut out = json!({"files": files, "count": count}); + // Listed only when a set was left out, so an export without a missing image reads as before. + if !self.skipped.is_empty() { + out["skipped"] = json!(self.skipped); + } if let Some(stop) = &self.stopped { out["stopped"] = json!({"name": stop.name, "index": stop.index, "remaining": stop.remaining, "error": stop.error}); } @@ -693,7 +697,7 @@ pub fn specs() -> Vec { "file.export.dataSetsAsFiles", "Data Sets as Files…", &["File", "Export"], - "{dir, format?:png, dataSets?[names], naming?:\"{name}|{index}|{document}\", missingImage?:error|skip|stop, start?:n} → {files,count,skipped,stopped?:{name,index,remaining,error}}: apply each data set and export the flattened document; colliding filenames are rejected before writing (include {index} to disambiguate). A set whose Pixel Replacement image does not exist ends the export with an error (missingImage error, the default), is left out and listed in `skipped` (skip), or ends the export without an error, named in `stopped` (stop); `start` resumes at that 0-based set, keeping {index}", + "{dir, format?:png, dataSets?[names], naming?:\"{name}|{index}|{document}\", missingImage?:error|skip|stop, start?:n} → {files,count,skipped?,stopped?:{name,index,remaining,error}}: apply each data set and export the flattened document; colliding filenames are rejected before writing (include {index} to disambiguate). A set whose Pixel Replacement image does not exist ends the export with an error (missingImage error, the default), is left out and listed in `skipped` (skip), or ends the export without an error, named in `stopped` (stop); `start` resumes at that 0-based set, keeping {index}", has_data_sets, |s, p| export_as_files(s, p) ), diff --git a/crates/ui-egui/src/export_data_sets_missing_image_tests.rs b/crates/ui-egui/src/export_data_sets_missing_image_tests.rs index 9085ee0464a..f6078fd135f 100644 --- a/crates/ui-egui/src/export_data_sets_missing_image_tests.rs +++ b/crates/ui-egui/src/export_data_sets_missing_image_tests.rs @@ -167,7 +167,7 @@ fn the_command_reports_skipped_and_stopped_sets_without_a_prompt() { assert_eq!(r["stopped"]["index"], json!(1)); assert_eq!(r["stopped"]["remaining"], json!(1)); assert!(r["stopped"]["error"].as_str().unwrap().starts_with(photocraft_engine::DATA_SET_FILE_MISSING)); - assert_eq!(r["skipped"], json!([])); + assert!(r.get("skipped").is_none(), "nothing was skipped: {r}"); assert_eq!(files(&dir.join("stop")), ["001.png"]); // `start` resumes after the stop and keeps the numbering of the whole batch. From 17fbcc9f81df3bfccdcb5402e818db4ef56afd41 Mon Sep 17 00:00:00 2001 From: qvest-ssels <214787280+qvest-ssels@users.noreply.github.com> Date: Sun, 29 Nov 2026 01:21:07 +0100 Subject: [PATCH 33/81] Data Sets as Files: end the export when the data sets changed while the question was open The batch resumes by position, so edited data sets would resume at another set. --- .../export_data_sets_missing_image_tests.rs | 18 ++++++++++++++++++ crates/ui-egui/src/menus/view_cmds/dialogs.rs | 16 +++++++++++++--- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/crates/ui-egui/src/export_data_sets_missing_image_tests.rs b/crates/ui-egui/src/export_data_sets_missing_image_tests.rs index f6078fd135f..96f9087e3db 100644 --- a/crates/ui-egui/src/export_data_sets_missing_image_tests.rs +++ b/crates/ui-egui/src/export_data_sets_missing_image_tests.rs @@ -196,3 +196,21 @@ fn bad_missing_image_and_start_params_are_errors_not_panics() { assert!(files(&dir.join("out")).is_empty(), "a refused batch writes nothing"); let _ = std::fs::remove_dir_all(dir); } + +#[test] +fn data_sets_changed_while_asking_end_the_export_instead_of_resuming_at_another_set() { + let dir = scratch("changed"); + let out = dir.join("out"); + let (mut app, ctx) = app(&dir, &[true, false, true]); + export_from_form(&mut app, &ctx, &out); + let (id, _) = question(&app).unwrap(); + // Reorder the sets while the question is open: position 2 is now another set. + let sets = app.run("variables.list", json!({})).unwrap()["dataSets"].as_array().unwrap().clone(); + let reordered: Vec = [2, 0, 1].iter().map(|i| sets[*i].clone()).collect(); + app.run("image.variables.dataSets", json!({"dataSets": reordered})).unwrap(); + answer(&mut app, &ctx, id, true); + assert!(question(&app).is_none()); + assert_eq!(files(&out), ["Data_Set_1.png"], "nothing more is written"); + assert!(app.ui.status_error && app.ui.status.contains("changed"), "{}", app.ui.status); + let _ = std::fs::remove_dir_all(dir); +} diff --git a/crates/ui-egui/src/menus/view_cmds/dialogs.rs b/crates/ui-egui/src/menus/view_cmds/dialogs.rs index 38a6eedd406..3e491396477 100644 --- a/crates/ui-egui/src/menus/view_cmds/dialogs.rs +++ b/crates/ui-egui/src/menus/view_cmds/dialogs.rs @@ -1091,10 +1091,12 @@ pub(crate) fn data_sets_run(app: &mut PhotocraftApp, ctx: &egui::Context, mut re } } -/// The question a missing replacement image asks: the document, the export's parameters, the set -/// it stopped at and where the batch resumes, and the sets skipped so far. +/// The question a missing replacement image asks: the document and its data sets as the export +/// read them, the export's parameters, the set it stopped at and where the batch resumes, and the +/// sets skipped so far. pub(crate) struct DataSetsMissingImage { pub(crate) doc: Option, + pub(crate) sets: Vec, pub(crate) params: Value, pub(crate) name: String, pub(crate) resume: usize, @@ -1120,7 +1122,8 @@ fn data_sets_went_on(app: &mut PhotocraftApp, doc: Option return; }; let message = crate::i18n::fmt(tl!("“{name}” was not exported: its replacement file was not found. Export the remaining data sets?"), &[("name", &name)]); - let tag = DataSetsMissingImage { doc, params, name, resume: index.saturating_add(1), skipped }; + let sets = app.session.active().map(|st| st.doc.variables.data_sets.clone()).unwrap_or_default(); + let tag = DataSetsMissingImage { doc, sets, params, name, resume: index.saturating_add(1), skipped }; let prompt = craft::ui::dialog::StandardPrompt::custom(message) .title(tl!("Data Sets as Files")) .icon(craft::behavior::IconId::new("info")) @@ -1142,6 +1145,13 @@ pub(crate) fn data_sets_answer(app: &mut PhotocraftApp, _ctx: &egui::Context, an app.ui.status_error = false; return true; } + // The batch resumes by position: data sets edited while the question was open would resume at + // another set, so the export ends there instead. + let current = |app: &PhotocraftApp| app.session.documents().iter().find(|st| Some(st.doc.id) == pending.doc).map(|st| st.doc.variables.data_sets.clone()); + if pending.doc.is_some() && current(app).as_ref() != Some(&pending.sets) { + crate::dialogs::alerts::report_error(app, tl!("Data Sets as Files stopped: the data sets changed while the question was open")); + return true; + } let mut params = pending.params.clone(); if let Some(map) = params.as_object_mut() { map.insert("start".into(), json!(pending.resume)); From 0e446923e86f635e6639cea585ac1304c5a2376a Mon Sep 17 00:00:00 2001 From: qvest-ssels <214787280+qvest-ssels@users.noreply.github.com> Date: Sun, 29 Nov 2026 01:44:19 +0100 Subject: [PATCH 34/81] Print: Scale takes up to 1500 % with 2 decimals, lower bound 0.01 % (#14135) The Scale field stopped at 1000 % and started at 1 %. The reference application accepts up to 1500.00 %; the lower bound stays above 0 at the smallest 2-decimal step. --- crates/ui-egui/src/dialogs/file_ui/print.rs | 2 +- crates/ui-egui/tests/it/main.rs | 1 + crates/ui-egui/tests/it/print_scale_range.rs | 79 ++++++++++++++++++++ 3 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 crates/ui-egui/tests/it/print_scale_range.rs diff --git a/crates/ui-egui/src/dialogs/file_ui/print.rs b/crates/ui-egui/src/dialogs/file_ui/print.rs index 613fdb9f9c0..7f7e9ca8791 100644 --- a/crates/ui-egui/src/dialogs/file_ui/print.rs +++ b/crates/ui-egui/src/dialogs/file_ui/print.rs @@ -270,7 +270,7 @@ pub(super) fn sections(fields: &DialogFields) -> Vec { position("top", tl!("Top")), position("left", tl!("Left")), Param::new("scaleToFit", tl!("Scale to Fit Media"), ParamKind::bool(false)), - Param::new("scale", tl!("Scale (%)"), ParamKind::number(Some(1.0), Some(1000.0), 100.0, 1.0, 2)) + Param::new("scale", tl!("Scale (%)"), ParamKind::number(Some(0.01), Some(1500.0), 100.0, 1.0, 2)) .enabled_when("scaleToFit", FieldValue::Bool(false)), ], ), diff --git a/crates/ui-egui/tests/it/main.rs b/crates/ui-egui/tests/it/main.rs index 5315c28e74b..7fae6cd74f2 100644 --- a/crates/ui-egui/tests/it/main.rs +++ b/crates/ui-egui/tests/it/main.rs @@ -29,6 +29,7 @@ mod magnetic_lasso_right_click; mod mixer_reset_defaults; mod paint_bucket_all_layers; mod pending_remove_pointer; +mod print_scale_range; mod radial_blur_center; mod save_memory_gate; mod system_locale; diff --git a/crates/ui-egui/tests/it/print_scale_range.rs b/crates/ui-egui/tests/it/print_scale_range.rs new file mode 100644 index 00000000000..65a4fa18dc3 --- /dev/null +++ b/crates/ui-egui/tests/it/print_scale_range.rs @@ -0,0 +1,79 @@ +//! #14135 (range part): File › Print's Scale field takes up to 1500 % with 2 decimals, as the reference application +//! does; the lower bound stays above 0 (the smallest step of 2 decimals, 0.01 %). Values are typed into the field as +//! a user types them. + +use egui::{Event, Key, Modifiers, PointerButton}; +use egui_kittest::Harness; +use egui_kittest::kittest::Queryable; +use photocraft_engine::print_cmds::PrintExt; +use photocraft_ui_egui::PhotocraftApp; +use photocraft_ui_egui::control::{ControlRequest, Reply}; +use serde_json::{Value, json}; + +type H = Harness<'static, Box>; + +fn harness() -> H { + let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), photocraft_ui_egui::Services::default()); + // Print lists this printer and does not ask the spooler. + *app.session.printer_source_mut() = + Some(std::sync::Arc::new(|| vec![craft::print::Printer { name: "Test printer".into(), default: true, two_sided: None, description: String::new() }])); + app.run("file.new", json!({"width": 600, "height": 400})).unwrap(); + photocraft_engine::print_cmds::with_spooler(|| photocraft_ui_egui::file_ui::open_print(&mut app)); + let mut h = Harness::builder() + .with_size(egui::vec2(1000.0, 900.0)) + .with_max_steps(64) + .with_context(app.ctx().clone()) + .build_ui_state(|ui, app: &mut Box| photocraft_ui_egui::dialogs::run(app, ui), app); + h.run_steps(4); + h +} + +/// The Print dialog's `scale` as `ui.inspect` lists it. +fn scale(h: &mut H) -> f64 { + let (request, _) = ControlRequest::new("ui.inspect", json!({})); + let ctx = h.ctx.clone(); + let Reply::Done(reply) = photocraft_ui_egui::control::handle(h.state_mut(), &ctx, &request) else { panic!("ui.inspect did not answer") }; + let dialogs = reply["result"]["dialogs"].as_array().cloned().unwrap_or_default(); + dialogs.iter().find_map(|d| d["fields"].get("scale").and_then(Value::as_f64)).expect("the Print dialog lists its scale") +} + +/// Types `text` into the Scale field and leaves it with Tab. The decimal mark is typed as the system writes it, since +/// the field takes only that one on a system that sets it (a German system refuses a typed `.`). +fn type_scale(h: &mut H, text: &str) { + let text = text.replace('.', &photocraft_ui_egui::i18n::decimal_separator().unwrap_or('.').to_string()); + let pos = h.get_by_role_and_label(egui::accesskit::Role::SpinButton, "Scale (%)").rect().center(); + h.event(Event::PointerMoved(pos)); + h.event(Event::PointerButton { pos, button: PointerButton::Primary, pressed: true, modifiers: Modifiers::NONE }); + h.run_steps(1); + h.event(Event::PointerButton { pos, button: PointerButton::Primary, pressed: false, modifiers: Modifiers::NONE }); + h.run_steps(1); + h.key_press_modifiers(Modifiers::COMMAND, Key::A); + h.event(Event::Text(text)); + h.run_steps(1); + h.key_press(Key::Tab); + h.run_steps(3); +} + +/// The Scale field after typing `typed` into a freshly opened Print dialog. +fn typed_scale(typed: &str) -> f64 { + let mut h = harness(); + type_scale(&mut h, typed); + scale(&mut h) +} + +#[test] +fn scale_defaults_to_100_and_takes_up_to_1500_with_two_decimals() { + assert_eq!(scale(&mut harness()), 100.0); + for (typed, want) in [("1500", 1500.0), ("1200.5", 1200.5), ("413.19", 413.19), ("2000", 1500.0), ("1500.01", 1500.0)] { + let shown = typed_scale(typed); + assert!((shown - want).abs() < 1e-9, "typed {typed}: {shown} (want {want})"); + } +} + +#[test] +fn the_lower_bound_stays_above_zero() { + for (typed, want) in [("0.01", 0.01), ("0", 0.01), ("-5", 0.01)] { + let shown = typed_scale(typed); + assert!(shown > 0.0 && (shown - want).abs() < 1e-9, "typed {typed}: {shown} (want {want})"); + } +} From 44c80e3f489077bbaa46835954eec8bc7ac02a40 Mon Sep 17 00:00:00 2001 From: qvest-ssels <214787280+qvest-ssels@users.noreply.github.com> Date: Sun, 29 Nov 2026 10:09:14 +0100 Subject: [PATCH 35/81] Data Sets as Files: ask again with the stopped document's sets, and keep earlier skipped sets in No's status (#13767) The next missing-image question read the active document's data sets, so a document made active while the first question was open made the next Yes end the export as "changed". No after an earlier Yes listed only the set it stopped at; it now lists every set left out. --- .../export_data_sets_missing_image_tests.rs | 38 +++++++++++++++++++ crates/ui-egui/src/menus/view_cmds/dialogs.rs | 14 ++++++- 2 files changed, 50 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/export_data_sets_missing_image_tests.rs b/crates/ui-egui/src/export_data_sets_missing_image_tests.rs index 96f9087e3db..774375498b5 100644 --- a/crates/ui-egui/src/export_data_sets_missing_image_tests.rs +++ b/crates/ui-egui/src/export_data_sets_missing_image_tests.rs @@ -214,3 +214,41 @@ fn data_sets_changed_while_asking_end_the_export_instead_of_resuming_at_another_ assert!(app.ui.status_error && app.ui.status.contains("changed"), "{}", app.ui.status); let _ = std::fs::remove_dir_all(dir); } + +#[test] +fn no_after_an_earlier_yes_lists_every_set_left_out() { + let dir = scratch("yes-no-status"); + let out = dir.join("out"); + let (mut app, ctx) = app(&dir, &[true, false, false, true]); + export_from_form(&mut app, &ctx, &out); + let (id, _) = question(&app).unwrap(); + answer(&mut app, &ctx, id, true); + let (id, _) = question(&app).expect("set 3 asks too"); + answer(&mut app, &ctx, id, false); + assert_eq!(files(&out), ["Data_Set_1.png"], "No writes nothing more"); + let status = &app.ui.status; + assert!(status.contains("Data Set 2") && status.contains("Data Set 3") && !app.ui.status_error, "both sets left out are listed: {status}"); + let _ = std::fs::remove_dir_all(dir); +} + +#[test] +fn another_document_made_active_while_asking_does_not_stop_the_next_yes() { + let dir = scratch("other-doc"); + let out = dir.join("out"); + let (mut app, ctx) = app(&dir, &[true, false, false, true]); + export_from_form(&mut app, &ctx, &out); + let (id, _) = question(&app).unwrap(); + // A second document, with no data sets, becomes the active one while the question is open. + app.run("file.new", json!({"width": 8, "height": 8})).unwrap(); + app.sync_views(); + let other = app.session.active().unwrap().doc.id; + answer(&mut app, &ctx, id, true); + assert_eq!(app.session.active().unwrap().doc.id, other, "the other document stays active"); + let (id, message) = question(&app).expect("set 3 asks"); + assert!(message.contains("Data Set 3"), "{message}"); + answer(&mut app, &ctx, id, true); + assert!(question(&app).is_none()); + assert_eq!(files(&out), ["Data_Set_1.png", "Data_Set_4.png"], "the export goes on with the document it ran on"); + assert!(!app.ui.status_error, "{}", app.ui.status); + let _ = std::fs::remove_dir_all(dir); +} diff --git a/crates/ui-egui/src/menus/view_cmds/dialogs.rs b/crates/ui-egui/src/menus/view_cmds/dialogs.rs index 3e491396477..a51fc09a189 100644 --- a/crates/ui-egui/src/menus/view_cmds/dialogs.rs +++ b/crates/ui-egui/src/menus/view_cmds/dialogs.rs @@ -1122,7 +1122,9 @@ fn data_sets_went_on(app: &mut PhotocraftApp, doc: Option return; }; let message = crate::i18n::fmt(tl!("“{name}” was not exported: its replacement file was not found. Export the remaining data sets?"), &[("name", &name)]); - let sets = app.session.active().map(|st| st.doc.variables.data_sets.clone()).unwrap_or_default(); + // The sets of the document the export ran on, as Yes compares them: a resumed run restores the document that was + // active, which may be another one by now. + let sets = app.session.documents().iter().find(|st| Some(st.doc.id) == doc).map(|st| st.doc.variables.data_sets.clone()).unwrap_or_default(); let tag = DataSetsMissingImage { doc, sets, params, name, resume: index.saturating_add(1), skipped }; let prompt = craft::ui::dialog::StandardPrompt::custom(message) .title(tl!("Data Sets as Files")) @@ -1141,7 +1143,15 @@ pub(crate) fn data_sets_answer(app: &mut PhotocraftApp, _ctx: &egui::Context, an let Some(mut pending) = answer.take_tag::() else { return false }; pending.skipped.push(pending.name.clone()); if answer.choice != craft::ui::dialog::PromptChoice::Proceed { - app.ui.status = crate::i18n::fmt(tl!("Data Sets as Files stopped at “{name}”"), &[("name", &pending.name)]); + // Sets skipped by an earlier Yes stay listed next to the one it stopped at. + app.ui.status = if pending.skipped.len() > 1 { + crate::i18n::fmt( + tl!("Data Sets as Files stopped at “{name}”. Data sets not exported (replacement file not found): {names}"), + &[("name", &pending.name), ("names", &pending.skipped.join(", "))], + ) + } else { + crate::i18n::fmt(tl!("Data Sets as Files stopped at “{name}”"), &[("name", &pending.name)]) + }; app.ui.status_error = false; return true; } From 9fb0ba2f8f267c09ce22c8618caaf63787177252 Mon Sep 17 00:00:00 2001 From: qvest-ssels <214787280+qvest-ssels@users.noreply.github.com> Date: Sun, 29 Nov 2026 10:29:22 +0100 Subject: [PATCH 36/81] Data Sets as Files: end the export when the variables were bound anew while the question was open (#13767) Yes compared only the data sets, so a variable bound to another layer while the question was open made the rest of the batch come from that layer. It now compares the variable definitions too. --- .../export_data_sets_missing_image_tests.rs | 18 ++++++++++++ crates/ui-egui/src/menus/view_cmds/dialogs.rs | 29 ++++++++++++++----- 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/crates/ui-egui/src/export_data_sets_missing_image_tests.rs b/crates/ui-egui/src/export_data_sets_missing_image_tests.rs index 774375498b5..2a1e0ac33e5 100644 --- a/crates/ui-egui/src/export_data_sets_missing_image_tests.rs +++ b/crates/ui-egui/src/export_data_sets_missing_image_tests.rs @@ -252,3 +252,21 @@ fn another_document_made_active_while_asking_does_not_stop_the_next_yes() { assert!(!app.ui.status_error, "{}", app.ui.status); let _ = std::fs::remove_dir_all(dir); } + +#[test] +fn a_variable_bound_anew_while_asking_ends_the_export() { + let dir = scratch("rebound"); + let out = dir.join("out"); + let (mut app, ctx) = app(&dir, &[true, false, true]); + export_from_form(&mut app, &ctx, &out); + let (id, _) = question(&app).unwrap(); + // Bind the variable to another layer while the question is open: the rest would come from it. + app.run("layer.new.layer", json!({"name": "other"})).unwrap(); + let layer = app.session.active().unwrap().active_layer.unwrap().0; + app.run("image.variables.define", json!({"defs": [{"name": "photo", "layer": layer, "type": "pixelReplacement"}]})).unwrap(); + answer(&mut app, &ctx, id, true); + assert!(question(&app).is_none()); + assert_eq!(files(&out), ["Data_Set_1.png"], "nothing more is written"); + assert!(app.ui.status_error && app.ui.status.contains("changed"), "{}", app.ui.status); + let _ = std::fs::remove_dir_all(dir); +} diff --git a/crates/ui-egui/src/menus/view_cmds/dialogs.rs b/crates/ui-egui/src/menus/view_cmds/dialogs.rs index a51fc09a189..d810131d1fe 100644 --- a/crates/ui-egui/src/menus/view_cmds/dialogs.rs +++ b/crates/ui-egui/src/menus/view_cmds/dialogs.rs @@ -1091,11 +1091,12 @@ pub(crate) fn data_sets_run(app: &mut PhotocraftApp, ctx: &egui::Context, mut re } } -/// The question a missing replacement image asks: the document and its data sets as the export -/// read them, the export's parameters, the set it stopped at and where the batch resumes, and the +/// The question a missing replacement image asks: the document and its variables and data sets as +/// the export read them, the export's parameters, the set it stopped at and where the batch resumes, and the /// sets skipped so far. pub(crate) struct DataSetsMissingImage { pub(crate) doc: Option, + pub(crate) defs: Vec, pub(crate) sets: Vec, pub(crate) params: Value, pub(crate) name: String, @@ -1124,8 +1125,14 @@ fn data_sets_went_on(app: &mut PhotocraftApp, doc: Option let message = crate::i18n::fmt(tl!("“{name}” was not exported: its replacement file was not found. Export the remaining data sets?"), &[("name", &name)]); // The sets of the document the export ran on, as Yes compares them: a resumed run restores the document that was // active, which may be another one by now. - let sets = app.session.documents().iter().find(|st| Some(st.doc.id) == doc).map(|st| st.doc.variables.data_sets.clone()).unwrap_or_default(); - let tag = DataSetsMissingImage { doc, sets, params, name, resume: index.saturating_add(1), skipped }; + let (defs, sets) = app + .session + .documents() + .iter() + .find(|st| Some(st.doc.id) == doc) + .map(|st| (st.doc.variables.defs.clone(), st.doc.variables.data_sets.clone())) + .unwrap_or_default(); + let tag = DataSetsMissingImage { doc, defs, sets, params, name, resume: index.saturating_add(1), skipped }; let prompt = craft::ui::dialog::StandardPrompt::custom(message) .title(tl!("Data Sets as Files")) .icon(craft::behavior::IconId::new("info")) @@ -1156,10 +1163,16 @@ pub(crate) fn data_sets_answer(app: &mut PhotocraftApp, _ctx: &egui::Context, an return true; } // The batch resumes by position: data sets edited while the question was open would resume at - // another set, so the export ends there instead. - let current = |app: &PhotocraftApp| app.session.documents().iter().find(|st| Some(st.doc.id) == pending.doc).map(|st| st.doc.variables.data_sets.clone()); - if pending.doc.is_some() && current(app).as_ref() != Some(&pending.sets) { - crate::dialogs::alerts::report_error(app, tl!("Data Sets as Files stopped: the data sets changed while the question was open")); + // another set, and variables bound anew would write the rest from other layers, so the export + // ends there instead. + let unchanged = app + .session + .documents() + .iter() + .find(|st| Some(st.doc.id) == pending.doc) + .is_some_and(|st| st.doc.variables.defs == pending.defs && st.doc.variables.data_sets == pending.sets); + if pending.doc.is_some() && !unchanged { + crate::dialogs::alerts::report_error(app, tl!("Data Sets as Files stopped: the variables or data sets changed while the question was open")); return true; } let mut params = pending.params.clone(); From e4acd66b5f7732dc3c9389c1e3121678229921c9 Mon Sep 17 00:00:00 2001 From: sukit70 <361631270+sukit70@users.noreply.github.com> Date: Sun, 29 Nov 2026 08:25:52 -0300 Subject: [PATCH 37/81] Channels: intersecting a luminosity selection with the composite narrows it again select.loadSelection combined a loaded channel with the selection tools' min/max arithmetic, so Ctrl+Alt+Shift-clicking the composite after Ctrl-clicking it left the selection unchanged, and Select All minus the lights minus the darks came out empty. A loaded channel now combines with channel arithmetic: Intersect multiplies, Add screens and Subtract keeps a*(1-b). Fully selected and unselected pixels combine as before, so the selection tools and hard-edged loads are unchanged. --- crates/algo/src/selection.rs | 30 ++++++++++ crates/algo/src/selection/combine_mask.rs | 57 ++++++++++++++++--- .../algo/src/selection/combine_mask/tests.rs | 31 ++++++++++ crates/engine-core/src/cmd/channel_cmds.rs | 2 +- .../src/cmd/channel_cmds/selection.rs | 5 +- .../engine-core/src/cmd/channel_cmds/tests.rs | 47 +++++++++++++++ 6 files changed, 161 insertions(+), 11 deletions(-) diff --git a/crates/algo/src/selection.rs b/crates/algo/src/selection.rs index b0dec119566..44f1ee8bf9f 100644 --- a/crates/algo/src/selection.rs +++ b/crates/algo/src/selection.rs @@ -170,6 +170,36 @@ pub fn combine(old: Option<&Surface>, new: &[f32], area: Rect, mode: SelectionMo (s.tile_count() > 0).then_some(s) } +/// [`combine`] for a channel loaded as a selection, with Photoshop's channel arithmetic: where +/// coverage is partial, Add screens (`a + b − a·b`), Subtract keeps what `new` leaves +/// (`a·(1 − b)`) and Intersect multiplies (`a·b`). Intersecting a luminosity selection with the +/// luminosity again so narrows it to brighter tones at every step (a 50% grey goes 50%, 25%, +/// 12.5%, … while white stays selected), and Select All minus the lights minus the darks leaves +/// the midtones; [`combine`]'s min and max would leave the first unchanged and the second empty. +/// Fully selected and unselected pixels combine as in [`combine`]. Source: Greg Benz, "Photoshop +/// channel math: add, subtract, intersect" (gregbenzphotography.com, luminosity-masking). +pub fn combine_scaled(old: Option<&Surface>, new: &[f32], area: Rect, mode: SelectionMode) -> Option { + if area.is_empty() { + return None; + } + if mode == SelectionMode::Replace || (old.is_none() && mode == SelectionMode::Add) { + return combine(old, new, area, mode); + } + let old = old?; + if old.format() == PixelFormat::GRAY8 { + return combine_mask::gray8_with(Some(old), new, area, mode, false, combine_mask::Arithmetic::Scaled); + } + // Quantized to the 8-bit grid first, as in `combine`, so the float path agrees with the GRAY8 one. + let q = |v: f32| f32::from(coverage8(v)) / 255.0; + let prev = mask_from_surface(Some(old), area); + let s = match mode { + SelectionMode::Add => surface_from_masks(area, new, Some(&prev), |p, v| p + q(v) - p * q(v)), + SelectionMode::Subtract => surface_from_masks(area, new, Some(&prev), |p, v| p * (1.0 - q(v))), + _ => surface_from_masks(area, new, Some(&prev), |p, v| p * q(v)), + }; + (s.tile_count() > 0).then_some(s) +} + fn close(a: [f32; 4], b: [f32; 4], tol: f32) -> bool { (a[3] == 0.0 && b[3] == 0.0) || (0..4).all(|c| (a[c] - b[c]).abs() * 255.0 <= tol + 1e-3) } diff --git a/crates/algo/src/selection/combine_mask.rs b/crates/algo/src/selection/combine_mask.rs index 5c45ed8ff00..62b640551be 100644 --- a/crates/algo/src/selection/combine_mask.rs +++ b/crates/algo/src/selection/combine_mask.rs @@ -39,8 +39,45 @@ pub fn combine_band(old: Option<&Surface>, mask: &[f32], band: Rect, mode: Selec (out.tile_count() > 0).then_some(out) } +/// How two 8-bit coverages meet where both are partial. Fully selected and unselected pixels +/// combine the same way under both. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub(super) enum Arithmetic { + /// The selection tools': Add keeps the larger coverage, Subtract takes the clipped + /// difference and Intersect keeps the smaller. + Extremes, + /// A channel loaded as a selection (Photoshop's channel arithmetic): Add screens + /// (`a + b − a·b`), Subtract keeps what the new coverage leaves (`a·(1 − b)`) and Intersect + /// multiplies (`a·b`). Intersecting a partial selection with itself narrows it. + Scaled, +} + +impl Arithmetic { + pub(super) fn apply(self, mode: SelectionMode, prev: u8, new: u8) -> u8 { + match (self, mode) { + (_, SelectionMode::Replace) => new, + (Arithmetic::Extremes, SelectionMode::Add) => prev.max(new), + (Arithmetic::Extremes, SelectionMode::Subtract) => prev.saturating_sub(new), + (Arithmetic::Extremes, SelectionMode::Intersect) => prev.min(new), + (Arithmetic::Scaled, SelectionMode::Add) => u8::MAX - mul8(u8::MAX - prev, u8::MAX - new), + (Arithmetic::Scaled, SelectionMode::Subtract) => mul8(prev, u8::MAX - new), + (Arithmetic::Scaled, SelectionMode::Intersect) => mul8(prev, new), + } + } +} + +/// `a·b / 255` rounded to the nearest byte, exactly, for every pair of bytes. +pub(super) fn mul8(a: u8, b: u8) -> u8 { + let t = u32::from(a) * u32::from(b) + 128; + u8::try_from((t + (t >> 8)) >> 8).unwrap_or(u8::MAX) +} + pub(super) fn gray8(old: Option<&Surface>, mask: &[f32], area: Rect, mode: SelectionMode, keep_outside: bool) -> Option { - build(old, area, mode, keep_outside, |i| coverage8(mask.get(i).copied().unwrap_or(0.0))) + gray8_with(old, mask, area, mode, keep_outside, Arithmetic::Extremes) +} + +pub(super) fn gray8_with(old: Option<&Surface>, mask: &[f32], area: Rect, mode: SelectionMode, keep_outside: bool, arithmetic: Arithmetic) -> Option { + build(old, area, mode, keep_outside, arithmetic, |i| coverage8(mask.get(i).copied().unwrap_or(0.0))) } pub(super) fn gray8_bytes(old: Option<&Surface>, mask: &[u8], area: Rect, mode: SelectionMode) -> Option { @@ -48,10 +85,17 @@ pub(super) fn gray8_bytes(old: Option<&Surface>, mask: &[u8], area: Rect, mode: if area.is_empty() { return if keep { old.cloned().filter(|s| !s.content_bounds().is_empty()) } else { None }; } - build(old, area, mode, keep, |i| mask.get(i).copied().unwrap_or(0)) + build(old, area, mode, keep, Arithmetic::Extremes, |i| mask.get(i).copied().unwrap_or(0)) } -fn build(old: Option<&Surface>, area: Rect, mode: SelectionMode, keep_outside: bool, sample: impl Fn(usize) -> u8 + Sync) -> Option { +fn build( + old: Option<&Surface>, + area: Rect, + mode: SelectionMode, + keep_outside: bool, + arithmetic: Arithmetic, + sample: impl Fn(usize) -> u8 + Sync, +) -> Option { let mut out = if keep_outside { old.cloned().unwrap_or_else(|| Surface::new(PixelFormat::GRAY8)) } else { Surface::new(PixelFormat::GRAY8) }; let default = old.and_then(|s| s.default_bytes().first()).copied().unwrap_or(0); let out_default = out.default_bytes().first().copied().unwrap_or(0); @@ -77,12 +121,7 @@ fn build(old: Option<&Surface>, area: Rect, mode: SelectionMode, keep_outside: b for (i, d) in dst.iter_mut().enumerate() { let new = start.and_then(|j| j.checked_add(i)).map(&sample).unwrap_or(0); let prev = src.and_then(|s| s.get(i)).copied().unwrap_or(default); - *d = match mode { - SelectionMode::Replace => new, - SelectionMode::Add => prev.max(new), - SelectionMode::Subtract => prev.saturating_sub(new), - SelectionMode::Intersect => prev.min(new), - }; + *d = arithmetic.apply(mode, prev, new); } } let (lo, hi) = tile.bytes().iter().fold((u8::MAX, 0u8), |(lo, hi), b| (lo.min(*b), hi.max(*b))); diff --git a/crates/algo/src/selection/combine_mask/tests.rs b/crates/algo/src/selection/combine_mask/tests.rs index 5c55d9d90ab..1766965d890 100644 --- a/crates/algo/src/selection/combine_mask/tests.rs +++ b/crates/algo/src/selection/combine_mask/tests.rs @@ -76,6 +76,37 @@ fn cropped_bands_match_dense_writeback_with_defaults_and_short_masks() { } } +#[test] +fn scaled_combining_narrows_partial_coverage_and_keeps_hard_edges() { + use crate::selection::combine_scaled; + let area = Rect::new(0, 0, 256, 256); + let prev: Vec = (0..65536).map(|i| (i / 256) as f32 / 255.0).collect(); + let mask: Vec = (0..65536).map(|i| (i % 256) as f32 / 255.0).collect(); + let gray8 = crate::selection::mask_to_surface(&prev, area); + // An unusual (float) selection surface takes the float path; it must agree with the byte path everywhere. + let mut float = Surface::new(PixelFormat::new(ColorMode::Grayscale, SampleType::F32, false)); + float.write_region(area, &prev); + for mode in MODES { + let scaled = combine_scaled(Some(&gray8), &mask, area, mode); + assert_eq!(scaled, combine_scaled(Some(&float), &mask, area, mode), "{mode:?}: float and byte paths"); + let scaled = mask_from_surface(scaled.as_ref(), area); + let tools = mask_from_surface(combine(Some(&gray8), &mask, area, mode).as_ref(), area); + for (i, ((&p, &m), (&s, &t))) in prev.iter().zip(&mask).zip(scaled.iter().zip(&tools)).enumerate() { + if m == 0.0 || m == 1.0 { + assert_eq!(s, t, "{mode:?} {i}: a fully selected or unselected pixel combines as the tools do"); + continue; + } + match mode { + SelectionMode::Add => assert!(s >= t, "{mode:?} {i}: adding partial coverage keeps at least the larger one"), + SelectionMode::Subtract => assert!(s >= t, "{mode:?} {i}: subtracting scales the selection, never below the difference"), + SelectionMode::Intersect if p == m && p > 0.0 => assert!(s < p, "{mode:?} {i}: intersecting a partial selection with itself narrows it"), + SelectionMode::Intersect => assert!(s <= t, "{mode:?} {i}: intersecting keeps no more than the smaller one"), + SelectionMode::Replace => assert_eq!(s, t), + } + } + } +} + #[test] fn unusual_selection_formats_keep_their_float_behavior() { let area = Rect::new(-2, -1, 3, 2); diff --git a/crates/engine-core/src/cmd/channel_cmds.rs b/crates/engine-core/src/cmd/channel_cmds.rs index 0c7619d0cb4..f7c0d3ed7f2 100644 --- a/crates/engine-core/src/cmd/channel_cmds.rs +++ b/crates/engine-core/src/cmd/channel_cmds.rs @@ -169,7 +169,7 @@ pub fn specs() -> Vec { "Load Selection…", ["Select"], None, - r##"{"channel":index|name|"composite"|"red|green|blue|…"|"transparency"|"mask"|"vectorMask"|"quickMask"|"selection"|"targeted" (the Channels panel's target),"layer":id|name|{"name":str}|{"background":true}?,"document":index?,"invert":bool=false,"operation":"new|add|subtract|intersect"="new"}"##, + r##"{"channel":index|name|"composite"|"red|green|blue|…"|"transparency"|"mask"|"vectorMask"|"quickMask"|"selection"|"targeted" (the Channels panel's target),"layer":id|name|{"name":str}|{"background":true}?,"document":index?,"invert":bool=false,"operation":"new|add|subtract|intersect"="new"} (partial coverage combines as channels do: add screens, subtract keeps a·(1−b), intersect multiplies)"##, has_doc, load_selection ), diff --git a/crates/engine-core/src/cmd/channel_cmds/selection.rs b/crates/engine-core/src/cmd/channel_cmds/selection.rs index f5b1dc3f30f..6f053e37804 100644 --- a/crates/engine-core/src/cmd/channel_cmds/selection.rs +++ b/crates/engine-core/src/cmd/channel_cmds/selection.rs @@ -107,8 +107,11 @@ pub(super) fn load_selection(s: &mut Session, p: &Value) -> Result { let plane = source(s, p, cmd, true)?.into_iter().next().ok_or_else(|| bad(cmd, "the channel has no pixels"))?; let doc = &s.active().ok_or(EngineError::NoDocument)?.doc; let label = load_label(doc, p); + // A loaded channel meets the selection with channel arithmetic (multiply, screen), as Photoshop combines one: + // ⌘⇧⌥-clicking the composite again narrows a luminosity selection to brighter tones each time (lights, + // brighter lights, … up to the pure whites), where min / max would leave it unchanged. let selected = s.edit(label, |doc, _| { - doc.selection = sel::combine(doc.selection.as_ref(), &plane, doc.bounds(), mode); + doc.selection = sel::combine_scaled(doc.selection.as_ref(), &plane, doc.bounds(), mode); Ok(doc.selection.is_some()) })?; Ok(json!({ "selected": selected })) diff --git a/crates/engine-core/src/cmd/channel_cmds/tests.rs b/crates/engine-core/src/cmd/channel_cmds/tests.rs index 19666516f78..41f3cd47adf 100644 --- a/crates/engine-core/src/cmd/channel_cmds/tests.rs +++ b/crates/engine-core/src/cmd/channel_cmds/tests.rs @@ -101,6 +101,53 @@ fn load_selection_operations_and_invert() { assert_eq!(sel_at(&s, 25, 5), 1.0); } +/// Paints the 40 × 20 background with neutral greys, `grey(x)` in column `x` (`edit.fill` is +/// engine-paint's, not in this crate's session). +fn paint_greys(s: &mut Session, grey: impl Fn(usize) -> f32) { + let d = s.active_mut().unwrap(); + let id = d.active_layer.unwrap(); + let surf = std::sync::Arc::make_mut(d.doc_mut()).layer_mut(id).unwrap().surface_mut().unwrap(); + let n = surf.format().channels(); + let mut px = vec![1.0; 40 * 20 * n]; + for (i, p) in px.chunks_exact_mut(n).enumerate() { + p[..3].fill(grey(i % 40)); + } + surf.write_region(Rect::new(0, 0, 40, 20), &px); +} + +#[test] +fn intersecting_the_composite_luminosity_with_itself_narrows_it_toward_the_whites() { + // Luminosity masks: ⌘-click the composite, then ⌘⇧⌥-click it again and again. Each step multiplies the + // selection by the luminosity, so it narrows to brighter tones while white stays fully selected; Select All + // minus the lights minus the darks leaves the midtones. Min / max combining left the first unchanged and the + // second empty. + for depth in [8, 16] { + let mut s = session_depth(depth); + // Neutral greys from black (x 0) to white (x 39). + paint_greys(&mut s, |x| x as f32 / 39.0); + let load = |s: &mut Session, operation: &str, invert: bool| { + s.execute("select.loadSelection", json!({"channel": "composite", "operation": operation, "invert": invert})).unwrap(); + (0..40).map(|x| sel_at(s, x, 5)).collect::>() + }; + let lights = load(&mut s, "new", false); + let lights2 = load(&mut s, "intersect", false); + let lights3 = load(&mut s, "intersect", false); + let step = 1.0 / 255.0 + 1e-6; + for x in 1..39 { + assert!(lights2[x] < lights[x] && lights3[x] <= lights2[x], "depth {depth}, x {x}: each step selects every grey less"); + assert!((lights2[x] - lights[x] * lights[x]).abs() <= step, "depth {depth}, x {x}: the step multiplies by the luminosity"); + } + assert!(lights3[20] < lights2[20], "depth {depth}: a middle grey keeps narrowing"); + assert!([&lights, &lights2, &lights3].iter().all(|l| l[39] == 1.0 && l[0] == 0.0), "depth {depth}: white stays selected, black never is"); + s.execute("select.all", json!({})).unwrap(); + let darks = load(&mut s, "subtract", false); + assert!(darks[0] == 1.0 && darks[39] == 0.0 && darks[20] > 0.4, "depth {depth}: Select All minus the lights is the darks"); + let mids = load(&mut s, "subtract", true); + assert!(mids[0] == 0.0 && mids[39] == 0.0, "depth {depth}: the midtones hold neither black nor white"); + assert!(mids[20] > 0.2 && mids[20] > mids[5] && mids[20] > mids[34], "depth {depth}: they peak at the middle grey"); + } +} + #[test] fn channel_management_and_view_state() { let mut s = session(); From f7d84ace262ad483b36a13f97b58c8348687c906 Mon Sep 17 00:00:00 2001 From: sukit70 <361631270+sukit70@users.noreply.github.com> Date: Sun, 29 Nov 2026 08:25:54 -0300 Subject: [PATCH 38/81] Channels: Ctrl-clicking the composite loads its luminosity in the working gray Loading the RGB composite as a selection used a fixed conversion (8-bit sRGB to Gray Gamma 2.2, otherwise Rec. 601 weights on the encoded values) whatever Edit > Color Settings > Gray said, so the selection did not follow the Gray working space as the reference editor's does. The composite is now converted from the document's profile into the working gray with the Color Settings intent and black point compensation, and Invert applies to the converted gray. Colour channels, alphas and masks still load their stored values, and Calculations and Apply Image keep their measured conversion. --- crates/engine-core/src/cmd/channel_cmds.rs | 2 +- .../src/cmd/channel_cmds/selection.rs | 51 +++++++++++++++++-- .../engine-core/src/cmd/channel_cmds/tests.rs | 19 +++++++ 3 files changed, 68 insertions(+), 4 deletions(-) diff --git a/crates/engine-core/src/cmd/channel_cmds.rs b/crates/engine-core/src/cmd/channel_cmds.rs index f7c0d3ed7f2..efc4247bb12 100644 --- a/crates/engine-core/src/cmd/channel_cmds.rs +++ b/crates/engine-core/src/cmd/channel_cmds.rs @@ -169,7 +169,7 @@ pub fn specs() -> Vec { "Load Selection…", ["Select"], None, - r##"{"channel":index|name|"composite"|"red|green|blue|…"|"transparency"|"mask"|"vectorMask"|"quickMask"|"selection"|"targeted" (the Channels panel's target),"layer":id|name|{"name":str}|{"background":true}?,"document":index?,"invert":bool=false,"operation":"new|add|subtract|intersect"="new"} (partial coverage combines as channels do: add screens, subtract keeps a·(1−b), intersect multiplies)"##, + r##"{"channel":index|name|"composite"|"red|green|blue|…"|"transparency"|"mask"|"vectorMask"|"quickMask"|"selection"|"targeted" (the Channels panel's target),"layer":id|name|{"name":str}|{"background":true}?,"document":index?,"invert":bool=false,"operation":"new|add|subtract|intersect"="new"} (an RGB composite loads its luminosity converted into the working gray, edit.colorSettings workingGray; partial coverage combines as channels do: add screens, subtract keeps a·(1−b), intersect multiplies)"##, has_doc, load_selection ), diff --git a/crates/engine-core/src/cmd/channel_cmds/selection.rs b/crates/engine-core/src/cmd/channel_cmds/selection.rs index 6f053e37804..42c3664fa00 100644 --- a/crates/engine-core/src/cmd/channel_cmds/selection.rs +++ b/crates/engine-core/src/cmd/channel_cmds/selection.rs @@ -1,7 +1,11 @@ use super::planes::{channel_format, next_alpha_name, plane_surface, read_plane}; use super::refs::{ChanRef, bad, doc_index, parse_ref, source}; use super::view::{ChannelTarget, QuickMaskOptions}; -use super::{AlphaChannel, ColorIndicates, Document, EngineError, PixelFormat, Rect, Result, SelectionMode, Session, Surface, Value, json, operation, sel}; +use super::{ + AlphaChannel, ColorIndicates, ColorMode, Document, EngineError, PixelFormat, Rect, Result, SelectionMode, Session, Surface, Value, json, operation, sel, +}; +use crate::color_cmds::{ColorExt, cms_err, document_profile}; +use craft_cms::TransformOptions; pub(super) fn save_selection(s: &mut Session, p: &Value) -> Result { let cmd = "select.saveSelection"; @@ -77,6 +81,43 @@ fn load_label(doc: &Document, p: &Value) -> &'static str { } } +/// The composite of an RGB document as a luminosity selection, as Photoshop builds one: the composite converted +/// from the document's profile into the working gray (Edit › Color Settings › Gray) with the Color Settings +/// conversion options. The working gray decides how much each tone is selected: with Gray Gamma 2.2 (Adobe RGB's +/// tone curve) a middle grey loads about half selected, with a dot gain gray clearly less, and the 50 % ants move +/// with it. `None` for any other channel or document mode, which loads its values as before. Source: Greg Benz, +/// "How to optimize your gray working space for better luminosity masks" (gregbenzphotography.com). +fn composite_luminosity(s: &Session, p: &Value, cmd: &str) -> Result>> { + // Pixels converted per call, so the interleaved RGB copy stays small. + const BAND: usize = 1 << 16; + let di = doc_index(s, p, "document")?; + let Some(doc) = s.documents().get(di).map(|st| &st.doc) else { return Ok(None) }; + if doc.mode != ColorMode::Rgb || p.get("channel").and_then(|v| parse_ref(v, doc)) != Some(ChanRef::Composite) { + return Ok(None); + } + // Invert applies to the gray, after the conversion, not to each colour plane. + let mut plain = p.clone(); + if let Some(m) = plain.as_object_mut() { + m.remove("invert"); + } + let planes = source(s, &plain, cmd, false)?; + let [red, green, blue] = planes.as_slice() else { return Ok(None) }; + let color = s.color(); + let options = TransformOptions { intent: color.settings.intent(), bpc: color.settings.bpc, ..TransformOptions::default() }; + let transform = craft_cms::cached(&document_profile(doc), &color.working(ColorMode::Grayscale), options).map_err(cms_err)?; + let mut gray = vec![0.0f32; red.len()]; + let mut rgb = Vec::with_capacity(BAND * 3); + for (((out, r), g), b) in gray.chunks_mut(BAND).zip(red.chunks(BAND)).zip(green.chunks(BAND)).zip(blue.chunks(BAND)) { + rgb.clear(); + rgb.extend(r.iter().zip(g).zip(b).flat_map(|((&r, &g), &b)| [r, g, b])); + transform.convert_f32(&rgb, 3, out, 1, false).map_err(cms_err)?; + } + if p.get("invert").and_then(Value::as_bool).unwrap_or(false) { + gray.iter_mut().for_each(|v| *v = 1.0 - *v); + } + Ok(Some(gray)) +} + pub(super) fn load_selection(s: &mut Session, p: &Value) -> Result { let cmd = "select.loadSelection"; let mode = match operation(p, "operation") { @@ -103,8 +144,12 @@ pub(super) fn load_selection(s: &mut Session, p: &Value) -> Result { }; } let p = &targeted; - // Composite and colour channels load their luminosity / values, as ⌘-clicking them does. - let plane = source(s, p, cmd, true)?.into_iter().next().ok_or_else(|| bad(cmd, "the channel has no pixels"))?; + // An RGB composite loads its luminosity in the working gray; other channels (colour channels, alphas, masks) + // load their values, as ⌘-clicking them does. + let plane = match composite_luminosity(s, p, cmd)? { + Some(plane) => plane, + None => source(s, p, cmd, true)?.into_iter().next().ok_or_else(|| bad(cmd, "the channel has no pixels"))?, + }; let doc = &s.active().ok_or(EngineError::NoDocument)?.doc; let label = load_label(doc, p); // A loaded channel meets the selection with channel arithmetic (multiply, screen), as Photoshop combines one: diff --git a/crates/engine-core/src/cmd/channel_cmds/tests.rs b/crates/engine-core/src/cmd/channel_cmds/tests.rs index 41f3cd47adf..fcf9dac2bae 100644 --- a/crates/engine-core/src/cmd/channel_cmds/tests.rs +++ b/crates/engine-core/src/cmd/channel_cmds/tests.rs @@ -148,6 +148,25 @@ fn intersecting_the_composite_luminosity_with_itself_narrows_it_toward_the_white } } +#[test] +fn the_composite_loads_its_luminosity_in_the_working_gray() { + // ⌘-click on the composite converts it into Color Settings › Gray, as Photoshop does: a dot gain gray selects a + // middle grey clearly less than Gray Gamma 2.2 (about half), so the 50 % ants move with the setting. Inverting + // inverts that gray, not each colour plane before the conversion. + let load = |gray: &str, invert: bool| { + let mut s = session(); + s.execute("edit.colorSettings", json!({"workingGray": gray})).unwrap(); + paint_greys(&mut s, |_| 128.0 / 255.0); + s.execute("select.loadSelection", json!({"channel": "composite", "invert": invert})).unwrap(); + sel_at(&s, 5, 5) + }; + let (gamma, dot_gain) = (load("gray-gamma-2.2", false), load("dot-gain-20-compat", false)); + assert!((gamma - 0.5).abs() < 0.03, "Gray Gamma 2.2: a middle grey is about half selected ({gamma})"); + assert!(dot_gain < gamma - 0.05, "a dot gain gray selects it less ({dot_gain} vs {gamma})"); + let inverted = load("dot-gain-20-compat", true); + assert!((inverted - (1.0 - dot_gain)).abs() <= 1.0 / 255.0 + 1e-6, "inverted: {inverted} vs 1 - {dot_gain}"); +} + #[test] fn channel_management_and_view_state() { let mut s = session(); From 731b311b25a456d29e0e96972056a5d9d2d33e96 Mon Sep 17 00:00:00 2001 From: qvest-ssels <214787280+qvest-ssels@users.noreply.github.com> Date: Sun, 29 Nov 2026 13:11:31 +0100 Subject: [PATCH 39/81] Data Sets as Files: end the export when the document changed while asking (#13767) Yes resumed from the document as it was then, so a document edited or resized while the missing-image question was open wrote the remaining sets from different pixels than the files already written. The question now also records the document's edit revision (without view-only changes) and ends the export, like a change to the variables or data sets, when it moved. --- .../export_data_sets_missing_image_tests.rs | 16 ++++++++++ crates/ui-egui/src/menus/view_cmds/dialogs.rs | 30 ++++++++++++------- 2 files changed, 35 insertions(+), 11 deletions(-) diff --git a/crates/ui-egui/src/export_data_sets_missing_image_tests.rs b/crates/ui-egui/src/export_data_sets_missing_image_tests.rs index 2a1e0ac33e5..a0a2faa8966 100644 --- a/crates/ui-egui/src/export_data_sets_missing_image_tests.rs +++ b/crates/ui-egui/src/export_data_sets_missing_image_tests.rs @@ -270,3 +270,19 @@ fn a_variable_bound_anew_while_asking_ends_the_export() { assert!(app.ui.status_error && app.ui.status.contains("changed"), "{}", app.ui.status); let _ = std::fs::remove_dir_all(dir); } + +#[test] +fn a_document_edited_while_asking_ends_the_export() { + let dir = scratch("edited"); + let out = dir.join("out"); + let (mut app, ctx) = app(&dir, &[true, false, true]); + export_from_form(&mut app, &ctx, &out); + let (id, _) = question(&app).unwrap(); + // Resize the canvas while the question is open: the rest would no longer match the files written. + app.run("image.canvasSize", json!({"width": 24, "height": 24})).unwrap(); + answer(&mut app, &ctx, id, true); + assert!(question(&app).is_none()); + assert_eq!(files(&out), ["Data_Set_1.png"], "nothing more is written"); + assert!(app.ui.status_error && app.ui.status.contains("changed"), "{}", app.ui.status); + let _ = std::fs::remove_dir_all(dir); +} diff --git a/crates/ui-egui/src/menus/view_cmds/dialogs.rs b/crates/ui-egui/src/menus/view_cmds/dialogs.rs index 8359503bdeb..fe0865e92d0 100644 --- a/crates/ui-egui/src/menus/view_cmds/dialogs.rs +++ b/crates/ui-egui/src/menus/view_cmds/dialogs.rs @@ -1091,11 +1091,12 @@ pub(crate) fn data_sets_run(app: &mut PhotocraftApp, ctx: &egui::Context, mut re } } -/// The question a missing replacement image asks: the document and its variables and data sets as -/// the export read them, the export's parameters, the set it stopped at and where the batch resumes, and the -/// sets skipped so far. +/// The question a missing replacement image asks: the document, its edit revision and its variables +/// and data sets as the export read them, the export's parameters, the set it stopped at and where +/// the batch resumes, and the sets skipped so far. pub(crate) struct DataSetsMissingImage { pub(crate) doc: Option, + pub(crate) revision: u64, pub(crate) defs: Vec, pub(crate) sets: Vec, pub(crate) params: Value, @@ -1125,14 +1126,14 @@ fn data_sets_went_on(app: &mut PhotocraftApp, doc: Option let message = crate::i18n::fmt(tl!("“{name}” was not exported: its replacement file was not found. Export the remaining data sets?"), &[("name", &name)]); // The sets of the document the export ran on, as Yes compares them: a resumed run restores the document that was // active, which may be another one by now. - let (defs, sets) = app + let (revision, defs, sets) = app .session .documents() .iter() .find(|st| Some(st.doc.id) == doc) - .map(|st| (st.doc.variables.defs.clone(), st.doc.variables.data_sets.clone())) + .map(|st| (edit_revision(st), st.doc.variables.defs.clone(), st.doc.variables.data_sets.clone())) .unwrap_or_default(); - let tag = DataSetsMissingImage { doc, defs, sets, params, name, resume: index.saturating_add(1), skipped }; + let tag = DataSetsMissingImage { doc, revision, defs, sets, params, name, resume: index.saturating_add(1), skipped }; let prompt = craft::ui::dialog::StandardPrompt::custom(message) .title(tl!("Data Sets as Files")) .icon(craft::behavior::IconId::new("info")) @@ -1144,6 +1145,12 @@ fn data_sets_went_on(app: &mut PhotocraftApp, doc: Option } } +/// A document's revision without its view-only changes (channel eyes, Layers panel isolation), +/// which leave the exported files as they are. +fn edit_revision(st: &photocraft_engine::DocState) -> u64 { + st.revision.wrapping_sub(st.view_revision) +} + /// The `PROMPTS` entry of the missing-image question: Yes skips that set and exports the rest /// (asking again at the next missing image), No stops with the files written so far. pub(crate) fn data_sets_answer(app: &mut PhotocraftApp, _ctx: &egui::Context, answer: &mut craft::ui::dialog::PromptAnswer) -> bool { @@ -1162,17 +1169,18 @@ pub(crate) fn data_sets_answer(app: &mut PhotocraftApp, _ctx: &egui::Context, an app.ui.status_error = false; return true; } - // The batch resumes by position: data sets edited while the question was open would resume at - // another set, and variables bound anew would write the rest from other layers, so the export - // ends there instead. + // The batch resumes by position from the document as it is now: data sets edited while the + // question was open would resume at another set, variables bound anew would write the rest from + // other layers, and an edited or resized document would make the rest differ from the files + // already written, so the export ends there instead. let unchanged = app .session .documents() .iter() .find(|st| Some(st.doc.id) == pending.doc) - .is_some_and(|st| st.doc.variables.defs == pending.defs && st.doc.variables.data_sets == pending.sets); + .is_some_and(|st| edit_revision(st) == pending.revision && st.doc.variables.defs == pending.defs && st.doc.variables.data_sets == pending.sets); if pending.doc.is_some() && !unchanged { - crate::dialogs::alerts::report_error(app, tl!("Data Sets as Files stopped: the variables or data sets changed while the question was open")); + crate::dialogs::alerts::report_error(app, tl!("Data Sets as Files stopped: the document changed while the question was open")); return true; } let mut params = pending.params.clone(); From 65e10fa0bd46ddaa4e1072dac3462ef00766e286 Mon Sep 17 00:00:00 2001 From: qvest-ssels <214787280+qvest-ssels@users.noreply.github.com> Date: Sun, 29 Nov 2026 13:23:07 +0100 Subject: [PATCH 40/81] Data Sets as Files: keep sets left out by Yes in the last set's error (#13767) When a Yes skipped a set and the resumed export then stopped at a missing image in the last set, the error notice named only that last file, so the set left out earlier was no longer reported. The notice now appends the existing "Data sets not exported" list. --- .../src/export_data_sets_missing_image_tests.rs | 16 ++++++++++++++++ crates/ui-egui/src/menus/view_cmds/dialogs.rs | 7 ++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/export_data_sets_missing_image_tests.rs b/crates/ui-egui/src/export_data_sets_missing_image_tests.rs index a0a2faa8966..daa0094931d 100644 --- a/crates/ui-egui/src/export_data_sets_missing_image_tests.rs +++ b/crates/ui-egui/src/export_data_sets_missing_image_tests.rs @@ -286,3 +286,19 @@ fn a_document_edited_while_asking_ends_the_export() { assert!(app.ui.status_error && app.ui.status.contains("changed"), "{}", app.ui.status); let _ = std::fs::remove_dir_all(dir); } + +#[test] +fn a_missing_last_set_after_a_yes_still_lists_the_set_left_out() { + let dir = scratch("yes-then-last"); + let out = dir.join("out"); + let (mut app, ctx) = app(&dir, &[true, false, false]); + export_from_form(&mut app, &ctx, &out); + let (id, _) = question(&app).unwrap(); + answer(&mut app, &ctx, id, true); + assert!(question(&app).is_none(), "the last set keeps today's error, no question"); + assert_eq!(files(&out), ["Data_Set_1.png"]); + let status = &app.ui.status; + assert!(app.ui.status_error && status.starts_with(photocraft_engine::DATA_SET_FILE_MISSING), "{status}"); + assert!(status.contains("Data Set 2"), "the set an earlier Yes left out stays listed: {status}"); + let _ = std::fs::remove_dir_all(dir); +} diff --git a/crates/ui-egui/src/menus/view_cmds/dialogs.rs b/crates/ui-egui/src/menus/view_cmds/dialogs.rs index fe0865e92d0..d6895686b78 100644 --- a/crates/ui-egui/src/menus/view_cmds/dialogs.rs +++ b/crates/ui-egui/src/menus/view_cmds/dialogs.rs @@ -1119,7 +1119,12 @@ fn data_sets_went_on(app: &mut PhotocraftApp, doc: Option let index = stopped.get("index").and_then(Value::as_u64).and_then(|n| usize::try_from(n).ok()); let remaining = stopped.get("remaining").and_then(Value::as_u64).unwrap_or(0); let (Some(index), true) = (index, remaining > 0) else { - let error = stopped.get("error").and_then(Value::as_str).unwrap_or(photocraft_engine::DATA_SET_FILE_MISSING).to_owned(); + let mut error = stopped.get("error").and_then(Value::as_str).unwrap_or(photocraft_engine::DATA_SET_FILE_MISSING).to_owned(); + // Sets an earlier Yes left out stay listed next to the last set's error. + if !skipped.is_empty() { + error.push(' '); + error.push_str(&crate::i18n::fmt(tl!("Data sets not exported (replacement file not found): {names}"), &[("names", &skipped.join(", "))])); + } crate::notices::error(app, error); return; }; From 9632cc90926bcbbcb3bd4829e5bc55be40b6abb2 Mon Sep 17 00:00:00 2001 From: ruchirguitar Date: Mon, 30 Nov 2026 18:48:39 +0530 Subject: [PATCH 41/81] ui-egui: Digits select in the Character panel (#10996) The Character panel shows the target's digit style (as typed, Western, contextual or an Indic script) and a pick sets it through the type command's digits key. --- .../panels/type_panels_ui/style_options.rs | 21 +++++- .../type_tool/character_panel_digits_tests.rs | 68 +++++++++++++++++++ crates/ui-egui/src/tools/type_tool/panel.rs | 7 +- crates/ui-egui/src/tools/type_tool/values.rs | 26 ++++++- docs/scorecard.md | 2 +- scorecard/type.toml | 2 +- 6 files changed, 120 insertions(+), 6 deletions(-) create mode 100644 crates/ui-egui/src/tools/type_tool/character_panel_digits_tests.rs diff --git a/crates/ui-egui/src/panels/type_panels_ui/style_options.rs b/crates/ui-egui/src/panels/type_panels_ui/style_options.rs index 255a6aeddbf..c69fdf91fc7 100644 --- a/crates/ui-egui/src/panels/type_panels_ui/style_options.rs +++ b/crates/ui-egui/src/panels/type_panels_ui/style_options.rs @@ -7,7 +7,7 @@ use craft::text::ui::character::{ StyleOptionValues, StyleOptionsChange, TextAlign, TextStyleOptions, }; use craft::theme::Rgba; -use photocraft_doc::text::{CharStyle, ParagraphStyle}; +use photocraft_doc::text::{CharStyle, Digits, ParagraphStyle}; use serde_json::{Value, json}; use super::{color_picker, run}; @@ -157,10 +157,29 @@ pub(crate) fn character_values(style: &CharStyle) -> CharacterValues { values.strikethrough = Some(style.strikethrough); values.opentype = opentype; values.language = style.language.clone(); + values.digits = Some(digit_name(style.digits).to_string()); values } /// The values the Paragraph controls show for `style`. +/// The engine's `digits` name of a digit style. +pub(crate) fn digit_name(d: Digits) -> &'static str { + match d { + Digits::AsTyped => "asTyped", + Digits::Western => "western", + Digits::Contextual => "contextual", + Digits::Devanagari => "devanagari", + Digits::Bengali => "bengali", + Digits::Gurmukhi => "gurmukhi", + Digits::Gujarati => "gujarati", + Digits::Odia => "odia", + Digits::Tamil => "tamil", + Digits::Telugu => "telugu", + Digits::Kannada => "kannada", + Digits::Malayalam => "malayalam", + } +} + pub(crate) fn paragraph_values(style: &ParagraphStyle) -> ParagraphValues { use photocraft_doc::text::TextDirection as D; let mut values = ParagraphValues::default(); diff --git a/crates/ui-egui/src/tools/type_tool/character_panel_digits_tests.rs b/crates/ui-egui/src/tools/type_tool/character_panel_digits_tests.rs new file mode 100644 index 00000000000..1e35edee681 --- /dev/null +++ b/crates/ui-egui/src/tools/type_tool/character_panel_digits_tests.rs @@ -0,0 +1,68 @@ +//! The Character panel's Digits select (#10996): it shows the selected layer's digit style, and a pick restyles the +//! selected type layer's digits through the type command, in one history step. + +use egui::accesskit::Role; +use egui::vec2; +use egui_kittest::Harness; +use egui_kittest::kittest::Queryable; +use photocraft_doc::LayerId; +use photocraft_doc::text::Digits; +use serde_json::json; + +use crate::PhotocraftApp; +use crate::app::framework::BuildApp; + +const SELECT: &str = "Digits"; + +/// One selected type layer with digits in its text. +fn one_layer() -> (Box, LayerId) { + let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default()); + app.run("file.new", json!({"width": 800, "height": 600})).unwrap(); + app.sync_views(); + app.ui.tool = crate::state::Tool::Type; + let made = app.run("type.create", json!({"text": "Room 42", "font": "Inter", "size": 24, "x": 40, "y": 80})).unwrap(); + let id = LayerId(made["layer"].as_u64().unwrap()); + app.run("layer.select", json!({"layer": id.0, "mode": "replace"})).unwrap(); + (app, id) +} + +fn harness(app: Box) -> Harness<'static, Box> { + // Wait for the font scan: while it runs the panels repaint every 100 ms and `Harness::run` gives up. + let _ = photocraft_text::shared(); + let mut h = Harness::builder().with_context(app.ctx().clone()).with_size(vec2(760.0, 1200.0)).with_max_steps(16).build_app( + move |ui, app: &mut PhotocraftApp| { + ui.set_width(340.0); + super::character_panel(app, ui, false); + }, + app, + ); + h.run_steps(4); + h +} + +fn digits(app: &PhotocraftApp, id: LayerId) -> Vec { + let text = super::super::text_layer(&app.session.active().unwrap().doc, id).unwrap(); + text.char_runs().into_iter().map(|r| r.style.digits).collect() +} + +fn shown(h: &Harness<'static, Box>) -> String { + h.get_by_role_and_label(Role::ComboBox, SELECT).value().unwrap_or_default() +} + +#[test] +fn a_digits_pick_restyles_the_selected_layer_in_one_history_step() { + let (app, id) = one_layer(); + let before = digits(&app, id); + let steps = app.session.active().unwrap().history.entries().len(); + let mut h = harness(app); + let was = shown(&h); + h.get_by_role_and_label(Role::ComboBox, SELECT).click(); + h.run(); + h.get_by_role_and_label(Role::ListBoxOption, "Devanagari").click(); + h.run(); + let after = digits(h.state(), id); + assert_ne!(after, before, "the pick changed the layer's digits"); + assert!(after.iter().all(|d| *d == Digits::Devanagari), "every run takes the picked style: {after:?}"); + assert_eq!(h.state().session.active().unwrap().history.entries().len(), steps + 1, "one history step"); + assert_ne!(shown(&h), was, "the select shows the new style"); +} diff --git a/crates/ui-egui/src/tools/type_tool/panel.rs b/crates/ui-egui/src/tools/type_tool/panel.rs index e9eb1a7d1f0..32cb870607b 100644 --- a/crates/ui-egui/src/tools/type_tool/panel.rs +++ b/crates/ui-egui/src/tools/type_tool/panel.rs @@ -78,7 +78,8 @@ fn character_controls(app: &mut PhotocraftApp, ui: &mut egui::Ui, unit: DocUnit, let styles = values::style_names(app, &shown); let face = values::face_axes(app); let mut font_state = fonts::font_state(app); - let mut controls = CharacterControls::new(tl!("Character"), &shown, &families, &styles).unit(unit); + let digits = values::digit_entries(); + let mut controls = CharacterControls::new(tl!("Character"), &shown, &families, &styles).unit(unit).digits(&digits); controls = controls.font_picker(font_state.source()); if let Some(face) = &face { controls = controls.axes(face.view()); @@ -147,6 +148,10 @@ fn type_options(app: &mut PhotocraftApp, ui: &mut egui::Ui) { }); } +#[cfg(test)] +#[path = "character_panel_digits_tests.rs"] +mod character_panel_digits_tests; + #[cfg(test)] #[path = "character_panel_anti_alias_tests.rs"] mod character_panel_anti_alias_tests; diff --git a/crates/ui-egui/src/tools/type_tool/values.rs b/crates/ui-egui/src/tools/type_tool/values.rs index c9bdb4fe9e5..6653f9db7d4 100644 --- a/crates/ui-egui/src/tools/type_tool/values.rs +++ b/crates/ui-egui/src/tools/type_tool/values.rs @@ -16,14 +16,14 @@ use craft::text::ui::character::{ use craft::text::ui::type_bar::TypeBarChange; use craft::text::ui::type_options::{TextAntiAlias, TextOrientation}; use craft::ui::runtime::env::UnitKind; -use photocraft_doc::text::{CharStyle, ParagraphStyle}; +use photocraft_doc::text::{CharStyle, Digits, ParagraphStyle}; use super::defaults::{apply, default_styles, formatting_params, open_color_picker, shown_scale, target, target_doc, target_text}; use super::fonts; use super::options_bar::{kerning_at, styles_at}; use super::panel::{OPENTYPE_BUTTONS, toggle_opentype}; use super::{LayerId, PhotocraftApp, byte_of, json, text_layer}; -use crate::panels::type_panels_ui::style_options::{character_values as style_character_values, paragraph_values as style_paragraph_values}; +use crate::panels::type_panels_ui::style_options::{character_values as style_character_values, digit_name, paragraph_values as style_paragraph_values}; /// The unit the type controls show lengths in (Preferences ▸ Units & Rulers ▸ Type); pixels follow the document's /// resolution. Values stay in points. @@ -93,6 +93,27 @@ fn runs_at_target(app: &PhotocraftApp) -> Option<(Vec, Vec Vec<(String, String)> { + [ + (Digits::AsTyped, tl!("As Typed")), + (Digits::Western, tl!("Western")), + (Digits::Contextual, tl!("Contextual")), + (Digits::Devanagari, tl!("Devanagari")), + (Digits::Bengali, tl!("Bengali")), + (Digits::Gurmukhi, tl!("Gurmukhi")), + (Digits::Gujarati, tl!("Gujarati")), + (Digits::Odia, tl!("Odia")), + (Digits::Tamil, tl!("Tamil")), + (Digits::Telugu, tl!("Telugu")), + (Digits::Kannada, tl!("Kannada")), + (Digits::Malayalam, tl!("Malayalam")), + ] + .into_iter() + .map(|(d, label)| (digit_name(d).to_string(), label.to_string())) + .collect() +} + /// The character values at the target: equal values shown, differing ones mixed. Sizes show as the layer appears /// (a 12 pt layer scaled 200 % reads 24 pt). pub(crate) fn character_values(app: &PhotocraftApp) -> CharacterValues { @@ -305,6 +326,7 @@ fn character_step(change: &CharacterChange) -> Option { CharacterChange::Strikethrough(on) => json!({"strikethrough": on}), CharacterChange::OpenType { tag, on, .. } => return Some(Step::OpenType { tag, on: *on }), CharacterChange::Language(tag) => json!({"language": tag}), + CharacterChange::Digits(tag) => json!({"digits": tag}), CharacterChange::Axes(axes) => { let map: serde_json::Map = axes.iter().map(|(tag, v)| (String::from_utf8_lossy(tag).trim().to_string(), json!(v))).collect(); diff --git a/docs/scorecard.md b/docs/scorecard.md index e984cf914e7..4579ee1b59a 100644 --- a/docs/scorecard.md +++ b/docs/scorecard.md @@ -261,7 +261,7 @@ Unread: `general.color_picker`, `workspace.auto_show_hidden_panels`, `workspace. | TYPE-218-8 | Text editing: select all, double/triple/quadruple-click selection, paste, with tests | done | [#218](https://github.com/storytold/photocraft/issues/218) | Like Photoshop, 2 clicks select the word, 3 the laid-out line (a column in vertical type), 4 the paragraph up to the hard return, 5 all text, and the next quick click starts over (#3493; type_tool.rs next_click_count, click_selection, multi_click). Tested through real canvas clicks in point, paragraph and vertical type, with paste replacing the selection and Cmd+A selecting all (type_tool_tests.rs multi_click_selects_word_line_paragraph_and_all_in_point_text, multi_click_separates_wrapped_lines_from_paragraphs, click_counts_cycle_and_restart, click_selection_without_layout_and_on_hostile_input, multi_click_without_a_session_does_nothing) | | TYPE-218-9 | Distort/Perspective/Warp on live type as in Photoshop (was: offer 'Rasterize and continue?'; Photoshop doesn't prompt) | done | [#218](https://github.com/storytold/photocraft/issues/218) | Photoshop 2026 prompts for none of these: Edit › Transform › Warp on live type stays enabled with no rasterize prompt and offers only the warp styles (the mesh can't be dragged), so the type stays editable; Distort, Perspective and the split warps are greyed. PhotoCraft does the same: Warp on type commits the layer's Warp Text in one step (transform_tool.rs enter_type_warp, warp_cmds.rs warp_type_layer, #3004; warp_on_type_takes_a_style_and_keeps_the_type_editable), Distort/Perspective greyed (enable_rules.rs, #2701) | | TYPE-218-10 | Area type: Type tool click inside a closed path or shape wraps text inside it, holes and dents included, PSD round trip | partial | [#218](https://github.com/storytold/photocraft/issues/218) | TextShape::Area (doc text.rs) laid out line by line into the spans the path leaves (text area.rs, layout.rs break_area), type.fillPath (engine type_area_cmds.rs), released to box text by type.detachFromPath, area/path cursors and click-to-place (ui-egui type_tool.rs path_target), .pcraft round trip. Missing: PSD area type (saves as paragraph text over the path's bounds, with an export warning); mixed type sizes in one area paragraph space at its largest line; area type takes paths of at most 4096 anchors: beyond that a Type tool click makes point text (the pointer shows the plain I-beam), and type.fillPath refuses the path with "the path has too many anchor points" (type.attachToPath still takes a subpath of up to 100,000 anchors); a word too wide for every span in the shape overflows its span (box text breaks it at the edge, #6694); the first line starts about 0.24 em lower than in a text box of the same size; Photoshop area type in a PSD opens as box text; the area path has no handles to edit it after the type is placed | -| TYPE-10996-1 | Digit style: digits drawn as typed, Western, by the script of the letters before them, or in an Indic script (Devanagari, Bengali, Gurmukhi, Gujarati, Odia, Tamil, Telugu, Kannada, Malayalam) | partial | [#10996](https://github.com/storytold/photocraft/issues/10996) | CharStyle `digits` (doc text.rs), drawn in shaping (text digits.rs) while the layer text keeps the typed digits; set through the type commands' `digits` key. No Character panel control yet (needs the shared panel in craft-libs); Arabic and Persian digits are #6685; not saved in PSD | +| TYPE-10996-1 | Digit style: digits drawn as typed, Western, by the script of the letters before them, or in an Indic script (Devanagari, Bengali, Gurmukhi, Gujarati, Odia, Tamil, Telugu, Kannada, Malayalam) | partial | [#10996](https://github.com/storytold/photocraft/issues/10996) | CharStyle `digits` (doc text.rs), drawn in shaping (text digits.rs) while the layer text keeps the typed digits; set through the type commands' `digits` key. The Character panel's Digits select sets it; Arabic and Persian digits are #6685; not saved in PSD | ## Automation diff --git a/scorecard/type.toml b/scorecard/type.toml index 579e92e5715..9626765742b 100644 --- a/scorecard/type.toml +++ b/scorecard/type.toml @@ -79,4 +79,4 @@ id = "TYPE-10996-1" target = "Digit style: digits drawn as typed, Western, by the script of the letters before them, or in an Indic script (Devanagari, Bengali, Gurmukhi, Gujarati, Odia, Tamil, Telugu, Kannada, Malayalam)" status = "partial" issue = 10996 -note = "CharStyle `digits` (doc text.rs), drawn in shaping (text digits.rs) while the layer text keeps the typed digits; set through the type commands' `digits` key. No Character panel control yet (needs the shared panel in craft-libs); Arabic and Persian digits are #6685; not saved in PSD" +note = "CharStyle `digits` (doc text.rs), drawn in shaping (text digits.rs) while the layer text keeps the typed digits; set through the type commands' `digits` key. The Character panel's Digits select sets it; Arabic and Persian digits are #6685; not saved in PSD" From 20201d4ed4726f703d47b954641eaa6e57d22b0b Mon Sep 17 00:00:00 2001 From: ruchirguitar Date: Mon, 30 Nov 2026 21:33:36 +0530 Subject: [PATCH 42/81] ui-egui: keep a caret's chosen font across a Digits change before typing A character change at a collapsed caret (Digits, size, tracking...) cleared the font chosen there but not yet typed. The pending font now holds for the new revision on the style the command stored, so the next typed text takes both. --- .../ui-egui/src/tools/type_tool/defaults.rs | 8 ++++++- .../src/tools/type_tool/font_commit_tests.rs | 23 +++++++++++++++++++ .../src/tools/type_tool/insertion_style.rs | 17 ++++++++++++++ 3 files changed, 47 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/tools/type_tool/defaults.rs b/crates/ui-egui/src/tools/type_tool/defaults.rs index 48b9408096d..0c62fbd6698 100644 --- a/crates/ui-egui/src/tools/type_tool/defaults.rs +++ b/crates/ui-egui/src/tools/type_tool/defaults.rs @@ -230,6 +230,8 @@ pub(super) fn apply(app: &mut PhotocraftApp, props: serde_json::Value, coalesce: if insertion_style::set_font(app, &props) { return; } + // A font chosen at the caret and not yet typed outlives another character change there (#10996). + let kept = insertion_style::pending(app).cloned(); app.ui.type_insertion_style = None; let Some(mut p) = formatting_params(app) else { apply_defaults(app, &props); @@ -243,7 +245,11 @@ pub(super) fn apply(app: &mut PhotocraftApp, props: serde_json::Value, coalesce: if let Some(key) = app.ui.text_edit.as_ref().map(|ed| ed.session.clone()).or(coalesce) { p["coalesce"] = json!(key); } - let _ = app.run("type.setStyle", p); + if app.run("type.setStyle", p).is_ok() + && let Some(kept) = kept + { + insertion_style::rebase(app, kept); + } } /// Open the shared Color Picker with a snapshot of the text target. Sampling or cancelling diff --git a/crates/ui-egui/src/tools/type_tool/font_commit_tests.rs b/crates/ui-egui/src/tools/type_tool/font_commit_tests.rs index 9d1c96e054d..7451cf30acf 100644 --- a/crates/ui-egui/src/tools/type_tool/font_commit_tests.rs +++ b/crates/ui-egui/src/tools/type_tool/font_commit_tests.rs @@ -385,3 +385,26 @@ fn an_existing_empty_layer_keeps_its_font_when_committed() { assert_eq!(families(&saved(&h, id)), [FONTS[1]]); } } + +/// A font chosen at the caret survives a Digits change there before typing (#10996): the typed digit takes the +/// chosen font and the picked digit style. +#[test] +fn a_digits_change_at_the_caret_keeps_the_chosen_typing_font() { + let (mut h, id) = fixture(0, "abcdef"); + select(&mut h, [3, 3]); + h.run(); + choose(&mut h, FONTS[1], "enter"); + assert!(super::insertion_style::pending(h.state()).is_some(), "a pending font at the caret"); + super::apply(h.state_mut(), json!({"digits": "devanagari"}), None); + assert!(super::insertion_style::pending(h.state()).is_some(), "the Digits change keeps the pending font"); + super::host::type_text(h.state_mut(), "5"); + h.run(); + assert_eq!(families(&saved(&h, id))[3], FONTS[1], "the typed digit takes the chosen font"); + let t = layer(&h.state().session.active().unwrap().doc, id); + let mut offset = 0; + let digits = t.char_runs().into_iter().find_map(|r| { + offset += r.len; + (offset > 3).then_some(r.style.digits) + }); + assert_eq!(digits, Some(photocraft_doc::text::Digits::Devanagari), "the typed digit takes the picked digit style"); +} diff --git a/crates/ui-egui/src/tools/type_tool/insertion_style.rs b/crates/ui-egui/src/tools/type_tool/insertion_style.rs index 05a2624c99a..a8c33c2e2b0 100644 --- a/crates/ui-egui/src/tools/type_tool/insertion_style.rs +++ b/crates/ui-egui/src/tools/type_tool/insertion_style.rs @@ -49,6 +49,23 @@ pub(super) fn set_font(app: &mut PhotocraftApp, props: &serde_json::Value) -> bo true } +/// Keeps the caret's pending font `kept` after another character change at the same caret: the style the command +/// stored there (in the layer's own units) with the chosen font on it, for the new revision, so the next typed text +/// still takes the chosen font and the change. +pub(super) fn rebase(app: &mut PhotocraftApp, mut kept: TypeInsertionStyle) { + let Some((mut style, _)) = styles_at(app) else { return }; + let Some(st) = app.session.active() else { return }; + let chosen = &kept.style; + style.font_family.clone_from(&chosen.font_family); + style.weight = chosen.weight; + style.italic = chosen.italic; + style.postscript_name.clone_from(&chosen.postscript_name); + style.variations.clone_from(&chosen.variations); + kept.style = style; + kept.revision = st.revision; + app.ui.type_insertion_style = Some(kept); +} + /// How many characters `text` adds once the engine stores it: a CRLF pair becomes one `\n` (a lone CR is one /// character either way), so a pasted Windows line break moves the caret by one, not two. pub(super) fn stored_chars(text: &str) -> usize { From c06f404773bd4bebbd22be7dd8d36135e102ef9c Mon Sep 17 00:00:00 2001 From: ruchirguitar Date: Tue, 1 Dec 2026 16:32:29 +0530 Subject: [PATCH 43/81] ui-egui: keep an axis change at the caret over the chosen font's saved axes rebase put the chosen font's saved variations back after every change, so an axis change at the caret reverted. Axes the change sets now win; the others keep their chosen values. --- .../ui-egui/src/tools/type_tool/defaults.rs | 2 +- .../src/tools/type_tool/font_commit_tests.rs | 26 +++++++++++++++++++ .../src/tools/type_tool/insertion_style.rs | 12 ++++++++- 3 files changed, 38 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/tools/type_tool/defaults.rs b/crates/ui-egui/src/tools/type_tool/defaults.rs index 0c62fbd6698..b5e483fb240 100644 --- a/crates/ui-egui/src/tools/type_tool/defaults.rs +++ b/crates/ui-egui/src/tools/type_tool/defaults.rs @@ -248,7 +248,7 @@ pub(super) fn apply(app: &mut PhotocraftApp, props: serde_json::Value, coalesce: if app.run("type.setStyle", p).is_ok() && let Some(kept) = kept { - insertion_style::rebase(app, kept); + insertion_style::rebase(app, kept, &props); } } diff --git a/crates/ui-egui/src/tools/type_tool/font_commit_tests.rs b/crates/ui-egui/src/tools/type_tool/font_commit_tests.rs index 7451cf30acf..81fa78c3711 100644 --- a/crates/ui-egui/src/tools/type_tool/font_commit_tests.rs +++ b/crates/ui-egui/src/tools/type_tool/font_commit_tests.rs @@ -408,3 +408,29 @@ fn a_digits_change_at_the_caret_keeps_the_chosen_typing_font() { }); assert_eq!(digits, Some(photocraft_doc::text::Digits::Devanagari), "the typed digit takes the picked digit style"); } + +/// An axis change at the caret after a font was chosen there wins over the chosen font's saved axes; the axes it does +/// not set keep their chosen values. +#[test] +fn an_axis_change_at_the_caret_keeps_its_value_with_the_chosen_typing_font() { + let (mut h, id) = fixture(0, "abcdef"); + h.state_mut().run("type.setStyle", json!({"layer": id.0, "variations": {"wght": 650, "wdth": 95}})).unwrap(); + select(&mut h, [3, 3]); + h.run(); + choose(&mut h, FONTS[1], "enter"); + super::apply(h.state_mut(), json!({"variations": {"wdth": 110}}), None); + super::host::type_text(h.state_mut(), "X"); + h.run(); + assert_eq!(families(&saved(&h, id))[3], FONTS[1], "the typed letter takes the chosen font"); + let mut offset = 0; + let axes = layer(&h.state().session.active().unwrap().doc, id) + .char_runs() + .into_iter() + .find_map(|r| { + offset += r.len; + (offset > 3).then_some(r.style.variations) + }) + .unwrap(); + assert!(axes.iter().any(|v| v.axis == "wdth" && v.value == 110.0), "the changed axis holds: {axes:?}"); + assert!(axes.iter().any(|v| v.axis == "wght" && v.value == 650.0), "an axis the change left keeps its value: {axes:?}"); +} diff --git a/crates/ui-egui/src/tools/type_tool/insertion_style.rs b/crates/ui-egui/src/tools/type_tool/insertion_style.rs index a8c33c2e2b0..aa6e023bd0b 100644 --- a/crates/ui-egui/src/tools/type_tool/insertion_style.rs +++ b/crates/ui-egui/src/tools/type_tool/insertion_style.rs @@ -52,7 +52,7 @@ pub(super) fn set_font(app: &mut PhotocraftApp, props: &serde_json::Value) -> bo /// Keeps the caret's pending font `kept` after another character change at the same caret: the style the command /// stored there (in the layer's own units) with the chosen font on it, for the new revision, so the next typed text /// still takes the chosen font and the change. -pub(super) fn rebase(app: &mut PhotocraftApp, mut kept: TypeInsertionStyle) { +pub(super) fn rebase(app: &mut PhotocraftApp, mut kept: TypeInsertionStyle, props: &serde_json::Value) { let Some((mut style, _)) = styles_at(app) else { return }; let Some(st) = app.session.active() else { return }; let chosen = &kept.style; @@ -61,6 +61,16 @@ pub(super) fn rebase(app: &mut PhotocraftApp, mut kept: TypeInsertionStyle) { style.italic = chosen.italic; style.postscript_name.clone_from(&chosen.postscript_name); style.variations.clone_from(&chosen.variations); + // An axis the change set itself wins over the chosen font's saved value; the others stay as chosen. + if let Some(axes) = props.get("variations").and_then(serde_json::Value::as_object) { + for (axis, value) in axes { + let Some(value) = value.as_f64() else { continue }; + match style.variations.iter_mut().find(|v| v.axis == *axis) { + Some(v) => v.value = value as f32, + None => style.variations.push(photocraft_doc::text::FontVariation { axis: axis.clone(), value: value as f32 }), + } + } + } kept.style = style; kept.revision = st.revision; app.ui.type_insertion_style = Some(kept); From 573984f5ed95e9e6d2d56526ad61a24b7bd38cae Mon Sep 17 00:00:00 2001 From: bflatastic Date: Tue, 1 Dec 2026 21:15:55 +0700 Subject: [PATCH 44/81] ui-egui: keep paragraph_values' doc comment on it --- crates/ui-egui/src/panels/type_panels_ui/style_options.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/ui-egui/src/panels/type_panels_ui/style_options.rs b/crates/ui-egui/src/panels/type_panels_ui/style_options.rs index c69fdf91fc7..538be23058c 100644 --- a/crates/ui-egui/src/panels/type_panels_ui/style_options.rs +++ b/crates/ui-egui/src/panels/type_panels_ui/style_options.rs @@ -161,7 +161,6 @@ pub(crate) fn character_values(style: &CharStyle) -> CharacterValues { values } -/// The values the Paragraph controls show for `style`. /// The engine's `digits` name of a digit style. pub(crate) fn digit_name(d: Digits) -> &'static str { match d { @@ -180,6 +179,7 @@ pub(crate) fn digit_name(d: Digits) -> &'static str { } } +/// The values the Paragraph controls show for `style`. pub(crate) fn paragraph_values(style: &ParagraphStyle) -> ParagraphValues { use photocraft_doc::text::TextDirection as D; let mut values = ParagraphValues::default(); From 17adbc6e3cb0ba3e8ac41db77ff29f385e8775de Mon Sep 17 00:00:00 2001 From: ruchirguitar Date: Tue, 1 Dec 2026 21:38:02 +0530 Subject: [PATCH 45/81] Move the craft-libs pin past craft-libs#4514 Picks up the Script select in the font picker's Toolbar layout. --- Cargo.lock | 224 +++++++++++++++++++--------------- Cargo.toml | 84 ++++++------- crates/engine-core/Cargo.toml | 2 +- crates/ipp/Cargo.toml | 2 +- 4 files changed, 171 insertions(+), 141 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d002ee7975c..3274fbe898b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -768,6 +768,17 @@ dependencies = [ "brotli-decompressor 5.0.3", ] +[[package]] +name = "brotli" +version = "9.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9071f285ed78f04f37d675abaaef5de7689e2f30a216c8dc6795465d81910a13" +dependencies = [ + "alloc-no-stdlib 3.0.0", + "alloc-stdlib 0.3.0", + "brotli-decompressor 6.3.2", +] + [[package]] name = "brotli-decompressor" version = "5.0.3" @@ -1365,7 +1376,7 @@ dependencies = [ [[package]] name = "craft" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "craft-automation", "craft-behavior", @@ -1406,7 +1417,7 @@ dependencies = [ [[package]] name = "craft-affinity" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "crc32fast", "flate2", @@ -1427,18 +1438,19 @@ dependencies = [ [[package]] name = "craft-appkit" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "block2 0.6.2", "objc2 0.6.5", "objc2-app-kit 0.3.2", + "objc2-core-graphics", "objc2-foundation 0.3.2", ] [[package]] name = "craft-atomic" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "rustix 1.1.6", ] @@ -1446,7 +1458,7 @@ dependencies = [ [[package]] name = "craft-automation" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "base64 0.23.1", "craft-behavior", @@ -1471,7 +1483,7 @@ dependencies = [ [[package]] name = "craft-behavior" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "accesskit", "bitflags 2.13.2", @@ -1489,7 +1501,7 @@ dependencies = [ [[package]] name = "craft-browse" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "craft-behavior", "craft-docpath", @@ -1507,7 +1519,7 @@ dependencies = [ [[package]] name = "craft-cloud-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "egui", ] @@ -1515,7 +1527,7 @@ dependencies = [ [[package]] name = "craft-cms" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "md-5", "rayon", @@ -1524,12 +1536,12 @@ dependencies = [ [[package]] name = "craft-codepage" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" [[package]] name = "craft-color" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "serde", ] @@ -1537,7 +1549,7 @@ dependencies = [ [[package]] name = "craft-color-transform" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "craft-cms", "craft-color", @@ -1547,10 +1559,11 @@ dependencies = [ [[package]] name = "craft-color-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "craft-behavior", "craft-cms", + "craft-drawingml", "craft-host", "craft-i18n", "craft-keymap", @@ -1567,7 +1580,7 @@ dependencies = [ [[package]] name = "craft-control" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "craft-ai-agents", "craft-atomic", @@ -1583,7 +1596,7 @@ dependencies = [ [[package]] name = "craft-control-protocol" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "getrandom 0.3.4", "serde_json", @@ -1593,7 +1606,7 @@ dependencies = [ [[package]] name = "craft-crs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "craft-metadata", "craft-xml", @@ -1603,7 +1616,7 @@ dependencies = [ [[package]] name = "craft-crw" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "thiserror 2.0.21", ] @@ -1611,7 +1624,7 @@ dependencies = [ [[package]] name = "craft-dds" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "rayon", ] @@ -1619,7 +1632,7 @@ dependencies = [ [[package]] name = "craft-develop" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "craft-color", "craft-color-transform", @@ -1634,7 +1647,7 @@ dependencies = [ [[package]] name = "craft-develop-model" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "craft-geom", "craft-metadata", @@ -1646,7 +1659,7 @@ dependencies = [ [[package]] name = "craft-dialogs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "block2 0.6.2", "craft-appkit", @@ -1672,7 +1685,7 @@ dependencies = [ [[package]] name = "craft-docpath" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "serde", ] @@ -1680,7 +1693,7 @@ dependencies = [ [[package]] name = "craft-draw" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "craft-behavior", "craft-color-ui", @@ -1696,15 +1709,27 @@ dependencies = [ "serde_json", ] +[[package]] +name = "craft-drawingml" +version = "0.1.0" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" +dependencies = [ + "chrono", + "craft-xml", + "kurbo 0.13.1", + "log", + "serde", +] + [[package]] name = "craft-eps" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" [[package]] name = "craft-file-formats" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "craft-eps", "craft-idml", @@ -1722,7 +1747,7 @@ dependencies = [ [[package]] name = "craft-flags" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "craft-atomic", "dirs", @@ -1732,7 +1757,7 @@ dependencies = [ [[package]] name = "craft-font-catalog" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "fontique", "harfrust 0.13.3", @@ -1747,7 +1772,7 @@ dependencies = [ [[package]] name = "craft-font-manager" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "craft-behavior", "craft-font-catalog", @@ -1767,7 +1792,7 @@ dependencies = [ [[package]] name = "craft-font-os-windows" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "windows-registry", "windows-sys 0.61.2", @@ -1776,7 +1801,7 @@ dependencies = [ [[package]] name = "craft-font-store" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "cap-primitives", "craft-atomic", @@ -1799,12 +1824,12 @@ dependencies = [ [[package]] name = "craft-fonts-build" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" [[package]] name = "craft-geom" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "serde", ] @@ -1812,7 +1837,7 @@ dependencies = [ [[package]] name = "craft-heif" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "heic-rs", "rayon", @@ -1821,7 +1846,7 @@ dependencies = [ [[package]] name = "craft-host" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "bitflags 2.13.2", "craft-i18n", @@ -1834,8 +1859,10 @@ dependencies = [ [[package]] name = "craft-i18n" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ + "brotli 9.1.3", + "brotli-decompressor 6.3.2", "chrono", "fixed_decimal", "icu_calendar", @@ -1862,7 +1889,7 @@ dependencies = [ [[package]] name = "craft-idml" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "craft-xml", "craft-zip", @@ -1872,7 +1899,7 @@ dependencies = [ [[package]] name = "craft-image-codecs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "craft-dds", "craft-heif", @@ -1900,7 +1927,7 @@ dependencies = [ [[package]] name = "craft-imaging" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "craft-behavior", "craft-color-ui", @@ -1918,12 +1945,12 @@ dependencies = [ [[package]] name = "craft-ipp" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" [[package]] name = "craft-jpeg" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "thiserror 2.0.21", ] @@ -1931,7 +1958,7 @@ dependencies = [ [[package]] name = "craft-keymap" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "craft-host", "craft-i18n", @@ -1946,7 +1973,7 @@ dependencies = [ [[package]] name = "craft-kra" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "craft-xml", "craft-zip", @@ -1956,7 +1983,7 @@ dependencies = [ [[package]] name = "craft-layers" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "craft-behavior", "craft-i18n", @@ -1970,7 +1997,7 @@ dependencies = [ [[package]] name = "craft-menu" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "craft-behavior", "craft-host", @@ -1988,7 +2015,7 @@ dependencies = [ [[package]] name = "craft-metadata" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "brotli-decompressor 6.3.2", "chrono", @@ -2000,7 +2027,7 @@ dependencies = [ [[package]] name = "craft-nightly" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "uds_windows", "winsafe", @@ -2009,7 +2036,7 @@ dependencies = [ [[package]] name = "craft-ora" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "craft-xml", "craft-zip", @@ -2019,7 +2046,7 @@ dependencies = [ [[package]] name = "craft-pages" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "craft-behavior", "craft-keymap", @@ -2035,7 +2062,7 @@ dependencies = [ [[package]] name = "craft-pcraft-bundle" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "blake3", "craft-atomic", @@ -2048,7 +2075,7 @@ dependencies = [ [[package]] name = "craft-pcraft-format" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "flate2", "serde", @@ -2059,7 +2086,7 @@ dependencies = [ [[package]] name = "craft-pdf" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "bytemuck", "flate2", @@ -2074,7 +2101,7 @@ dependencies = [ [[package]] name = "craft-pdn" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "flate2", "thiserror 2.0.21", @@ -2083,12 +2110,12 @@ dependencies = [ [[package]] name = "craft-platform" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "async-channel", "async-io", "async-process", - "core-graphics2", + "craft-appkit", "craft-atomic", "craft-docpath", "craft-host", @@ -2098,6 +2125,8 @@ dependencies = [ "js-sys", "log", "objc2-app-kit 0.3.2", + "objc2-core-foundation", + "objc2-core-graphics", "rfd", "serde", "serde_json", @@ -2114,7 +2143,7 @@ dependencies = [ [[package]] name = "craft-plist" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "thiserror 2.0.21", ] @@ -2122,7 +2151,7 @@ dependencies = [ [[package]] name = "craft-print" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "craft-behavior", "craft-host", @@ -2146,7 +2175,7 @@ dependencies = [ [[package]] name = "craft-psd" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "encoding_rs", "flate2", @@ -2157,7 +2186,7 @@ dependencies = [ [[package]] name = "craft-quit" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "dispatch2", "egui", @@ -2170,7 +2199,7 @@ dependencies = [ [[package]] name = "craft-raw" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "chrono", "craft-crw", @@ -2188,7 +2217,7 @@ dependencies = [ [[package]] name = "craft-review" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "base64 0.23.1", "craft-behavior", @@ -2207,7 +2236,7 @@ dependencies = [ [[package]] name = "craft-settings" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "craft-atomic", "craft-host", @@ -2224,7 +2253,7 @@ dependencies = [ [[package]] name = "craft-svg" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "craft-image-codecs", "craft-xml", @@ -2245,7 +2274,7 @@ dependencies = [ [[package]] name = "craft-table" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "craft-behavior", "craft-keymap", @@ -2257,7 +2286,7 @@ dependencies = [ [[package]] name = "craft-testkit" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "rustix 1.1.6", "tempfile", @@ -2267,7 +2296,7 @@ dependencies = [ [[package]] name = "craft-text" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "craft-behavior", "craft-font-manager", @@ -2290,7 +2319,7 @@ dependencies = [ [[package]] name = "craft-theme" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "bitflags 2.13.2", "craft-tracked", @@ -2305,7 +2334,7 @@ dependencies = [ [[package]] name = "craft-theme-editor" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "craft-behavior", "craft-theme", @@ -2316,7 +2345,7 @@ dependencies = [ [[package]] name = "craft-theme-store" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "craft-atomic", "craft-behavior", @@ -2331,7 +2360,7 @@ dependencies = [ [[package]] name = "craft-tiff" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "serde", "thiserror 2.0.21", @@ -2341,7 +2370,7 @@ dependencies = [ [[package]] name = "craft-time" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "serde", "thiserror 2.0.21", @@ -2350,7 +2379,7 @@ dependencies = [ [[package]] name = "craft-timeline" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "craft-behavior", "craft-keymap", @@ -2365,7 +2394,7 @@ dependencies = [ [[package]] name = "craft-tracked" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "serde", ] @@ -2373,7 +2402,7 @@ dependencies = [ [[package]] name = "craft-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "craft-cloud-ui", "craft-ui-canvas", @@ -2387,9 +2416,10 @@ dependencies = [ [[package]] name = "craft-ui-canvas" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "craft-behavior", + "craft-font-catalog", "craft-i18n", "craft-keymap", "craft-theme", @@ -2403,7 +2433,7 @@ dependencies = [ [[package]] name = "craft-ui-contract" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "accesskit", "craft-behavior", @@ -2445,7 +2475,7 @@ dependencies = [ [[package]] name = "craft-ui-macros" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -2456,7 +2486,7 @@ dependencies = [ [[package]] name = "craft-ui-panels" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "craft-behavior", "craft-host", @@ -2474,7 +2504,7 @@ dependencies = [ [[package]] name = "craft-ui-patterns" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "craft-behavior", "craft-host", @@ -2495,7 +2525,7 @@ dependencies = [ [[package]] name = "craft-ui-shell" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "craft-behavior", "craft-host", @@ -2515,7 +2545,7 @@ dependencies = [ [[package]] name = "craft-ui-widgets" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "craft-behavior", "craft-host", @@ -2534,7 +2564,7 @@ dependencies = [ [[package]] name = "craft-update" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "base64 0.22.1", "chrono", @@ -2566,7 +2596,7 @@ dependencies = [ [[package]] name = "craft-win32" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "winsafe", ] @@ -2574,7 +2604,7 @@ dependencies = [ [[package]] name = "craft-window" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "craft-appkit", "craft-atomic", @@ -2606,7 +2636,7 @@ dependencies = [ [[package]] name = "craft-xcf" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "flate2", "thiserror 2.0.21", @@ -2615,7 +2645,7 @@ dependencies = [ [[package]] name = "craft-xml" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "quick-xml 0.41.0", "serde", @@ -2625,7 +2655,7 @@ dependencies = [ [[package]] name = "craft-zip" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "flate2", "thiserror 2.0.21", @@ -4145,7 +4175,7 @@ dependencies = [ [[package]] name = "hayro" version = "0.7.1" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "bytemuck", "hayro-interpret", @@ -4168,14 +4198,14 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a14afde3344be69225fec4f6f44f6a219a3a492f9d8301eb25ef608fe4b7014c" dependencies = [ - "brotli", + "brotli 8.0.4", "hayro-postscript", ] [[package]] name = "hayro-interpret" version = "0.7.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "bitflags 2.13.2", "hayro-cmap", @@ -4193,7 +4223,7 @@ dependencies = [ [[package]] name = "hayro-jbig2" version = "0.3.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "fearless_simd", "hayro-ccitt", @@ -4217,7 +4247,7 @@ checksum = "bc2d80da85f31c3fdc0366431f44cfd645a9da1e242ed1f4a61f213d9765660f" [[package]] name = "hayro-syntax" version = "0.7.2" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "flate2", "hayro-ccitt", @@ -5310,7 +5340,7 @@ checksum = "d4a5ff6bcca6c4867b1c4fd4ef63e4db7436ef363e0ad7531d1558856bae64f4" [[package]] name = "linesweeper" version = "0.5.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "arrayvec", "kurbo 0.13.1", @@ -9821,7 +9851,7 @@ dependencies = [ [[package]] name = "vello_common" version = "0.0.8" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "bytemuck", "fearless_simd", @@ -9869,7 +9899,7 @@ dependencies = [ [[package]] name = "vello_cpu" version = "0.0.8" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "bytemuck", "glifo 0.1.1", @@ -11515,14 +11545,14 @@ source = "git+https://github.com/storytold/egui.git?rev=14c39fed181756be6f357c28 [[patch.unused]] name = "hayro-cmap" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" [[patch.unused]] name = "hayro-postscript" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" [[patch.unused]] name = "krilla" version = "0.8.2" -source = "git+https://github.com/storytold/craft-libs?rev=f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa#f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" diff --git a/Cargo.toml b/Cargo.toml index 8a8adec3087..30193c16908 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,21 +12,21 @@ rust-version = "1.95" [workspace.dependencies] # The craft framework through its facade (`craft::ui::…`). The egui `[patch]` below must match # `craft::egui_fork::REV` (checked by `cargo xtask ci`). -craft = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa", default-features = false } -craft-tracked = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } -craft-ui-macros = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } +craft = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3", default-features = false } +craft-tracked = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } +craft-ui-macros = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } # internal photocraft-geom = { path = "crates/geom" } photocraft-color = { path = "crates/color" } photocraft-raster = { path = "crates/raster" } photocraft-doc = { path = "crates/doc" } photocraft-ops = { path = "crates/ops" } -craft-plist = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } -craft-psd = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } -photocraft-codecs = { package = "craft-image-codecs", git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } -photocraft-formats = { package = "craft-file-formats", git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa", features = ["raster-codecs", "pdf", "svg", "ora", "kra", "xcf", "pdn", "raw", "psd", "affinity", "pcraft"] } +craft-plist = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } +craft-psd = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } +photocraft-codecs = { package = "craft-image-codecs", git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } +photocraft-formats = { package = "craft-file-formats", git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3", features = ["raster-codecs", "pdf", "svg", "ora", "kra", "xcf", "pdn", "raw", "psd", "affinity", "pcraft"] } photocraft-raw = { path = "crates/raw" } -craft-affinity = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } +craft-affinity = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } photocraft-compose = { path = "crates/compose" } photocraft-gpu = { path = "crates/gpu" } photocraft-paint = { path = "crates/paint" } @@ -48,38 +48,38 @@ photocraft-ipp = { path = "crates/ipp" } # external # ICC colour management: the shared crate (replaces crates/cms; craft-libs#779). -craft-cms = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } -craft-print = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } +craft-cms = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } +craft-print = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } # HEIC/HEIF: the shared decoder (replaces crates/heif; craft-libs#784). -craft-heif = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } -craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa", features = ["raster", "write-raster"] } -craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } -craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } -craft-jpeg = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } -craft-pcraft-format = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } -craft-pcraft-bundle = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } -craft-zip = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } -craft-ora = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } -craft-kra = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } -craft-xcf = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } -craft-pdn = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } +craft-heif = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } +craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3", features = ["raster", "write-raster"] } +craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } +craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } +craft-jpeg = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } +craft-pcraft-format = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } +craft-pcraft-bundle = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } +craft-zip = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } +craft-ora = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } +craft-kra = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } +craft-xcf = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } +craft-pdn = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } # Keep the shared embedded-image validation API until the framework revision includes it. -craft-svg = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa", features = ["tree-render", "tree-render-system-fonts"] } -craft-raw = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } -craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } +craft-svg = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3", features = ["tree-render", "tree-render-system-fonts"] } +craft-raw = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } +craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } # Camera-field EXIF reader/writer, shared prerequisite craft-libs#1563. -craft-metadata = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } -craft-crs = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } -craft-develop = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } -craft-develop-model = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } +craft-metadata = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } +craft-crs = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } +craft-develop = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } +craft-develop-model = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } # Interface translations: lookup, fallback, CLDR plurals and language names over the craft-i18n # catalogs that `crates/ui-egui/build.rs` embeds from `CRAFT_I18N_DIR` (storytold/craft-i18n, at # the commit in `craft-i18n.rev`). Already in the tree through craft. -craft-i18n = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } +craft-i18n = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } # craft-update: app-specific pretend versions apply to startup and manual checks. -craft-update = { git = "https://github.com/storytold/craft-libs", version = "=0.1.0", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa", features = ["ui"] } +craft-update = { git = "https://github.com/storytold/craft-libs", version = "=0.1.0", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3", features = ["ui"] } # Self-contained nightly profile isolation, launch protocol, and security fence. -craft-nightly = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } +craft-nightly = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } thiserror = "2" serde = { version = "1", features = ["derive", "rc"] } serde_json = "1" @@ -352,16 +352,16 @@ opt-level = 3 # Keep the complete egui family and native event bridge on reviewed fork commits. [patch.crates-io] -krilla = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } -hayro = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } -hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } -hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } -hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } -hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } -hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } -linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } -vello_common = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } -vello_cpu = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } +krilla = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } +hayro = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } +hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } +hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } +hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } +hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } +hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } +linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } +vello_common = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } +vello_cpu = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } ecolor = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } emath = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } epaint = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } diff --git a/crates/engine-core/Cargo.toml b/crates/engine-core/Cargo.toml index 41bb4f31eaf..25bfb4af0c7 100644 --- a/crates/engine-core/Cargo.toml +++ b/crates/engine-core/Cargo.toml @@ -19,7 +19,7 @@ photocraft-geom = { workspace = true } photocraft-color = { workspace = true } craft-cms = { workspace = true } # PCTIP codec from craft-libs#1564; kept at the same shared revision as the workspace. -craft-pcraft-tip = { package = "craft-pcraft-format", git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } +craft-pcraft-tip = { package = "craft-pcraft-format", git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } photocraft-raster = { workspace = true } photocraft-doc = { workspace = true } photocraft-ops = { workspace = true } diff --git a/crates/ipp/Cargo.toml b/crates/ipp/Cargo.toml index 23fc19a72fd..8c4df389b76 100644 --- a/crates/ipp/Cargo.toml +++ b/crates/ipp/Cargo.toml @@ -7,7 +7,7 @@ license.workspace = true rust-version.workspace = true [dependencies] -craft-ipp = { git = "https://github.com/storytold/craft-libs", rev = "f0f9bb38ff21cd1bf7fa68f08f9f0cc7f22983fa" } +craft-ipp = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } [lints] workspace = true From 60cd87cd8e64fd68386def1fc93b8abba51d7586 Mon Sep 17 00:00:00 2001 From: ruchirguitar Date: Tue, 1 Dec 2026 22:28:26 +0530 Subject: [PATCH 46/81] Keep main's other pins after the merge; craft-libs stays at fc3262f --- Cargo.lock | 32 ++++++++++++++++++-------------- Cargo.toml | 28 ++++++++++++++-------------- crates/engine-core/Cargo.toml | 10 ++++++---- 3 files changed, 38 insertions(+), 32 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3274fbe898b..271ff15964a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3072,7 +3072,7 @@ dependencies = [ [[package]] name = "ecolor" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=14c39fed181756be6f357c284354e0ab55b64443#14c39fed181756be6f357c284354e0ab55b64443" +source = "git+https://github.com/storytold/egui.git?rev=07c20531f89717e461c0f387dd1f9649553f9321#07c20531f89717e461c0f387dd1f9649553f9321" dependencies = [ "bytemuck", "emath", @@ -3106,7 +3106,7 @@ dependencies = [ [[package]] name = "eframe" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=14c39fed181756be6f357c284354e0ab55b64443#14c39fed181756be6f357c284354e0ab55b64443" +source = "git+https://github.com/storytold/egui.git?rev=07c20531f89717e461c0f387dd1f9649553f9321#07c20531f89717e461c0f387dd1f9649553f9321" dependencies = [ "ahash", "bytemuck", @@ -3143,7 +3143,7 @@ dependencies = [ [[package]] name = "egui" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=14c39fed181756be6f357c284354e0ab55b64443#14c39fed181756be6f357c284354e0ab55b64443" +source = "git+https://github.com/storytold/egui.git?rev=07c20531f89717e461c0f387dd1f9649553f9321#07c20531f89717e461c0f387dd1f9649553f9321" dependencies = [ "accesskit", "ahash", @@ -3164,7 +3164,7 @@ dependencies = [ [[package]] name = "egui-wgpu" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=14c39fed181756be6f357c284354e0ab55b64443#14c39fed181756be6f357c284354e0ab55b64443" +source = "git+https://github.com/storytold/egui.git?rev=07c20531f89717e461c0f387dd1f9649553f9321#07c20531f89717e461c0f387dd1f9649553f9321" dependencies = [ "ahash", "bytemuck", @@ -3183,7 +3183,7 @@ dependencies = [ [[package]] name = "egui-winit" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=14c39fed181756be6f357c284354e0ab55b64443#14c39fed181756be6f357c284354e0ab55b64443" +source = "git+https://github.com/storytold/egui.git?rev=07c20531f89717e461c0f387dd1f9649553f9321#07c20531f89717e461c0f387dd1f9649553f9321" dependencies = [ "accesskit_winit", "arboard", @@ -3209,7 +3209,7 @@ dependencies = [ [[package]] name = "egui_extras" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=14c39fed181756be6f357c284354e0ab55b64443#14c39fed181756be6f357c284354e0ab55b64443" +source = "git+https://github.com/storytold/egui.git?rev=07c20531f89717e461c0f387dd1f9649553f9321#07c20531f89717e461c0f387dd1f9649553f9321" dependencies = [ "ahash", "egui", @@ -3223,7 +3223,7 @@ dependencies = [ [[package]] name = "egui_glow" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=14c39fed181756be6f357c284354e0ab55b64443#14c39fed181756be6f357c284354e0ab55b64443" +source = "git+https://github.com/storytold/egui.git?rev=07c20531f89717e461c0f387dd1f9649553f9321#07c20531f89717e461c0f387dd1f9649553f9321" dependencies = [ "bytemuck", "egui", @@ -3236,7 +3236,7 @@ dependencies = [ [[package]] name = "egui_kittest" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=14c39fed181756be6f357c284354e0ab55b64443#14c39fed181756be6f357c284354e0ab55b64443" +source = "git+https://github.com/storytold/egui.git?rev=07c20531f89717e461c0f387dd1f9649553f9321#07c20531f89717e461c0f387dd1f9649553f9321" dependencies = [ "dify", "eframe", @@ -3262,7 +3262,7 @@ checksum = "0e9c71c2167ca323c882b99918929403426e2373ea17242ff5653e0d5e1058be" [[package]] name = "emath" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=14c39fed181756be6f357c284354e0ab55b64443#14c39fed181756be6f357c284354e0ab55b64443" +source = "git+https://github.com/storytold/egui.git?rev=07c20531f89717e461c0f387dd1f9649553f9321#07c20531f89717e461c0f387dd1f9649553f9321" dependencies = [ "bytemuck", "serde", @@ -3355,7 +3355,7 @@ dependencies = [ [[package]] name = "epaint" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=14c39fed181756be6f357c284354e0ab55b64443#14c39fed181756be6f357c284354e0ab55b64443" +source = "git+https://github.com/storytold/egui.git?rev=07c20531f89717e461c0f387dd1f9649553f9321#07c20531f89717e461c0f387dd1f9649553f9321" dependencies = [ "ahash", "bytemuck", @@ -3382,7 +3382,11 @@ dependencies = [ [[package]] name = "epaint_default_fonts" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=14c39fed181756be6f357c284354e0ab55b64443#14c39fed181756be6f357c284354e0ab55b64443" +source = "git+https://github.com/storytold/egui.git?rev=07c20531f89717e461c0f387dd1f9649553f9321#07c20531f89717e461c0f387dd1f9649553f9321" +dependencies = [ + "brotli 9.1.3", + "brotli-decompressor 6.3.2", +] [[package]] name = "equivalent" @@ -11530,17 +11534,17 @@ dependencies = [ [[patch.unused]] name = "egui_demo_lib" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=14c39fed181756be6f357c284354e0ab55b64443#14c39fed181756be6f357c284354e0ab55b64443" +source = "git+https://github.com/storytold/egui.git?rev=07c20531f89717e461c0f387dd1f9649553f9321#07c20531f89717e461c0f387dd1f9649553f9321" [[patch.unused]] name = "egui_inspection" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=14c39fed181756be6f357c284354e0ab55b64443#14c39fed181756be6f357c284354e0ab55b64443" +source = "git+https://github.com/storytold/egui.git?rev=07c20531f89717e461c0f387dd1f9649553f9321#07c20531f89717e461c0f387dd1f9649553f9321" [[patch.unused]] name = "egui_system_font_provider" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=14c39fed181756be6f357c284354e0ab55b64443#14c39fed181756be6f357c284354e0ab55b64443" +source = "git+https://github.com/storytold/egui.git?rev=07c20531f89717e461c0f387dd1f9649553f9321#07c20531f89717e461c0f387dd1f9649553f9321" [[patch.unused]] name = "hayro-cmap" diff --git a/Cargo.toml b/Cargo.toml index 30193c16908..c941befcf2b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -362,18 +362,18 @@ hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "fc3 linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } vello_common = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } vello_cpu = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } -ecolor = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } -emath = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } -epaint = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } -epaint_default_fonts = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } -egui = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } -egui-winit = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } -egui-wgpu = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } -egui_glow = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } -egui_extras = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } -egui_kittest = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } -egui_system_font_provider = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } -eframe = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } -egui_demo_lib = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } -egui_inspection = { git = "https://github.com/storytold/egui.git", rev = "14c39fed181756be6f357c284354e0ab55b64443" } +ecolor = { git = "https://github.com/storytold/egui.git", rev = "07c20531f89717e461c0f387dd1f9649553f9321" } +emath = { git = "https://github.com/storytold/egui.git", rev = "07c20531f89717e461c0f387dd1f9649553f9321" } +epaint = { git = "https://github.com/storytold/egui.git", rev = "07c20531f89717e461c0f387dd1f9649553f9321" } +epaint_default_fonts = { git = "https://github.com/storytold/egui.git", rev = "07c20531f89717e461c0f387dd1f9649553f9321" } +egui = { git = "https://github.com/storytold/egui.git", rev = "07c20531f89717e461c0f387dd1f9649553f9321" } +egui-winit = { git = "https://github.com/storytold/egui.git", rev = "07c20531f89717e461c0f387dd1f9649553f9321" } +egui-wgpu = { git = "https://github.com/storytold/egui.git", rev = "07c20531f89717e461c0f387dd1f9649553f9321" } +egui_glow = { git = "https://github.com/storytold/egui.git", rev = "07c20531f89717e461c0f387dd1f9649553f9321" } +egui_extras = { git = "https://github.com/storytold/egui.git", rev = "07c20531f89717e461c0f387dd1f9649553f9321" } +egui_kittest = { git = "https://github.com/storytold/egui.git", rev = "07c20531f89717e461c0f387dd1f9649553f9321" } +egui_system_font_provider = { git = "https://github.com/storytold/egui.git", rev = "07c20531f89717e461c0f387dd1f9649553f9321" } +eframe = { git = "https://github.com/storytold/egui.git", rev = "07c20531f89717e461c0f387dd1f9649553f9321" } +egui_demo_lib = { git = "https://github.com/storytold/egui.git", rev = "07c20531f89717e461c0f387dd1f9649553f9321" } +egui_inspection = { git = "https://github.com/storytold/egui.git", rev = "07c20531f89717e461c0f387dd1f9649553f9321" } winit = { git = "https://github.com/storytold/winit.git", rev = "f8b490f135ea439dd31aae100bb5591c63cb076f" } diff --git a/crates/engine-core/Cargo.toml b/crates/engine-core/Cargo.toml index 25bfb4af0c7..be32b115541 100644 --- a/crates/engine-core/Cargo.toml +++ b/crates/engine-core/Cargo.toml @@ -28,7 +28,8 @@ serde = { workspace = true } serde_json = { workspace = true } thiserror = { workspace = true } rayon = { workspace = true } -chrono = { workspace = true } +# New-document XMP dates use the actual local clock on native and web. +chrono = { workspace = true, features = ["clock"] } web-time = { workspace = true } photocraft-paint = { workspace = true } photocraft-algo = { workspace = true } @@ -54,11 +55,12 @@ craft = { workspace = true, features = ["automation", "color-ui", "keymap", "pla # Release tags use the same semantic versions as Cargo. semver = "1" +# Chrono reads the browser clock and time-zone offset through its existing JS bindings. +[target.'cfg(target_arch = "wasm32")'.dependencies] +chrono = { workspace = true, features = ["wasmbind"] } + [target.'cfg(not(target_arch = "wasm32"))'.dependencies] tempfile = "3" -# `clock`: the local time that names History Options' snapshot on save (#2966); already in the -# tree through rmcp. The web build has no local clock here and names it "Snapshot N". -chrono = { workspace = true, features = ["clock"] } # `file_cmds::same_file` on Windows: the volume serial number and file index, so a hard link to a # file is that file (std's `MetadataExt::file_index` is unstable). From 76c64f19e60be07fe21160a26319e9ce3abefbc3 Mon Sep 17 00:00:00 2001 From: ruchirguitar Date: Tue, 1 Dec 2026 23:21:36 +0530 Subject: [PATCH 47/81] Filter the font menu by script, with the Indic scripts The font pickers offer Latin, the nine Indic scripts, East Asian, Japanese and Thai in the toolbar's Script select (craft-libs#4514). Scorecard row TYPE-10996-2. --- .../src/tools/type_tool/font_picker_tests.rs | 19 ++++++++++++++ crates/ui-egui/src/tools/type_tool/fonts.rs | 25 +++++++++++++++++-- docs/scorecard.md | 3 ++- scorecard/type.toml | 7 ++++++ 4 files changed, 51 insertions(+), 3 deletions(-) diff --git a/crates/ui-egui/src/tools/type_tool/font_picker_tests.rs b/crates/ui-egui/src/tools/type_tool/font_picker_tests.rs index 3cfabae49fb..c9e87099eef 100644 --- a/crates/ui-egui/src/tools/type_tool/font_picker_tests.rs +++ b/crates/ui-egui/src/tools/type_tool/font_picker_tests.rs @@ -233,3 +233,22 @@ fn hovering_a_font_adds_no_history_step_and_a_pick_adds_one() { assert_eq!(layer_font(h.state()), "JetBrains Mono"); assert_eq!(history_len(h.state()), before + 1, "the pick is one history step"); } + +/// The toolbar's Script select offers the Indic scripts (#10996); picking Devanagari narrows the family list and is +/// kept as the pickers' filter. +#[test] +fn the_family_list_filters_by_an_indic_script() { + let mut h = bar_harness(app_with_layer()); + h.run_steps(4); + assert_eq!(h.state().ui.font_filters.script, None, "no script filter at first"); + field(&h).click(); + h.run(); + let families = |h: &Harness<'static, Box>| h.query_all_by_role(Role::TreeItem).count(); + let before = families(&h); + h.get_by_role_and_label(Role::ComboBox, "Script").click(); + h.run(); + h.get_by_label("Devanagari").click(); + h.run(); + assert_eq!(h.state().ui.font_filters.script, Some(craft::font_manager::picker::FontScript::Devanagari)); + assert!(families(&h) < before, "the Latin-only families leave the list ({} of {before} left)", families(&h)); +} diff --git a/crates/ui-egui/src/tools/type_tool/fonts.rs b/crates/ui-egui/src/tools/type_tool/fonts.rs index 034d72a3f8d..db04c76ced3 100644 --- a/crates/ui-egui/src/tools/type_tool/fonts.rs +++ b/crates/ui-egui/src/tools/type_tool/fonts.rs @@ -1,4 +1,4 @@ -use craft::font_manager::picker::{FontFilters, FontPickerSettings, FontPreviewSize}; +use craft::font_manager::picker::{FontFilters, FontPickerSettings, FontPreviewSize, FontScript}; use craft::text::ui::character::FontPickerSource; use craft::ui::contract::Bind; use photocraft_engine::prefs::FontPreview; @@ -95,6 +95,23 @@ pub(super) fn preview_text(app: &PhotocraftApp) -> Option { (!line.is_empty()).then_some(line) } +/// The scripts the font pickers' script row offers: Latin, the Indic scripts, then the East Asian ones and Thai. +const PICKER_SCRIPTS: [FontScript; 13] = [ + FontScript::Latin, + FontScript::Devanagari, + FontScript::Bengali, + FontScript::Gurmukhi, + FontScript::Gujarati, + FontScript::Odia, + FontScript::Tamil, + FontScript::Telugu, + FontScript::Kannada, + FontScript::Malayalam, + FontScript::EastAsian, + FontScript::Japanese, + FontScript::Thai, +]; + /// The font picker's most recent families the settings may hold, whatever the preference says. const MAX_RECENT_FONTS: usize = 50; @@ -137,7 +154,11 @@ impl FontSourceState { /// The picker's source over this state. pub(crate) fn source(&mut self) -> FontPickerSource<'_> { let catalog = photocraft_text::fonts::catalog(); - let mut source = FontPickerSource::new(catalog).settings(Bind::bound(&mut self.settings)).filters(Bind::bound(&mut self.filters)).served(&self.served); + let mut source = FontPickerSource::new(catalog) + .settings(Bind::bound(&mut self.settings)) + .filters(Bind::bound(&mut self.filters)) + .served(&self.served) + .scripts(&PICKER_SCRIPTS); if let Some(text) = self.preview_text.as_deref() { source = source.preview_text(text); } diff --git a/docs/scorecard.md b/docs/scorecard.md index e984cf914e7..016cab7ceb7 100644 --- a/docs/scorecard.md +++ b/docs/scorecard.md @@ -10,7 +10,7 @@ Generated by `cargo xtask scorecard` from `perf/budgets.toml`, `perf/baseline.js | [File compatibility](#file-compatibility) | 11 | 14 | 2 | io corpus: oracle ≥ 148/170, round trip ≥ 169/170; psd-tools corpus: oracle ≥ 249/309, round trip ≥ 308/309; photoshop oracles: oracle ≥ 190/258, round trip ≥ 258/258 | | [Tools](#tools) | 36 | 9 | 0 | | | [Workspace and UI](#workspace-and-ui) | 15 | 6 | 2 | settings that do nothing: 9 of 204 (target 0) | -| [Type](#type) | 5 | 6 | 0 | | +| [Type](#type) | 6 | 6 | 0 | | | [Automation](#automation) | 6 | 4 | 2 | 663 of 663 menu items live (100.0%) | | [Reliability](#reliability) | 5 | 2 | 0 | never-crash lints on 28 of 28 crates; panic_hunt present | | [Distribution](#distribution) | 5 | 5 | 1 | | @@ -261,6 +261,7 @@ Unread: `general.color_picker`, `workspace.auto_show_hidden_panels`, `workspace. | TYPE-218-8 | Text editing: select all, double/triple/quadruple-click selection, paste, with tests | done | [#218](https://github.com/storytold/photocraft/issues/218) | Like Photoshop, 2 clicks select the word, 3 the laid-out line (a column in vertical type), 4 the paragraph up to the hard return, 5 all text, and the next quick click starts over (#3493; type_tool.rs next_click_count, click_selection, multi_click). Tested through real canvas clicks in point, paragraph and vertical type, with paste replacing the selection and Cmd+A selecting all (type_tool_tests.rs multi_click_selects_word_line_paragraph_and_all_in_point_text, multi_click_separates_wrapped_lines_from_paragraphs, click_counts_cycle_and_restart, click_selection_without_layout_and_on_hostile_input, multi_click_without_a_session_does_nothing) | | TYPE-218-9 | Distort/Perspective/Warp on live type as in Photoshop (was: offer 'Rasterize and continue?'; Photoshop doesn't prompt) | done | [#218](https://github.com/storytold/photocraft/issues/218) | Photoshop 2026 prompts for none of these: Edit › Transform › Warp on live type stays enabled with no rasterize prompt and offers only the warp styles (the mesh can't be dragged), so the type stays editable; Distort, Perspective and the split warps are greyed. PhotoCraft does the same: Warp on type commits the layer's Warp Text in one step (transform_tool.rs enter_type_warp, warp_cmds.rs warp_type_layer, #3004; warp_on_type_takes_a_style_and_keeps_the_type_editable), Distort/Perspective greyed (enable_rules.rs, #2701) | | TYPE-218-10 | Area type: Type tool click inside a closed path or shape wraps text inside it, holes and dents included, PSD round trip | partial | [#218](https://github.com/storytold/photocraft/issues/218) | TextShape::Area (doc text.rs) laid out line by line into the spans the path leaves (text area.rs, layout.rs break_area), type.fillPath (engine type_area_cmds.rs), released to box text by type.detachFromPath, area/path cursors and click-to-place (ui-egui type_tool.rs path_target), .pcraft round trip. Missing: PSD area type (saves as paragraph text over the path's bounds, with an export warning); mixed type sizes in one area paragraph space at its largest line; area type takes paths of at most 4096 anchors: beyond that a Type tool click makes point text (the pointer shows the plain I-beam), and type.fillPath refuses the path with "the path has too many anchor points" (type.attachToPath still takes a subpath of up to 100,000 anchors); a word too wide for every span in the shape overflows its span (box text breaks it at the edge, #6694); the first line starts about 0.24 em lower than in a text box of the same size; Photoshop area type in a PSD opens as box text; the area path has no handles to edit it after the type is placed | +| TYPE-10996-2 | Font menu filter by script, with the Indic scripts (Devanagari, Bengali, Gurmukhi, Gujarati, Odia, Tamil, Telugu, Kannada, Malayalam) beside Latin, East Asian, Japanese and Thai | done | [#10996](https://github.com/storytold/photocraft/issues/10996) | The font pickers (options bar, Character panel, Style Options) offer the script row (ui-egui type_tool fonts.rs); coverage is read from the cmap in craft-font-manager. Arabic and Hebrew are not offered yet | | TYPE-10996-1 | Digit style: digits drawn as typed, Western, by the script of the letters before them, or in an Indic script (Devanagari, Bengali, Gurmukhi, Gujarati, Odia, Tamil, Telugu, Kannada, Malayalam) | partial | [#10996](https://github.com/storytold/photocraft/issues/10996) | CharStyle `digits` (doc text.rs), drawn in shaping (text digits.rs) while the layer text keeps the typed digits; set through the type commands' `digits` key. No Character panel control yet (needs the shared panel in craft-libs); Arabic and Persian digits are #6685; not saved in PSD | ## Automation diff --git a/scorecard/type.toml b/scorecard/type.toml index 579e92e5715..df80105c4f0 100644 --- a/scorecard/type.toml +++ b/scorecard/type.toml @@ -74,6 +74,13 @@ status = "partial" issue = 218 note = "TextShape::Area (doc text.rs) laid out line by line into the spans the path leaves (text area.rs, layout.rs break_area), type.fillPath (engine type_area_cmds.rs), released to box text by type.detachFromPath, area/path cursors and click-to-place (ui-egui type_tool.rs path_target), .pcraft round trip. Missing: PSD area type (saves as paragraph text over the path's bounds, with an export warning); mixed type sizes in one area paragraph space at its largest line; area type takes paths of at most 4096 anchors: beyond that a Type tool click makes point text (the pointer shows the plain I-beam), and type.fillPath refuses the path with \"the path has too many anchor points\" (type.attachToPath still takes a subpath of up to 100,000 anchors); a word too wide for every span in the shape overflows its span (box text breaks it at the edge, #6694); the first line starts about 0.24 em lower than in a text box of the same size; Photoshop area type in a PSD opens as box text; the area path has no handles to edit it after the type is placed" +[[item]] +id = "TYPE-10996-2" +target = "Font menu filter by script, with the Indic scripts (Devanagari, Bengali, Gurmukhi, Gujarati, Odia, Tamil, Telugu, Kannada, Malayalam) beside Latin, East Asian, Japanese and Thai" +status = "done" +issue = 10996 +note = "The font pickers (options bar, Character panel, Style Options) offer the script row (ui-egui type_tool fonts.rs); coverage is read from the cmap in craft-font-manager. Arabic and Hebrew are not offered yet" + [[item]] id = "TYPE-10996-1" target = "Digit style: digits drawn as typed, Western, by the script of the letters before them, or in an Indic script (Devanagari, Bengali, Gurmukhi, Gujarati, Odia, Tamil, Telugu, Kannada, Malayalam)" From 553b17b5301fa0751f3fb884adb6f3887bcc5f18 Mon Sep 17 00:00:00 2001 From: ruchirguitar Date: Tue, 1 Dec 2026 23:31:22 +0530 Subject: [PATCH 48/81] Move craft-libs pin to fc3262f6 (craft-libs#4514) Brings in the font picker's Toolbar Script select. --- Cargo.lock | 192 +++++++++++++++++----------------- Cargo.toml | 84 +++++++-------- crates/engine-core/Cargo.toml | 2 +- crates/ipp/Cargo.toml | 2 +- 4 files changed, 140 insertions(+), 140 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 980c2438d55..271ff15964a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1376,7 +1376,7 @@ dependencies = [ [[package]] name = "craft" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "craft-automation", "craft-behavior", @@ -1417,7 +1417,7 @@ dependencies = [ [[package]] name = "craft-affinity" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "crc32fast", "flate2", @@ -1438,7 +1438,7 @@ dependencies = [ [[package]] name = "craft-appkit" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "block2 0.6.2", "objc2 0.6.5", @@ -1450,7 +1450,7 @@ dependencies = [ [[package]] name = "craft-atomic" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "rustix 1.1.6", ] @@ -1458,7 +1458,7 @@ dependencies = [ [[package]] name = "craft-automation" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "base64 0.23.1", "craft-behavior", @@ -1483,7 +1483,7 @@ dependencies = [ [[package]] name = "craft-behavior" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "accesskit", "bitflags 2.13.2", @@ -1501,7 +1501,7 @@ dependencies = [ [[package]] name = "craft-browse" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "craft-behavior", "craft-docpath", @@ -1519,7 +1519,7 @@ dependencies = [ [[package]] name = "craft-cloud-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "egui", ] @@ -1527,7 +1527,7 @@ dependencies = [ [[package]] name = "craft-cms" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "md-5", "rayon", @@ -1536,12 +1536,12 @@ dependencies = [ [[package]] name = "craft-codepage" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" [[package]] name = "craft-color" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "serde", ] @@ -1549,7 +1549,7 @@ dependencies = [ [[package]] name = "craft-color-transform" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "craft-cms", "craft-color", @@ -1559,7 +1559,7 @@ dependencies = [ [[package]] name = "craft-color-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "craft-behavior", "craft-cms", @@ -1580,7 +1580,7 @@ dependencies = [ [[package]] name = "craft-control" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "craft-ai-agents", "craft-atomic", @@ -1596,7 +1596,7 @@ dependencies = [ [[package]] name = "craft-control-protocol" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "getrandom 0.3.4", "serde_json", @@ -1606,7 +1606,7 @@ dependencies = [ [[package]] name = "craft-crs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "craft-metadata", "craft-xml", @@ -1616,7 +1616,7 @@ dependencies = [ [[package]] name = "craft-crw" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "thiserror 2.0.21", ] @@ -1624,7 +1624,7 @@ dependencies = [ [[package]] name = "craft-dds" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "rayon", ] @@ -1632,7 +1632,7 @@ dependencies = [ [[package]] name = "craft-develop" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "craft-color", "craft-color-transform", @@ -1647,7 +1647,7 @@ dependencies = [ [[package]] name = "craft-develop-model" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "craft-geom", "craft-metadata", @@ -1659,7 +1659,7 @@ dependencies = [ [[package]] name = "craft-dialogs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "block2 0.6.2", "craft-appkit", @@ -1685,7 +1685,7 @@ dependencies = [ [[package]] name = "craft-docpath" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "serde", ] @@ -1693,7 +1693,7 @@ dependencies = [ [[package]] name = "craft-draw" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "craft-behavior", "craft-color-ui", @@ -1712,7 +1712,7 @@ dependencies = [ [[package]] name = "craft-drawingml" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "chrono", "craft-xml", @@ -1724,12 +1724,12 @@ dependencies = [ [[package]] name = "craft-eps" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" [[package]] name = "craft-file-formats" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "craft-eps", "craft-idml", @@ -1747,7 +1747,7 @@ dependencies = [ [[package]] name = "craft-flags" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "craft-atomic", "dirs", @@ -1757,7 +1757,7 @@ dependencies = [ [[package]] name = "craft-font-catalog" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "fontique", "harfrust 0.13.3", @@ -1772,7 +1772,7 @@ dependencies = [ [[package]] name = "craft-font-manager" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "craft-behavior", "craft-font-catalog", @@ -1792,7 +1792,7 @@ dependencies = [ [[package]] name = "craft-font-os-windows" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "windows-registry", "windows-sys 0.61.2", @@ -1801,7 +1801,7 @@ dependencies = [ [[package]] name = "craft-font-store" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "cap-primitives", "craft-atomic", @@ -1824,12 +1824,12 @@ dependencies = [ [[package]] name = "craft-fonts-build" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" [[package]] name = "craft-geom" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "serde", ] @@ -1837,7 +1837,7 @@ dependencies = [ [[package]] name = "craft-heif" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "heic-rs", "rayon", @@ -1846,7 +1846,7 @@ dependencies = [ [[package]] name = "craft-host" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "bitflags 2.13.2", "craft-i18n", @@ -1859,7 +1859,7 @@ dependencies = [ [[package]] name = "craft-i18n" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "brotli 9.1.3", "brotli-decompressor 6.3.2", @@ -1889,7 +1889,7 @@ dependencies = [ [[package]] name = "craft-idml" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "craft-xml", "craft-zip", @@ -1899,7 +1899,7 @@ dependencies = [ [[package]] name = "craft-image-codecs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "craft-dds", "craft-heif", @@ -1927,7 +1927,7 @@ dependencies = [ [[package]] name = "craft-imaging" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "craft-behavior", "craft-color-ui", @@ -1945,12 +1945,12 @@ dependencies = [ [[package]] name = "craft-ipp" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" [[package]] name = "craft-jpeg" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "thiserror 2.0.21", ] @@ -1958,7 +1958,7 @@ dependencies = [ [[package]] name = "craft-keymap" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "craft-host", "craft-i18n", @@ -1973,7 +1973,7 @@ dependencies = [ [[package]] name = "craft-kra" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "craft-xml", "craft-zip", @@ -1983,7 +1983,7 @@ dependencies = [ [[package]] name = "craft-layers" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "craft-behavior", "craft-i18n", @@ -1997,7 +1997,7 @@ dependencies = [ [[package]] name = "craft-menu" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "craft-behavior", "craft-host", @@ -2015,7 +2015,7 @@ dependencies = [ [[package]] name = "craft-metadata" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "brotli-decompressor 6.3.2", "chrono", @@ -2027,7 +2027,7 @@ dependencies = [ [[package]] name = "craft-nightly" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "uds_windows", "winsafe", @@ -2036,7 +2036,7 @@ dependencies = [ [[package]] name = "craft-ora" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "craft-xml", "craft-zip", @@ -2046,7 +2046,7 @@ dependencies = [ [[package]] name = "craft-pages" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "craft-behavior", "craft-keymap", @@ -2062,7 +2062,7 @@ dependencies = [ [[package]] name = "craft-pcraft-bundle" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "blake3", "craft-atomic", @@ -2075,7 +2075,7 @@ dependencies = [ [[package]] name = "craft-pcraft-format" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "flate2", "serde", @@ -2086,7 +2086,7 @@ dependencies = [ [[package]] name = "craft-pdf" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "bytemuck", "flate2", @@ -2101,7 +2101,7 @@ dependencies = [ [[package]] name = "craft-pdn" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "flate2", "thiserror 2.0.21", @@ -2110,7 +2110,7 @@ dependencies = [ [[package]] name = "craft-platform" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "async-channel", "async-io", @@ -2143,7 +2143,7 @@ dependencies = [ [[package]] name = "craft-plist" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "thiserror 2.0.21", ] @@ -2151,7 +2151,7 @@ dependencies = [ [[package]] name = "craft-print" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "craft-behavior", "craft-host", @@ -2175,7 +2175,7 @@ dependencies = [ [[package]] name = "craft-psd" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "encoding_rs", "flate2", @@ -2186,7 +2186,7 @@ dependencies = [ [[package]] name = "craft-quit" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "dispatch2", "egui", @@ -2199,7 +2199,7 @@ dependencies = [ [[package]] name = "craft-raw" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "chrono", "craft-crw", @@ -2217,7 +2217,7 @@ dependencies = [ [[package]] name = "craft-review" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "base64 0.23.1", "craft-behavior", @@ -2236,7 +2236,7 @@ dependencies = [ [[package]] name = "craft-settings" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "craft-atomic", "craft-host", @@ -2253,7 +2253,7 @@ dependencies = [ [[package]] name = "craft-svg" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "craft-image-codecs", "craft-xml", @@ -2274,7 +2274,7 @@ dependencies = [ [[package]] name = "craft-table" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "craft-behavior", "craft-keymap", @@ -2286,7 +2286,7 @@ dependencies = [ [[package]] name = "craft-testkit" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "rustix 1.1.6", "tempfile", @@ -2296,7 +2296,7 @@ dependencies = [ [[package]] name = "craft-text" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "craft-behavior", "craft-font-manager", @@ -2319,7 +2319,7 @@ dependencies = [ [[package]] name = "craft-theme" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "bitflags 2.13.2", "craft-tracked", @@ -2334,7 +2334,7 @@ dependencies = [ [[package]] name = "craft-theme-editor" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "craft-behavior", "craft-theme", @@ -2345,7 +2345,7 @@ dependencies = [ [[package]] name = "craft-theme-store" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "craft-atomic", "craft-behavior", @@ -2360,7 +2360,7 @@ dependencies = [ [[package]] name = "craft-tiff" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "serde", "thiserror 2.0.21", @@ -2370,7 +2370,7 @@ dependencies = [ [[package]] name = "craft-time" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "serde", "thiserror 2.0.21", @@ -2379,7 +2379,7 @@ dependencies = [ [[package]] name = "craft-timeline" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "craft-behavior", "craft-keymap", @@ -2394,7 +2394,7 @@ dependencies = [ [[package]] name = "craft-tracked" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "serde", ] @@ -2402,7 +2402,7 @@ dependencies = [ [[package]] name = "craft-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "craft-cloud-ui", "craft-ui-canvas", @@ -2416,7 +2416,7 @@ dependencies = [ [[package]] name = "craft-ui-canvas" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "craft-behavior", "craft-font-catalog", @@ -2433,7 +2433,7 @@ dependencies = [ [[package]] name = "craft-ui-contract" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "accesskit", "craft-behavior", @@ -2475,7 +2475,7 @@ dependencies = [ [[package]] name = "craft-ui-macros" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -2486,7 +2486,7 @@ dependencies = [ [[package]] name = "craft-ui-panels" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "craft-behavior", "craft-host", @@ -2504,7 +2504,7 @@ dependencies = [ [[package]] name = "craft-ui-patterns" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "craft-behavior", "craft-host", @@ -2525,7 +2525,7 @@ dependencies = [ [[package]] name = "craft-ui-shell" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "craft-behavior", "craft-host", @@ -2545,7 +2545,7 @@ dependencies = [ [[package]] name = "craft-ui-widgets" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "craft-behavior", "craft-host", @@ -2564,7 +2564,7 @@ dependencies = [ [[package]] name = "craft-update" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "base64 0.22.1", "chrono", @@ -2596,7 +2596,7 @@ dependencies = [ [[package]] name = "craft-win32" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "winsafe", ] @@ -2604,7 +2604,7 @@ dependencies = [ [[package]] name = "craft-window" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "craft-appkit", "craft-atomic", @@ -2636,7 +2636,7 @@ dependencies = [ [[package]] name = "craft-xcf" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "flate2", "thiserror 2.0.21", @@ -2645,7 +2645,7 @@ dependencies = [ [[package]] name = "craft-xml" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "quick-xml 0.41.0", "serde", @@ -2655,7 +2655,7 @@ dependencies = [ [[package]] name = "craft-zip" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "flate2", "thiserror 2.0.21", @@ -4179,7 +4179,7 @@ dependencies = [ [[package]] name = "hayro" version = "0.7.1" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "bytemuck", "hayro-interpret", @@ -4209,7 +4209,7 @@ dependencies = [ [[package]] name = "hayro-interpret" version = "0.7.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "bitflags 2.13.2", "hayro-cmap", @@ -4227,7 +4227,7 @@ dependencies = [ [[package]] name = "hayro-jbig2" version = "0.3.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "fearless_simd", "hayro-ccitt", @@ -4251,7 +4251,7 @@ checksum = "bc2d80da85f31c3fdc0366431f44cfd645a9da1e242ed1f4a61f213d9765660f" [[package]] name = "hayro-syntax" version = "0.7.2" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "flate2", "hayro-ccitt", @@ -5344,7 +5344,7 @@ checksum = "d4a5ff6bcca6c4867b1c4fd4ef63e4db7436ef363e0ad7531d1558856bae64f4" [[package]] name = "linesweeper" version = "0.5.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "arrayvec", "kurbo 0.13.1", @@ -9855,7 +9855,7 @@ dependencies = [ [[package]] name = "vello_common" version = "0.0.8" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "bytemuck", "fearless_simd", @@ -9903,7 +9903,7 @@ dependencies = [ [[package]] name = "vello_cpu" version = "0.0.8" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" dependencies = [ "bytemuck", "glifo 0.1.1", @@ -11549,14 +11549,14 @@ source = "git+https://github.com/storytold/egui.git?rev=07c20531f89717e461c0f387 [[patch.unused]] name = "hayro-cmap" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" [[patch.unused]] name = "hayro-postscript" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" [[patch.unused]] name = "krilla" version = "0.8.2" -source = "git+https://github.com/storytold/craft-libs?rev=475f6feb712bd2db2f235d9999be61c68477ae39#475f6feb712bd2db2f235d9999be61c68477ae39" +source = "git+https://github.com/storytold/craft-libs?rev=fc3262f68babdb19a98a89c415c84c6b327073d3#fc3262f68babdb19a98a89c415c84c6b327073d3" diff --git a/Cargo.toml b/Cargo.toml index 61da67d493e..c941befcf2b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,21 +12,21 @@ rust-version = "1.95" [workspace.dependencies] # The craft framework through its facade (`craft::ui::…`). The egui `[patch]` below must match # `craft::egui_fork::REV` (checked by `cargo xtask ci`). -craft = { git = "https://github.com/storytold/craft-libs", rev = "475f6feb712bd2db2f235d9999be61c68477ae39", default-features = false } -craft-tracked = { git = "https://github.com/storytold/craft-libs", rev = "475f6feb712bd2db2f235d9999be61c68477ae39" } -craft-ui-macros = { git = "https://github.com/storytold/craft-libs", rev = "475f6feb712bd2db2f235d9999be61c68477ae39" } +craft = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3", default-features = false } +craft-tracked = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } +craft-ui-macros = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } # internal photocraft-geom = { path = "crates/geom" } photocraft-color = { path = "crates/color" } photocraft-raster = { path = "crates/raster" } photocraft-doc = { path = "crates/doc" } photocraft-ops = { path = "crates/ops" } -craft-plist = { git = "https://github.com/storytold/craft-libs", rev = "475f6feb712bd2db2f235d9999be61c68477ae39" } -craft-psd = { git = "https://github.com/storytold/craft-libs", rev = "475f6feb712bd2db2f235d9999be61c68477ae39" } -photocraft-codecs = { package = "craft-image-codecs", git = "https://github.com/storytold/craft-libs", rev = "475f6feb712bd2db2f235d9999be61c68477ae39" } -photocraft-formats = { package = "craft-file-formats", git = "https://github.com/storytold/craft-libs", rev = "475f6feb712bd2db2f235d9999be61c68477ae39", features = ["raster-codecs", "pdf", "svg", "ora", "kra", "xcf", "pdn", "raw", "psd", "affinity", "pcraft"] } +craft-plist = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } +craft-psd = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } +photocraft-codecs = { package = "craft-image-codecs", git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } +photocraft-formats = { package = "craft-file-formats", git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3", features = ["raster-codecs", "pdf", "svg", "ora", "kra", "xcf", "pdn", "raw", "psd", "affinity", "pcraft"] } photocraft-raw = { path = "crates/raw" } -craft-affinity = { git = "https://github.com/storytold/craft-libs", rev = "475f6feb712bd2db2f235d9999be61c68477ae39" } +craft-affinity = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } photocraft-compose = { path = "crates/compose" } photocraft-gpu = { path = "crates/gpu" } photocraft-paint = { path = "crates/paint" } @@ -48,38 +48,38 @@ photocraft-ipp = { path = "crates/ipp" } # external # ICC colour management: the shared crate (replaces crates/cms; craft-libs#779). -craft-cms = { git = "https://github.com/storytold/craft-libs", rev = "475f6feb712bd2db2f235d9999be61c68477ae39" } -craft-print = { git = "https://github.com/storytold/craft-libs", rev = "475f6feb712bd2db2f235d9999be61c68477ae39" } +craft-cms = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } +craft-print = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } # HEIC/HEIF: the shared decoder (replaces crates/heif; craft-libs#784). -craft-heif = { git = "https://github.com/storytold/craft-libs", rev = "475f6feb712bd2db2f235d9999be61c68477ae39" } -craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "475f6feb712bd2db2f235d9999be61c68477ae39", features = ["raster", "write-raster"] } -craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "475f6feb712bd2db2f235d9999be61c68477ae39" } -craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "475f6feb712bd2db2f235d9999be61c68477ae39" } -craft-jpeg = { git = "https://github.com/storytold/craft-libs", rev = "475f6feb712bd2db2f235d9999be61c68477ae39" } -craft-pcraft-format = { git = "https://github.com/storytold/craft-libs", rev = "475f6feb712bd2db2f235d9999be61c68477ae39" } -craft-pcraft-bundle = { git = "https://github.com/storytold/craft-libs", rev = "475f6feb712bd2db2f235d9999be61c68477ae39" } -craft-zip = { git = "https://github.com/storytold/craft-libs", rev = "475f6feb712bd2db2f235d9999be61c68477ae39" } -craft-ora = { git = "https://github.com/storytold/craft-libs", rev = "475f6feb712bd2db2f235d9999be61c68477ae39" } -craft-kra = { git = "https://github.com/storytold/craft-libs", rev = "475f6feb712bd2db2f235d9999be61c68477ae39" } -craft-xcf = { git = "https://github.com/storytold/craft-libs", rev = "475f6feb712bd2db2f235d9999be61c68477ae39" } -craft-pdn = { git = "https://github.com/storytold/craft-libs", rev = "475f6feb712bd2db2f235d9999be61c68477ae39" } +craft-heif = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } +craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3", features = ["raster", "write-raster"] } +craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } +craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } +craft-jpeg = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } +craft-pcraft-format = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } +craft-pcraft-bundle = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } +craft-zip = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } +craft-ora = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } +craft-kra = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } +craft-xcf = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } +craft-pdn = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } # Keep the shared embedded-image validation API until the framework revision includes it. -craft-svg = { git = "https://github.com/storytold/craft-libs", rev = "475f6feb712bd2db2f235d9999be61c68477ae39", features = ["tree-render", "tree-render-system-fonts"] } -craft-raw = { git = "https://github.com/storytold/craft-libs", rev = "475f6feb712bd2db2f235d9999be61c68477ae39" } -craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "475f6feb712bd2db2f235d9999be61c68477ae39" } +craft-svg = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3", features = ["tree-render", "tree-render-system-fonts"] } +craft-raw = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } +craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } # Camera-field EXIF reader/writer, shared prerequisite craft-libs#1563. -craft-metadata = { git = "https://github.com/storytold/craft-libs", rev = "475f6feb712bd2db2f235d9999be61c68477ae39" } -craft-crs = { git = "https://github.com/storytold/craft-libs", rev = "475f6feb712bd2db2f235d9999be61c68477ae39" } -craft-develop = { git = "https://github.com/storytold/craft-libs", rev = "475f6feb712bd2db2f235d9999be61c68477ae39" } -craft-develop-model = { git = "https://github.com/storytold/craft-libs", rev = "475f6feb712bd2db2f235d9999be61c68477ae39" } +craft-metadata = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } +craft-crs = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } +craft-develop = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } +craft-develop-model = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } # Interface translations: lookup, fallback, CLDR plurals and language names over the craft-i18n # catalogs that `crates/ui-egui/build.rs` embeds from `CRAFT_I18N_DIR` (storytold/craft-i18n, at # the commit in `craft-i18n.rev`). Already in the tree through craft. -craft-i18n = { git = "https://github.com/storytold/craft-libs", rev = "475f6feb712bd2db2f235d9999be61c68477ae39" } +craft-i18n = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } # craft-update: app-specific pretend versions apply to startup and manual checks. -craft-update = { git = "https://github.com/storytold/craft-libs", version = "=0.1.0", rev = "475f6feb712bd2db2f235d9999be61c68477ae39", features = ["ui"] } +craft-update = { git = "https://github.com/storytold/craft-libs", version = "=0.1.0", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3", features = ["ui"] } # Self-contained nightly profile isolation, launch protocol, and security fence. -craft-nightly = { git = "https://github.com/storytold/craft-libs", rev = "475f6feb712bd2db2f235d9999be61c68477ae39" } +craft-nightly = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } thiserror = "2" serde = { version = "1", features = ["derive", "rc"] } serde_json = "1" @@ -352,16 +352,16 @@ opt-level = 3 # Keep the complete egui family and native event bridge on reviewed fork commits. [patch.crates-io] -krilla = { git = "https://github.com/storytold/craft-libs", rev = "475f6feb712bd2db2f235d9999be61c68477ae39" } -hayro = { git = "https://github.com/storytold/craft-libs", rev = "475f6feb712bd2db2f235d9999be61c68477ae39" } -hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "475f6feb712bd2db2f235d9999be61c68477ae39" } -hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "475f6feb712bd2db2f235d9999be61c68477ae39" } -hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "475f6feb712bd2db2f235d9999be61c68477ae39" } -hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "475f6feb712bd2db2f235d9999be61c68477ae39" } -hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "475f6feb712bd2db2f235d9999be61c68477ae39" } -linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "475f6feb712bd2db2f235d9999be61c68477ae39" } -vello_common = { git = "https://github.com/storytold/craft-libs", rev = "475f6feb712bd2db2f235d9999be61c68477ae39" } -vello_cpu = { git = "https://github.com/storytold/craft-libs", rev = "475f6feb712bd2db2f235d9999be61c68477ae39" } +krilla = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } +hayro = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } +hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } +hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } +hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } +hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } +hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } +linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } +vello_common = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } +vello_cpu = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } ecolor = { git = "https://github.com/storytold/egui.git", rev = "07c20531f89717e461c0f387dd1f9649553f9321" } emath = { git = "https://github.com/storytold/egui.git", rev = "07c20531f89717e461c0f387dd1f9649553f9321" } epaint = { git = "https://github.com/storytold/egui.git", rev = "07c20531f89717e461c0f387dd1f9649553f9321" } diff --git a/crates/engine-core/Cargo.toml b/crates/engine-core/Cargo.toml index ac24b32f634..be32b115541 100644 --- a/crates/engine-core/Cargo.toml +++ b/crates/engine-core/Cargo.toml @@ -19,7 +19,7 @@ photocraft-geom = { workspace = true } photocraft-color = { workspace = true } craft-cms = { workspace = true } # PCTIP codec from craft-libs#1564; kept at the same shared revision as the workspace. -craft-pcraft-tip = { package = "craft-pcraft-format", git = "https://github.com/storytold/craft-libs", rev = "475f6feb712bd2db2f235d9999be61c68477ae39" } +craft-pcraft-tip = { package = "craft-pcraft-format", git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } photocraft-raster = { workspace = true } photocraft-doc = { workspace = true } photocraft-ops = { workspace = true } diff --git a/crates/ipp/Cargo.toml b/crates/ipp/Cargo.toml index b25a5ccd3f7..8c4df389b76 100644 --- a/crates/ipp/Cargo.toml +++ b/crates/ipp/Cargo.toml @@ -7,7 +7,7 @@ license.workspace = true rust-version.workspace = true [dependencies] -craft-ipp = { git = "https://github.com/storytold/craft-libs", rev = "475f6feb712bd2db2f235d9999be61c68477ae39" } +craft-ipp = { git = "https://github.com/storytold/craft-libs", rev = "fc3262f68babdb19a98a89c415c84c6b327073d3" } [lints] workspace = true From 1a59cfab37f768a76b17b72143cfdee1748e77a9 Mon Sep 17 00:00:00 2001 From: Ivan Sanchez Date: Tue, 1 Dec 2026 14:26:33 -0800 Subject: [PATCH 49/81] Gradient: a right press during the drag makes the gradient there A right press while the left button drags a gradient reaches the app as the canvas host's context request, and the drag went on: the gradient ended wherever the left button came up. As in the reference application, the right press now ends the drag there (#18703). The gradient is made at once from the press to that point (classic pixels, or a new or redrawn Gradient Fill layer) as one History step, no menu opens, and later moves and the left release change nothing. A drag still too short makes nothing, as a short release. A right-click without a drag, other tools, and a right press with a modifier held (not measured) keep today's behaviour. --- crates/ui-egui/src/canvas/canvas_tool_menu.rs | 3 +- crates/ui-egui/src/tools/gradient_ui.rs | 2 + .../right_click_during_drag_tests.rs | 107 ++++++++++++++++++ crates/ui-egui/src/tools/gradient_ui/tool.rs | 36 +++++- 4 files changed, 145 insertions(+), 3 deletions(-) create mode 100644 crates/ui-egui/src/tools/gradient_ui/right_click_during_drag_tests.rs diff --git a/crates/ui-egui/src/canvas/canvas_tool_menu.rs b/crates/ui-egui/src/canvas/canvas_tool_menu.rs index ba6cf181f71..38ef019fb0e 100644 --- a/crates/ui-egui/src/canvas/canvas_tool_menu.rs +++ b/crates/ui-egui/src/canvas/canvas_tool_menu.rs @@ -2065,7 +2065,8 @@ pub(crate) fn run( let doc = view.to_doc(at); open_at(app, tool, mods, at, [doc.x, doc.y], None); } - if let Some(request) = host.context { + // A right press that ended a Gradient drag made the gradient instead (#18703). + if let Some(request) = host.context.filter(|_| !app.canvas_tools.gradient.ended_by_right_press()) { // A Space-held Hand opens the Hand's menu over the current tool. A momentary Zoom opens no menu of its own, but // with ⌘ held the right-click is still the one that lists the layers under the pointer (#307). let tool = match request.momentary { diff --git a/crates/ui-egui/src/tools/gradient_ui.rs b/crates/ui-egui/src/tools/gradient_ui.rs index 82577cbeeb0..42e59bb1653 100644 --- a/crates/ui-egui/src/tools/gradient_ui.rs +++ b/crates/ui-egui/src/tools/gradient_ui.rs @@ -34,6 +34,8 @@ mod editor_tests; #[cfg(test)] mod live_overlay_tests; #[cfg(test)] +mod right_click_during_drag_tests; +#[cfg(test)] mod tests; /// Id of the temporary layer previewing a new gradient while it is drawn. diff --git a/crates/ui-egui/src/tools/gradient_ui/right_click_during_drag_tests.rs b/crates/ui-egui/src/tools/gradient_ui/right_click_during_drag_tests.rs new file mode 100644 index 00000000000..8356f5ec48c --- /dev/null +++ b/crates/ui-egui/src/tools/gradient_ui/right_click_during_drag_tests.rs @@ -0,0 +1,107 @@ +//! #18703: a right press while a Gradient drag runs ends the drag there, as in the reference application. The gradient +//! (classic pixels, or a new Gradient Fill layer) is made at once from the press to the right press, as one History +//! step and with no menu; moving on and releasing the left button afterwards changes nothing. A drag still too short +//! makes nothing, and with a modifier held (not measured) the right press keeps today's behaviour. + +use egui::Modifiers; +use photocraft_doc::{Layer, LayerId}; +use serde_json::json; + +use crate::PhotocraftApp; +use crate::canvas::testing::{move_to, press, release, secondary_click}; +use crate::state::Tool; + +const A: [f64; 2] = [40.0, 60.0]; +const B: [f64; 2] = [160.0, 100.0]; +/// Where the left button goes after the right press, away from B. +const C: [f64; 2] = [180.0, 30.0]; + +/// A 200×150 document with the Gradient tool in classic or Gradient (fill layer) mode. +fn app(classic: bool) -> Box { + let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default()); + app.session.execute("file.new", json!({"width": 200, "height": 150})).unwrap(); + app.sync_views(); + app.ui.tool = Tool::Gradient; + app.ui.tool_options.gradient_classic = classic; + app.ui.extras.snap = false; + app +} + +fn steps(app: &PhotocraftApp) -> usize { + app.session.active().unwrap().history.past_len() +} + +fn newest(app: &PhotocraftApp) -> Option { + app.session.active().unwrap().history.entries().pop() +} + +/// The document's layers, top to bottom, with their ids left out: ids are numbered across the process, so two +/// documents made the same way get different ones. +fn layers(app: &PhotocraftApp) -> Vec { + let mut layers: Vec = app.session.active().unwrap().doc.layers.iter().cloned().collect(); + for layer in &mut layers { + layer.id = LayerId(0); + } + layers +} + +/// The left button down at A and dragged to B, still held. +fn drag_to_b(app: &mut PhotocraftApp) { + press(app, A, Modifiers::NONE); + move_to(app, [100.0, 80.0], Modifiers::NONE); + move_to(app, B, Modifiers::NONE); +} + +/// The layers and newest step of a plain drag from A released at B. +fn released_at_b(classic: bool) -> (Vec, Option) { + let mut app = app(classic); + drag_to_b(&mut app); + release(&mut app, B, Modifiers::NONE); + (layers(&app), newest(&app)) +} + +#[test] +fn a_right_press_mid_drag_makes_the_gradient_there_and_the_release_adds_nothing() { + for classic in [true, false] { + let mut app = app(classic); + let before = steps(&app); + drag_to_b(&mut app); + secondary_click(&mut app, B, Modifiers::NONE); + assert_eq!(steps(&app), before + 1, "the right press makes the gradient as one step (classic: {classic})"); + assert!(app.ui.canvas_tool_menu.is_none(), "no menu opens (classic: {classic})"); + let made = layers(&app); + let (reference, step) = released_at_b(classic); + assert_eq!(newest(&app), step, "the step a release at B makes (classic: {classic})"); + assert!(made == reference, "the gradient a release at B makes (classic: {classic})"); + + move_to(&mut app, C, Modifiers::NONE); + release(&mut app, C, Modifiers::NONE); + assert_eq!(steps(&app), before + 1, "the left release adds no step (classic: {classic})"); + assert!(layers(&app) == made, "nor moves the end point (classic: {classic})"); + } +} + +#[test] +fn a_right_press_before_the_drag_is_long_enough_makes_nothing() { + let mut app = app(true); + let (before, shown) = (steps(&app), layers(&app)); + press(&mut app, A, Modifiers::NONE); + secondary_click(&mut app, A, Modifiers::NONE); + move_to(&mut app, B, Modifiers::NONE); + release(&mut app, B, Modifiers::NONE); + assert_eq!(steps(&app), before, "no step"); + assert!(layers(&app) == shown, "the document is unchanged"); + assert!(app.ui.canvas_tool_menu.is_none(), "no menu opens"); +} + +/// Not measured with a modifier held: the drag goes on and its release makes the gradient, as before. +#[test] +fn with_a_modifier_held_the_right_press_leaves_the_drag_going() { + let mut app = app(true); + let before = steps(&app); + drag_to_b(&mut app); + secondary_click(&mut app, B, Modifiers::SHIFT); + assert_eq!(steps(&app), before, "the right press makes nothing yet"); + release(&mut app, B, Modifiers::NONE); + assert_eq!(steps(&app), before + 1, "the release makes the gradient"); +} diff --git a/crates/ui-egui/src/tools/gradient_ui/tool.rs b/crates/ui-egui/src/tools/gradient_ui/tool.rs index 4591dd5a685..a7f925d0f2b 100644 --- a/crates/ui-egui/src/tools/gradient_ui/tool.rs +++ b/crates/ui-egui/src/tools/gradient_ui/tool.rs @@ -32,12 +32,21 @@ pub(crate) struct GradientDraw { pub(crate) redraw: Option, /// Whether the last sample snapped to 45°. pub(crate) shift: bool, + /// Whether the drag has gone at least [`MIN_DRAG`] on screen, for a right press that ends it. + far: bool, + /// Whether this pass's right press ended the drag, so the canvas menu stays closed for it. + ended_by_right_press: bool, } impl GradientDraw { fn clear(&mut self) { *self = GradientDraw::default(); } + + /// Whether this pass's right press ended the drag: the canvas menu does not open for it. + pub(crate) fn ended_by_right_press(&self) -> bool { + self.ended_by_right_press + } } /// The Gradient tool for one pass. @@ -47,9 +56,28 @@ pub(crate) fn tool<'a>(scope: &'a ToolScope<'a>, state: &'a mut GradientDraw, _h /// Ends the drag when the host reports its end. The tool clears it at release and cancel itself; this covers a gesture /// the host ended without a call, so none is left behind. -pub(crate) fn drain(_app: &mut PhotocraftApp, state: &mut GradientDraw, response: &ToolHostResponse) { - if matches!(response.gesture, Some(GesturePhase::Commit | GesturePhase::Cancel)) { +/// +/// A right press during the drag reaches the app as the host's context request while the left press goes on. With no +/// modifier held it ends the drag there (#18703): the gradient is made at once, as a release would make it, and the +/// rest of the left press changes nothing. A drag still shorter than [`MIN_DRAG`] makes nothing, as a short release. +pub(crate) fn drain(app: &mut PhotocraftApp, state: &mut GradientDraw, response: &ToolHostResponse) { + state.ended_by_right_press = false; + if let Some(request) = response.context + && request.momentary.is_none() + && request.mods.is_none() + && let Some(from) = state.from + { + let (to, redraw, far) = (state.to, state.redraw, state.far); state.clear(); + state.ended_by_right_press = true; + if far { + commit(app, from, to, redraw); + } + } + if matches!(response.gesture, Some(GesturePhase::Commit | GesturePhase::Cancel)) { + let ended = state.ended_by_right_press; + state.clear(); + state.ended_by_right_press = ended; } } @@ -120,6 +148,10 @@ impl CanvasTool for GradientTool<'_> { let (Some(from), Some(at)) = (self.state.from, doc_at(cx, pointer.pos)) else { return }; self.state.shift = pointer.mods.shift; self.state.to = snapped(from, at, pointer.mods.shift); + if let Some(space) = cx.space() { + let screen = |p: [f32; 2]| space.view.to_screen(Point::new(f64::from(p[0]), f64::from(p[1]))); + self.state.far = screen(from).distance(screen(self.state.to)) >= MIN_DRAG; + } } fn release(&mut self, pointer: &ToolPointer, cx: &mut ToolContext<'_>) { From 0dc49c63748d943de902a0dccb3081d72e535d50 Mon Sep 17 00:00:00 2001 From: dholzric Date: Tue, 1 Dec 2026 18:20:28 -0600 Subject: [PATCH 50/81] Gradient: alert for a hidden or Lock All layer's mask in Gradient mode (#18637) paint.gradient with a pixel layer's mask as the target refuses a hidden layer and a Lock All layer with the reference's words, and a Gradient mode drag shows them in a one-button alert instead of the status bar. Co-Authored-By: Claude Opus 5.5 --- crates/engine-core/src/hidden_target.rs | 29 ++++++ .../gradient_mask_target_alerts_tests.rs | 93 +++++++++++++++++++ crates/ui-egui/src/tools/gradient_ui/tool.rs | 19 ++++ 3 files changed, 141 insertions(+) create mode 100644 crates/ui-egui/src/tools/gradient_mask_target_alerts_tests.rs diff --git a/crates/engine-core/src/hidden_target.rs b/crates/engine-core/src/hidden_target.rs index 5422f1e2e79..2097181273e 100644 --- a/crates/engine-core/src/hidden_target.rs +++ b/crates/engine-core/src/hidden_target.rs @@ -14,6 +14,11 @@ pub const HIDDEN: &str = "Could not complete your request because the target lay /// The Art History Brush's own alert text (#12638). pub const ART_HISTORY_HIDDEN: &str = "Could not use the art history brush because the target layer is hidden."; +/// The gradient's alerts for a pixel layer's mask it can't draw into (#18637): the layer is hidden, or it has Lock All +/// (its own or a group's). Measured with the Gradient tool in Gradient mode. +pub const GRADIENT_MASK_HIDDEN: &str = "Could not use the gradient tool because the target layer mask is hidden."; +pub const GRADIENT_MASK_LOCKED: &str = "Could not use the gradient tool because the layer is locked."; + /// The Color Replacement tool's alerts for a target it can't recolour (#17782): a pixel layer's /// mask, an adjustment layer (its mask or its content), a group's mask, an alpha channel or the /// Quick Mask. @@ -71,6 +76,11 @@ pub fn refusal(s: &Session, id: &str, params: &Value) -> Option<&'static str> { { return Some(why); } + if id == "paint.gradient" + && let Some(why) = gradient_mask_refusal(s, ¶ms) + { + return Some(why); + } if crate::channel_cmds::is_channel_target(¶ms) { return None; } @@ -85,6 +95,25 @@ pub fn refusal(s: &Session, id: &str, params: &Value) -> Option<&'static str> { (st.doc.layer(layer).is_some() && !shown(&st.doc, layer)).then_some(why) } +/// Why `paint.gradient` with `params` (its `target` filled in) can't draw into a pixel layer's mask (#18637): the layer is +/// hidden, else it has Lock All. A hidden or locked adjustment, fill or group layer's mask was not measured and keeps the +/// generic refusals. +fn gradient_mask_refusal(s: &Session, params: &Value) -> Option<&'static str> { + if crate::channel_cmds::target_of(params) != crate::channel_cmds::Target::Mask { + return None; + } + let st = s.active()?; + let id = crate::commands::layer_param(s, params).ok()?; + let layer = st.doc.layer(id).filter(|l| matches!(l.content, photocraft_doc::LayerContent::Raster(_)) && l.mask.is_some())?; + if !shown(&st.doc, layer.id) { + Some(GRADIENT_MASK_HIDDEN) + } else if st.doc.effective_locks(layer.id).all { + Some(GRADIENT_MASK_LOCKED) + } else { + None + } +} + /// Why `paint.colorReplacement` with `params` (its `target` filled in) can't recolour its target /// (#17782): the tool works on a pixel layer's full colour composite only, not on some of its /// colour channels (#17783). The target decides diff --git a/crates/ui-egui/src/tools/gradient_mask_target_alerts_tests.rs b/crates/ui-egui/src/tools/gradient_mask_target_alerts_tests.rs new file mode 100644 index 00000000000..863555bd700 --- /dev/null +++ b/crates/ui-egui/src/tools/gradient_mask_target_alerts_tests.rs @@ -0,0 +1,93 @@ +//! #18637: a Gradient mode drag into the layer mask of a hidden or Lock All pixel layer opens the reference +//! application's one-button alert on release, changes nothing and adds no History state. A disabled mask on a shown, +//! unlocked layer is still drawn into. CLI and automation callers get the same words from `paint.gradient`. + +use serde_json::json; + +use crate::PhotocraftApp; +use crate::canvas::{ToolEvent, tool_event}; +use crate::state::Tool; + +const HIDDEN: &str = "Could not use the gradient tool because the target layer mask is hidden."; +const LOCKED: &str = "Could not use the gradient tool because the layer is locked."; + +/// A new pixel layer with a Reveal All mask, the mask targeted, the Gradient tool in Gradient mode. +fn app() -> Box { + let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default()); + app.run("file.new", json!({"width": 200, "height": 120, "background": "white"})).unwrap(); + app.run("layer.new.layer", json!({"name": "LockMask"})).unwrap(); + app.run("layer.layerMask.revealAll", json!({})).unwrap(); + app.run("channel.target", json!({"channel": "mask"})).unwrap(); + app.ui.tool = Tool::Gradient; + app.ui.tool_options.gradient_classic = false; + app +} + +fn drag(app: &mut PhotocraftApp) { + let none = egui::Modifiers::NONE; + tool_event(app, ToolEvent::Down { x: 20.0, y: 60.0, pressure: 1.0 }, none); + tool_event(app, ToolEvent::Move { x: 100.0, y: 60.0, pressure: 1.0 }, none); + tool_event(app, ToolEvent::Move { x: 180.0, y: 60.0, pressure: 1.0 }, none); + tool_event(app, ToolEvent::Up { x: 180.0, y: 60.0 }, none); +} + +/// The messages of the open alerts. +fn alerts(app: &PhotocraftApp) -> Vec { + app.framework.dialogs.open_dialogs().iter().filter_map(|d| d.fields.as_ref()?.get("message")?.as_str().map(str::to_string)).collect() +} + +fn history(app: &PhotocraftApp) -> usize { + app.session.active().unwrap().history.past_len() +} + +fn mask_pixels(app: &PhotocraftApp) -> Vec { + let st = app.session.active().unwrap(); + let l = st.doc.layer(st.active_layer.unwrap()).unwrap(); + (0..200).step_by(20).flat_map(|x| l.mask.as_ref().unwrap().surface.pixel(x, 60)).collect() +} + +fn assert_refused(app: &mut PhotocraftApp, message: &str, case: &str) { + let (steps, before) = (history(app), mask_pixels(app)); + drag(app); + assert_eq!(alerts(app), [message.to_string()], "{case}: one alert with the reference text"); + assert_eq!(history(app), steps, "{case}: no History state"); + assert_eq!(mask_pixels(app), before, "{case}: the mask is unchanged"); + assert!(!app.ui.status_error || !app.ui.status.contains("Could not"), "{case}: not (also) on the status bar: {}", app.ui.status); +} + +#[test] +fn a_hidden_layers_mask_alerts() { + let mut app = app(); + app.run("layer.setProps", json!({"visible": false})).unwrap(); + assert_refused(&mut app, HIDDEN, "hidden layer"); +} + +#[test] +fn a_lock_all_layers_mask_alerts() { + let mut app = app(); + app.run("layer.setProps", json!({"locks": {"all": true}})).unwrap(); + assert_refused(&mut app, LOCKED, "Lock All"); +} + +#[test] +fn a_disabled_mask_on_a_shown_unlocked_layer_is_still_drawn_into() { + let mut app = app(); + app.run("layer.layerMask.enabled", json!({"enabled": false})).unwrap(); + let (steps, before) = (history(&app), mask_pixels(&app)); + drag(&mut app); + assert!(alerts(&app).is_empty(), "{:?}", alerts(&app)); + assert_eq!(history(&app), steps + 1); + assert_ne!(mask_pixels(&app), before, "the gradient is drawn into the mask"); +} + +/// Automation callers get the same words. +#[test] +fn the_engine_refuses_with_the_same_text() { + let gradient = json!({"from": [20.0, 60.0], "to": [180.0, 60.0], "target": "mask"}); + for (props, message) in [(json!({"visible": false}), HIDDEN), (json!({"locks": {"all": true}}), LOCKED)] { + let mut app = app(); + app.run("layer.setProps", props).unwrap(); + let err = app.session.execute("paint.gradient", gradient.clone()).unwrap_err().to_string(); + assert!(err.contains(message), "{err}"); + } +} diff --git a/crates/ui-egui/src/tools/gradient_ui/tool.rs b/crates/ui-egui/src/tools/gradient_ui/tool.rs index 4591dd5a685..ed737b43670 100644 --- a/crates/ui-egui/src/tools/gradient_ui/tool.rs +++ b/crates/ui-egui/src/tools/gradient_ui/tool.rs @@ -94,7 +94,22 @@ fn commit(app: &mut PhotocraftApp, from: [f32; 2], to: [f32; 2], redraw: Option< "from": from, "to": to, "style": o.gradient_style, "reverse": o.gradient_reverse, "dither": o.gradient_dither, "opacity": o.fill_opacity, "mode": mode, "target": target, }); + let status = (app.ui.status.clone(), app.ui.status_error); let result = app.run("paint.gradient", params); + // In Gradient mode a hidden or Lock All layer's mask is refused with the reference's alert (#18637); Classic keeps + // its press-time alerts and the status bar. + if !o.gradient_classic + && let Err(error) = &result + { + use photocraft_engine::hidden_target::{GRADIENT_MASK_HIDDEN, GRADIENT_MASK_LOCKED}; + let text = error.to_string(); + if let Some(message) = [GRADIENT_MASK_HIDDEN, GRADIENT_MASK_LOCKED].into_iter().find(|m| text.contains(m)) { + // The alert says it; `run` put it on the status bar too. + (app.ui.status, app.ui.status_error) = status; + let _ = crate::dialogs::alerts::alert(app, tl!(message).to_string()); + return; + } + } report(app, result); } @@ -172,3 +187,7 @@ impl CanvasTool for GradientTool<'_> { ToolPath::Command("the New Gradient Fill Layer command") } } + +#[cfg(test)] +#[path = "../gradient_mask_target_alerts_tests.rs"] +mod gradient_mask_target_alerts_tests; From bbade8815563f2700b22a31f2e55da19e1287094 Mon Sep 17 00:00:00 2001 From: yoriswind Date: Tue, 1 Dec 2026 16:54:05 -0800 Subject: [PATCH 51/81] Show a visible Background around artboards --- .../artboard_top_level_background_tests.rs | 58 +++++++++++++++++++ crates/ui-egui/src/canvas/artboard_ui.rs | 40 ++++++++----- 2 files changed, 82 insertions(+), 16 deletions(-) create mode 100644 crates/ui-egui/src/artboard_top_level_background_tests.rs diff --git a/crates/ui-egui/src/artboard_top_level_background_tests.rs b/crates/ui-egui/src/artboard_top_level_background_tests.rs new file mode 100644 index 00000000000..55fb0b121ab --- /dev/null +++ b/crates/ui-egui/src/artboard_top_level_background_tests.rs @@ -0,0 +1,58 @@ +//! Canvas surround for an artboard document with a converted Background (#17309). + +use craft::behavior::CanvasView; +use craft::behavior::kurbo::{Point, Rect as DocRect}; +use craft::ui::canvas::{PageFrame, Pasteboard}; +use egui::{Rect, pos2}; +use photocraft_doc::Document; +use photocraft_engine::Session; +use photocraft_geom::Rect as PixelRect; +use serde_json::json; + +use super::{doc_rect, uncovered}; + +fn in_pasteboard(doc: &Document, point: Point) -> bool { + let screen = Rect::from_min_max(pos2(-40.0, -40.0), pos2(340.0, 240.0)); + let view = CanvasView::new(screen, Point::new(150.0, 100.0), 1.0); + let pages: Vec<_> = doc.artboards().into_iter().map(|(_, _, board)| PageFrame::new(doc_rect(board.rect))).collect(); + let point = view.to_screen(point); + Pasteboard::quads(&view, &pages, &uncovered(doc)).iter().any(|quad| Rect::from_points(quad).contains(point)) +} + +#[test] +fn a_converted_background_shows_around_the_board_but_stops_at_the_canvas() { + let mut session = Session::new(); + session.execute("file.new", json!({"width": 300, "height": 200, "background": "transparent"})).unwrap(); + let layer = session.active().unwrap().active_layer.unwrap(); + session.execute("select.rect", json!({"x": 20, "y": 20, "width": 40, "height": 40})).unwrap(); + session.execute("edit.fill", json!({"color": "#c81e1e"})).unwrap(); + session.execute("select.deselect", json!({})).unwrap(); + let board = session.execute("layer.new.artboardFromLayers", json!({})).unwrap()["layer"].as_u64().unwrap(); + session.execute("layer.artboard.set", json!({"layer": board, "background": "white"})).unwrap(); + let around = Point::new(200.0, 150.0); + let on_board = Point::new(30.0, 30.0); + let outside = Point::new(320.0, 220.0); + let doc = &session.active().unwrap().doc; + assert!(doc.background().is_none()); + assert_eq!(doc.artboards()[0].2.rect, PixelRect::new(20, 20, 60, 60)); + assert!(in_pasteboard(doc, around)); + assert!(!in_pasteboard(doc, on_board)); + + session.tools.background = [0.0, 200.0 / 255.0, 0.0, 1.0]; + session.execute("layer.new.backgroundFromLayer", json!({"layer": layer.0})).unwrap(); + let doc = &session.active().unwrap().doc; + assert_eq!(doc.bounds(), PixelRect::new(0, 0, 300, 200)); + assert!(doc.is_background(layer)); + assert_eq!(uncovered(doc), [DocRect::new(0.0, 0.0, 300.0, 200.0)]); + assert!(!in_pasteboard(doc, around), "the actual pasteboard quads leave the Background open"); + assert!(!in_pasteboard(doc, on_board)); + assert!(in_pasteboard(doc, outside), "the real pasteboard beyond the canvas is still covered"); + + let green = photocraft_compose::render(doc, PixelRect::new(200, 150, 201, 151)).px[0]; + assert!(green[0] < 0.01 && green[1] > 0.5 && green[2] < 0.01 && green[3] > 0.99, "{green:?}"); + let white = photocraft_compose::render(doc, PixelRect::new(30, 30, 31, 31)).px[0]; + assert!(white.iter().all(|channel| *channel > 0.99), "the board remains white above it: {white:?}"); + + session.execute("layer.setProps", json!({"layer": layer.0, "visible": false})).unwrap(); + assert!(in_pasteboard(&session.active().unwrap().doc, around), "a hidden Background leaves the usual pasteboard"); +} diff --git a/crates/ui-egui/src/canvas/artboard_ui.rs b/crates/ui-egui/src/canvas/artboard_ui.rs index 1966f9c2b8b..1293319277b 100644 --- a/crates/ui-egui/src/canvas/artboard_ui.rs +++ b/crates/ui-egui/src/canvas/artboard_ui.rs @@ -33,21 +33,25 @@ pub(crate) fn pages(app: &PhotocraftApp, idx: usize) -> Arc<[PageFrame]> { }) } -/// Where visible layers outside the boards draw: Photoshop shows those over the pasteboard, so a -/// board added next to earlier work must not paint over it (#5712). The Background and any layer -/// that covers the whole canvas (or may draw anywhere, such as a fill layer) are backdrop, not -/// loose work: they keep the pasteboard. The framework subtracts these rects and the pages from -/// the pasteboard in every view. +/// Where visible layers outside the boards draw. Loose work stays over the pasteboard (#5712), +/// and a visible Background opens the whole canvas (#17309). Other canvas-wide layers, such as +/// fill layers, keep the pasteboard. The framework subtracts these rects and the pages from it. pub(crate) fn uncovered(doc: &Document) -> Vec { let canvas = doc.bounds(); - let background = doc.background().map(|b| b.id); - doc.layers - .iter() - .filter(|l| l.visible && !is_artboard(l) && Some(l.id) != background) - .filter_map(|l| photocraft_compose::composite_bounds(l, canvas)) - .filter(|b| !b.is_empty() && !b.contains_rect(&canvas)) - .map(doc_rect) - .collect() + let background = doc.background(); + let mut regions = Vec::new(); + if background.is_some_and(|layer| layer.visible) && !canvas.is_empty() { + regions.push(doc_rect(canvas)); + } + regions.extend( + doc.layers + .iter() + .filter(|l| l.visible && !is_artboard(l) && Some(l.id) != background.map(|layer| layer.id)) + .filter_map(|l| photocraft_compose::composite_bounds(l, canvas)) + .filter(|b| !b.is_empty() && !b.contains_rect(&canvas)) + .map(doc_rect), + ); + regions } fn is_artboard(l: &Layer) -> bool { @@ -149,12 +153,12 @@ mod tests { #[test] fn full_canvas_layers_keep_the_pasteboard() { - // The white Background (from `app()`) and a loose layer filling the whole canvas are - // backdrop: the pasteboard still shows outside the board. + // An ordinary layer filling the whole canvas still keeps the pasteboard. let (mut app, _) = app(); app.run("layer.new.artboard", json!({"rect": [0, 0, 40, 50]})).unwrap(); let mut doc = (*app.session.active().unwrap().doc).clone(); - assert!(doc.background().is_some()); + doc.background_mut().unwrap().locks.position = false; + assert!(doc.background().is_none()); let mut px = photocraft_doc::Layer::raster("Wash", doc.pixel_format()); px.surface_mut().unwrap().fill_rect(doc.bounds(), &[0.0, 0.0, 1.0, 1.0]); doc.layers.push(px); @@ -186,3 +190,7 @@ mod tests { assert_eq!(crate::comps_ui::target(&app), Some(b)); } } + +#[cfg(test)] +#[path = "../artboard_top_level_background_tests.rs"] +mod top_level_background_tests; From c9798be4029552bd694fa1417a0df4e9e2d1b2f4 Mon Sep 17 00:00:00 2001 From: yoriswind Date: Tue, 1 Dec 2026 17:00:43 -0800 Subject: [PATCH 52/81] Show the active Smart Object stack mode in its menu --- crates/ui-egui/src/menus/state.rs | 10 +- .../src/stack_mode_check_mark_tests.rs | 101 ++++++++++++++++++ 2 files changed, 110 insertions(+), 1 deletion(-) create mode 100644 crates/ui-egui/src/stack_mode_check_mark_tests.rs diff --git a/crates/ui-egui/src/menus/state.rs b/crates/ui-egui/src/menus/state.rs index eb0d9ebbe41..2e6d4f99535 100644 --- a/crates/ui-egui/src/menus/state.rs +++ b/crates/ui-egui/src/menus/state.rs @@ -9,6 +9,10 @@ use super::{DOCUMENT_ITEM, PhotocraftApp, Value}; #[path = "type_paste_lorem_greyed_tests.rs"] mod type_paste_lorem_greyed_tests; +#[cfg(test)] +#[path = "../stack_mode_check_mark_tests.rs"] +mod stack_mode_check_mark_tests; + /// Whether View › Zoom Out has stopped at a document-specific minimum. pub(crate) fn zoom_out_at_minimum(app: &PhotocraftApp) -> bool { let Some(document) = app.session.active() else { return false }; @@ -171,7 +175,7 @@ fn panel_of(id: &str) -> Option<&str> { /// Is a UI-level toggle currently on (for checkmarks)? pub(super) fn checked(app: &PhotocraftApp, id: &str) -> Option { - use photocraft_doc::{ColorMode, SampleType}; + use photocraft_doc::{ColorMode, LayerContent, SampleType, StackMode}; if let Some(c) = crate::view_cmds::checked(app, id) { return Some(c); } @@ -192,6 +196,10 @@ pub(super) fn checked(app: &PhotocraftApp, id: &str) -> Option { if id == "edit.transform.warp" { return Some(crate::transform_tool::warps_active_layer(app)); } + if let Some(mode) = id.strip_prefix("layer.smartObjects.stackMode.").and_then(StackMode::from_id) { + let active_layer = app.session.active().and_then(|d| d.doc.layer(d.active_layer?)); + return Some(matches!(active_layer.map(|layer| &layer.content), Some(LayerContent::Smart(smart)) if smart.stack_mode == Some(mode))); + } if id == "view.proofColors" || id == "view.gamutWarning" { let Some(d) = app.session.active() else { return Some(false) }; let pv = app.session.color().proof(d.doc.id); diff --git a/crates/ui-egui/src/stack_mode_check_mark_tests.rs b/crates/ui-egui/src/stack_mode_check_mark_tests.rs new file mode 100644 index 00000000000..3802e7aac2b --- /dev/null +++ b/crates/ui-egui/src/stack_mode_check_mark_tests.rs @@ -0,0 +1,101 @@ +//! The Stack Mode flyout reports the active Smart Object's stored mode in automation and AccessKit. + +use craft::window::policy::{CaptionFamily, Captions, Decision, Desktop, DesktopKind, Frame}; +use egui::accesskit::{Role, Toggled}; +use egui::{Event, Modifiers, PointerButton}; +use egui_kittest::kittest::{NodeT, Queryable}; +use photocraft_doc::StackMode; +use photocraft_engine::Session; +use photocraft_geom::Rect; +use serde_json::{Value, json}; + +use crate::control::{ControlRequest, Reply}; +use crate::shortcut_dispatch::tests::app_harness; +use crate::{PhotocraftApp, Services}; + +const PREFIX: &str = "layer.smartObjects.stackMode."; +const NONE: &str = "layer.smartObjects.stackMode.none"; + +fn smart_object() -> Session { + let mut session = Session::new(); + session.execute("file.new", json!({"width": 16, "height": 12})).unwrap(); + session.execute("layer.new.layer", json!({})).unwrap(); + session + .edit("paint", |doc, active| { + doc.layer_mut(active.unwrap()).unwrap().surface_mut().unwrap().fill_rect(Rect::new(2, 2, 10, 8), &[1.0, 0.0, 0.0, 1.0]); + Ok(()) + }) + .unwrap(); + session.execute("layer.smartObjects.convertToSmartObject", json!({})).unwrap(); + session +} + +fn assert_listed_mode(app: &mut PhotocraftApp, current: Option, enabled: bool) { + let (request, _reply) = ControlRequest::new("ui.menu.list", json!({})); + let ctx = app.ctx().clone(); + let Reply::Done(reply) = crate::control::handle(app, &ctx, &request) else { panic!("expected an immediate menu response") }; + let rows = reply["result"].as_array().expect("ui.menu.list returns rows"); + let find = |id: &str| rows.iter().find(|row| row["id"] == id).unwrap_or_else(|| panic!("missing row {id}")); + for mode in StackMode::ALL { + let row = find(&format!("{PREFIX}{}", mode.id())); + assert_eq!(row["checked"], Some(mode) == current, "{row}"); + assert_eq!(row["enabled"], enabled, "{row}"); + } + assert_eq!(find(NONE)["checked"], Value::Null, "None remains a plain command"); + assert_eq!(find(NONE)["enabled"], enabled); +} + +#[test] +fn menu_list_checks_only_the_active_smart_objects_current_mode() { + let mut app = PhotocraftApp::new(smart_object(), Services::default()); + let smart = app.session.active().unwrap().active_layer.unwrap(); + assert_listed_mode(&mut app, None, true); + + app.session.execute("layer.smartObjects.stackMode.median", json!({})).unwrap(); + assert_listed_mode(&mut app, Some(StackMode::Median), true); + + app.session.execute("layer.smartObjects.stackMode.standardDeviation", json!({})).unwrap(); + assert_listed_mode(&mut app, Some(StackMode::StandardDeviation), true); + + app.session.execute("layer.new.layer", json!({})).unwrap(); + assert_listed_mode(&mut app, None, false); + app.session.select_layer(smart).unwrap(); + assert_listed_mode(&mut app, Some(StackMode::StandardDeviation), true); + + app.session.execute(NONE, json!({})).unwrap(); + assert_listed_mode(&mut app, None, true); +} + +#[test] +fn the_stack_mode_flyout_exposes_its_check_in_the_accessibility_tree() { + let mut session = smart_object(); + session.execute("layer.smartObjects.stackMode.median", json!({})).unwrap(); + + // Use the in-window bar even on hosts that ordinarily use a native menu bar. + let ctx = egui::Context::default(); + let frame = Frame::Integrated(Captions { family: CaptionFamily::Windows, layout: craft::window::Layout::default() }); + let desktop = Desktop { kind: DesktopKind::Other, ssd: None, gtk_theme: None, icon_theme: None }; + PhotocraftApp::setup_window(&ctx, Default::default(), Decision { frame, overridden: None, desktop }, None); + let mut h = app_harness(PhotocraftApp::with_context(ctx, session, Services::default())); + + let at = h.get_by_role_and_label(Role::MenuItem, "Layer").rect().center(); + h.event(Event::PointerMoved(at)); + h.step(); + for pressed in [true, false] { + h.event(Event::PointerButton { pos: at, button: PointerButton::Primary, pressed, modifiers: Modifiers::NONE }); + h.step(); + } + h.run_steps(6); + for submenu in ["Smart Objects", "Stack Mode"] { + let at = h.get_by_role_and_label(Role::MenuItem, submenu).rect().center(); + h.event(Event::PointerMoved(at)); + h.run_steps(6); + } + + let median = h.get_by_role_and_label(Role::MenuItemCheckBox, "Median"); + assert_eq!(median.accesskit_node().toggled(), Some(Toggled::True)); + let mean = h.get_by_role_and_label(Role::MenuItemCheckBox, "Mean"); + assert_eq!(mean.accesskit_node().toggled(), Some(Toggled::False)); + let none = h.get_by_role_and_label(Role::MenuItem, "None"); + assert_eq!(none.accesskit_node().toggled(), None); +} From c90a85ec9a48af8dfb3229083ab6f6579aeea457 Mon Sep 17 00:00:00 2001 From: yoriswind Date: Tue, 1 Dec 2026 17:02:07 -0800 Subject: [PATCH 53/81] Keep unavailable blend modes disabled in New Layer --- crates/engine-core/src/new_layer.rs | 29 +++- crates/engine-core/src/session/execute.rs | 6 +- .../dialogs/new_layer_greyed_modes_tests.rs | 164 ++++++++++++++++++ crates/ui-egui/src/dialogs/new_layer_ui.rs | 18 +- 4 files changed, 212 insertions(+), 5 deletions(-) create mode 100644 crates/ui-egui/src/dialogs/new_layer_greyed_modes_tests.rs diff --git a/crates/engine-core/src/new_layer.rs b/crates/engine-core/src/new_layer.rs index 1d5bb067210..96e46d89d4f 100644 --- a/crates/engine-core/src/new_layer.rs +++ b/crates/engine-core/src/new_layer.rs @@ -1,7 +1,8 @@ //! Layer › New › Layer: Photoshop's New Layer options (name, Use Previous Layer to Create Clipping //! Mask, color label, mode, opacity, and Fill with neutral color), applied in one history step. -use photocraft_doc::{BlendMode, LabelColor, Layer}; +use photocraft_color::{ColorMode, SampleType}; +use photocraft_doc::{BlendMode, Document, LabelColor, Layer}; use serde_json::{Value, json}; use crate::{EngineError, Result, Session}; @@ -12,6 +13,31 @@ fn bad(msg: impl Into) -> EngineError { EngineError::BadParams { cmd: CMD.into(), msg: msg.into() } } +/// The New Layer dialog only greys modes measured in RGB 32-bit and Lab 8-bit. +pub fn greyed_modes(doc: &Document) -> &'static [BlendMode] { + match (doc.mode, doc.depth) { + (ColorMode::Rgb, SampleType::F32) | (ColorMode::Lab, SampleType::U8) => crate::pixel_fill::greyed_modes(doc.mode, doc.depth), + _ => &[], + } +} + +fn check_mode_available(s: &Session, mode: BlendMode) -> Result<()> { + if let Some(st) = s.active() + && greyed_modes(&st.doc).contains(&mode) + { + crate::pixel_fill::check_mode_available(CMD, &st.doc, mode)?; + } + Ok(()) +} + +/// Refuse an unavailable mode before dispatch can settle a floating selection or the UI can commit a transform. +pub(crate) fn precheck_mode(s: &Session, p: &Value) -> Result<()> { + if let Some(mode) = p.get("mode").and_then(Value::as_str).and_then(crate::commands::parse_blend) { + check_mode_available(s, mode)?; + } + Ok(()) +} + /// The color that leaves everything below unchanged in `mode` (Photoshop's "Fill with /// Multiply-neutral color (white)"), as RGB, and its name. `None` for modes that have none. pub fn neutral_color(mode: BlendMode) -> Option<([f32; 3], &'static str)> { @@ -40,6 +66,7 @@ pub(crate) struct NewLayer { /// panel's ⌘/Ctrl-click), joining the clip group it lands in. pub fn run(s: &mut Session, p: &Value) -> Result { let NewLayer { clip, mode, opacity, label, neutral, below, name } = parse(p)?; + check_mode_available(s, mode)?; let place = if below { crate::layer_place::Place::Below } else { crate::layer_place::Place::Auto }; let id = s.edit("New Layer", |doc, active| { let name = name.clone().unwrap_or_else(|| doc.next_layer_suggestion()); diff --git a/crates/engine-core/src/session/execute.rs b/crates/engine-core/src/session/execute.rs index f22f31e193f..9b675b80ed5 100644 --- a/crates/engine-core/src/session/execute.rs +++ b/crates/engine-core/src/session/execute.rs @@ -33,7 +33,11 @@ impl Session { /// `check_params` hooks. pub(crate) fn validate_params(&self, id: &str, spec: &crate::registry::CommandSpec, params: &Value) -> Result<()> { crate::param_check::check(spec, params)?; - crate::registry::hooks().check_params.iter().try_for_each(|check| check(self, id, params)) + crate::registry::hooks().check_params.iter().try_for_each(|check| check(self, id, params))?; + if id == "layer.new.layer" { + crate::new_layer::precheck_mode(self, params)?; + } + Ok(()) } /// Check a call without running it: the command exists, its params have the shape diff --git a/crates/ui-egui/src/dialogs/new_layer_greyed_modes_tests.rs b/crates/ui-egui/src/dialogs/new_layer_greyed_modes_tests.rs new file mode 100644 index 00000000000..c6f037b1a11 --- /dev/null +++ b/crates/ui-egui/src/dialogs/new_layer_greyed_modes_tests.rs @@ -0,0 +1,164 @@ +//! #17369: New Layer keeps every mode listed and refuses the unavailable modes in measured document types. + +use craft::ui::patterns::form_dialogs::ParamKind; +use egui::accesskit::Role; +use egui::{Event, Key, Modifiers, PointerButton, Pos2}; +use egui_kittest::Harness; +use egui_kittest::kittest::{NodeT, Queryable}; +use photocraft_doc::BlendMode; +use photocraft_engine::{Session, float_cmds}; +use serde_json::json; + +use super::{COMMAND, layer_mode_param}; +use crate::PhotocraftApp; + +type H = Harness<'static, Box>; + +const RGB_32: &[&str] = &[ + "Color Burn", + "Linear Burn", + "Screen", + "Color Dodge", + "Overlay", + "Soft Light", + "Hard Light", + "Vivid Light", + "Linear Light", + "Pin Light", + "Hard Mix", + "Exclusion", +]; +const LAB_8: &[&str] = &["Darken", "Color Burn", "Lighten", "Color Dodge", "Difference", "Exclusion", "Subtract", "Divide"]; + +fn document(mode: &str, depth: u32) -> Session { + let mut session = Session::new(); + session.execute("file.new", json!({"width": 16, "height": 16, "mode": mode, "depth": depth})).unwrap(); + session +} + +#[test] +fn the_mode_row_greys_only_the_measured_unavailable_modes() { + for (mode, depth, unavailable) in [ + ("rgb", 32, RGB_32), + ("lab", 8, LAB_8), + ("grayscale", 8, &[][..]), + ("lab", 16, &[][..]), + ("rgb", 8, &[][..]), + ("rgb", 16, &[][..]), + ("cmyk", 8, &[][..]), + ("bitmap", 1, &[][..]), + ] { + let session = document(mode, depth); + let row = layer_mode_param(&session.active().unwrap().doc); + let ParamKind::Blend { modes, .. } = &row.kind else { panic!("Mode is a blend row") }; + assert_eq!(modes.len(), BlendMode::LAYER_MODES.len(), "{mode} {depth}: every mode is listed"); + for blend in BlendMode::LAYER_MODES { + assert_eq!(row.option_enabled(blend.key()), !unavailable.contains(&blend.label()), "{mode} {depth}: {}", blend.label()); + } + } +} + +fn lab_dialog() -> H { + let mut app = PhotocraftApp::new(document("lab", 8), crate::Services::default()); + let ctx = app.ctx().clone(); + crate::menus::invoke(&mut app, &ctx, COMMAND, json!({})).unwrap(); + let mut h = Harness::builder() + .with_size(egui::vec2(1280.0, 800.0)) + .with_max_steps(64) + .with_context(ctx) + .build_ui_state(|ui, app: &mut Box| crate::dialogs::run(app, ui), app); + PhotocraftApp::setup_context(&h.ctx, Default::default()); + h.run_steps(4); + h +} + +fn pointer_click(h: &mut H, pos: Pos2) { + h.event(Event::PointerMoved(pos)); + for pressed in [true, false] { + h.event(Event::PointerButton { pos, button: PointerButton::Primary, pressed, modifiers: Modifiers::NONE }); + h.run_steps(3); + } +} + +fn open_mode_list(h: &mut H) { + let pos = h.get_by_role_and_label(Role::ComboBox, "Mode").rect().center(); + pointer_click(h, pos); +} + +fn assert_mode(h: &H, mode: &str) { + assert_eq!(h.get_by_role_and_label(Role::ComboBox, "Mode").accesskit_node().value().as_deref(), Some(mode)); +} + +#[test] +fn the_picker_skips_an_unavailable_mode_for_pointer_arrows_and_type_ahead() { + let mut h = lab_dialog(); + open_mode_list(&mut h); + let darken = h.get_by_role_and_label(Role::ListBoxOption, "Darken"); + assert!(darken.accesskit_node().is_disabled()); + let pos = darken.rect().center(); + pointer_click(&mut h, pos); + assert_mode(&h, "Normal"); + + let pos = h.get_by_role_and_label(Role::ListBoxOption, "Dissolve").rect().center(); + pointer_click(&mut h, pos); + assert_mode(&h, "Dissolve"); + open_mode_list(&mut h); + h.key_press(Key::ArrowDown); + h.run_steps(3); + assert_mode(&h, "Multiply"); + + h.event(Event::Text("Darken".into())); + h.run_steps(3); + assert_mode(&h, "Multiply"); + h.event(Event::Text("Hue".into())); + h.run_steps(3); + assert_mode(&h, "Hue"); +} + +#[test] +fn the_new_layer_command_refuses_greyed_modes_and_keeps_other_modes_available() { + for (mode, depth, unavailable, allowed) in [ + ("rgb", 32, RGB_32, BlendMode::LinearDodge), + ("lab", 8, LAB_8, BlendMode::Multiply), + ("lab", 16, &[][..], BlendMode::Darken), + ("grayscale", 8, &[][..], BlendMode::Hue), + ("rgb", 8, &[][..], BlendMode::Overlay), + ("rgb", 16, &[][..], BlendMode::Overlay), + ("cmyk", 8, &[][..], BlendMode::ColorBurn), + ] { + let mut session = document(mode, depth); + let snapshot = |session: &Session| { + let state = session.active().unwrap(); + (state.doc.layers.len(), state.active_layer, state.history.past_len(), state.doc.next_layer_suggestion()) + }; + let before = snapshot(&session); + for &blend in unavailable { + let params = json!({"mode": blend}); + let error = session.execute(COMMAND, params.clone()).unwrap_err().to_string(); + assert!(error.contains(blend) && error.contains("not available"), "{mode} {depth}: {error}"); + assert_eq!(session.precheck(COMMAND, ¶ms).unwrap_err().to_string(), error, "Free Transform precheck agrees"); + assert_eq!(snapshot(&session), before, "{mode} {depth}: refusing {blend} leaves the document unchanged"); + } + session.execute(COMMAND, json!({"mode": allowed.key()})).unwrap(); + let state = session.active().unwrap(); + assert_eq!(state.doc.layer(state.active_layer.unwrap()).unwrap().blend, allowed, "{mode} {depth}"); + } +} + +#[test] +fn a_refused_mode_leaves_a_pending_selection_floating() { + let mut session = document("rgb", 32); + session.execute(COMMAND, json!({})).unwrap(); + session.execute("edit.fill", json!({"color": "#ff0000"})).unwrap(); + session.execute("select.rect", json!({"x": 2, "y": 2, "width": 4, "height": 4})).unwrap(); + session.execute("select.float", json!({"dx": 4})).unwrap(); + let state = session.active().unwrap(); + let history = state.history.past_len(); + let offset = float_cmds::floating(state).unwrap().offset; + + let error = session.execute(COMMAND, json!({"mode": "Overlay", "fillNeutral": true})).unwrap_err().to_string(); + assert!(error.contains("Overlay") && error.contains("not available"), "{error}"); + let state = session.active().unwrap(); + assert_eq!(state.history.past_len(), history); + assert_eq!(float_cmds::floating(state).unwrap().offset, offset); +} diff --git a/crates/ui-egui/src/dialogs/new_layer_ui.rs b/crates/ui-egui/src/dialogs/new_layer_ui.rs index 1375f74fe39..d1b27592903 100644 --- a/crates/ui-egui/src/dialogs/new_layer_ui.rs +++ b/crates/ui-egui/src/dialogs/new_layer_ui.rs @@ -8,7 +8,7 @@ use craft::ui::dialog::DialogId; use craft::ui::patterns::form_dialogs::{DialogFields, Param, ParamDialog, ParamKind, ParamResult}; use craft::ui::runtime::env::{Label, UnitKind}; use craft::ui::value_drag::SliderScale; -use photocraft_doc::{BlendMode, LabelColor}; +use photocraft_doc::{BlendMode, Document, LabelColor}; use photocraft_engine::new_layer::neutral_color; use serde_json::{Value, json}; @@ -40,9 +40,17 @@ fn layer_opacity_param() -> Param { Param::new("opacity", tl!("Opacity:"), ParamKind::range(0.0, 100.0, 100.0, SliderScale::Linear)).decimals(0).unit(UnitKind::Percent).popup_slider() } +fn layer_mode_param(doc: &Document) -> Param { + super::blend_options::blend_param("mode", tl!("Mode:"), false, BlendMode::Normal) + .disabled_options(photocraft_engine::new_layer::greyed_modes(doc).iter().map(|mode| mode.key())) + .beside_next() +} + /// Open the dialog for the active document, with the name the layer would get. pub fn open(app: &mut PhotocraftApp) -> Result { - let name = app.session.active().ok_or("no document open")?.doc.next_layer_suggestion(); + let doc = &app.session.active().ok_or("no document open")?.doc; + let name = doc.next_layer_suggestion(); + let mode_row = layer_mode_param(doc); Ok(params::open_param(app, COMMAND, DialogFields::new(), Value::Null, move |fields: &mut DialogFields| { let neutral_modes: Vec = BlendMode::LAYER_MODES.into_iter().filter(|m| neutral_color(*m).is_some()).map(|mode| mode.key().to_string()).collect(); @@ -51,7 +59,7 @@ pub fn open(app: &mut PhotocraftApp) -> Result { Param::new("clipToPrevious", tl!("Use Previous Layer to Create Clipping Mask"), ParamKind::bool(false)), color_param(), // Opacity shares the Mode row, as in the reference application. - crate::dialogs::blend_options::blend_param("mode", tl!("Mode:"), false, BlendMode::Normal).beside_next(), + mode_row.clone(), layer_opacity_param(), Param::new("fillNeutral", neutral_label(mode(fields)), ParamKind::bool(false)).enabled_when_in("mode", neutral_modes), ]; @@ -134,6 +142,10 @@ pub(crate) mod testing { #[path = "new_layer_name_trim_tests.rs"] mod new_layer_name_trim_tests; +#[cfg(test)] +#[path = "new_layer_greyed_modes_tests.rs"] +mod new_layer_greyed_modes_tests; + #[cfg(test)] mod tests { use serde_json::json; From 5c3e942637da4a14fdb50ae27a4325f6f3307e11 Mon Sep 17 00:00:00 2001 From: yoriswind Date: Tue, 1 Dec 2026 17:07:57 -0800 Subject: [PATCH 54/81] Keep the pasteboard with ordinary full-canvas layers --- crates/ui-egui/src/canvas/artboard_ui.rs | 39 +++++++++++++++--------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/crates/ui-egui/src/canvas/artboard_ui.rs b/crates/ui-egui/src/canvas/artboard_ui.rs index 1293319277b..c4711aacb87 100644 --- a/crates/ui-egui/src/canvas/artboard_ui.rs +++ b/crates/ui-egui/src/canvas/artboard_ui.rs @@ -34,23 +34,30 @@ pub(crate) fn pages(app: &PhotocraftApp, idx: usize) -> Arc<[PageFrame]> { } /// Where visible layers outside the boards draw. Loose work stays over the pasteboard (#5712), -/// and a visible Background opens the whole canvas (#17309). Other canvas-wide layers, such as -/// fill layers, keep the pasteboard. The framework subtracts these rects and the pages from it. +/// and a visible Background opens the whole canvas (#17309) unless an ordinary canvas-wide +/// layer keeps the pasteboard. The framework subtracts these rects and the pages from it. pub(crate) fn uncovered(doc: &Document) -> Vec { let canvas = doc.bounds(); let background = doc.background(); + let background_id = background.map(|layer| layer.id); let mut regions = Vec::new(); - if background.is_some_and(|layer| layer.visible) && !canvas.is_empty() { + let mut has_canvas_wide_layer = false; + let layer_bounds = doc + .layers + .iter() + .filter(|l| l.visible && !is_artboard(l) && Some(l.id) != background_id) + .filter_map(|l| photocraft_compose::composite_bounds(l, canvas)) + .filter(|b| !b.is_empty()); + for bounds in layer_bounds { + if bounds.contains_rect(&canvas) { + has_canvas_wide_layer = true; + } else { + regions.push(doc_rect(bounds)); + } + } + if background.is_some_and(|layer| layer.visible) && !canvas.is_empty() && !has_canvas_wide_layer { regions.push(doc_rect(canvas)); } - regions.extend( - doc.layers - .iter() - .filter(|l| l.visible && !is_artboard(l) && Some(l.id) != background.map(|layer| layer.id)) - .filter_map(|l| photocraft_compose::composite_bounds(l, canvas)) - .filter(|b| !b.is_empty() && !b.contains_rect(&canvas)) - .map(doc_rect), - ); regions } @@ -153,16 +160,18 @@ mod tests { #[test] fn full_canvas_layers_keep_the_pasteboard() { - // An ordinary layer filling the whole canvas still keeps the pasteboard. + // An ordinary layer filling the whole canvas keeps the pasteboard, with or without a Background. let (mut app, _) = app(); app.run("layer.new.artboard", json!({"rect": [0, 0, 40, 50]})).unwrap(); let mut doc = (*app.session.active().unwrap().doc).clone(); - doc.background_mut().unwrap().locks.position = false; - assert!(doc.background().is_none()); + assert!(doc.background().unwrap().visible); let mut px = photocraft_doc::Layer::raster("Wash", doc.pixel_format()); px.surface_mut().unwrap().fill_rect(doc.bounds(), &[0.0, 0.0, 1.0, 1.0]); doc.layers.push(px); - assert!(uncovered(&doc).is_empty()); + assert!(uncovered(&doc).is_empty(), "a visible Background does not expose the full-canvas layer"); + doc.background_mut().unwrap().locks.position = false; + assert!(doc.background().is_none()); + assert!(uncovered(&doc).is_empty(), "the same rule applies without a Background"); } #[test] From ba1b81b8a09152995e93c600cbab6e815c4a54f4 Mon Sep 17 00:00:00 2001 From: yoriswind Date: Tue, 1 Dec 2026 17:18:28 -0800 Subject: [PATCH 55/81] Keep the pasteboard with unbounded ordinary layers --- crates/ui-egui/src/canvas/artboard_ui.rs | 26 +++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/canvas/artboard_ui.rs b/crates/ui-egui/src/canvas/artboard_ui.rs index c4711aacb87..68b076dd7d2 100644 --- a/crates/ui-egui/src/canvas/artboard_ui.rs +++ b/crates/ui-egui/src/canvas/artboard_ui.rs @@ -46,7 +46,7 @@ pub(crate) fn uncovered(doc: &Document) -> Vec { .layers .iter() .filter(|l| l.visible && !is_artboard(l) && Some(l.id) != background_id) - .filter_map(|l| photocraft_compose::composite_bounds(l, canvas)) + .map(|l| photocraft_compose::composite_bounds(l, canvas).unwrap_or(canvas)) .filter(|b| !b.is_empty()); for bounds in layer_bounds { if bounds.contains_rect(&canvas) { @@ -174,6 +174,30 @@ mod tests { assert!(uncovered(&doc).is_empty(), "the same rule applies without a Background"); } + #[test] + fn layers_with_an_opaque_default_keep_the_pasteboard() { + let (mut app, _) = app(); + app.run("layer.new.artboard", json!({"rect": [0, 0, 40, 50]})).unwrap(); + let mut doc = (*app.session.active().unwrap().doc).clone(); + let canvas = doc.bounds(); + assert!(doc.background().unwrap().visible); + + // An empty ordinary layer has bounded, empty content. It does not hide the Background. + let fmt = doc.pixel_format(); + doc.layers.push(Layer::raster("Empty", fmt)); + assert_eq!(uncovered(&doc), vec![doc_rect(canvas)]); + + // An opaque default can paint anywhere even without allocated raster tiles. + let mut wash = Layer::raster("Opaque wash", fmt); + *wash.surface_mut().unwrap() = photocraft_raster::Surface::with_default(fmt, &[0.0, 0.0, 1.0, 1.0]); + for layer in [wash.clone(), Layer::group("Wash group", vec![wash])] { + assert!(photocraft_compose::composite_bounds(&layer, canvas).is_none()); + let mut shown = doc.clone(); + shown.layers.push(layer); + assert!(uncovered(&shown).is_empty()); + } + } + #[test] fn pages_mark_only_the_active_layers_board() { let (mut app, _) = app(); From 8df7f7b374d2353ee70a7ccb384b803fcbc55da6 Mon Sep 17 00:00:00 2001 From: yoriswind Date: Tue, 1 Dec 2026 17:23:09 -0800 Subject: [PATCH 56/81] Toggle the Info panel and canvas Color Samplers --- crates/ui-egui/src/panels/info.rs | 7 + .../info_color_samplers_toggle_tests.rs | 155 ++++++++++++++++++ crates/ui-egui/src/panels/region_versions.rs | 6 +- crates/ui-egui/src/panels/registry.rs | 44 ++++- crates/ui-egui/src/tools/analysis/canvas.rs | 2 +- crates/ui-egui/src/tools/analysis/mod.rs | 4 + 6 files changed, 213 insertions(+), 5 deletions(-) create mode 100644 crates/ui-egui/src/panels/info_color_samplers_toggle_tests.rs diff --git a/crates/ui-egui/src/panels/info.rs b/crates/ui-egui/src/panels/info.rs index e02f88514ea..a5a53753573 100644 --- a/crates/ui-egui/src/panels/info.rs +++ b/crates/ui-egui/src/panels/info.rs @@ -171,6 +171,9 @@ fn channels(v: &Value) -> Option<[u8; N]> { /// unit and the same RGB/CMYK readout as the pointer (one composite pixel each). A point with no colour /// to read is left out. pub(crate) fn sampler_rows(app: &mut PhotocraftApp) -> Vec<(SamplerReadout, [Label; 2])> { + if app.ui.analysis.hide_color_samplers { + return Vec::new(); + } let readouts = sampler_readouts(app); let Some(st) = app.session.active() else { return Vec::new() }; let (size, dpi) = (st.doc.size, f64::from(st.doc.resolution_dpi)); @@ -309,3 +312,7 @@ mod info_ruler_tests; #[cfg(test)] #[path = "info_unit_format_tests.rs"] mod info_unit_format_tests; + +#[cfg(test)] +#[path = "info_color_samplers_toggle_tests.rs"] +mod info_color_samplers_toggle_tests; diff --git a/crates/ui-egui/src/panels/info_color_samplers_toggle_tests.rs b/crates/ui-egui/src/panels/info_color_samplers_toggle_tests.rs new file mode 100644 index 00000000000..99a98141434 --- /dev/null +++ b/crates/ui-egui/src/panels/info_color_samplers_toggle_tests.rs @@ -0,0 +1,155 @@ +use craft::ui::menu::PanelRow; +use craft::ui::runtime::commands::{CommandRef, CommandState}; +use egui::accesskit::{Role, Toggled}; +use egui::{Event, Modifiers, PointerButton, Pos2, Shape}; +use egui_kittest::Harness; +use egui_kittest::kittest::{NodeT, Queryable}; +use serde_json::json; + +use super::sampler_rows; +use crate::canvas::testing::to_screen; +use crate::input::shortcut_dispatch::tests::app_harness; +use crate::panels::{panel_docking, region_versions, registry}; +use crate::{PhotocraftApp, Services}; + +const MENU_LABEL: &str = "Color Samplers"; +const POINT: [f64; 2] = [25.5, 18.5]; +type AppHarness = Harness<'static, Box>; + +fn app() -> Box { + PhotocraftApp::new(photocraft_engine::Session::new(), Services::default()) +} + +fn add_document(app: &mut PhotocraftApp) { + app.run("file.new", json!({"width": 64, "height": 48, "background": "white"})).unwrap(); +} + +fn add_sampler(app: &mut PhotocraftApp) { + app.run("view.colorSamplers.add", json!({"x": POINT[0], "y": POINT[1]})).unwrap(); +} + +fn command(app: &PhotocraftApp) -> CommandRef { + let info = registry::entry("info").unwrap(); + let rows = (info.rows)(app); + let [PanelRow::Command(command)] = rows.as_slice() else { panic!("one Info command") }; + command.clone() +} + +fn menu_state(app: &PhotocraftApp) -> CommandState { + let info = registry::entry("info").unwrap(); + let command = command(app); + (info.states)(app, info.id).iter().find(|(cmd, _)| cmd == &command).unwrap().1.clone() +} + +fn fire(app: &mut PhotocraftApp) { + let ctx = app.ctx().clone(); + let command = command(app); + assert!(registry::run_fired(app, &ctx, &command)); +} + +#[test] +fn color_samplers_toggle_is_session_wide_and_requires_points_in_the_active_document() { + let mut app = app(); + let state = |enabled, checked| CommandState::new().enabled(enabled).checked(checked); + assert_eq!(menu_state(&app), state(false, true)); + fire(&mut app); + add_document(&mut app); + assert_eq!(menu_state(&app), state(false, true)); + + add_sampler(&mut app); + assert_eq!(menu_state(&app), state(true, true)); + assert_eq!(sampler_rows(&mut app).len(), 1); + let info_version = region_versions::panel(&app, "info"); + let canvas_version = region_versions::canvas(&app); + let active = app.session.active().unwrap(); + let (revision, history) = (active.revision, active.history.past_len()); + fire(&mut app); + assert_ne!(region_versions::panel(&app, "info"), info_version, "the Info body is invalidated"); + assert_ne!(region_versions::canvas(&app), canvas_version, "the canvas body is invalidated"); + let active = app.session.active().unwrap(); + assert_eq!((active.revision, active.history.past_len()), (revision, history)); + assert_eq!(menu_state(&app), state(true, false)); + assert!(sampler_rows(&mut app).is_empty()); + assert_eq!(crate::analysis::sampler_at(&app, POINT), Some(0), "the sampler tools can still find the stored point"); + + add_document(&mut app); + assert_eq!(menu_state(&app), state(false, false)); + fire(&mut app); + add_sampler(&mut app); + assert_eq!(menu_state(&app), state(true, false)); + assert!(sampler_rows(&mut app).is_empty()); + fire(&mut app); + assert_eq!(sampler_rows(&mut app).len(), 1); + assert!(app.session.set_active(0)); + assert_eq!(menu_state(&app), state(true, true)); + assert_eq!(sampler_rows(&mut app).len(), 1); +} + +fn open_menu(h: &mut AppHarness) { + let at = h.get_by_role_and_label(Role::Tab, "Info").rect().center(); + h.event(Event::PointerMoved(at)); + h.run_steps(1); + for pressed in [true, false] { + h.event(Event::PointerButton { pos: at, button: PointerButton::Secondary, pressed, modifiers: Modifiers::NONE }); + h.run_steps(2); + } +} + +fn sampler_mark(shape: &Shape, at: Pos2) -> bool { + match shape { + Shape::Circle(circle) => circle.center.distance(at) < 0.5 && circle.stroke.width > 0.0, + Shape::Vec(shapes) => shapes.iter().any(|shape| sampler_mark(shape, at)), + Shape::PaintChunk(shapes) => shapes.iter().any(|shape| sampler_mark(&shape.shape, at)), + _ => false, + } +} + +fn shows_marker(h: &AppHarness) -> bool { + let at = to_screen(h.state(), POINT); + h.output().shapes.iter().any(|clipped| clipped.clip_rect.contains(at) && sampler_mark(&clipped.shape, at)) +} + +#[test] +fn the_info_flyout_hides_and_restores_the_readout_and_canvas_marker_without_history() { + let _language = crate::i18n::language_scope(crate::i18n::Lang::EN); + let mut app = app(); + add_document(&mut app); + add_sampler(&mut app); + for panel in ["navigator", "histogram", "info"] { + panel_docking::show_panel(&mut app, panel, Some(true)).unwrap(); + } + app.run("window.panel.iconic", json!({"panel": "info", "iconic": false})).unwrap(); + panel_docking::show_panel(&mut app, "info", Some(true)).unwrap(); + let mut h = app_harness(app); + + assert!(shows_marker(&h)); + assert_eq!(sampler_rows(h.state_mut()).len(), 1); + open_menu(&mut h); + let row = h.get_by_role_and_label(Role::MenuItemCheckBox, MENU_LABEL); + assert_eq!(row.accesskit_node().toggled(), Some(Toggled::True)); + assert!(!row.accesskit_node().is_disabled()); + let stored = h.state_mut().run("view.colorSamplers.list", json!({})).unwrap(); + let active = h.state().session.active().unwrap(); + let (revision, history) = (active.revision, active.history.past_len()); + h.get_by_role_and_label(Role::MenuItemCheckBox, MENU_LABEL).click(); + h.run_steps(4); + + assert!(!shows_marker(&h)); + assert!(sampler_rows(h.state_mut()).is_empty()); + assert_eq!(h.state_mut().run("view.colorSamplers.list", json!({})).unwrap(), stored); + let active = h.state().session.active().unwrap(); + assert_eq!((active.revision, active.history.past_len()), (revision, history)); + + open_menu(&mut h); + let row = h.get_by_role_and_label(Role::MenuItemCheckBox, MENU_LABEL); + assert_eq!(row.accesskit_node().toggled(), Some(Toggled::False)); + row.click(); + h.run_steps(4); + assert!(shows_marker(&h)); + assert_eq!(sampler_rows(h.state_mut()).len(), 1); + + h.state_mut().ui.view.extras = false; + h.run_steps(4); + assert!(!shows_marker(&h)); + assert_eq!(sampler_rows(h.state_mut()).len(), 1, "View > Extras only hides the canvas marker"); +} diff --git a/crates/ui-egui/src/panels/region_versions.rs b/crates/ui-egui/src/panels/region_versions.rs index a426a679912..18a6b21f20e 100644 --- a/crates/ui-egui/src/panels/region_versions.rs +++ b/crates/ui-egui/src/panels/region_versions.rs @@ -125,7 +125,9 @@ pub(crate) fn panel(app: &PhotocraftApp, id: &str) -> u64 { } "info" => { let crop = crate::crop_ui::info_size(app).map(|size| size.map(f64::to_bits)); - version(app, (app.hover_doc.map(|at| at.map(f64::to_bits)), app.current_zoom().to_bits(), app.ui.tool_options.eyedropper.size.pixels(), crop)) + let pointer = app.hover_doc.map(|at| at.map(f64::to_bits)); + let sample = (app.current_zoom().to_bits(), app.ui.tool_options.eyedropper.size.pixels()); + version(app, (pointer, sample, crop, app.ui.analysis.hide_color_samplers)) } "cloneSource" => version(app, app.ui.presets_ui.clone_cursor.map(|(document, at)| (document, at.map(f64::to_bits)))), "modifierKeys" => version(app, app.ui.shell.latched), @@ -296,7 +298,7 @@ pub(crate) fn canvas(app: &PhotocraftApp) -> u64 { &ui.selected_guide, &ui.direct_selection, &ui.hidden_work_path, - (&ui.analysis, &ui.slices, &ui.frame_tool, &ui.artboard_tool), + (&ui.analysis, ui.analysis.hide_color_samplers, &ui.slices, &ui.frame_tool, &ui.artboard_tool), )); let sessions = (crate::transform_tool::bar_key(app), crate::puppet_ui::bar_key(app), crate::perspective_ui::bar_key(app), crate::crop_ui::bar::bar_key(app)); diff --git a/crates/ui-egui/src/panels/registry.rs b/crates/ui-egui/src/panels/registry.rs index df2ef2b3443..26c1bd1a56d 100644 --- a/crates/ui-egui/src/panels/registry.rs +++ b/crates/ui-egui/src/panels/registry.rs @@ -12,7 +12,7 @@ use craft::ui::contract::{Scroll, ShowContainer as _}; use craft::ui::docking::DockHeights; use craft::ui::layout_components::Stack; use craft::ui::menu::PanelRow; -use craft::ui::runtime::commands::{CommandRef, CommandSet as _}; +use craft::ui::runtime::commands::{CommandRef, CommandSet as _, CommandState}; use egui::{Rect, pos2, vec2}; use std::sync::Arc; @@ -145,7 +145,12 @@ pub(crate) static PANELS: &[PanelEntry] = &[ run: super::histogram_panel::run_fired, ..panel("histogram", || tl!("Histogram").to_string(), "chart_line", LEAST, |app, ui| scrolled(app, ui, super::histogram_panel::show)) }, - panel("info", || tl!("Info").to_string(), "info", LEAST, |app, ui| scrolled(app, ui, super::info::info_panel)), + PanelEntry { + rows: |_| vec![PanelRow::Command(CommandRef::from(InfoCommand::ColorSamplers))], + states: info_source_states, + run: info_run, + ..panel("info", || tl!("Info").to_string(), "info", LEAST, |app, ui| scrolled(app, ui, super::info::info_panel)) + }, PanelEntry { heights: Some(HISTORY_HEIGHTS), rows: super::history_menu_ui::panel_rows, @@ -226,6 +231,41 @@ pub(crate) static PANELS: &[PanelEntry] = &[ floating("notes", || tl!("Notes").to_string(), "square_plus", [260.0, 300.0], |app, ui| scrolled(app, ui, crate::tools::analysis::notes_panel::body)), ]; +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, craft::ui::contract::CommandSet)] +#[command(prefix = "info")] +enum InfoCommand { + #[command(label = "Color Samplers")] + ColorSamplers, +} + +fn has_color_samplers(app: &PhotocraftApp) -> bool { + app.session.active().is_some_and(|doc| !doc.color_samplers.is_empty()) +} + +#[derive(craft::ui::contract::MemoProps)] +struct InfoMenuFacts { + available: bool, + visible: bool, +} + +fn info_source_states(app: &PhotocraftApp, name: &'static str) -> Arc { + let facts = InfoMenuFacts { available: has_color_samplers(app), visible: !app.ui.analysis.hide_color_samplers }; + derived_states(app, name, &facts, || { + vec![(CommandRef::from(InfoCommand::ColorSamplers), CommandState::new().enabled(facts.available).checked(facts.visible))] + }) +} + +fn info_run(app: &mut PhotocraftApp, ctx: &egui::Context, command: &CommandRef) -> bool { + if InfoCommand::from_ref(command) != Some(InfoCommand::ColorSamplers) { + return false; + } + if has_color_samplers(app) { + app.ui.analysis.hide_color_samplers = !app.ui.analysis.hide_color_samplers; + ctx.request_repaint(); + } + true +} + /// The Color panel menu's states, from the panel's own state. fn color_states(app: &PhotocraftApp) -> SourceStates { let state = &app.ui.color_panel.panel; diff --git a/crates/ui-egui/src/tools/analysis/canvas.rs b/crates/ui-egui/src/tools/analysis/canvas.rs index 1c9953d725a..1cd42e8dfaa 100644 --- a/crates/ui-egui/src/tools/analysis/canvas.rs +++ b/crates/ui-egui/src/tools/analysis/canvas.rs @@ -224,7 +224,7 @@ pub(crate) fn body(app: &mut PhotocraftApp, ui: &mut egui::Ui, rect: Rect) { let view = &app.ui.view; let (show_count, show_notes, extras) = (view.shows(view.show.count), view.shows(view.show.notes), view.extras); let line = ruler_line(app).filter(|_| extras); - let samplers = samplers_of(app).map(|(s, _)| s).filter(|_| extras); + let samplers = if extras && !app.ui.analysis.hide_color_samplers { samplers_of(app).map(|(samplers, _)| samplers) } else { None }; let groups: Vec = if show_count { app.session.active().map_or_else(Vec::new, |d| { d.doc diff --git a/crates/ui-egui/src/tools/analysis/mod.rs b/crates/ui-egui/src/tools/analysis/mod.rs index d1cbd264ce9..5f15ad18e4c 100644 --- a/crates/ui-egui/src/tools/analysis/mod.rs +++ b/crates/ui-egui/src/tools/analysis/mod.rs @@ -96,6 +96,9 @@ pub struct AnalysisUi { pub note_color: [f32; 3], /// Ruler options bar: show values in the measurement scale's units. pub use_measurement_scale: bool, + /// The Info panel and canvas hide sampler readouts and marks for this app session. + #[serde(skip)] + pub(crate) hide_color_samplers: bool, } impl Default for AnalysisUi { @@ -107,6 +110,7 @@ impl Default for AnalysisUi { note_author: String::new(), note_color: photocraft_engine::notes_cmds::DEFAULT_NOTE_COLOR, use_measurement_scale: false, + hide_color_samplers: false, } } } From 15d4349d1dffef7c21ac82b969c594e8cc9f7442 Mon Sep 17 00:00:00 2001 From: yoriswind Date: Tue, 1 Dec 2026 17:33:37 -0800 Subject: [PATCH 57/81] Separate New Layer picker type-ahead attempts in the fixture --- crates/ui-egui/src/dialogs/new_layer_greyed_modes_tests.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crates/ui-egui/src/dialogs/new_layer_greyed_modes_tests.rs b/crates/ui-egui/src/dialogs/new_layer_greyed_modes_tests.rs index c6f037b1a11..8d05aabdb4a 100644 --- a/crates/ui-egui/src/dialogs/new_layer_greyed_modes_tests.rs +++ b/crates/ui-egui/src/dialogs/new_layer_greyed_modes_tests.rs @@ -110,6 +110,9 @@ fn the_picker_skips_an_unavailable_mode_for_pointer_arrows_and_type_ahead() { h.event(Event::Text("Darken".into())); h.run_steps(3); assert_mode(&h, "Multiply"); + // Start a second search after the picker's one-second type-ahead buffer expires. + let next_search = h.ctx.input(|input| input.time) + 1.25; + h.input_mut().time = Some(next_search); h.event(Event::Text("Hue".into())); h.run_steps(3); assert_mode(&h, "Hue"); From a7e7be0da268f68a737231d58fc445ae54a3ae62 Mon Sep 17 00:00:00 2001 From: yoriswind Date: Tue, 1 Dec 2026 17:35:04 -0800 Subject: [PATCH 58/81] Show Quick Mask states on the toolbar --- ATTRIBUTION.md | 1 + assets/icons/quick-mask-masked-areas.svg | 3 + assets/icons/quick-mask-off.svg | 4 ++ assets/icons/quick-mask-selected-areas.svg | 4 ++ crates/ui-egui/src/icon_data.rs | 3 + crates/ui-egui/src/input/shortcut_dispatch.rs | 2 +- crates/ui-egui/src/panels/region_versions.rs | 7 +- crates/ui-egui/src/panels/toolbar.rs | 41 +++++++++-- .../panels/toolbar_quick_mask_icon_tests.rs | 69 +++++++++++++++++++ 9 files changed, 124 insertions(+), 10 deletions(-) create mode 100644 assets/icons/quick-mask-masked-areas.svg create mode 100644 assets/icons/quick-mask-off.svg create mode 100644 assets/icons/quick-mask-selected-areas.svg create mode 100644 crates/ui-egui/src/panels/toolbar_quick_mask_icon_tests.rs diff --git a/ATTRIBUTION.md b/ATTRIBUTION.md index 6b028524c1f..0e6b69b3f0a 100644 --- a/ATTRIBUTION.md +++ b/ATTRIBUTION.md @@ -19,6 +19,7 @@ next to them. | `assets/icons/vector-shape.svg` | Vector path shape-layer glyph with four anchor points | @superplay2021 | Original work for PhotoCraft | MIT OR Apache-2.0 | | `assets/icons/spirit-level.svg` | Straighten tool glyph: a spirit level with its vial and bubble under a dotted arc | PhotoCraft contributors | Original work | MIT OR Apache-2.0 | | `assets/icons/type-vertical.svg` | Vertical Type tool glyph: Lucide `type`'s T, drawn narrower to make room for a downward arrow of our own at its left | Lucide Icons and Contributors; arrow by PhotoCraft contributors | Derived from `icons/type.svg` | ISC, [`assets/icons/LICENSE-lucide.txt`](assets/icons/LICENSE-lucide.txt) | +| `assets/icons/quick-mask-{off,masked-areas,selected-areas}.svg` | Quick Mask toolbar glyphs showing the inactive mode and the two overlay meanings | PhotoCraft contributors | Original work | MIT OR Apache-2.0 | | `assets/icons/path-op-{new-layer,combine,subtract,intersect,exclude,merge}.svg` | Path Operations glyphs (Pen options bar): a single square for New Layer, and two overlapping squares showing the area each operation keeps (union, back minus front, overlap, everything but the overlap, the merged outline), drawn on Lucide's 24 px grid and stroke | PhotoCraft contributors | Original work | MIT OR Apache-2.0 | | `assets/icons/arrange-{tile-all-vertically,tile-all-horizontally,two-up-horizontal,two-up-vertical,three-up-horizontal,three-up-vertical,three-up-stacked,four-up,six-up,consolidate-all-to-tabs}.svg` | Window › Arrange layout glyphs: a window outline split into the panes each entry lays out (columns, rows, the n-up splits, and one window with a tab row for Consolidate All to Tabs), drawn on Lucide's 24 px grid and stroke | PhotoCraft contributors | Original work | MIT OR Apache-2.0 | | `assets/icons/history-brush.svg` | History Brush tool glyph: Lucide `brush` plus counter-clockwise history rewind arrow | Lucide Icons and Contributors; arrow by PhotoCraft contributors | Derived from `icons/brush.svg` | ISC, [`assets/icons/LICENSE-lucide.txt`](assets/icons/LICENSE-lucide.txt) | diff --git a/assets/icons/quick-mask-masked-areas.svg b/assets/icons/quick-mask-masked-areas.svg new file mode 100644 index 00000000000..5890c17a665 --- /dev/null +++ b/assets/icons/quick-mask-masked-areas.svg @@ -0,0 +1,3 @@ + + + diff --git a/assets/icons/quick-mask-off.svg b/assets/icons/quick-mask-off.svg new file mode 100644 index 00000000000..b65c0038596 --- /dev/null +++ b/assets/icons/quick-mask-off.svg @@ -0,0 +1,4 @@ + + + + diff --git a/assets/icons/quick-mask-selected-areas.svg b/assets/icons/quick-mask-selected-areas.svg new file mode 100644 index 00000000000..bc28117be10 --- /dev/null +++ b/assets/icons/quick-mask-selected-areas.svg @@ -0,0 +1,4 @@ + + + + diff --git a/crates/ui-egui/src/icon_data.rs b/crates/ui-egui/src/icon_data.rs index f630565fb1e..6e791460ba0 100644 --- a/crates/ui-egui/src/icon_data.rs +++ b/crates/ui-egui/src/icon_data.rs @@ -36,6 +36,9 @@ pub static ICONS: &[(&str, &[u8])] = &[ ("path-op-new-layer", include_bytes!("../../../assets/icons/path-op-new-layer.svg")), ("path-op-subtract", include_bytes!("../../../assets/icons/path-op-subtract.svg")), ("pipette", include_bytes!("../../../assets/icons/pipette.svg")), + ("quick-mask-masked-areas", include_bytes!("../../../assets/icons/quick-mask-masked-areas.svg")), + ("quick-mask-off", include_bytes!("../../../assets/icons/quick-mask-off.svg")), + ("quick-mask-selected-areas", include_bytes!("../../../assets/icons/quick-mask-selected-areas.svg")), ("rectangle-horizontal", include_bytes!("../../../assets/icons/rectangle-horizontal.svg")), ("rectangle-vertical", include_bytes!("../../../assets/icons/rectangle-vertical.svg")), ("redo-2", include_bytes!("../../../assets/icons/redo-2.svg")), diff --git a/crates/ui-egui/src/input/shortcut_dispatch.rs b/crates/ui-egui/src/input/shortcut_dispatch.rs index 351b3166d20..af137c2c5dd 100644 --- a/crates/ui-egui/src/input/shortcut_dispatch.rs +++ b/crates/ui-egui/src/input/shortcut_dispatch.rs @@ -342,7 +342,7 @@ pub(crate) fn command_rows(app: &PhotocraftApp) -> Vec { def.has_alt_variant = true; } } - // Edit in Quick Mask Mode is a button in the tool rail's footer, which shows its command's icon. + // Edit in Quick Mask Mode has a generic command icon. The tool rail shows the active document's mask state. if let Some(&at) = index.get(crate::panels::QUICK_MASK) { rows[at].icon = Some("square-dashed".into()); } diff --git a/crates/ui-egui/src/panels/region_versions.rs b/crates/ui-egui/src/panels/region_versions.rs index a426a679912..62ba0f402f6 100644 --- a/crates/ui-egui/src/panels/region_versions.rs +++ b/crates/ui-egui/src/panels/region_versions.rs @@ -71,11 +71,10 @@ pub(crate) fn status_bar(app: &PhotocraftApp) -> u64 { version(app, (item, zoom, message, super::chrome_ui::render_path_label(app), progress)) } -/// The version of the toolbar's footer: the colour chips' two colours, whether the active document is in Quick Mask and -/// the screen mode the Screen Mode button shows. A shortcut changed in the keymap reaches the buttons' tooltips through -/// the framework, which tracks the keymap a view reads. +/// The version of the toolbar's footer: the colour chips, the active document's Quick Mask state and the screen mode. +/// A shortcut changed in the keymap reaches the buttons' tooltips through the framework, which tracks the keymap a view reads. pub(crate) fn toolbar_footer(app: &PhotocraftApp) -> u64 { - let quick_mask = app.session.active().is_some_and(|st| st.doc.quick_mask.is_some()); + let quick_mask = super::toolbar::QuickMaskState::of(app); version(app, (colours(app), quick_mask, app.ui.view.screen_mode)) } diff --git a/crates/ui-egui/src/panels/toolbar.rs b/crates/ui-egui/src/panels/toolbar.rs index e3cf32a56cf..88cd4519597 100644 --- a/crates/ui-egui/src/panels/toolbar.rs +++ b/crates/ui-egui/src/panels/toolbar.rs @@ -1,15 +1,18 @@ use super::{PhotocraftApp, Tool, json}; +use craft::behavior::IconId; use craft::behavior::overlay::Side; use craft::color_ui::ui::{PairWell, SwatchPair, Well}; use craft::ui::contract::{Bind, Gap, MemoProps, MemoView, Props as _, Show as _, ShowContainer as _, Tracked, clicked}; use craft::ui::layout::RowAlign; use craft::ui::layout_components::{Row, Stack}; +use craft::ui::primitives::IconSpec; use craft::ui::rails::{ DrawerGroup, FlyoutButton, LastUsed, RailFooter, RailTool, ToolRail, ToolSlot, ToolbarDrawer, ToolbarEdit, apply_toolbar_edit, visible_slots, }; use craft::ui::runtime::commands::CommandRef; use craft::ui::runtime::env::Label; use craft::ui::shell::ScreenModeButton; +use photocraft_doc::ColorIndicates; use photocraft_engine::prefs::ToolbarCustomization; use super::tool_commands; @@ -21,6 +24,9 @@ mod toolbar_docking_tests; #[path = "toolbar_flyout_mark_tests.rs"] mod toolbar_flyout_mark_tests; #[cfg(test)] +#[path = "toolbar_quick_mask_icon_tests.rs"] +mod toolbar_quick_mask_icon_tests; +#[cfg(test)] #[path = "toolbar_tab_reveal_tests.rs"] mod toolbar_tab_reveal_tests; @@ -171,12 +177,37 @@ pub(crate) fn run_quick_mask(app: &mut PhotocraftApp, params: serde_json::Value) Ok(reply) } -/// Quick Mask as a rail button, the size of the tool buttons: a click runs Edit in Quick Mask Mode, and the button shows -/// on while the active document is in Quick Mask. +/// The Quick Mask glyph and selected state shown for the active document. +#[derive(Clone, Copy, PartialEq, Eq, Hash)] +pub(super) enum QuickMaskState { + Off, + MaskedAreas, + SelectedAreas, +} + +impl QuickMaskState { + pub(super) fn of(app: &PhotocraftApp) -> Self { + match app.session.active().and_then(|st| st.doc.quick_mask.as_ref()).map(|mask| mask.indicates) { + None => Self::Off, + Some(ColorIndicates::MaskedAreas) => Self::MaskedAreas, + Some(ColorIndicates::SelectedAreas) => Self::SelectedAreas, + } + } + + fn icon(self) -> IconSpec<'static> { + IconSpec::svg(match self { + Self::Off => IconId::new("quick-mask-off"), + Self::MaskedAreas => IconId::new("quick-mask-masked-areas"), + Self::SelectedAreas => IconId::new("quick-mask-selected-areas"), + }) + } +} + +/// A rail button that runs Edit in Quick Mask Mode and shows which areas the active mask marks. fn quick_mask_button(app: &PhotocraftApp, ui: &mut egui::Ui) { - let on = app.session.active().is_some_and(|s| s.doc.quick_mask.is_some()); - let tools = [RailTool::new(0_u8, CommandRef::new(QUICK_MASK))]; - let _ = FlyoutButton::new(&tools, &0).id_salt("quick-mask").selected(on).show(ui); + let state = QuickMaskState::of(app); + let tools = [RailTool::new(0_u8, CommandRef::new(QUICK_MASK)).icon(state.icon())]; + let _ = FlyoutButton::new(&tools, &0).id_salt("quick-mask").selected(state != QuickMaskState::Off).show(ui); } /// The side of the toolbar its tool flyouts, "…" flyout and Edit Toolbar drawer open on: the end (the right in a diff --git a/crates/ui-egui/src/panels/toolbar_quick_mask_icon_tests.rs b/crates/ui-egui/src/panels/toolbar_quick_mask_icon_tests.rs new file mode 100644 index 00000000000..864bf360963 --- /dev/null +++ b/crates/ui-egui/src/panels/toolbar_quick_mask_icon_tests.rs @@ -0,0 +1,69 @@ +//! #17795: the Quick Mask button paints three distinct glyphs and follows the current document. + +use egui::accesskit::{Role, Toggled}; +use egui::{Rect, Shape, TextureId}; +use egui_kittest::Harness; +use egui_kittest::kittest::{NodeT, Queryable}; +use serde_json::json; + +use super::{PhotocraftApp, QUICK_MASK}; +use crate::input::shortcut_dispatch::tests::app_harness; + +const LABEL: &str = "Edit in Quick Mask Mode"; + +fn icon_texture(shape: &Shape, button: Rect) -> Option { + match shape { + Shape::Vec(shapes) => shapes.iter().find_map(|shape| icon_texture(shape, button)), + Shape::PaintChunk(shapes) => shapes.iter().find_map(|shape| icon_texture(&shape.shape, button)), + Shape::Mesh(mesh) if mesh.texture_id != TextureId::default() && button.contains(mesh.calc_bounds().center()) => Some(mesh.texture_id), + _ => None, + } +} + +/// Read the glyph that was actually painted inside the accessible button's bounds. +fn glyph(h: &Harness<'_, Box>, pressed: Toggled) -> TextureId { + let button = h.get_by_role_and_label(Role::Button, LABEL); + assert_eq!(button.accesskit_node().toggled(), Some(pressed)); + h.output().shapes.iter().find_map(|shape| icon_texture(&shape.shape, button.rect())).expect("Quick Mask button paints a glyph") +} + +#[test] +fn the_quick_mask_glyph_tracks_color_indicates_and_the_active_document() { + let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default()); + for name in ["First", "Second"] { + app.run("file.new", json!({"width": 64, "height": 64, "name": name})).unwrap(); + } + assert!(app.session.set_active(0)); + let mut h = app_harness(app); + + let off = glyph(&h, Toggled::False); + h.state_mut().run(QUICK_MASK, json!({"on": true})).unwrap(); + h.run_steps(3); + let masked = glyph(&h, Toggled::True); + assert_ne!(masked, off); + + // The options command changes the indicator without toggling the mask or touching the toolbar. + h.state_mut().run("channel.options", json!({"channel": "quickMask", "indicates": "selected"})).unwrap(); + h.run_steps(3); + let selected = glyph(&h, Toggled::True); + assert_ne!(selected, off); + assert_ne!(selected, masked); + + // The session now defaults to Selected Areas. The second document is still off until it enters Quick Mask. + assert!(h.state_mut().session.set_active(1)); + h.run_steps(3); + assert_eq!(glyph(&h, Toggled::False), off); + h.state_mut().run(QUICK_MASK, json!({"on": true})).unwrap(); + h.state_mut().run("channel.options", json!({"channel": "quickMask", "indicates": "masked"})).unwrap(); + h.run_steps(3); + assert_eq!(glyph(&h, Toggled::True), masked); + + // The session default changed again, but the first document still marks Selected Areas. + assert!(h.state_mut().session.set_active(0)); + h.run_steps(3); + assert_eq!(glyph(&h, Toggled::True), selected); + + h.get_by_role_and_label(Role::Button, LABEL).click(); + h.run_steps(3); + assert_eq!(glyph(&h, Toggled::False), off); +} From 0434207dd44c4abe33f71f0b9887056279b5a664 Mon Sep 17 00:00:00 2001 From: yoriswind Date: Tue, 1 Dec 2026 17:36:09 -0800 Subject: [PATCH 59/81] Keep neutral-fill coverage for existing 32-bit layers --- crates/engine/tests/it/paint_in_new_layer.rs | 26 +++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/crates/engine/tests/it/paint_in_new_layer.rs b/crates/engine/tests/it/paint_in_new_layer.rs index eead47485be..4b5151d185b 100644 --- a/crates/engine/tests/it/paint_in_new_layer.rs +++ b/crates/engine/tests/it/paint_in_new_layer.rs @@ -1,12 +1,12 @@ //! Tests that run paint commands, moved from the engine-core `new_layer` tests: 1 test(s). -use photocraft_doc::BlendMode; +use photocraft_doc::{BlendMode, Layer}; use photocraft_geom::Rect; use serde_json::json; -use photocraft_engine::new_layer::neutral_color; +use photocraft_engine::new_layer::{greyed_modes, neutral_color}; use photocraft_engine::Session; @@ -41,9 +41,27 @@ fn neutral_fills_leave_the_image_unchanged() { let s0 = busy(mode, depth); let doc0 = s0.active().unwrap().doc.clone(); let shown = photocraft_compose::render(&doc0, doc0.bounds()); - for m in BlendMode::LAYER_MODES.into_iter().filter(|m| neutral_color(*m).is_some()) { + for (m, neutral) in BlendMode::LAYER_MODES.into_iter().filter_map(|m| neutral_color(m).map(|(rgb, _)| (m, rgb))) { let mut s = busy(mode, depth); - s.execute("layer.new.layer", json!({"mode": m.label(), "fillNeutral": true})).unwrap(); + let result = s.execute("layer.new.layer", json!({"mode": m.label(), "fillNeutral": true})); + if greyed_modes(&doc0).contains(&m) { + let error = result.unwrap_err().to_string(); + assert!(error.contains(m.label()) && error.contains("not available"), "{error}"); + assert_eq!(s.active().unwrap().doc.layers.len(), doc0.layers.len()); + // A file can still contain a layer in a mode that New Layer cannot create at this depth. + s.edit("Imported neutral layer", |doc, active| { + let fmt = doc.pixel_format(); + let bounds = doc.bounds(); + let mut layer = Layer::raster("Imported neutral layer", fmt); + layer.blend = m; + layer.surface_mut().unwrap().fill_rect(bounds, &photocraft_raster::from_rgba(&fmt, [neutral[0], neutral[1], neutral[2], 1.0])); + *active = Some(doc.insert_above(*active, layer)); + Ok(()) + }) + .unwrap(); + } else { + result.unwrap(); + } let doc = &s.active().unwrap().doc; let top = doc.layers.last().unwrap(); assert_eq!(top.blend, m); From da1718617eaeb5ddd2d809fb8ad4bc83528d2a15 Mon Sep 17 00:00:00 2001 From: "autocraft-bot[bot]" <354215646+autocraft-bot[bot]@users.noreply.github.com> Date: Wed, 2 Dec 2026 01:39:51 +0000 Subject: [PATCH 60/81] Part 1: the recorded Data Sets as Files step no longer carries the form' Part 1: the recorded Data Sets as Files step no longer carries the form's question parameters. In `crates/ui-egui/src/menus/view_cmds/dialogs.rs` I added `keep_prompt_params_out_of_the_journal`. `data_sets_run` calls it right after the form's own run and removes `missingImage` (and any `start`) from the step the journal recorded. A playback is then the plain export, so a missing replacement image is an error again instead of a silent `stopped`. `data_sets_answer` calls it after the resumed run that follows Yes and drops that run's journal step, so no second step with a fixed `start` is recorded. The command and the engine are unchanged. I added the test `the_recorded_step_keeps_the_forms_question_parameters_out` to `export_data_sets_missing_image_tests.rs`: after Yes, Yes it expects exactly one recorded export step without `missingImage` or `start`. `cargo fmt --check` is clean. Clippy with `-D warnings` on ui-egui printed no warning or error from this change, only workspace-level warnings (unused workspace dependencies and unused patches). All 13 `export_data_sets` tests pass, including the new one. I did not run the rest of the ui-egui suite. --- .../export_data_sets_missing_image_tests.rs | 21 +++++++++++ crates/ui-egui/src/menus/view_cmds/dialogs.rs | 36 ++++++++++++++++++- 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/export_data_sets_missing_image_tests.rs b/crates/ui-egui/src/export_data_sets_missing_image_tests.rs index daa0094931d..63c12bb7373 100644 --- a/crates/ui-egui/src/export_data_sets_missing_image_tests.rs +++ b/crates/ui-egui/src/export_data_sets_missing_image_tests.rs @@ -302,3 +302,24 @@ fn a_missing_last_set_after_a_yes_still_lists_the_set_left_out() { assert!(status.contains("Data Set 2"), "the set an earlier Yes left out stays listed: {status}"); let _ = std::fs::remove_dir_all(dir); } + +#[test] +fn the_recorded_step_keeps_the_forms_question_parameters_out() { + let dir = scratch("journal"); + let out = dir.join("out"); + let (mut app, ctx) = app(&dir, &[true, false, false, true]); + let from = app.session.journal.len(); + export_from_form(&mut app, &ctx, &out); + let (id, _) = question(&app).unwrap(); + answer(&mut app, &ctx, id, true); + let (id, _) = question(&app).unwrap(); + answer(&mut app, &ctx, id, true); + assert_eq!(files(&out), ["Data_Set_1.png", "Data_Set_4.png"]); + + let steps: Vec<&Value> = app.session.journal[from..].iter().filter(|(id, _)| id == EXPORT).map(|(_, p)| p).collect(); + assert_eq!(steps.len(), 1, "the resumed runs are not recorded as steps: {steps:?}"); + for key in ["missingImage", "start"] { + assert!(steps[0].get(key).is_none(), "{key} stays out of the recorded step: {:?}", steps[0]); + } + let _ = std::fs::remove_dir_all(dir); +} diff --git a/crates/ui-egui/src/menus/view_cmds/dialogs.rs b/crates/ui-egui/src/menus/view_cmds/dialogs.rs index d6895686b78..1bc0c615eee 100644 --- a/crates/ui-egui/src/menus/view_cmds/dialogs.rs +++ b/crates/ui-egui/src/menus/view_cmds/dialogs.rs @@ -1085,12 +1085,44 @@ pub(crate) fn data_sets_run(app: &mut PhotocraftApp, ctx: &egui::Context, mut re result.fields.set("missingImage", FieldValue::Text("stop".into())); let doc = app.session.active().map(|st| st.doc.id); let params = crate::dialogs::filter_dialog::command_params(DATA_SETS, &result.fields); - match crate::dialogs::filter_dialog::run_command(app, ctx, DATA_SETS, result) { + let journal = app.session.journal.len(); + let outcome = crate::dialogs::filter_dialog::run_command(app, ctx, DATA_SETS, result); + keep_prompt_params_out_of_the_journal(app, journal, false); + match outcome { Ok(reply) => data_sets_went_on(app, doc, params, Vec::new(), &reply), Err(error) => crate::notices::error(app, error), } } +/// `missingImage` and `start` belong to the question this form asks, not to the export: a recorded step +/// that kept them would, on playback, stop at a missing image without an error and skip the sets after it, +/// or write from a position chosen for another document. The step the form ran loses `missingImage` +/// (a playback is the plain export, and a missing image is an error again); the resumed run after Yes +/// (`resumed`) is part of the same export, so its step is not recorded at all. +fn keep_prompt_params_out_of_the_journal(app: &mut PhotocraftApp, from: usize, resumed: bool) { + let journal = &mut app.session.journal; + if journal.len() <= from { + return; + } + if resumed { + let mut index = 0; + journal.retain(|(id, _)| { + let keep = index < from || id != DATA_SETS; + index += 1; + keep + }); + return; + } + for (id, params) in journal.iter_mut().skip(from) { + if id == DATA_SETS + && let Some(map) = params.as_object_mut() + { + map.remove("missingImage"); + map.remove("start"); + } + } +} + /// The question a missing replacement image asks: the document, its edit revision and its variables /// and data sets as the export read them, the export's parameters, the set it stopped at and where /// the batch resumes, and the sets skipped so far. @@ -1194,10 +1226,12 @@ pub(crate) fn data_sets_answer(app: &mut PhotocraftApp, _ctx: &egui::Context, an map.insert("missingImage".into(), json!("stop")); } let run = |app: &mut PhotocraftApp| app.run(DATA_SETS, params.clone()); + let journal = app.session.journal.len(); let outcome = match pending.doc { Some(doc) => app.with_document(doc, run), None => run(app), }; + keep_prompt_params_out_of_the_journal(app, journal, true); match outcome { Ok(reply) => data_sets_went_on(app, pending.doc, pending.params, pending.skipped, &reply), Err(error) => crate::notices::error(app, error), From c35196905f007e1045d3ed18504db50946a71579 Mon Sep 17 00:00:00 2001 From: yoriswind Date: Tue, 1 Dec 2026 17:43:35 -0800 Subject: [PATCH 61/81] Keep the unavailable Color Samplers menu item checked --- crates/ui-egui/src/panels/info_color_samplers_toggle_tests.rs | 2 +- crates/ui-egui/src/panels/registry.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/panels/info_color_samplers_toggle_tests.rs b/crates/ui-egui/src/panels/info_color_samplers_toggle_tests.rs index 99a98141434..7ed63c8dfac 100644 --- a/crates/ui-egui/src/panels/info_color_samplers_toggle_tests.rs +++ b/crates/ui-egui/src/panels/info_color_samplers_toggle_tests.rs @@ -73,7 +73,7 @@ fn color_samplers_toggle_is_session_wide_and_requires_points_in_the_active_docum assert_eq!(crate::analysis::sampler_at(&app, POINT), Some(0), "the sampler tools can still find the stored point"); add_document(&mut app); - assert_eq!(menu_state(&app), state(false, false)); + assert_eq!(menu_state(&app), state(false, true), "empty documents show the disabled item checked"); fire(&mut app); add_sampler(&mut app); assert_eq!(menu_state(&app), state(true, false)); diff --git a/crates/ui-egui/src/panels/registry.rs b/crates/ui-egui/src/panels/registry.rs index 26c1bd1a56d..c7910f94d31 100644 --- a/crates/ui-egui/src/panels/registry.rs +++ b/crates/ui-egui/src/panels/registry.rs @@ -251,7 +251,7 @@ struct InfoMenuFacts { fn info_source_states(app: &PhotocraftApp, name: &'static str) -> Arc { let facts = InfoMenuFacts { available: has_color_samplers(app), visible: !app.ui.analysis.hide_color_samplers }; derived_states(app, name, &facts, || { - vec![(CommandRef::from(InfoCommand::ColorSamplers), CommandState::new().enabled(facts.available).checked(facts.visible))] + vec![(CommandRef::from(InfoCommand::ColorSamplers), CommandState::new().enabled(facts.available).checked(!facts.available || facts.visible))] }) } From b9b398c0b6187cb134f5815e32b3156076096a2a Mon Sep 17 00:00:00 2001 From: yoriswind Date: Tue, 1 Dec 2026 17:57:56 -0800 Subject: [PATCH 62/81] Add RAW output sharpening strength to Defaults --- .../file_cmds/raw_defaults_sharpen_tests.rs | 85 +++++++++++++++++++ .../engine-core/src/cmd/file_cmds/raw_open.rs | 11 ++- crates/engine-core/src/prefs.rs | 20 +++++ crates/engine-core/src/prefs/validate.rs | 5 +- .../src/dialogs/camera_raw_ui/convert.rs | 9 +- .../ui-egui/src/prefs/prefs_ui/custom_rows.rs | 44 ++++++++++ crates/ui-egui/src/prefs/prefs_ui/fields.rs | 3 + docs/scorecard.md | 4 +- 8 files changed, 163 insertions(+), 18 deletions(-) create mode 100644 crates/engine-core/src/cmd/file_cmds/raw_defaults_sharpen_tests.rs diff --git a/crates/engine-core/src/cmd/file_cmds/raw_defaults_sharpen_tests.rs b/crates/engine-core/src/cmd/file_cmds/raw_defaults_sharpen_tests.rs new file mode 100644 index 00000000000..10f3ef7c0df --- /dev/null +++ b/crates/engine-core/src/cmd/file_cmds/raw_defaults_sharpen_tests.rs @@ -0,0 +1,85 @@ +//! RAW Defaults output sharpening (#17776). + +use photocraft_algo::camera_raw::CameraRaw; +use photocraft_raw::testgen::{DngSpec, mosaic}; +use serde_json::json; + +use crate::prefs::{RawColorSpace, RawSharpen, RawSharpenAmount, SavedPrefsExt}; +use crate::{Session, file_cmds}; + +#[test] +fn saved_media_keep_their_existing_strength_without_an_amount() { + for (medium, expected) in [("none", None), ("screen", Some((25.0, 1.0))), ("glossy", Some((40.0, 1.0))), ("matte", Some((35.0, 1.2)))] { + let mut s = crate::session(); + let saved = json!({"rawDefaults": {"sharpenFor": medium}}); + assert!(s.load_prefs_json(&saved.to_string()).unwrap().is_empty()); + let defaults = &s.prefs().raw_defaults; + assert_eq!(defaults.sharpen_amount, RawSharpenAmount::Standard); + let mut settings = CameraRaw::default(); + assert_eq!(defaults.apply_output_sharpening(&mut settings), expected.is_some()); + if let Some(pair) = expected { + assert_eq!((settings.sharpen_amount, settings.sharpen_radius), pair); + } else { + assert_eq!(settings, CameraRaw::default()); + } + } +} + +#[test] +fn prefs_set_rejects_unknown_sharpening_amounts_and_keeps_the_previous_choice() { + let mut s = crate::session(); + let path = "rawDefaults.sharpenAmount"; + for valid in ["low", "standard", "high"] { + s.execute("prefs.set", json!({"path":path, "value":valid})).unwrap(); + assert_eq!(s.execute("prefs.get", json!({"path":path})).unwrap(), json!(valid)); + } + for invalid in [json!("medium"), json!(25)] { + let err = s.execute("prefs.set", json!({"path":path, "value":invalid})).unwrap_err(); + assert!(err.to_string().contains(path), "{err}"); + assert_eq!(s.prefs().raw_defaults.sharpen_amount, RawSharpenAmount::High); + } +} + +#[test] +fn raw_detail_sharpening_takes_precedence_over_output_sharpening() { + let mut s = crate::session(); + s.execute("prefs.set", json!({"values":{"rawDefaults.sharpenFor":"matte","rawDefaults.sharpenAmount":"high"}})).unwrap(); + let detail = CameraRaw { sharpen_amount: 12.0, sharpen_radius: 2.0, ..CameraRaw::default() }; + let mut settings = detail.clone(); + assert!(!s.prefs().raw_defaults.apply_output_sharpening(&mut settings)); + assert_eq!(settings, detail); +} + +#[test] +fn quiet_raw_sharpening_levels_order_the_pixel_change_from_unsharpened() { + let (w, h) = (24, 16); + // Keep the edge away from clipping so each change in strength can affect the pixels. + let scene: Vec<_> = (0..w * h).map(|i| if i % w < w / 2 { [0.20; 3] } else { [0.32; 3] }).collect(); + let raw = DngSpec::cfa(w, h, mosaic(&scene, w, [0, 1, 1, 2], 0, 65535)).build(); + let open = |medium, amount| { + let mut s = crate::session(); + s.execute("edit.colorSettings", json!({"askOnMismatch":false,"askOnMissing":false})).unwrap(); + let mut defaults = s.prefs().raw_defaults.clone(); + defaults.color_space = RawColorSpace::ProPhoto; + defaults.sharpen_for = medium; + defaults.sharpen_amount = amount; + s.batch_raw_open = Some(defaults); + file_cmds::open_bytes_as(&mut s, "IMG_0001.dng", &raw, None, None).unwrap(); + s + }; + let pixels = |s: &Session| { + let doc = &s.active().unwrap().doc; + photocraft_compose::render(doc, doc.bounds()).px + }; + let off = open(RawSharpen::None, RawSharpenAmount::High); + let unsharpened = pixels(&off); + let distance = |developed: &[[f32; 4]]| developed.iter().flatten().zip(unsharpened.iter().flatten()).map(|(a, b)| f64::from((a - b).abs())).sum::(); + let [low, standard, high] = + [RawSharpenAmount::Low, RawSharpenAmount::Standard, RawSharpenAmount::High].map(|amount| pixels(&open(RawSharpen::Screen, amount))); + let (low_distance, standard_distance, high_distance) = (distance(&low), distance(&standard), distance(&high)); + assert!(0.0 < low_distance && low_distance < standard_distance && standard_distance < high_distance); + + let mut previous = off; + previous.execute("filter.cameraRaw", json!({"sharpenAmount":25.0,"sharpenRadius":1.0})).unwrap(); + assert_eq!(standard, pixels(&previous)); +} diff --git a/crates/engine-core/src/cmd/file_cmds/raw_open.rs b/crates/engine-core/src/cmd/file_cmds/raw_open.rs index eb61322f353..908d8386e14 100644 --- a/crates/engine-core/src/cmd/file_cmds/raw_open.rs +++ b/crates/engine-core/src/cmd/file_cmds/raw_open.rs @@ -112,12 +112,7 @@ pub(super) fn prepare(s: &Session, name: &str, shown: &str, path: Option<&str>, settings.tint = 0.0; } } - if let Some((amount, radius)) = defaults.sharpen_for.preset() - && settings.sharpen_amount == 0.0 - { - settings.sharpen_amount = amount; - settings.sharpen_radius = radius; - } + defaults.apply_output_sharpening(&mut settings); Ok(Some((imported, settings))) } @@ -148,3 +143,7 @@ pub(super) fn finish(s: &mut Session, settings: CameraRaw) -> Result<()> { } Ok(()) } + +#[cfg(test)] +#[path = "raw_defaults_sharpen_tests.rs"] +mod raw_defaults_sharpen_tests; diff --git a/crates/engine-core/src/prefs.rs b/crates/engine-core/src/prefs.rs index 76d893ed933..8a6bfab825e 100644 --- a/crates/engine-core/src/prefs.rs +++ b/crates/engine-core/src/prefs.rs @@ -117,6 +117,7 @@ choice!(FontPreview { Off = "off", Small = "small", Medium = "medium", Large = " choice!(RawColorSpace { Srgb = "srgb", AdobeRgb = "adobeRgb", ProPhoto = "proPhoto", DisplayP3 = "displayP3" } default DisplayP3); choice!(RawDepth { Eight = "8", Sixteen = "16" } default Sixteen); choice!(RawSharpen { None = "none", Screen = "screen", Glossy = "glossy", Matte = "matte" } default None); +choice!(RawSharpenAmount { Low = "low", Standard = "standard", High = "high" } default Standard); choice!( /// How a raw file's colour filter array is filled in when it is developed: AHD /// (Hirakawa–Parks) keeps edges cleanest, Malvar–He–Cutler is sharp and fast, bilinear is the @@ -1177,6 +1178,7 @@ pub struct RawDefaults { #[serde(deserialize_with = "raw_resolution")] pub resolution: u32, pub sharpen_for: RawSharpen, + pub sharpen_amount: RawSharpenAmount, pub open_as_smart_object: bool, pub apply_auto_tone: bool, /// Opening a raw file interactively shows the Camera Raw dialog first (Open / Cancel), as @@ -1194,6 +1196,23 @@ pub struct RawDefaults { impl RawDefaults { /// What Resolution takes, as the reference application's field does. pub const RESOLUTION: std::ops::RangeInclusive = 1..=999; + + /// Apply output sharpening if a medium is selected and the raw has no Detail sharpening. + pub fn apply_output_sharpening(&self, settings: &mut photocraft_algo::camera_raw::CameraRaw) -> bool { + if settings.sharpen_amount != 0.0 { + return false; + } + let Some((amount, radius)) = self.sharpen_for.preset() else { return false }; + // Vary the strength around the existing Standard preset while keeping the medium's radius. + let amount = match self.sharpen_amount { + RawSharpenAmount::Low => amount * 0.5, + RawSharpenAmount::Standard => amount, + RawSharpenAmount::High => amount * 1.5, + }; + settings.sharpen_amount = amount; + settings.sharpen_radius = radius; + true + } } /// A saved Raw Defaults › Resolution as the field takes it: the nearest whole number within @@ -1251,6 +1270,7 @@ impl Default for RawDefaults { bit_depth: RawDepth::Sixteen, resolution: 300, sharpen_for: RawSharpen::None, + sharpen_amount: RawSharpenAmount::Standard, open_as_smart_object: false, apply_auto_tone: false, open_in_camera_raw: true, diff --git a/crates/engine-core/src/prefs/validate.rs b/crates/engine-core/src/prefs/validate.rs index 8e969114baf..6c2dac83b42 100644 --- a/crates/engine-core/src/prefs/validate.rs +++ b/crates/engine-core/src/prefs/validate.rs @@ -2,8 +2,8 @@ use super::shortcuts::normalize_shortcut; use super::{ AppearanceMode, Ask, CanvasBorder, CanvasColor, CheckerColors, CheckerSize, ColorPicker, ExportLocation, ExportMetadata, FontPreview, GpuBackend, Interpolation, LineStyle, LinuxDisplayServer, LogDestination, LogDetail, OtherCursor, PaintingCursor, PlaybackPerformance, PointSize, PressureCurve, - QuickExportFormat, RawColorSpace, RawDemosaic, RawDepth, RawSharpen, RenderingMode, RightClickPaint, TabletInput, TextEngine, TypeUnit, UiDensity, - UiFontSize, UiScale, Unit, Value, WhenAppClosed, + QuickExportFormat, RawColorSpace, RawDemosaic, RawDepth, RawSharpen, RawSharpenAmount, RenderingMode, RightClickPaint, TabletInput, TextEngine, TypeUnit, + UiDensity, UiFontSize, UiScale, Unit, Value, WhenAppClosed, }; /// Preferences dialog sections in Photoshop's order: (id, title). @@ -96,6 +96,7 @@ pub fn choices(path: &str) -> Option<&'static [&'static str]> { "rawDefaults.colorSpace" => RawColorSpace::NAMES, "rawDefaults.bitDepth" => RawDepth::NAMES, "rawDefaults.sharpenFor" => RawSharpen::NAMES, + "rawDefaults.sharpenAmount" => RawSharpenAmount::NAMES, "rawDefaults.demosaic" => RawDemosaic::NAMES, "performance.gpuBackend" => GpuBackend::NAMES, "performance.linuxDisplayServer" => LinuxDisplayServer::NAMES, diff --git a/crates/ui-egui/src/dialogs/camera_raw_ui/convert.rs b/crates/ui-egui/src/dialogs/camera_raw_ui/convert.rs index 7817d007380..98c7a949d8f 100644 --- a/crates/ui-egui/src/dialogs/camera_raw_ui/convert.rs +++ b/crates/ui-egui/src/dialogs/camera_raw_ui/convert.rs @@ -12,14 +12,7 @@ use serde_json::json; /// Camera Raw Defaults › Sharpen For: output sharpening, folded into the Camera Raw step `rest` /// as the workflow's Sharpen For is. Returns what it applied. pub(super) fn output_sharpening(d: &photocraft_engine::prefs::RawDefaults, rest: &mut CameraRaw) -> Vec<&'static str> { - match d.sharpen_for.preset() { - Some((amount, radius)) if rest.sharpen_amount == 0.0 => { - rest.sharpen_amount = amount; - rest.sharpen_radius = radius; - vec!["sharpenFor"] - } - _ => Vec::new(), - } + if d.apply_output_sharpening(rest) { vec!["sharpenFor"] } else { Vec::new() } } /// The Camera Raw Defaults [`apply_raw_conversions`] applies. Resolution is not among them: the diff --git a/crates/ui-egui/src/prefs/prefs_ui/custom_rows.rs b/crates/ui-egui/src/prefs/prefs_ui/custom_rows.rs index 92cbda9b71f..5e5057ab1c2 100644 --- a/crates/ui-egui/src/prefs/prefs_ui/custom_rows.rs +++ b/crates/ui-egui/src/prefs/prefs_ui/custom_rows.rs @@ -25,6 +25,7 @@ use serde_json::{Value, json}; use super::fields::{PrefPages, choice_label}; use super::{PhotocraftApp, prefs}; use craft::ui::patterns::preferences::{CustomSettings, SettingsDraft}; +use photocraft_engine::prefs::{RawSharpen, RawSharpenAmount}; const MEMORY_PERCENT: &str = "performance.memoryUsagePercent"; const MEMORY_MB: &str = "performance.memoryUsageMb"; @@ -39,6 +40,8 @@ const DARK_THEME: &str = "interface.darkTheme"; const FAVORITE_THEMES: &str = "interface.favoriteThemes"; const DENSITY: &str = "interface.density"; const RAW_RESOLUTION: &str = "rawDefaults.resolution"; +const RAW_SHARPEN_FOR: &str = "rawDefaults.sharpenFor"; +const RAW_SHARPEN_AMOUNT: &str = "rawDefaults.sharpenAmount"; /// The page agents' settings live on, drawn whole by [`craft::automation::ui::agents::AgentsPage`]. #[cfg(not(target_arch = "wasm32"))] pub(super) const AGENTS_PAGE: &str = "integrations"; @@ -98,6 +101,8 @@ impl CustomSettings for PrefsCustom { "tools.tabletInput" => tablet_input_row(ui, draft), APPEARANCE_MODE => self.appearance_row(ui, draft), RAW_RESOLUTION => raw_resolution_row(ui, draft), + RAW_SHARPEN_FOR => raw_sharpen_for_row(ui, draft), + RAW_SHARPEN_AMOUNT => raw_sharpen_amount_row(ui, draft), _ => {} } false @@ -186,6 +191,45 @@ fn raw_resolution_row(ui: &mut egui::Ui, draft: &mut SettingsDraft) { } } +/// None is the saved off state. Show Screen as the disabled choice and start there when turned on. +fn raw_sharpen_for_row(ui: &mut egui::Ui, draft: &mut SettingsDraft) { + let stored: RawSharpen = draft.get(RAW_SHARPEN_FOR).unwrap_or_default(); + let was_on = stored != RawSharpen::None; + let mut on = was_on; + let mut medium = if was_on { stored } else { RawSharpen::Screen }; + let options = [ + Entry::new(RawSharpen::Screen, tl!("Screen").to_string()), + Entry::new(RawSharpen::Glossy, tl!("Glossy Paper").to_string()), + Entry::new(RawSharpen::Matte, tl!("Matte Paper").to_string()), + ]; + Row::new().show(ui, |ui, _| { + Checkbox::new(Bind::bound(&mut on)).label(tl!("Sharpen For")).show(ui); + Select::new(tl!("Output Medium").to_string(), Bind::bound(&mut medium), &options).enabled(on).show(ui); + }); + let next = if on { medium } else { RawSharpen::None }; + if next != stored { + draft.set(RAW_SHARPEN_FOR, &next); + } +} + +fn raw_sharpen_amount_row(ui: &mut egui::Ui, draft: &mut SettingsDraft) { + let on = draft.get::(RAW_SHARPEN_FOR).unwrap_or_default() != RawSharpen::None; + let stored: RawSharpenAmount = draft.get(RAW_SHARPEN_AMOUNT).unwrap_or_default(); + let mut amount = stored; + let options = [ + Entry::new(RawSharpenAmount::Low, tl!("Low").to_string()), + Entry::new(RawSharpenAmount::Standard, tl!("Standard").to_string()), + Entry::new(RawSharpenAmount::High, tl!("High").to_string()), + ]; + let label = tl!("Amount"); + Field::new(label.to_string()).show(ui, |ui, _| { + Select::new(label.to_string(), Bind::bound(&mut amount), &options).enabled(on).show(ui); + }); + if amount != stored { + draft.set(RAW_SHARPEN_AMOUNT, &amount); + } +} + /// A checkbox enabling a 1–95 % field; off stores no value. fn memory_percent_row(ui: &mut egui::Ui, draft: &mut SettingsDraft) { let stored: Option = draft.get(MEMORY_PERCENT); diff --git a/crates/ui-egui/src/prefs/prefs_ui/fields.rs b/crates/ui-egui/src/prefs/prefs_ui/fields.rs index d56107481ca..9cce7f64817 100644 --- a/crates/ui-egui/src/prefs/prefs_ui/fields.rs +++ b/crates/ui-egui/src/prefs/prefs_ui/fields.rs @@ -177,6 +177,9 @@ pub(super) fn rules(ctx: &egui::Context) -> Vec { // RAW Defaults › Resolution drops a typed comma and alerts when it clamps (#18027), which the window's own // whole-number row does not. tweak(&mut rules, "rawDefaults.resolution", |r| r.custom()); + // The sharpening checkbox uses the saved medium's None value as off. Its two selects stay visible when off. + tweak(&mut rules, "rawDefaults.sharpenFor", |r| r.custom_rows()); + tweak(&mut rules, "rawDefaults.sharpenAmount", |r| r.label("Amount").custom_rows()); // Rows that draw their own label or heading, so the window adds none: the Appearance page (Appearance Mode, the // themes), Rendering Mode's select, the Memory Usage block and its labelled percent checkbox. for path in ["interface.appearanceMode", "performance.renderingMode", "performance.memoryUsageMb", "performance.memoryUsagePercent"] { diff --git a/docs/scorecard.md b/docs/scorecard.md index e984cf914e7..692d5d4beec 100644 --- a/docs/scorecard.md +++ b/docs/scorecard.md @@ -9,7 +9,7 @@ Generated by `cargo xtask scorecard` from `perf/budgets.toml`, `perf/baseline.js | [Performance](#performance) | 3 | 22 | 59 | 93 scenarios: 3 within budget, 22 over budget or failing, 9 tracked only, 55 not run, 4 not measurable yet (baseline 2026-10-05) | | [File compatibility](#file-compatibility) | 11 | 14 | 2 | io corpus: oracle ≥ 148/170, round trip ≥ 169/170; psd-tools corpus: oracle ≥ 249/309, round trip ≥ 308/309; photoshop oracles: oracle ≥ 190/258, round trip ≥ 258/258 | | [Tools](#tools) | 36 | 9 | 0 | | -| [Workspace and UI](#workspace-and-ui) | 15 | 6 | 2 | settings that do nothing: 9 of 204 (target 0) | +| [Workspace and UI](#workspace-and-ui) | 15 | 6 | 2 | settings that do nothing: 9 of 205 (target 0) | | [Type](#type) | 5 | 6 | 0 | | | [Automation](#automation) | 6 | 4 | 2 | 663 of 663 menu items live (100.0%) | | [Reliability](#reliability) | 5 | 2 | 0 | never-crash lints on 28 of 28 crates; panic_hunt present | @@ -217,7 +217,7 @@ Corpus floors (`crates/io/tests/it/corpus.rs`): the enforced minimums; the corpu ## Workspace and UI -**Settings that do nothing: 9 of 204** (target 0, #204). Counted by the prefs audit (`xtask/src/scorecard.rs`): a `Preferences` field counts as read when code outside the prefs model (`prefs.rs` except its `impl Session` blocks; tests excluded; the schema-driven dialog never names a field) accesses `section.field`, or `.section` and `.field` in the same file, or calls a section method that reads `self.field`. It is a heuristic lower bound: a generic name can look read when it isn't. +**Settings that do nothing: 9 of 205** (target 0, #204). Counted by the prefs audit (`xtask/src/scorecard.rs`): a `Preferences` field counts as read when code outside the prefs model (`prefs.rs` except its `impl Session` blocks; tests excluded; the schema-driven dialog never names a field) accesses `section.field`, or `.section` and `.field` in the same file, or calls a section method that reads `self.field`. It is a heuristic lower bound: a generic name can look read when it isn't. Unread: `general.color_picker`, `workspace.auto_show_hidden_panels`, `workspace.enable_floating_document_window_docking`, `workspace.enable_narrow_options_bar`, `performance.legacy_compositing`, `plug_ins.show_extension_panels`, `plug_ins.allow_scripts_to_connect`, `type_.text_engine`, `enhanced_controls.scrubby_slider_acceleration`. From 55b1e440e7d1a0cdae49823567e747626e151193 Mon Sep 17 00:00:00 2001 From: yoriswind Date: Tue, 1 Dec 2026 18:13:01 -0800 Subject: [PATCH 63/81] Fix RAW sharpening test compilation --- .../src/cmd/file_cmds/raw_defaults_sharpen_tests.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/crates/engine-core/src/cmd/file_cmds/raw_defaults_sharpen_tests.rs b/crates/engine-core/src/cmd/file_cmds/raw_defaults_sharpen_tests.rs index 10f3ef7c0df..ec84e4e30b3 100644 --- a/crates/engine-core/src/cmd/file_cmds/raw_defaults_sharpen_tests.rs +++ b/crates/engine-core/src/cmd/file_cmds/raw_defaults_sharpen_tests.rs @@ -44,7 +44,9 @@ fn prefs_set_rejects_unknown_sharpening_amounts_and_keeps_the_previous_choice() fn raw_detail_sharpening_takes_precedence_over_output_sharpening() { let mut s = crate::session(); s.execute("prefs.set", json!({"values":{"rawDefaults.sharpenFor":"matte","rawDefaults.sharpenAmount":"high"}})).unwrap(); - let detail = CameraRaw { sharpen_amount: 12.0, sharpen_radius: 2.0, ..CameraRaw::default() }; + let mut detail = CameraRaw::default(); + detail.sharpen_amount = 12.0; + detail.sharpen_radius = 2.0; let mut settings = detail.clone(); assert!(!s.prefs().raw_defaults.apply_output_sharpening(&mut settings)); assert_eq!(settings, detail); @@ -69,17 +71,17 @@ fn quiet_raw_sharpening_levels_order_the_pixel_change_from_unsharpened() { }; let pixels = |s: &Session| { let doc = &s.active().unwrap().doc; - photocraft_compose::render(doc, doc.bounds()).px + photocraft_compose::render(doc, doc.bounds()) }; let off = open(RawSharpen::None, RawSharpenAmount::High); let unsharpened = pixels(&off); - let distance = |developed: &[[f32; 4]]| developed.iter().flatten().zip(unsharpened.iter().flatten()).map(|(a, b)| f64::from((a - b).abs())).sum::(); + let distance = |developed: &[[f32; 4]]| developed.iter().flatten().zip(unsharpened.px.iter().flatten()).map(|(a, b)| f64::from((a - b).abs())).sum::(); let [low, standard, high] = [RawSharpenAmount::Low, RawSharpenAmount::Standard, RawSharpenAmount::High].map(|amount| pixels(&open(RawSharpen::Screen, amount))); - let (low_distance, standard_distance, high_distance) = (distance(&low), distance(&standard), distance(&high)); + let (low_distance, standard_distance, high_distance) = (distance(&low.px), distance(&standard.px), distance(&high.px)); assert!(0.0 < low_distance && low_distance < standard_distance && standard_distance < high_distance); let mut previous = off; previous.execute("filter.cameraRaw", json!({"sharpenAmount":25.0,"sharpenRadius":1.0})).unwrap(); - assert_eq!(standard, pixels(&previous)); + assert_eq!(standard.px.as_slice(), pixels(&previous).px.as_slice()); } From 9123df29fc34325b5d69da95020c5dd35359bca2 Mon Sep 17 00:00:00 2001 From: yoriswind Date: Tue, 1 Dec 2026 18:13:24 -0800 Subject: [PATCH 64/81] Check the sampler marker at its painted pixel index --- crates/ui-egui/src/panels/info_color_samplers_toggle_tests.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/panels/info_color_samplers_toggle_tests.rs b/crates/ui-egui/src/panels/info_color_samplers_toggle_tests.rs index 7ed63c8dfac..dff51d0749c 100644 --- a/crates/ui-egui/src/panels/info_color_samplers_toggle_tests.rs +++ b/crates/ui-egui/src/panels/info_color_samplers_toggle_tests.rs @@ -105,7 +105,8 @@ fn sampler_mark(shape: &Shape, at: Pos2) -> bool { } fn shows_marker(h: &AppHarness) -> bool { - let at = to_screen(h.state(), POINT); + // The engine stores the pixel centre, but the shared ColorSamplers collection uses the pixel index to paint. + let at = to_screen(h.state(), POINT.map(f64::floor)); h.output().shapes.iter().any(|clipped| clipped.clip_rect.contains(at) && sampler_mark(&clipped.shape, at)) } From e23e6cfb3397775962e1f324151b66cada219541 Mon Sep 17 00:00:00 2001 From: yoriswind Date: Tue, 1 Dec 2026 18:29:26 -0800 Subject: [PATCH 65/81] Use the Ruler while Measurement Scale is open --- crates/ui-egui/src/canvas/document_display.rs | 2 +- crates/ui-egui/src/canvas/tools/mod.rs | 16 ++- crates/ui-egui/src/dialogs.rs | 6 +- crates/ui-egui/src/tools/analysis/canvas.rs | 93 +++++++++++- crates/ui-egui/src/tools/analysis/dialogs.rs | 103 ++++++++++++-- .../analysis/scale_ruler_while_open_tests.rs | 134 ++++++++++++++++++ 6 files changed, 334 insertions(+), 20 deletions(-) create mode 100644 crates/ui-egui/src/tools/analysis/scale_ruler_while_open_tests.rs diff --git a/crates/ui-egui/src/canvas/document_display.rs b/crates/ui-egui/src/canvas/document_display.rs index e0c6df2c2ec..9b73c016702 100644 --- a/crates/ui-egui/src/canvas/document_display.rs +++ b/crates/ui-egui/src/canvas/document_display.rs @@ -618,7 +618,7 @@ fn canvas_controls( crate::slice_ui::canvas_controls(ui, app, rect); crate::symmetry_ui::canvas_controls(ui, app, rect); crate::perspective_crop_ui::body(app, ui, rect); - crate::analysis::canvas::body(app, ui, rect); + crate::analysis::canvas::body(app, ui, rect, host); // The frame is the active document's: another document on screen shows none (#18368). if primary && app.session.active_index() == Some(host.idx) { reported.crop = super::tools::crop::show_frame(app, ui, rect); diff --git a/crates/ui-egui/src/canvas/tools/mod.rs b/crates/ui-egui/src/canvas/tools/mod.rs index 9090424e211..0f9031be618 100644 --- a/crates/ui-egui/src/canvas/tools/mod.rs +++ b/crates/ui-egui/src/canvas/tools/mod.rs @@ -514,6 +514,7 @@ fn with_rig( ) -> R { let tool = app.ui.tool; let fam = family(tool); + let scale_ruler = crate::analysis::canvas::scale_ruler_on(app, host); let in_gesture = ToolHost::in_gesture(ctx, host.canvas_id()); // Tools that own state the app lends nobody are built before the scope takes the app. The Crop tool edits the active // document's frame, so only that document's canvas runs it (#18368); a gesture keeps it to its cancel. @@ -528,7 +529,7 @@ fn with_rig( // gesture another pick began leaves it in the app, where that tool edits it: the Frame tool's press on an image // handle opens the session and its drag moves the box. let transform_open = app.ui.transform.is_some(); - let lends_transform = stand_ins && (!in_gesture || tools.gesture_pick == GesturePick::Transform); + let lends_transform = stand_ins && !scale_ruler && (!in_gesture || tools.gesture_pick == GesturePick::Transform); let free_transform = if lends_transform { app.ui.transform.take() } else { None }; let BodyShown { crop: crop_shown, transform_snapped, .. } = shown; let mut transform = free_transform.as_ref().map(|session| crate::transform_tool::canvas_tool(session, transform_snapped)); @@ -539,7 +540,7 @@ fn with_rig( (Some(tool), Some(run)) => Some(crop::pass(tool, run, ctx, crop_shown)), _ => None, }; - let command_wanted = stand_ins && !transform_open && takes_command_stand_in(tool); + let command_wanted = stand_ins && !scale_ruler && !transform_open && takes_command_stand_in(tool); let alt_wanted = stand_ins && !transform_open && super::cursor_policy::alt_eyedropper(tool); let source_wanted = stand_ins && matches!(tool, Tool::CloneStamp | Tool::Healing); @@ -653,7 +654,7 @@ fn with_rig( alt_t = Some(retouch::source_tool(&scope, state, host)); } let alt_stand_in = alt_t.is_some(); - let mut pre = Preflight { scope: &scope, inner: selected, tool, dialog: dialog_picked, outline_open, alt_stand_in }; + let mut pre = Preflight { scope: &scope, inner: selected, tool, dialog: dialog_picked || scale_ruler, outline_open, alt_stand_in }; let mut tool_host = ToolHost::new().momentary(momentary); if let Some(mover) = command_t.as_mut() { tool_host = tool_host.stand_in(StandInKey::Command, dynamic(mover)); @@ -806,6 +807,15 @@ pub(crate) fn tool_changed(app: &mut PhotocraftApp, ctx: &egui::Context, host: C app.canvas_tools = tools; } +/// Cancels the gesture that belongs to `doc`, using its original canvas even if the document has closed. +pub(crate) fn cancel_document_gesture(app: &mut PhotocraftApp, ctx: &egui::Context, doc: photocraft_doc::DocId) { + let Some((_, host)) = app.canvas_tools.gesture_on.filter(|(owner, _)| *owner == doc.0) else { return }; + app.canvas_tools.gesture_on = None; + if ToolHost::in_gesture(ctx, host.canvas_id()) { + tool_changed(app, ctx, host); + } +} + /// Whether the active document's own canvas has a gesture running, for the readers with no `Context` at hand. pub(crate) fn in_gesture(app: &PhotocraftApp) -> bool { let Some(idx) = app.session.active_index() else { return false }; diff --git a/crates/ui-egui/src/dialogs.rs b/crates/ui-egui/src/dialogs.rs index c6488558ceb..54e009bd0a4 100644 --- a/crates/ui-egui/src/dialogs.rs +++ b/crates/ui-egui/src/dialogs.rs @@ -132,7 +132,11 @@ pub(crate) mod params { check: Some(crate::canvas_tool_menu::pen_dialogs::check), ..ParamFamily::new(crate::canvas_tool_menu::pen_dialogs::owns, crate::canvas_tool_menu::pen_dialogs::run) }, - ParamFamily::new(crate::analysis::dialogs::owns, crate::analysis::dialogs::run), + ParamFamily { + cancel: Some(crate::analysis::dialogs::cancel), + document: Some(crate::analysis::dialogs::document), + ..ParamFamily::new(crate::analysis::dialogs::owns, crate::analysis::dialogs::run) + }, ParamFamily::new(crate::layers_panel_ui::owns, crate::layers_panel_ui::run), ParamFamily { check: Some(image_processor_ui::check), diff --git a/crates/ui-egui/src/tools/analysis/canvas.rs b/crates/ui-egui/src/tools/analysis/canvas.rs index 1c9953d725a..57995867ee1 100644 --- a/crates/ui-egui/src/tools/analysis/canvas.rs +++ b/crates/ui-egui/src/tools/analysis/canvas.rs @@ -9,10 +9,11 @@ use craft::behavior::{CancelReason, CountMark, Cursor, CursorBadge, CursorIcon, use craft::color_ui::ui::{ColorSamplerMarks, ColorSamplerTool, ColorSamplers, SamplerEvent}; use craft::draw::ui::{RulerLine, RulerTool}; use craft::ui::canvas::{CanvasTool, NoTool, ToolAction, ToolClaims, ToolContext, ToolHostResponse, ToolKey, ToolPath, ToolPointer, canvas_space}; -use craft::ui::contract::{Access, Common, Component, Cx, MeasureCx, PaintUi, Props as _, Role, Show as _}; +use craft::ui::contract::{Access, CanvasGesture, Common, Component, Cx, MeasureCx, PaintUi, Props as _, Role, Show as _}; use craft::ui::fonts::FontRef; use craft::ui::primitives::{DocRun, DocText, Draw, PaintShape, StrokeWidth}; use craft::ui::runtime::env::Label; +use craft::ui::runtime::sampler; use craft::ui::style::{ComponentStyle, DataColor, StyleColor, StyleCx}; use egui::{Color32, CornerRadius, Pos2, Rect, Response, Vec2, vec2}; use serde_json::json; @@ -26,6 +27,7 @@ use crate::state::Tool; /// The family's state between passes, kept in `CanvasTools::analysis`. pub(crate) struct AnalysisTools { ruler: RulerTool, + scale: ScaleRuler, sampler: ColorSamplerTool, /// The document's points as the framework's collection, which the sampler pass borrows. It is rebuilt from the /// document at every pass (`tool`); it is storage for that borrow, not state. @@ -38,6 +40,7 @@ impl Default for AnalysisTools { fn default() -> Self { Self { ruler: RulerTool::new(), + scale: ScaleRuler::default(), sampler: ColorSamplerTool::new(), samplers: ColorSamplers::new(), count: CountTool::default(), @@ -46,6 +49,72 @@ impl Default for AnalysisTools { } } +/// The scale form's temporary line and the draft value as they stood before a drag. Neither touches the document. +#[derive(Default)] +struct ScaleRuler { + tool: RulerTool, + line: Option, + before: Option<(Option, f64)>, +} + +impl ScaleRuler { + fn restore_drag(&mut self, app: &mut PhotocraftApp) { + if let Some((line, length)) = self.before.take() { + self.line = line; + super::dialogs::set_pixel_length(app, length); + } + } + + fn set_line(&mut self, app: &mut PhotocraftApp, line: Option) { + self.line = line; + if let Some(line) = line { + let length = line.start.distance(line.end); + if length.is_finite() && length > 0.0 { + super::dialogs::set_pixel_length(app, length.round().clamp(1.0, super::dialogs::MAX_PIXEL_LENGTH)); + } + } + } + + fn drain(&mut self, app: &mut PhotocraftApp) { + if !super::dialogs::measuring(app) { + if self.before.is_some() { + self.restore_drag(app); + self.tool = RulerTool::new(); + } + return; + } + for event in self.tool.take_events() { + match event { + EditEvent::Begin { .. } => { + self.before = super::dialogs::pixel_length(app).map(|length| (self.line, length)); + } + EditEvent::Update { value, .. } => self.set_line(app, value), + EditEvent::Commit { after, .. } => { + if self.before.is_some_and(|(line, _)| after == line && self.line != after) { + // A click or short release kept the preceding line. Keep the draft length too. + self.restore_drag(app); + } else { + self.set_line(app, after); + self.before = None; + } + } + EditEvent::Set { after, .. } => self.set_line(app, after), + EditEvent::Cancel { .. } => self.restore_drag(app), + _ => {} + } + } + } +} + +/// Whether this exact canvas may run the temporary scale ruler and paint its line. +pub(crate) fn scale_ruler_on(app: &PhotocraftApp, host: CanvasHost) -> bool { + app.session.active_index() == Some(host.idx) && host.is_primary(app) && super::dialogs::measuring(app) +} + +pub(super) fn clear_scale_ruler(app: &mut PhotocraftApp) { + app.canvas_tools.analysis.scale = ScaleRuler::default(); +} + /// The document's Color Sampler points as the framework's collection, with the document's size in pixels. The one /// place the document's list becomes `ColorSamplers`. pub(super) fn samplers_of(app: &PhotocraftApp) -> Option<(ColorSamplers, [u32; 2])> { @@ -68,10 +137,15 @@ fn ruler_line(app: &PhotocraftApp) -> Option { } /// The tool of `Tool::{Ruler, ColorSampler, Count, Note}` for one pass. -pub(crate) fn tool<'a>(scope: &'a ToolScope<'a>, state: &'a mut AnalysisTools, _host: CanvasHost) -> FamilyTool<'a> { +pub(crate) fn tool<'a>(scope: &'a ToolScope<'a>, state: &'a mut AnalysisTools, host: CanvasHost) -> FamilyTool<'a> { let tool = scope.with_app(|app| app.ui.tool); - let AnalysisTools { ruler, sampler, samplers, count, note } = state; + let AnalysisTools { ruler, scale, sampler, samplers, count, note } = state; match tool { + Tool::Ruler if scope.with_app(|app| scale_ruler_on(app, host)) => { + // The modal's ParamDialog keeps this canvas open for navigation. Pass the ruler's primary drag too. + sampler::pass_tool_gesture(scope.ctx(), host.canvas_id(), CanvasGesture::PRIMARY); + Box::new(scale.tool.pass(scale.line)) + } Tool::Ruler => { let line = scope.with_app(|app| ruler_line(app)); Box::new(ruler.pass(line)) @@ -97,6 +171,7 @@ pub(crate) fn tool<'a>(scope: &'a ToolScope<'a>, state: &'a mut AnalysisTools, _ /// Turns the events the tools reported into engine commands, in order. pub(crate) fn drain(app: &mut PhotocraftApp, state: &mut AnalysisTools, _response: &ToolHostResponse) { + state.scale.drain(app); for event in state.ruler.take_events() { match event { // A drag's updates are not applied: the pass shows the running line from the tool's own proposal, and the @@ -220,7 +295,8 @@ fn pixel_centre(at: [f64; 2]) -> [f64; 2] { /// The ruler line, the sampler marks, the count markers and the note cards over the document, in the canvas body over /// `rect`. The marks show with every tool; the line with its handles only with the Ruler. View › Extras off hides the /// line (View › Show has no Ruler entry, #11987) and the sampler marks, whose points and Info readouts stay (#11741). -pub(crate) fn body(app: &mut PhotocraftApp, ui: &mut egui::Ui, rect: Rect) { +pub(crate) fn body(app: &mut PhotocraftApp, ui: &mut egui::Ui, rect: Rect, host: CanvasHost) { + let scale = scale_ruler_on(app, host); let view = &app.ui.view; let (show_count, show_notes, extras) = (view.shows(view.show.count), view.shows(view.show.notes), view.extras); let line = ruler_line(app).filter(|_| extras); @@ -250,7 +326,10 @@ pub(crate) fn body(app: &mut PhotocraftApp, ui: &mut egui::Ui, rect: Rect) { }; let selected = app.ui.analysis.note_selected; let tools = &mut app.canvas_tools.analysis; - if app.ui.tool == Tool::Ruler { + if scale { + let scale = &mut tools.scale; + scale.tool.pass(scale.line.filter(|_| extras)).show_line(ui, rect); + } else if app.ui.tool == Tool::Ruler { tools.ruler.pass(line).show_line(ui, rect); } else if let Some(line) = line { // The line and its arm stay drawn under every tool (#11987); only the Ruler tool has handles on them. @@ -645,3 +724,7 @@ impl Component for NoteCards { cx.response.clone() } } + +#[cfg(test)] +#[path = "scale_ruler_while_open_tests.rs"] +mod scale_ruler_while_open_tests; diff --git a/crates/ui-egui/src/tools/analysis/dialogs.rs b/crates/ui-egui/src/tools/analysis/dialogs.rs index c4e96430ee7..d6bb2d27228 100644 --- a/crates/ui-egui/src/tools/analysis/dialogs.rs +++ b/crates/ui-egui/src/tools/analysis/dialogs.rs @@ -1,19 +1,22 @@ //! The Set Measurement Scale, Select Data Points and Place Scale Marker dialogs: parameter forms hosted on the dialog //! host, answered through the `ParamFamily` row of `dialogs.rs`. +use craft::behavior::IconId; use craft::ui::choice::Checkbox; use craft::ui::contract::{Bind, Props as _, Scroll, Show as _, ShowContainer as _}; -use craft::ui::dialog::DialogId; -use craft::ui::display::{Divider, Elide, Text}; -use craft::ui::layout_components::Stack; -use craft::ui::patterns::form_dialogs::{DialogFields, Param, ParamDialog, ParamKind, ParamResult}; +use craft::ui::dialog::{DialogId, dialog_id}; +use craft::ui::display::{Divider, Elide, Icon, Text}; +use craft::ui::layout_components::{Row, Stack}; +use craft::ui::patterns::form_dialogs::{DialogFields, FieldValue, HostedParamDialog, Param, ParamDialog, ParamKind, ParamResult}; +use craft::ui::primitives::IconSpec; use craft::ui::runtime::env::{Env, Label, UnitKind}; -use photocraft_doc::Document; +use photocraft_doc::{DocId, Document}; use photocraft_engine::analysis_cmds; use serde_json::{Value, json}; use crate::PhotocraftApp; use crate::dialogs::params; +use crate::state::Tool; /// The three analysis dialogs. #[derive(Clone, Copy, Debug, PartialEq, Eq)] @@ -58,9 +61,21 @@ fn suggested_length(d: &Document) -> f64 { pub(crate) fn open(app: &mut PhotocraftApp, kind: Kind) -> Result { let no_document = || tl!("No document is open.").to_owned(); let mut fields = DialogFields::new(); + let mut captured = Value::Null; match kind { Kind::Scale => { + let id = scale_id(); + if app.framework.dialogs.get_by_id::(id).is_some() { + return Ok(id); + } let doc = app.session.active().ok_or_else(no_document)?.doc.clone(); + let previous = crate::tool_memory::selected(app); + captured = json!({"document": doc.id.0, "previousTool": previous}); + let ctx = app.ctx().clone(); + crate::canvas::tools::cancel_document_gesture(app, &ctx, doc.id); + app.ui.spring = None; + app.stylus.tool_before_eraser = None; + app.ui.tool = Tool::Ruler; let sc = &doc.measurement.scale; fields.set("preset", "custom"); fields.set("pixelLength", sc.pixel_length); @@ -82,7 +97,53 @@ pub(crate) fn open(app: &mut PhotocraftApp, kind: Kind) -> Result DialogId { + dialog_id(Kind::Scale.command()) +} + +/// The document bound to the scale form, for the host's document-close and canvas-routing checks. +pub(crate) fn document(captured: &Value) -> Option { + captured.get("document").and_then(Value::as_u64).map(DocId) +} + +/// The top scale dialog can measure only the active document it opened on. +pub(super) fn measuring(app: &PhotocraftApp) -> bool { + app.framework.dialogs.stack().top() == Some(scale_id()) + && app.ui.tool == Tool::Ruler + && app.framework.captured.get(Kind::Scale.command()).and_then(document).is_some_and(|id| app.session.active().is_some_and(|st| st.doc.id == id)) +} + +pub(super) fn pixel_length(app: &PhotocraftApp) -> Option { + app.framework.dialogs.get_by_id::(scale_id())?.fields().number("pixelLength") +} + +pub(super) fn set_pixel_length(app: &mut PhotocraftApp, length: f64) { + if let Some(form) = app.framework.dialogs.get_mut_by_id::(scale_id()) + && form.fields().number("pixelLength") != Some(length) + { + form.set_field("pixelLength", FieldValue::Number(length)); + } +} + +/// OK and every cancellation path give the canvas and previous tool back together. +fn finish_scale(app: &mut PhotocraftApp, ctx: &egui::Context, captured: &Value) { + if let Some(doc) = document(captured) { + crate::canvas::tools::cancel_document_gesture(app, ctx, doc); + } + super::canvas::clear_scale_ruler(app); + if let Some(previous) = captured.get("previousTool").and_then(|tool| serde_json::from_value(tool.clone()).ok()) { + app.ui.tool = previous; + } +} + +pub(crate) fn cancel(app: &mut PhotocraftApp, ctx: &egui::Context, id: DialogId) { + if id == scale_id() { + let captured = params::captured(app, Kind::Scale.command()); + finish_scale(app, ctx, &captured); + } } /// Whether `key` is the key of one of these dialogs. @@ -109,10 +170,20 @@ pub(crate) fn command(kind: Kind, f: &DialogFields) -> Option<(&'static str, Val } /// OK: runs the dialog's command; an engine refusal goes to the status line. -pub(crate) fn run(app: &mut PhotocraftApp, _ctx: &egui::Context, result: ParamResult) { +pub(crate) fn run(app: &mut PhotocraftApp, ctx: &egui::Context, result: ParamResult) { let Some(kind) = Kind::of(&result.key) else { return }; - let Some((id, params)) = command(kind, &result.fields) else { return }; - if let Err(error) = app.run(id, params) + let Some((id, values)) = command(kind, &result.fields) else { return }; + let outcome = if kind == Kind::Scale { + let captured = params::captured(app, id); + finish_scale(app, ctx, &captured); + match document(&captured) { + Some(doc) => app.with_document(doc, |app| app.run(id, values)), + None => Err(tl!("No document is open.").to_owned()), + } + } else { + app.run(id, values) + }; + if let Err(error) = outcome && error != "cancelled" { app.ui.status = error; @@ -123,6 +194,8 @@ pub(crate) fn run(app: &mut PhotocraftApp, _ctx: &egui::Context, result: ParamRe /// The most characters of the scale readout that set its width: about the width of the dialog's fields. const READOUT_CHARS: usize = 46; +pub(super) const MAX_PIXEL_LENGTH: f64 = 1e7; + /// The Measurement Scale readout: ` pixel(s) = `, with `decimal` as the decimal mark, /// as the reference shows it while the values are typed (#17414). The Default preset reads 1 pixel(s) = 1 pixels. pub(crate) fn scale_readout(f: &DialogFields, decimal: char) -> String { @@ -135,6 +208,15 @@ pub(crate) fn scale_readout(f: &DialogFields, decimal: char) -> String { format!("{} pixel(s) = {} {units}", mark(pixels.to_string()), mark(format!("{length:.4}"))) } +fn scale_ruler_note(ui: &mut egui::Ui) { + Row::new().show(ui, |ui, _| { + Icon::new(IconSpec::svg(IconId::new("info"))).show(ui); + let note = tl!("The Ruler tool has been activated while this dialog is open. You may use it to measure the pixel length for use in your scale."); + let sample: String = note.chars().take(READOUT_CHARS).collect(); + Text::new(note).sample(Label::from(sample)).show(ui); + }); +} + fn options(pairs: &[(&str, &str)]) -> Vec<(String, Label)> { pairs.iter().map(|(key, name)| ((*key).to_owned(), Label::from((*name).to_owned()))).collect() } @@ -147,7 +229,7 @@ fn form(kind: Kind, fields: &mut DialogFields) -> ParamDialog<'_> { let rows = vec![ Param::new("preset", tl!("Presets:"), ParamKind::choice(options(&[("custom", tl!("Custom"))]), Some("custom".into()))).not_remembered(), // The dialog opens on its first text-entry field and selects its value. - Param::new("pixelLength", tl!("Pixel Length:"), ParamKind::number(Some(0.001), Some(1e7), 1.0, 1.0, 4)).not_remembered(), + Param::new("pixelLength", tl!("Pixel Length:"), ParamKind::number(Some(0.001), Some(MAX_PIXEL_LENGTH), 1.0, 1.0, 4)).not_remembered(), Param::new("logicalLength", tl!("Logical Length:"), ParamKind::number(Some(0.0001), Some(1e7), 1.0, 1.0, 4)).not_remembered(), Param::new("units", tl!("Logical Units:"), ParamKind::text("pixels")).not_remembered(), ]; @@ -159,6 +241,7 @@ fn form(kind: Kind, fields: &mut DialogFields) -> ParamDialog<'_> { // and long units are cut with "…" instead of widening the dialog. let sample: String = text.chars().take(READOUT_CHARS).collect(); Text::new(Label::from(text)).elide(Elide::End).sample(Label::from(sample)).show(ui); + scale_ruler_note(ui); }) } Kind::DataPoints => { diff --git a/crates/ui-egui/src/tools/analysis/scale_ruler_while_open_tests.rs b/crates/ui-egui/src/tools/analysis/scale_ruler_while_open_tests.rs new file mode 100644 index 00000000000..7ba50a15ca5 --- /dev/null +++ b/crates/ui-egui/src/tools/analysis/scale_ruler_while_open_tests.rs @@ -0,0 +1,134 @@ +//! #17415: the top Measurement Scale form keeps keyboard focus while a real Ruler drag edits its pixel length. +use craft::ui::patterns::form_dialogs::{DialogFields, HostedParamDialog}; +use egui::accesskit::Role; +use egui::{Key, Modifiers, PointerButton, Pos2, Rect}; +use egui_kittest::Harness; +use egui_kittest::kittest::{NodeT as _, Queryable as _}; +use serde_json::json; + +use super::super::dialogs::Kind; +use super::{CanvasHost, scale_ruler_on}; +use crate::PhotocraftApp; +use crate::state::Tool; + +type H = Harness<'static, Box>; +const COMMAND: &str = "image.analysis.setMeasurementScale"; +const NOTE: &str = "The Ruler tool has been activated while this dialog is open. You may use it to measure the pixel length for use in your scale."; + +fn fixture(tool: Tool) -> H { + let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default()); + app.run("file.new", json!({"width": 640, "height": 560})).unwrap(); + app.run(COMMAND, json!({"preset": "custom", "pixelLength": 42, "logicalLength": 3.5, "units": "cm"})).unwrap(); + app.sync_views(); + app.ui.extras.rulers = false; + app.ui.tool = tool; + let mut h = Harness::builder().with_context(app.ctx().clone()).with_size(egui::vec2(1600.0, 1000.0)).with_max_steps(64).build_eframe(move |_cc| app); + h.run_steps(4); + let view = &mut h.state_mut().ui.views[0]; + view.zoom = 1.0; + view.center = [320.0, 280.0]; + view.clear_pending(); + h.run_steps(2); + h +} + +fn open(h: &mut H) { + let ctx = h.ctx.clone(); + crate::menus::invoke(h.state_mut(), &ctx, COMMAND, json!({})).unwrap(); + h.run_steps(4); +} + +fn fields(h: &H) -> &DialogFields { + h.state().framework.dialogs.get_by_id::(craft::ui::dialog::dialog_id(COMMAND)).expect("Measurement Scale is open").fields() +} + +fn length_has_focus(h: &H) -> bool { + h.query_all_by_role(Role::SpinButton).any(|n| n.is_focused() && n.accesskit_node().label().is_some_and(|s| s.trim_end_matches(':') == "Pixel Length")) +} + +/// Finds the same 200 px drag in an exposed part of the bound image, away from the centred form. +fn points(h: &H) -> [Pos2; 2] { + let form = h + .query_all_by_role(Role::Window) + .chain(h.query_all_by_role(Role::Dialog)) + .find(|n| n.accesskit_node().label().as_deref() == Some("Measurement Scale")) + .expect("the form's window") + .rect(); + let canvas = crate::canvas::document_display::active_view(h.state()).expect("document canvas").rect; + [30.0, 95.0, 465.0, 530.0] + .into_iter() + .map(|y| [100.0, 300.0].map(|x| crate::canvas::testing::to_screen(h.state(), [x, y]))) + .find(|[a, b]| canvas.contains(*a) && canvas.contains(*b) && !form.intersects(Rect::from_two_pos(*a, *b).expand(3.0))) + .expect("an exposed 200 px span of the image") +} + +fn button(h: &mut H, pos: Pos2, pressed: bool) { + h.event(egui::Event::PointerButton { pos, button: PointerButton::Primary, pressed, modifiers: Modifiers::NONE }); + h.run_steps(2); +} + +fn drag(h: &mut H, [start, end]: [Pos2; 2]) { + h.event(egui::Event::PointerMoved(start)); + h.run_steps(2); + button(h, start, true); + h.event(egui::Event::PointerMoved(end)); + h.run_steps(3); +} + +#[test] +fn an_exposed_drag_updates_only_pixel_length_and_ok_restores_the_tool() { + let mut h = fixture(Tool::Move); + h.state_mut().run("image.analysis.rulerTool", json!({"start": [20, 30], "end": [60, 30]})).unwrap(); + let original = h.state().session.active().unwrap().doc.measurement.ruler; + open(&mut h); + assert_eq!(h.state().ui.tool, Tool::Ruler); + assert!(length_has_focus(&h)); + assert!(h.query_all_by_role(Role::Label).any(|n| n.accesskit_node().value().or_else(|| n.accesskit_node().label()).as_deref() == Some(NOTE))); + let primary = CanvasHost::primary(h.state(), 0); + assert!(scale_ruler_on(h.state(), primary)); + assert!(!scale_ruler_on(h.state(), CanvasHost { idx: 0, window: Some(99) })); + let span = points(&h); + drag(&mut h, span); + let f = fields(&h); + assert_eq!((f.number("pixelLength"), f.number("logicalLength"), f.text("units")), (Some(200.0), Some(3.5), Some("cm"))); + assert!(length_has_focus(&h), "the admitted canvas press leaves keyboard focus in the form"); + assert!(h.query_all_by_role(Role::Label).any(|n| { + n.accesskit_node().value().or_else(|| n.accesskit_node().label()).is_some_and(|t| t.starts_with("200 pixel(s) = ") && t.ends_with(" cm")) + })); + button(&mut h, span[1], false); + assert!(h.state().canvas_tools.analysis.scale.line.is_some(), "the temporary line stays while the form is open"); + h.get_by_role_and_label(Role::Button, "OK").click(); + h.run_steps(4); + assert!(!h.state().dialog_open()); + assert_eq!(h.state().ui.tool, Tool::Move); + assert!(h.state().canvas_tools.analysis.scale.line.is_none()); + let measurement = &h.state().session.active().unwrap().doc.measurement; + assert_eq!(measurement.ruler, original); + assert_eq!((measurement.scale.pixel_length, measurement.scale.logical_length, measurement.scale.units.as_str()), (200.0, 3.5, "cm")); +} + +#[test] +fn a_nested_prompt_blocks_measurement_and_escape_discards_the_scale_draft() { + let mut h = fixture(Tool::Brush); + open(&mut h); + let span = points(&h); + let alert = crate::dialogs::alerts::alert(h.state_mut(), "Test prompt over Measurement Scale"); + h.run_steps(4); + drag(&mut h, span); + button(&mut h, span[1], false); + assert_eq!(fields(&h).number("pixelLength"), Some(42.0)); + let ctx = h.ctx.clone(); + assert!(h.state_mut().framework.dialogs.cancel_by_id(&ctx, alert)); + h.run_steps(4); + drag(&mut h, span); + assert_eq!(fields(&h).number("pixelLength"), Some(200.0)); + h.key_press(Key::Escape); + h.run_steps(4); + button(&mut h, span[1], false); + assert!(!h.state().dialog_open()); + assert_eq!(h.state().ui.tool, Tool::Brush); + assert!(h.state().canvas_tools.analysis.scale.line.is_none()); + let measurement = &h.state().session.active().unwrap().doc.measurement; + assert!(measurement.ruler.is_none()); + assert_eq!(measurement.scale.pixel_length, 42.0); +} From 6c88ac568f8a9faca1d4d138b9b85806c98db1cb Mon Sep 17 00:00:00 2001 From: yoriswind Date: Tue, 1 Dec 2026 18:40:58 -0800 Subject: [PATCH 66/81] Use the Info panel menu button in the sampler fixture --- .../info_color_samplers_toggle_tests.rs | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/crates/ui-egui/src/panels/info_color_samplers_toggle_tests.rs b/crates/ui-egui/src/panels/info_color_samplers_toggle_tests.rs index dff51d0749c..d9ed6fb3e94 100644 --- a/crates/ui-egui/src/panels/info_color_samplers_toggle_tests.rs +++ b/crates/ui-egui/src/panels/info_color_samplers_toggle_tests.rs @@ -85,14 +85,20 @@ fn color_samplers_toggle_is_session_wide_and_requires_points_in_the_active_docum assert_eq!(sampler_rows(&mut app).len(), 1); } -fn open_menu(h: &mut AppHarness) { - let at = h.get_by_role_and_label(Role::Tab, "Info").rect().center(); +fn click(h: &mut AppHarness, at: Pos2) { h.event(Event::PointerMoved(at)); h.run_steps(1); for pressed in [true, false] { - h.event(Event::PointerButton { pos: at, button: PointerButton::Secondary, pressed, modifiers: Modifiers::NONE }); - h.run_steps(2); + h.event(Event::PointerButton { pos: at, button: PointerButton::Primary, pressed, modifiers: Modifiers::NONE }); + h.run_steps(1); } + h.run_steps(4); +} + +fn open_menu(h: &mut AppHarness) { + let info = h.get_by_role_and_label(Role::TabPanel, "Info"); + let at = info.get_by_role_and_label(Role::Button, "Panel Menu").rect().center(); + click(h, at); } fn sampler_mark(shape: &Shape, at: Pos2) -> bool { @@ -125,15 +131,16 @@ fn the_info_flyout_hides_and_restores_the_readout_and_canvas_marker_without_hist assert!(shows_marker(&h)); assert_eq!(sampler_rows(h.state_mut()).len(), 1); + let stored = h.state_mut().run("view.colorSamplers.list", json!({})).unwrap(); + let active = h.state().session.active().unwrap(); + let (revision, history) = (active.revision, active.history.past_len()); + open_menu(&mut h); let row = h.get_by_role_and_label(Role::MenuItemCheckBox, MENU_LABEL); assert_eq!(row.accesskit_node().toggled(), Some(Toggled::True)); assert!(!row.accesskit_node().is_disabled()); - let stored = h.state_mut().run("view.colorSamplers.list", json!({})).unwrap(); - let active = h.state().session.active().unwrap(); - let (revision, history) = (active.revision, active.history.past_len()); - h.get_by_role_and_label(Role::MenuItemCheckBox, MENU_LABEL).click(); - h.run_steps(4); + let at = row.rect().center(); + click(&mut h, at); assert!(!shows_marker(&h)); assert!(sampler_rows(h.state_mut()).is_empty()); @@ -144,8 +151,8 @@ fn the_info_flyout_hides_and_restores_the_readout_and_canvas_marker_without_hist open_menu(&mut h); let row = h.get_by_role_and_label(Role::MenuItemCheckBox, MENU_LABEL); assert_eq!(row.accesskit_node().toggled(), Some(Toggled::False)); - row.click(); - h.run_steps(4); + let at = row.rect().center(); + click(&mut h, at); assert!(shows_marker(&h)); assert_eq!(sampler_rows(h.state_mut()).len(), 1); From 8fb77b763495e86beca7c9531ad5df7d77621726 Mon Sep 17 00:00:00 2001 From: yoriswind Date: Tue, 1 Dec 2026 18:44:25 -0800 Subject: [PATCH 67/81] Remove unused Measurement Scale test import --- .../ui-egui/src/tools/analysis/scale_ruler_while_open_tests.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/ui-egui/src/tools/analysis/scale_ruler_while_open_tests.rs b/crates/ui-egui/src/tools/analysis/scale_ruler_while_open_tests.rs index 7ba50a15ca5..2f605a70dbf 100644 --- a/crates/ui-egui/src/tools/analysis/scale_ruler_while_open_tests.rs +++ b/crates/ui-egui/src/tools/analysis/scale_ruler_while_open_tests.rs @@ -6,7 +6,6 @@ use egui_kittest::Harness; use egui_kittest::kittest::{NodeT as _, Queryable as _}; use serde_json::json; -use super::super::dialogs::Kind; use super::{CanvasHost, scale_ruler_on}; use crate::PhotocraftApp; use crate::state::Tool; From 4f1866bd000f214817f456cfb34a5f46b7958798 Mon Sep 17 00:00:00 2001 From: dholzric Date: Tue, 1 Dec 2026 20:44:49 -0600 Subject: [PATCH 68/81] test: assert no gradient mask alert before the release (#18637) Co-Authored-By: Claude Opus 5.5 --- .../src/tools/gradient_mask_target_alerts_tests.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/tools/gradient_mask_target_alerts_tests.rs b/crates/ui-egui/src/tools/gradient_mask_target_alerts_tests.rs index 863555bd700..35f5f63fc17 100644 --- a/crates/ui-egui/src/tools/gradient_mask_target_alerts_tests.rs +++ b/crates/ui-egui/src/tools/gradient_mask_target_alerts_tests.rs @@ -23,11 +23,15 @@ fn app() -> Box { app } +/// Drags across the mask; no alert may open before the release. fn drag(app: &mut PhotocraftApp) { let none = egui::Modifiers::NONE; tool_event(app, ToolEvent::Down { x: 20.0, y: 60.0, pressure: 1.0 }, none); - tool_event(app, ToolEvent::Move { x: 100.0, y: 60.0, pressure: 1.0 }, none); - tool_event(app, ToolEvent::Move { x: 180.0, y: 60.0, pressure: 1.0 }, none); + assert!(alerts(app).is_empty(), "no alert on the press: {:?}", alerts(app)); + for x in [100.0, 180.0] { + tool_event(app, ToolEvent::Move { x, y: 60.0, pressure: 1.0 }, none); + assert!(alerts(app).is_empty(), "no alert while dragging: {:?}", alerts(app)); + } tool_event(app, ToolEvent::Up { x: 180.0, y: 60.0 }, none); } From 55be3688f67f9b4e5c931391b63c5372373341bf Mon Sep 17 00:00:00 2001 From: ruchirguitar Date: Wed, 2 Dec 2026 08:28:13 +0530 Subject: [PATCH 69/81] Check that the Devanagari filter drops a known Latin-only family Counting rows also counted layer rows and passed for an empty list. Inter, the layer's font, is listed before the filter and gone after. --- crates/ui-egui/src/tools/type_tool/font_picker_tests.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/ui-egui/src/tools/type_tool/font_picker_tests.rs b/crates/ui-egui/src/tools/type_tool/font_picker_tests.rs index c9e87099eef..d2b06737823 100644 --- a/crates/ui-egui/src/tools/type_tool/font_picker_tests.rs +++ b/crates/ui-egui/src/tools/type_tool/font_picker_tests.rs @@ -235,7 +235,7 @@ fn hovering_a_font_adds_no_history_step_and_a_pick_adds_one() { } /// The toolbar's Script select offers the Indic scripts (#10996); picking Devanagari narrows the family list and is -/// kept as the pickers' filter. +/// kept as the pickers' filter. Fonts come from the host, so the test checks only the bundled Latin-only Inter. #[test] fn the_family_list_filters_by_an_indic_script() { let mut h = bar_harness(app_with_layer()); @@ -243,12 +243,12 @@ fn the_family_list_filters_by_an_indic_script() { assert_eq!(h.state().ui.font_filters.script, None, "no script filter at first"); field(&h).click(); h.run(); - let families = |h: &Harness<'static, Box>| h.query_all_by_role(Role::TreeItem).count(); - let before = families(&h); + let inter = |h: &Harness<'static, Box>| h.query_by_role_and_label(Role::TreeItem, "Inter").is_some(); + assert!(inter(&h), "the layer's Latin-only family is listed before the filter"); h.get_by_role_and_label(Role::ComboBox, "Script").click(); h.run(); h.get_by_label("Devanagari").click(); h.run(); assert_eq!(h.state().ui.font_filters.script, Some(craft::font_manager::picker::FontScript::Devanagari)); - assert!(families(&h) < before, "the Latin-only families leave the list ({} of {before} left)", families(&h)); + assert!(!inter(&h), "a Latin-only family leaves the Devanagari list"); } From 99deb3ac679cd45234411dbb45ae3f7369f8b916 Mon Sep 17 00:00:00 2001 From: kubuntugamer Date: Mon, 30 Nov 2026 19:38:04 -0600 Subject: [PATCH 70/81] Background Eraser: read the resize readout's Opacity row from the Tolerance The row was merged fixed at 50 %, the Tolerance after Reset Tool, before the measurement in #18053 arrived. Measured, it reads the tool's Tolerance at every value, 0 and 100 % included, and the drag leaves it there. Refs #18053 --- crates/ui-egui/src/tools/brush_resize.rs | 10 ++--- ...ize_background_eraser_opacity_row_tests.rs | 37 +++++++++++-------- 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/crates/ui-egui/src/tools/brush_resize.rs b/crates/ui-egui/src/tools/brush_resize.rs index e438f73a636..e97f396a86b 100644 --- a/crates/ui-egui/src/tools/brush_resize.rs +++ b/crates/ui-egui/src/tools/brush_resize.rs @@ -33,10 +33,6 @@ const OPACITY_TRAVEL: f32 = 200.0; const TOLERANCE_TRAVEL: f32 = 400.0; /// The overlay alpha of the preview tint. const TINT_ALPHA: u8 = 110; -/// The Background Eraser's third readout row: the reference shows "Opacity : 50 %" there, the -/// tool's Tolerance after Reset Tool and not an opacity the tool has (#18053). Unmeasured for other -/// Tolerance values, so the row stays at 50 until they are (#18053). -const BACKGROUND_ERASER_READOUT_OPACITY: f64 = 50.0; /// The brush resize drag of the painting tools, kept in `PhotocraftApp::brush_resize`. The painting tool takes it /// out of the app for each call, so its methods get the app as an argument. @@ -152,7 +148,8 @@ impl PaintResize { /// Asks for the diameter and level readout beside the pointer while a resize runs. `hud`, not `readout`: Show /// Transformation Values never hides it. The request lasts one pass, so the tool repeats it every pass. - /// The Background Eraser gets a third row, Opacity (#18053); so does Color Replacement, showing its Tolerance (#17760). + /// The Background Eraser gets a third row, Opacity, which reads the tool's Tolerance (#18053); so does Color + /// Replacement, showing its Tolerance (#17760). pub(crate) fn hud(&self, app: &PhotocraftApp, cx: &mut ToolContext<'_>) { if !self.resize.active() { return; @@ -162,8 +159,9 @@ impl PaintResize { let mut rows = self.resize.readout_rows(&cx.units(), &words); // The reference's third row is there beside a Hardness row; with "Vary Round Brush Hardness on HUD" off the // level row is already Opacity, and a second one would repeat it. + // The tool has no opacity: the row shows its Tolerance, at every value, 0 and 100 % included (#18053). if app.ui.tool == Tool::BackgroundEraser && varies_hardness(app) { - let opacity = cx.units().percent(BACKGROUND_ERASER_READOUT_OPACITY); + let opacity = cx.units().percent(f64::from(app.ui.tool_options.bg_tolerance)); rows.push((words.opacity.clone(), opacity)); } if levels_tolerance(app) && varies_hardness(app) { diff --git a/crates/ui-egui/src/tools/brush_resize_background_eraser_opacity_row_tests.rs b/crates/ui-egui/src/tools/brush_resize_background_eraser_opacity_row_tests.rs index 5551976bafc..d7c3f309e83 100644 --- a/crates/ui-egui/src/tools/brush_resize_background_eraser_opacity_row_tests.rs +++ b/crates/ui-egui/src/tools/brush_resize_background_eraser_opacity_row_tests.rs @@ -1,7 +1,8 @@ //! #18053: the Background Eraser's Ctrl+Alt+drag (Alt+right-drag) readout has a third row, -//! "Opacity : 50 %", after Diameter and Hardness, as the reference application does. The row does -//! not follow the drag or the tool's Tolerance (not measured), and the gesture still changes only -//! the diameter and the hardness, erases nothing and adds no history state. +//! "Opacity : 50 %", after Diameter and Hardness, as the reference application does. The tool has +//! no opacity: the row reads its Tolerance, at every value, and the drag never changes it. The +//! gesture still changes only the diameter and the hardness, erases nothing and adds no history +//! state. use serde_json::json; @@ -39,9 +40,9 @@ fn values(rows: &[(String, String)]) -> Vec<&str> { } /// Done when 1: after Reset Tool's brush, three rows in the order Diameter, Hardness, Opacity, and -/// the Opacity row reads 50 %. +/// the Opacity row reads the Tolerance, 50 % after Reset Tool. #[test] -fn the_background_eraser_readout_has_a_fifty_percent_opacity_row() { +fn the_background_eraser_readout_has_a_third_opacity_row() { let mut a = app(Tool::BackgroundEraser, 1.0); let got = readout(&mut a, ToolEvent::Down { x: 100.0, y: 50.0, pressure: 1.0 }); assert_eq!( @@ -52,10 +53,10 @@ fn the_background_eraser_readout_has_a_fifty_percent_opacity_row() { readout(&mut a, ToolEvent::Up { x: 100.0, y: 50.0 }); } -/// Done when 2: horizontal and vertical movement leave the Opacity row at 50 %, the diameter and -/// the hardness following their own axes. +/// Done when 2: horizontal and vertical movement leave the Opacity row on the Tolerance, the +/// diameter and the hardness following their own axes. #[test] -fn the_opacity_row_stays_at_fifty_percent_through_the_drag() { +fn the_opacity_row_stays_on_the_tolerance_through_the_drag() { let mut a = app(Tool::BackgroundEraser, 0.5); readout(&mut a, ToolEvent::Down { x: 100.0, y: 50.0, pressure: 1.0 }); let right = readout(&mut a, ToolEvent::Move { x: 130.0, y: 50.0, pressure: 1.0 }); @@ -68,15 +69,19 @@ fn the_opacity_row_stays_at_fifty_percent_through_the_drag() { readout(&mut a, ToolEvent::Up { x: 130.0, y: 30.0 }); } -/// Done when 3: the row stays at 50 % for another Tolerance. The 50 is the Tolerance after Reset -/// Tool, but the reference's row was not measured for other values, so it does not follow it yet. +/// Done when 3: the row reads the Tolerance at every value, 0 and 100 % included, as measured in +/// the reference application, and a drag leaves it there. #[test] -fn another_tolerance_leaves_the_row_at_fifty_percent() { - let mut a = app(Tool::BackgroundEraser, 1.0); - a.ui.tool_options.bg_tolerance = 85.0; - let got = readout(&mut a, ToolEvent::Down { x: 100.0, y: 50.0, pressure: 1.0 }); - assert_eq!(values(&got), vec!["40 px", "100%", "50%"], "Tolerance 85 %: the row still reads 50 %"); - readout(&mut a, ToolEvent::Up { x: 100.0, y: 50.0 }); +fn the_opacity_row_follows_the_tolerance() { + for (tolerance, shown) in [(0.0, "0%"), (20.0, "20%"), (37.0, "37%"), (80.0, "80%"), (100.0, "100%")] { + let mut a = app(Tool::BackgroundEraser, 1.0); + a.ui.tool_options.bg_tolerance = tolerance; + let got = readout(&mut a, ToolEvent::Down { x: 100.0, y: 50.0, pressure: 1.0 }); + assert_eq!(values(&got), vec!["40 px", "100%", shown], "Tolerance {tolerance} %: the row reads it"); + let drag = readout(&mut a, ToolEvent::Move { x: 130.0, y: 50.0, pressure: 1.0 }); + assert_eq!(values(&drag), vec!["100 px", "100%", shown], "Tolerance {tolerance} %: the drag leaves it there"); + readout(&mut a, ToolEvent::Up { x: 130.0, y: 50.0 }); + } } /// Done when 2: the gesture changes only the diameter and the hardness, erases nothing and adds no From fffecde82acc9b142d781f0bb79b3798393de03c Mon Sep 17 00:00:00 2001 From: yoriswind Date: Tue, 1 Dec 2026 19:16:41 -0800 Subject: [PATCH 71/81] Keep the Scale Ruler gesture registered by the open dialog --- crates/ui-egui/src/tools/analysis/canvas.rs | 9 ++------- crates/ui-egui/src/tools/analysis/dialogs.rs | 20 ++++++++++++------- .../analysis/scale_ruler_while_open_tests.rs | 12 +++++++++++ 3 files changed, 27 insertions(+), 14 deletions(-) diff --git a/crates/ui-egui/src/tools/analysis/canvas.rs b/crates/ui-egui/src/tools/analysis/canvas.rs index 57995867ee1..a64e782242c 100644 --- a/crates/ui-egui/src/tools/analysis/canvas.rs +++ b/crates/ui-egui/src/tools/analysis/canvas.rs @@ -9,11 +9,10 @@ use craft::behavior::{CancelReason, CountMark, Cursor, CursorBadge, CursorIcon, use craft::color_ui::ui::{ColorSamplerMarks, ColorSamplerTool, ColorSamplers, SamplerEvent}; use craft::draw::ui::{RulerLine, RulerTool}; use craft::ui::canvas::{CanvasTool, NoTool, ToolAction, ToolClaims, ToolContext, ToolHostResponse, ToolKey, ToolPath, ToolPointer, canvas_space}; -use craft::ui::contract::{Access, CanvasGesture, Common, Component, Cx, MeasureCx, PaintUi, Props as _, Role, Show as _}; +use craft::ui::contract::{Access, Common, Component, Cx, MeasureCx, PaintUi, Props as _, Role, Show as _}; use craft::ui::fonts::FontRef; use craft::ui::primitives::{DocRun, DocText, Draw, PaintShape, StrokeWidth}; use craft::ui::runtime::env::Label; -use craft::ui::runtime::sampler; use craft::ui::style::{ComponentStyle, DataColor, StyleColor, StyleCx}; use egui::{Color32, CornerRadius, Pos2, Rect, Response, Vec2, vec2}; use serde_json::json; @@ -141,11 +140,7 @@ pub(crate) fn tool<'a>(scope: &'a ToolScope<'a>, state: &'a mut AnalysisTools, h let tool = scope.with_app(|app| app.ui.tool); let AnalysisTools { ruler, scale, sampler, samplers, count, note } = state; match tool { - Tool::Ruler if scope.with_app(|app| scale_ruler_on(app, host)) => { - // The modal's ParamDialog keeps this canvas open for navigation. Pass the ruler's primary drag too. - sampler::pass_tool_gesture(scope.ctx(), host.canvas_id(), CanvasGesture::PRIMARY); - Box::new(scale.tool.pass(scale.line)) - } + Tool::Ruler if scope.with_app(|app| scale_ruler_on(app, host)) => Box::new(scale.tool.pass(scale.line)), Tool::Ruler => { let line = scope.with_app(|app| ruler_line(app)); Box::new(ruler.pass(line)) diff --git a/crates/ui-egui/src/tools/analysis/dialogs.rs b/crates/ui-egui/src/tools/analysis/dialogs.rs index d6bb2d27228..2537c846e02 100644 --- a/crates/ui-egui/src/tools/analysis/dialogs.rs +++ b/crates/ui-egui/src/tools/analysis/dialogs.rs @@ -3,7 +3,7 @@ use craft::behavior::IconId; use craft::ui::choice::Checkbox; -use craft::ui::contract::{Bind, Props as _, Scroll, Show as _, ShowContainer as _}; +use craft::ui::contract::{Bind, CanvasGesture, Props as _, Sampler as _, Scroll, Show as _, ShowContainer as _}; use craft::ui::dialog::{DialogId, dialog_id}; use craft::ui::display::{Divider, Elide, Icon, Text}; use craft::ui::layout_components::{Row, Stack}; @@ -15,6 +15,7 @@ use photocraft_engine::analysis_cmds; use serde_json::{Value, json}; use crate::PhotocraftApp; +use crate::canvas::document_display::CanvasHost; use crate::dialogs::params; use crate::state::Tool; @@ -97,7 +98,8 @@ pub(crate) fn open(app: &mut PhotocraftApp, kind: Kind) -> Result DialogId { @@ -208,8 +210,12 @@ pub(crate) fn scale_readout(f: &DialogFields, decimal: char) -> String { format!("{} pixel(s) = {} {units}", mark(pixels.to_string()), mark(format!("{length:.4}"))) } -fn scale_ruler_note(ui: &mut egui::Ui) { - Row::new().show(ui, |ui, _| { +fn scale_ruler_note(ui: &mut egui::Ui, canvas: Option) { + Row::new().show(ui, |ui, cx| { + // The dialog runs every pass, even when the canvas replays its cached draw. + if let Some(canvas) = canvas { + cx.pass_canvas_gesture(canvas, CanvasGesture::PRIMARY); + } Icon::new(IconSpec::svg(IconId::new("info"))).show(ui); let note = tl!("The Ruler tool has been activated while this dialog is open. You may use it to measure the pixel length for use in your scale."); let sample: String = note.chars().take(READOUT_CHARS).collect(); @@ -222,7 +228,7 @@ fn options(pairs: &[(&str, &str)]) -> Vec<(String, Label)> { } /// The dialog of `kind` over `fields`. -fn form(kind: Kind, fields: &mut DialogFields) -> ParamDialog<'_> { +fn form(kind: Kind, fields: &mut DialogFields, scale_canvas: Option) -> ParamDialog<'_> { let key = kind.command(); let dialog = match kind { Kind::Scale => { @@ -233,7 +239,7 @@ fn form(kind: Kind, fields: &mut DialogFields) -> ParamDialog<'_> { Param::new("logicalLength", tl!("Logical Length:"), ParamKind::number(Some(0.0001), Some(1e7), 1.0, 1.0, 4)).not_remembered(), Param::new("units", tl!("Logical Units:"), ParamKind::text("pixels")).not_remembered(), ]; - ParamDialog::command(key, tl!("Measurement Scale"), rows).below(|ui, f| { + ParamDialog::command(key, tl!("Measurement Scale"), rows).below(move |ui, f| { // One line: units too long for it are cut with "…", so the dialog keeps its width (#17414). The decimal // mark is the one the fields above write: the system's (any mark, not only `.` or `,`) or the host's. let text = scale_readout(f, Env::of(ui).format().separators().0); @@ -241,7 +247,7 @@ fn form(kind: Kind, fields: &mut DialogFields) -> ParamDialog<'_> { // and long units are cut with "…" instead of widening the dialog. let sample: String = text.chars().take(READOUT_CHARS).collect(); Text::new(Label::from(text)).elide(Elide::End).sample(Label::from(sample)).show(ui); - scale_ruler_note(ui); + scale_ruler_note(ui, scale_canvas); }) } Kind::DataPoints => { diff --git a/crates/ui-egui/src/tools/analysis/scale_ruler_while_open_tests.rs b/crates/ui-egui/src/tools/analysis/scale_ruler_while_open_tests.rs index 2f605a70dbf..4eeff3d3ff6 100644 --- a/crates/ui-egui/src/tools/analysis/scale_ruler_while_open_tests.rs +++ b/crates/ui-egui/src/tools/analysis/scale_ruler_while_open_tests.rs @@ -86,8 +86,11 @@ fn an_exposed_drag_updates_only_pixel_length_and_ok_restores_the_tool() { let primary = CanvasHost::primary(h.state(), 0); assert!(scale_ruler_on(h.state(), primary)); assert!(!scale_ruler_on(h.state(), CanvasHost { idx: 0, window: Some(99) })); + // Let the canvas settle past the lifetime of any registration made when the form opened. + h.run_steps(4); let span = points(&h); drag(&mut h, span); + assert!(crate::canvas::tools::in_gesture(h.state()), "the visible canvas claims the modal ruler drag"); let f = fields(&h); assert_eq!((f.number("pixelLength"), f.number("logicalLength"), f.text("units")), (Some(200.0), Some(3.5), Some("cm"))); assert!(length_has_focus(&h), "the admitted canvas press leaves keyboard focus in the form"); @@ -114,6 +117,7 @@ fn a_nested_prompt_blocks_measurement_and_escape_discards_the_scale_draft() { let alert = crate::dialogs::alerts::alert(h.state_mut(), "Test prompt over Measurement Scale"); h.run_steps(4); drag(&mut h, span); + assert!(!crate::canvas::tools::in_gesture(h.state()), "the nested prompt owns the pointer"); button(&mut h, span[1], false); assert_eq!(fields(&h).number("pixelLength"), Some(42.0)); let ctx = h.ctx.clone(); @@ -123,7 +127,15 @@ fn a_nested_prompt_blocks_measurement_and_escape_discards_the_scale_draft() { assert_eq!(fields(&h).number("pixelLength"), Some(200.0)); h.key_press(Key::Escape); h.run_steps(4); + assert_eq!(fields(&h).number("pixelLength"), Some(42.0), "Escape cancels the held canvas drag before dismissing the form"); button(&mut h, span[1], false); + + let span = points(&h); + drag(&mut h, span); + button(&mut h, span[1], false); + assert_eq!(fields(&h).number("pixelLength"), Some(200.0)); + h.key_press(Key::Escape); + h.run_steps(4); assert!(!h.state().dialog_open()); assert_eq!(h.state().ui.tool, Tool::Brush); assert!(h.state().canvas_tools.analysis.scale.line.is_none()); From 609d953ea7a42f3cddde11d294c5d0d0d6050b20 Mon Sep 17 00:00:00 2001 From: yoriswind Date: Tue, 1 Dec 2026 19:21:03 -0800 Subject: [PATCH 72/81] Remember the Current Tool Only filter in Tool Presets --- crates/ui-egui/src/panels/preset_browser.rs | 8 +- crates/ui-egui/src/panels/preset_panels.rs | 28 ++++++- .../tool_presets_current_tool_only_tests.rs | 77 +++++++++++++++++++ .../src/panels/tool_presets_row_icon_tests.rs | 2 + 4 files changed, 109 insertions(+), 6 deletions(-) create mode 100644 crates/ui-egui/src/panels/tool_presets_current_tool_only_tests.rs diff --git a/crates/ui-egui/src/panels/preset_browser.rs b/crates/ui-egui/src/panels/preset_browser.rs index 0d8fd3e08c2..c2495fe0a05 100644 --- a/crates/ui-egui/src/panels/preset_browser.rs +++ b/crates/ui-egui/src/panels/preset_browser.rs @@ -31,7 +31,7 @@ use serde_json::{Value, json}; use std::hash::{DefaultHasher, Hash as _, Hasher as _}; use std::sync::Arc; -use super::preset_panels::{PresetUi, run, tool_presets}; +use super::preset_panels::{PresetUi, current_tool_only, remember_current_tool_only, run, tool_presets}; use crate::PhotocraftApp; use crate::state::Tool; @@ -798,7 +798,7 @@ pub fn finish_custom_shape(app: &mut PhotocraftApp, rect: [f64; 4], keep: bool, /// Window › Tool Presets: a click applies the preset's tool and options. Current Tool Only lists the current tool's /// presets. pub fn tool_presets_panel(app: &mut PhotocraftApp, ui: &mut egui::Ui) { - let only = app.ui.presets_ui.current_tool_only; + let only = current_tool_only(app); let current = app.ui.tool; let presets: Vec<(String, String)> = app .session @@ -820,12 +820,12 @@ pub fn tool_presets_panel(app: &mut PhotocraftApp, ui: &mut egui::Ui) { let look = Look { list: true, flat: true, - empty: Some(if only { tl!("No presets for the current tool.") } else { tl!("No tool presets.") }), + empty: Some(if only { tl!("No tool presets are defined for the current tool.") } else { tl!("No tool presets.") }), leading: Some(Box::new(leading)), ..Look::default() }; let (events, keys) = show(&mut app.ui.presets_ui, zone, ui, TOOL_PRESETS, &source, look); - app.ui.presets_ui.current_tool_only = flag.get(); + remember_current_tool_only(app, flag.get()); apply(app, ui.ctx(), TOOL_PRESETS, &[], &keys, events); } diff --git a/crates/ui-egui/src/panels/preset_panels.rs b/crates/ui-egui/src/panels/preset_panels.rs index fa41b34ae35..957afb08fbc 100644 --- a/crates/ui-egui/src/panels/preset_panels.rs +++ b/crates/ui-egui/src/panels/preset_panels.rs @@ -33,8 +33,6 @@ pub struct PresetUi { pub clone_cursor: Option<(photocraft_doc::DocId, [f64; 2])>, /// Selected preset per panel (by name / pattern id). pub selected: BTreeMap, - /// Tool Presets: Current Tool Only. - pub current_tool_only: bool, /// Custom Shape tool: the shape it draws. pub custom_shape: String, /// Custom Shape tool: the layer its last drag placed, in that document; with that tool active the @@ -117,6 +115,28 @@ impl PresetUi { } } +const TOOL_PRESETS_SECTION: &str = "photocraft.tool-presets"; + +/// Tool Presets starts filtered unless the user has explicitly changed it. +pub(super) fn current_tool_only(app: &PhotocraftApp) -> bool { + app.session + .prefs() + .sections + .get(TOOL_PRESETS_SECTION) + .and_then(|section| section.get("currentToolOnly")) + .and_then(Value::as_bool) + .unwrap_or(true) +} + +/// Save a changed filter and invalidate the dock body that reads it. +pub(super) fn remember_current_tool_only(app: &mut PhotocraftApp, on: bool) { + if current_tool_only(app) != on { + app.session.prefs.edit(|prefs| { + prefs.sections.insert(TOOL_PRESETS_SECTION.into(), serde_json::json!({"currentToolOnly": on})); + }); + } +} + /// Runs the engine command `id`; a failure goes to the status line. pub(crate) fn run(app: &mut PhotocraftApp, id: &str, p: Value) -> Option { match app.run(id, p) { @@ -129,6 +149,10 @@ pub(crate) fn run(app: &mut PhotocraftApp, id: &str, p: Value) -> Option } } +#[cfg(all(test, not(target_arch = "wasm32")))] +#[path = "tool_presets_current_tool_only_tests.rs"] +mod tool_presets_current_tool_only_tests; + #[cfg(test)] mod tests { use super::*; diff --git a/crates/ui-egui/src/panels/tool_presets_current_tool_only_tests.rs b/crates/ui-egui/src/panels/tool_presets_current_tool_only_tests.rs new file mode 100644 index 00000000000..4af7272d17a --- /dev/null +++ b/crates/ui-egui/src/panels/tool_presets_current_tool_only_tests.rs @@ -0,0 +1,77 @@ +//! The Tool Presets panel filters a fresh profile and keeps a user's choice across restarts. + +use egui::accesskit::{Role, Toggled}; +use egui_kittest::Harness; +use egui_kittest::kittest::{NodeT, Queryable}; +use photocraft_engine::presets::{PresetsExt, tools::ToolPreset}; +use serde_json::json; + +use crate::input::shortcut_dispatch::tests::app_harness; +use crate::{PhotocraftApp, Services, Tool}; + +const FILTER: &str = "Current Tool Only"; +const BRUSH: &str = "Filter fixture brush"; +const CROP: &str = "Filter fixture crop"; +const EMPTY: &str = "No tool presets are defined for the current tool."; + +type H = Harness<'static, Box>; + +fn open_panel(services: Services) -> H { + let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), services); + app.run("file.new", json!({"width": 64, "height": 48})).unwrap(); + app.ui.tool = Tool::Brush; + app.session.presets_mut().tool_presets = + [(BRUSH, "brush"), (CROP, "crop")].map(|(name, tool)| ToolPreset { name: name.into(), tool: tool.into(), options: json!({}) }).into(); + let mut h = app_harness(app); + let ctx = h.ctx.clone(); + crate::menus::invoke(h.state_mut(), &ctx, "window.panel.toolPresets", json!({"show": true})).unwrap(); + crate::menus::invoke(h.state_mut(), &ctx, "window.panel.window", json!({"panel": "toolPresets", "native": false})).unwrap(); + h.run_steps(6); + h +} + +fn filter_state(h: &H) -> Option { + h.get_by_role_and_label(Role::CheckBox, FILTER).accesskit_node().toggled() +} + +#[test] +fn tool_presets_filter_a_fresh_profile_and_explain_an_empty_current_tool() { + let mut h = open_panel(Services::default()); + assert_eq!(filter_state(&h), Some(Toggled::True)); + assert!(h.query_by_label_contains(BRUSH).is_some()); + assert!(h.query_by_label_contains(CROP).is_none()); + assert!(h.query_by_label(EMPTY).is_none()); + + h.state_mut().ui.tool = Tool::RectMarquee; + h.run_steps(4); + assert_eq!(filter_state(&h), Some(Toggled::True)); + assert!(h.query_by_label_contains(BRUSH).is_none()); + assert!(h.query_by_label_contains(CROP).is_none()); + assert!(h.query_by_label(EMPTY).is_some()); +} + +#[test] +fn tool_presets_keep_the_unchecked_filter_after_a_restart() { + use std::sync::Arc; + + let files = Arc::new(craft::settings::testing::MemoryFiles::new()); + let dir = std::env::temp_dir().join("photocraft-tool-presets-current-tool-only"); + let launch = || { + let options = photocraft_engine::prefs::store_options(Some(&dir)).files(files.clone()); + open_panel(Services { settings: Some(craft::settings::SettingsStore::open_with(options)), ..Default::default() }) + }; + let mut h = launch(); + h.get_by_role_and_label(Role::CheckBox, FILTER).click(); + h.run_steps(4); + assert_eq!(filter_state(&h), Some(Toggled::False)); + assert!(h.query_by_label_contains(BRUSH).is_some()); + assert!(h.query_by_label_contains(CROP).is_some()); + + crate::prefs_ui::save_preferences(h.state_mut()).unwrap(); + drop(h); + + let restarted = launch(); + assert_eq!(filter_state(&restarted), Some(Toggled::False)); + assert!(restarted.query_by_label_contains(BRUSH).is_some()); + assert!(restarted.query_by_label_contains(CROP).is_some()); +} diff --git a/crates/ui-egui/src/panels/tool_presets_row_icon_tests.rs b/crates/ui-egui/src/panels/tool_presets_row_icon_tests.rs index 3ac8d99c57b..1fde5a64680 100644 --- a/crates/ui-egui/src/panels/tool_presets_row_icon_tests.rs +++ b/crates/ui-egui/src/panels/tool_presets_row_icon_tests.rs @@ -30,6 +30,8 @@ fn tool_preset_rows_paint_distinct_tool_glyphs_and_a_fallback() { crate::menus::invoke(h.state_mut(), &ctx, "window.panel.toolPresets", json!({})).unwrap(); crate::menus::invoke(h.state_mut(), &ctx, "window.panel.window", json!({"panel": "toolPresets", "native": false})).unwrap(); h.run_steps(6); + h.get_by_role_and_label(egui::accesskit::Role::CheckBox, "Current Tool Only").click(); + h.run_steps(4); let textures = names.map(|name| { let row = h.query_by_label_contains(name).expect("the preset is exposed as a row in the panel"); From f69aa937415df41940ddabf9c90df5ee3ef5418a Mon Sep 17 00:00:00 2001 From: yoriswind Date: Tue, 1 Dec 2026 19:28:23 -0800 Subject: [PATCH 73/81] Match hosted formatting in the Tool Presets preference helper --- crates/ui-egui/src/panels/preset_panels.rs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/crates/ui-egui/src/panels/preset_panels.rs b/crates/ui-egui/src/panels/preset_panels.rs index 957afb08fbc..6ea75072e9b 100644 --- a/crates/ui-egui/src/panels/preset_panels.rs +++ b/crates/ui-egui/src/panels/preset_panels.rs @@ -119,13 +119,7 @@ const TOOL_PRESETS_SECTION: &str = "photocraft.tool-presets"; /// Tool Presets starts filtered unless the user has explicitly changed it. pub(super) fn current_tool_only(app: &PhotocraftApp) -> bool { - app.session - .prefs() - .sections - .get(TOOL_PRESETS_SECTION) - .and_then(|section| section.get("currentToolOnly")) - .and_then(Value::as_bool) - .unwrap_or(true) + app.session.prefs().sections.get(TOOL_PRESETS_SECTION).and_then(|section| section.get("currentToolOnly")).and_then(Value::as_bool).unwrap_or(true) } /// Save a changed filter and invalidate the dock body that reads it. From fc1352841e805a9db970840833d31930e1bc9a11 Mon Sep 17 00:00:00 2001 From: yoriswind Date: Tue, 1 Dec 2026 19:41:02 -0800 Subject: [PATCH 74/81] Propagate Tool Presets fixture errors through the tests --- .../tool_presets_current_tool_only_tests.rs | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/crates/ui-egui/src/panels/tool_presets_current_tool_only_tests.rs b/crates/ui-egui/src/panels/tool_presets_current_tool_only_tests.rs index 4af7272d17a..4b36c76e9b4 100644 --- a/crates/ui-egui/src/panels/tool_presets_current_tool_only_tests.rs +++ b/crates/ui-egui/src/panels/tool_presets_current_tool_only_tests.rs @@ -16,18 +16,18 @@ const EMPTY: &str = "No tool presets are defined for the current tool."; type H = Harness<'static, Box>; -fn open_panel(services: Services) -> H { +fn open_panel(services: Services) -> Result { let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), services); - app.run("file.new", json!({"width": 64, "height": 48})).unwrap(); + app.run("file.new", json!({"width": 64, "height": 48}))?; app.ui.tool = Tool::Brush; app.session.presets_mut().tool_presets = [(BRUSH, "brush"), (CROP, "crop")].map(|(name, tool)| ToolPreset { name: name.into(), tool: tool.into(), options: json!({}) }).into(); let mut h = app_harness(app); let ctx = h.ctx.clone(); - crate::menus::invoke(h.state_mut(), &ctx, "window.panel.toolPresets", json!({"show": true})).unwrap(); - crate::menus::invoke(h.state_mut(), &ctx, "window.panel.window", json!({"panel": "toolPresets", "native": false})).unwrap(); + crate::menus::invoke(h.state_mut(), &ctx, "window.panel.toolPresets", json!({"show": true}))?; + crate::menus::invoke(h.state_mut(), &ctx, "window.panel.window", json!({"panel": "toolPresets", "native": false}))?; h.run_steps(6); - h + Ok(h) } fn filter_state(h: &H) -> Option { @@ -35,8 +35,8 @@ fn filter_state(h: &H) -> Option { } #[test] -fn tool_presets_filter_a_fresh_profile_and_explain_an_empty_current_tool() { - let mut h = open_panel(Services::default()); +fn tool_presets_filter_a_fresh_profile_and_explain_an_empty_current_tool() -> Result<(), String> { + let mut h = open_panel(Services::default())?; assert_eq!(filter_state(&h), Some(Toggled::True)); assert!(h.query_by_label_contains(BRUSH).is_some()); assert!(h.query_by_label_contains(CROP).is_none()); @@ -48,10 +48,11 @@ fn tool_presets_filter_a_fresh_profile_and_explain_an_empty_current_tool() { assert!(h.query_by_label_contains(BRUSH).is_none()); assert!(h.query_by_label_contains(CROP).is_none()); assert!(h.query_by_label(EMPTY).is_some()); + Ok(()) } #[test] -fn tool_presets_keep_the_unchecked_filter_after_a_restart() { +fn tool_presets_keep_the_unchecked_filter_after_a_restart() -> Result<(), String> { use std::sync::Arc; let files = Arc::new(craft::settings::testing::MemoryFiles::new()); @@ -60,18 +61,19 @@ fn tool_presets_keep_the_unchecked_filter_after_a_restart() { let options = photocraft_engine::prefs::store_options(Some(&dir)).files(files.clone()); open_panel(Services { settings: Some(craft::settings::SettingsStore::open_with(options)), ..Default::default() }) }; - let mut h = launch(); + let mut h = launch()?; h.get_by_role_and_label(Role::CheckBox, FILTER).click(); h.run_steps(4); assert_eq!(filter_state(&h), Some(Toggled::False)); assert!(h.query_by_label_contains(BRUSH).is_some()); assert!(h.query_by_label_contains(CROP).is_some()); - crate::prefs_ui::save_preferences(h.state_mut()).unwrap(); + crate::prefs_ui::save_preferences(h.state_mut())?; drop(h); - let restarted = launch(); + let restarted = launch()?; assert_eq!(filter_state(&restarted), Some(Toggled::False)); assert!(restarted.query_by_label_contains(BRUSH).is_some()); assert!(restarted.query_by_label_contains(CROP).is_some()); + Ok(()) } From d1e58965d8fcc8a50e9053921b599acaaf85b385 Mon Sep 17 00:00:00 2001 From: yoriswind Date: Tue, 1 Dec 2026 19:56:52 -0800 Subject: [PATCH 75/81] Keep printer-managed color settings visible and add the document profile --- crates/ui-egui/src/dialogs/file_ui/print.rs | 93 ++++++++++---- .../tests/it/print_color_section_layout.rs | 118 ++++++++++++++++++ 2 files changed, 185 insertions(+), 26 deletions(-) create mode 100644 crates/ui-egui/tests/it/print_color_section_layout.rs diff --git a/crates/ui-egui/src/dialogs/file_ui/print.rs b/crates/ui-egui/src/dialogs/file_ui/print.rs index 613fdb9f9c0..aacf58a383f 100644 --- a/crates/ui-egui/src/dialogs/file_ui/print.rs +++ b/crates/ui-egui/src/dialogs/file_ui/print.rs @@ -1,7 +1,9 @@ use craft::behavior::EditEvent; +use craft::ui::choice::Checkbox; +use craft::ui::contract::{Bind, Outcome as _, Props as _, Show as _}; use craft::ui::dialog::{DialogId, DialogResult, StackDialog as _}; use craft::ui::patterns::form_dialogs::{DialogFields, FieldValue, NumberUnit, Param, ParamKind}; -use craft::ui::runtime::env::UnitKind; +use craft::ui::runtime::env::{Label, UnitKind}; use craft::ui::runtime::requests::PathKind; use craft_print::ui::{Destination, Duplex, HostedPrint, PrintAnswer, PrintFinish, PrintMarks, PrintSection, PrintSheet, Printer, Settings, State}; use serde_json::{Map, Value, json}; @@ -146,7 +148,17 @@ pub fn open_print(app: &mut PhotocraftApp) -> DialogId { } } write_settings(&mut fields, &state.settings); - let sections = sections(&fields); + let document_profile = app.session.active().map(|state| { + let doc = &state.doc; + if doc.icc_profile.is_some() { + Label::from(crate::panels::chrome_ui::profile_name(doc)) + } else if doc.mode == photocraft_doc::ColorMode::Lab { + Label::from(tl!("Lab Color")) + } else { + Label::from(tl!(crate::canvas::mode_label(doc))) + } + }); + let sections = sections(&fields, document_profile); app.framework.dialogs.open(HostedPrint::new(state, fields, sections).json_form(|fields, listing| { if fields.text("paper") == Some("custom") { listing.insert("paper".into(), print_params(fields)["paper"].clone()); @@ -157,7 +169,7 @@ pub fn open_print(app: &mut PhotocraftApp) -> DialogId { /// The dialog's sections under the printer panel, as rows over today's `file.print` keys. /// Lengths are shown in the unit `file.print` keeps them in: positions in inches, the custom paper /// in points. -pub(super) fn sections(fields: &DialogFields) -> Vec { +fn sections(fields: &DialogFields, document_profile: Option