From 1483e61f858c8294819c4c2acfe45a82f4013a84 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Tue, 17 Nov 2026 12:53:58 -0800 Subject: [PATCH] Swatches: Swatch Options and New Swatch show the out-of-gamut and web color warnings Both dialogs now show the out-of-gamut triangle and the out-of-web-color cube under the color, each with its correction beside it. A click on the icon or on the correction changes the dialog's color; OK applies it as one swatch.edit or swatch.new undo step. The warning icons in the Color panel and the Color Picker now correct the color too. The triangle shows in RGB, HSB and Lab and the cube in every mode but Web Safe RGB. A web correction of a Grayscale, Lab or CMYK color is edited in RGB; a gamut correction keeps the color's CMYK equivalent and is edited in CMYK. --- .../ui-egui/src/dialogs/color_picker/tests.rs | 3 +- crates/ui-egui/src/dialogs/new_swatch.rs | 30 ++- crates/ui-egui/src/dialogs/swatch_options.rs | 213 ++++++++++++++++-- crates/ui-egui/src/panels/color.rs | 20 +- docs/control-protocol.md | 5 +- docs/mcp.md | 4 +- docs/target-app-parity.md | 1 + 7 files changed, 246 insertions(+), 30 deletions(-) diff --git a/crates/ui-egui/src/dialogs/color_picker/tests.rs b/crates/ui-egui/src/dialogs/color_picker/tests.rs index 0786df7ca9..15344a131c 100644 --- a/crates/ui-egui/src/dialogs/color_picker/tests.rs +++ b/crates/ui-egui/src/dialogs/color_picker/tests.rs @@ -670,7 +670,8 @@ fn warnings_fit_below_the_preview_without_widening_the_dialog() { } let after = ctx.memory(|m| m.area_rect(id)).unwrap(); assert!((before.size() - after.size()).length() < 1.0, "{before:?} vs {after:?}"); - click_at(&ctx, &mut app, warnings[1].center()); + // The cube icon left of the web correction corrects the color too. + click_at(&ctx, &mut app, warnings[1].center() - vec2(19.0, 0.0)); assert!(is_web_safe(&picked(app.ui.dialog.as_ref().unwrap()).color), "web correction remains clickable"); } diff --git a/crates/ui-egui/src/dialogs/new_swatch.rs b/crates/ui-egui/src/dialogs/new_swatch.rs index 5b6c5b117c..ec2ab707d4 100644 --- a/crates/ui-egui/src/dialogs/new_swatch.rs +++ b/crates/ui-egui/src/dialogs/new_swatch.rs @@ -1,5 +1,5 @@ -//! New Swatch: the Swatch Options fields (name, colour type, Global, mode, sliders and hex) -//! prefilled from the active fill or stroke; a gradient, a pattern or a tint of a global colour +//! New Swatch: the Swatch Options fields (name, colour type, Global, mode, sliders, hex and the +//! colour warnings) prefilled from the active fill or stroke; a gradient, a pattern or a tint of a global colour //! (saved as a tint swatch, "Name 40%") only takes a name. OK runs `swatch.new`. //! //! Fields: `name`, `spot`, `global`, `mode` and `color` as in Swatch Options, `group` (the colour @@ -45,7 +45,7 @@ pub fn open(app: &mut VectorcraftApp, spot: bool, global: bool, group: Option<&s fn body(app: &mut VectorcraftApp, ui: &mut egui::Ui, d: &mut Dialog) -> bool { if d.fields.contains_key("__paint") { grid(ui, |ui| name_row(ui, d)); - } else if editor(ui, d) + } else if editor(app, ui, d) && d.str("name") == d.str("__auto") && let Some(st) = app.session.active() { @@ -87,6 +87,30 @@ mod tests { assert_eq!(params(&d), json!({"name": "Dots", "pattern": "Dots"})); } + #[test] + fn a_warning_corrects_the_new_colour_only_until_ok() { + use super::super::swatch_options::tests::{click_at, context, settled, warning_rows}; + let (ctx, mut app) = (context(), VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default())); + app.run("file.new", json!({"width": 100, "height": 100})).unwrap(); + app.run("shape.rectangle", json!({"x": 10, "y": 10, "width": 50, "height": 50})).unwrap(); + app.run("paint.setFill", json!({"color": "#0000fe"})).unwrap(); + let count = |app: &VectorcraftApp| app.session.active().unwrap().doc.swatches_iter().count(); + let before = count(&app); + open(&mut app, false, false, None).unwrap(); + let rows = warning_rows(&settled(&ctx, &mut app)); + assert_eq!(rows.len(), 2, "out of gamut and out of web colors"); + click_at(&ctx, &mut app, rows[1].1.center()); + let d = app.ui.dialog.clone().unwrap(); + assert_eq!((color_of(&d).to_hex(), d.str("mode")), ("#0000ff".to_string(), "rgb".to_string())); + assert_eq!(count(&app), before, "no swatch before OK"); + assert_eq!(warning_rows(&settled(&ctx, &mut app)).len(), 1, "the web warning is gone"); + let name = app.ui.dialog.as_ref().unwrap().str("name"); + super::super::confirm(&mut app).unwrap(); + assert_eq!(app.session.active().unwrap().doc.swatch(&name).and_then(|s| s.paint.color()).map(|c| c.to_hex()), Some("#0000ff".into())); + app.run("edit.undo", json!({})).unwrap(); + assert_eq!(count(&app), before, "one undo step"); + } + #[test] fn a_tint_opens_as_a_named_tint_swatch() { let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default()); diff --git a/crates/ui-egui/src/dialogs/swatch_options.rs b/crates/ui-egui/src/dialogs/swatch_options.rs index 9583b893ef..4ff5cdc1ba 100644 --- a/crates/ui-egui/src/dialogs/swatch_options.rs +++ b/crates/ui-egui/src/dialogs/swatch_options.rs @@ -1,7 +1,10 @@ //! Swatch Options: name, colour type (process or spot), Global, colour mode with sliders and hex, -//! previewed live on the canvas (Cancel rolls the preview back). Double-clicking a swatch opens it -//! for a solid colour; for a gradient it shows the name and the gradient; patterns open pattern -//! editing ([`open`]). +//! and the out-of-gamut and out-of-web-color warnings under the colour, previewed live on the canvas +//! (Cancel rolls the preview back). A click on a warning's icon or colour corrects the colour +//! (https://web.archive.org/web/20210601162814/https://helpx.adobe.com/pdf/illustrator_reference.pdf, +//! Swatch options; https://helpx.adobe.com/illustrator/using/adjusting-colors.html). +//! Double-clicking a swatch opens it for a solid colour; for a gradient it shows the name and the +//! gradient; patterns open pattern editing ([`open`]). //! //! Fields: `__swatch` (the swatch being edited), `name`, `spot`, `global`, `mode` (`gray`, `rgb`, //! `hsb`, `lab`, `cmyk` or `web`), `color` (`"#rrggbb"` or a colour object such as @@ -14,7 +17,9 @@ use vectorcraft_color::{Color, Paint}; use super::{DialogSpec, form, run_and_close}; use crate::VectorcraftApp; -use crate::panels::color::{Mode, components, from_components, parse_hex, track_color, web_safe}; +use crate::panels::color::{ + GAMUT_WARNING, Mode, WEB_WARNING, components, from_components, gamut_fix, is_web_safe, parse_hex, track_color, warning_chip, web_safe, +}; use crate::state::Dialog; use crate::theme::Tokens; use crate::widgets; @@ -113,7 +118,7 @@ fn body(app: &mut VectorcraftApp, ui: &mut egui::Ui, d: &mut Dialog) -> bool { widgets::gradient_chip(ui, r, &g); changed } - None => editor(ui, d), + None => editor(app, ui, d), }; ui.add_space(8.0); let mut pv = d.bool("preview"); @@ -157,9 +162,9 @@ pub(super) fn name_row(ui: &mut egui::Ui, d: &mut Dialog) -> bool { changed } -/// The shared fields of Swatch Options and New Swatch: name, colour type, Global, mode, sliders and -/// hex. Returns true when anything changed. -pub(super) fn editor(ui: &mut egui::Ui, d: &mut Dialog) -> bool { +/// The shared fields of Swatch Options and New Swatch: name, colour type, Global, mode, sliders, +/// hex and the colour warnings. Returns true when anything changed. +pub(super) fn editor(app: &mut VectorcraftApp, ui: &mut egui::Ui, d: &mut Dialog) -> bool { let mut changed = false; grid(ui, |ui| { changed |= name_row(ui, d); @@ -191,15 +196,46 @@ pub(super) fn editor(ui: &mut egui::Ui, d: &mut Dialog) -> bool { ui.end_row(); }); ui.add_space(6.0); - changed | sliders(ui, d) + changed | sliders(app, ui, d) } -/// One slider and value field per component of the dialog's mode, the hex field (RGB, HSB and Web) -/// and a chip of the colour. Returns true when the colour changed. -fn sliders(ui: &mut egui::Ui, d: &mut Dialog) -> bool { +/// A warning under the colour of the swatch dialogs. +#[derive(Clone, Copy, PartialEq, Eq, Debug)] +enum Warning { + Gamut, + Web, +} + +/// The warnings the swatch dialogs show in `mode`: out of gamut in RGB, HSB and Lab, and out of web +/// colors in every mode but Web Safe RGB. +fn shown_warnings(mode: Mode) -> (bool, bool) { + (matches!(mode, Mode::Rgb | Mode::Hsb | Mode::Lab), mode != Mode::WebSafe) +} + +/// The colour and mode a click on `warning` gives `c`, edited in `mode`: the nearest web-safe colour +/// (in RGB unless the mode is RGB or HSB), or the colour's CMYK equivalent in the active CMYK space +/// (in CMYK). `None` when the conversion returns no CMYK values. +fn corrected(app: &mut VectorcraftApp, warning: Warning, mode: Mode, c: &Color) -> Result, String> { + match warning { + Warning::Web => Ok(Some((web_safe(c), if matches!(mode, Mode::Rgb | Mode::Hsb) { mode } else { Mode::Rgb }))), + Warning::Gamut => { + let r = app.run("color.convert", json!({"color": crate::panels::color_json(c), "to": "cmyk"}))?; + let v = |i: usize| r["values"][i].as_f64().map(|v| v as f32); + Ok(v(0).zip(v(1)).zip(v(2)).zip(v(3)).map(|(((c, m), y), k)| (Color::cmyk(c, m, y, k), Mode::Cmyk))) + } + } +} + +/// One slider and value field per component of the dialog's mode, the hex field (RGB, HSB and Web), +/// a chip of the colour and under it the mode's warnings. Returns true when the colour changed. +fn sliders(app: &mut VectorcraftApp, ui: &mut egui::Ui, d: &mut Dialog) -> bool { let t = Tokens::get(ui.ctx()); let mode = mode_of(d); let color = color_of(d); + let (shows_gamut, shows_web) = shown_warnings(mode); + let gamut = if shows_gamut { gamut_fix(app, ui.ctx(), "swatch-gamut", &color) } else { None }; + let web = (shows_web && !is_web_safe(&color)).then(|| web_safe(&color)); + let mut clicked: Option = None; // Keep the displayed components while the colour is unchanged (hue survives S = 0 etc.). let key = format!("{}|{}", mode_id(mode), serde_json::to_string(&color).unwrap_or_default()); let comps: Vec = match d.fields.get("__comps") { @@ -239,13 +275,47 @@ fn sliders(ui: &mut egui::Ui, d: &mut Dialog) -> bool { }); } }); - let (r, _) = ui.allocate_exact_size(vec2(44.0, 44.0), egui::Sense::hover()); - widgets::swatch_tile(ui, r, &Paint::solid(color), false, false); + ui.vertical(|ui| { + let (r, _) = ui.allocate_exact_size(vec2(44.0, 44.0), egui::Sense::hover()); + widgets::swatch_tile(ui, r, &Paint::solid(color), false, false); + let warnings: Vec<_> = [(Warning::Gamut, GAMUT_WARNING, gamut), (Warning::Web, WEB_WARNING, web)] + .into_iter() + .filter_map(|(w, chip, fix)| Some((w, chip, fix?))) + .collect(); + for (w, chip, fix) in &warnings { + ui.add_space(4.0); + if warning_chip(ui, *chip, fix) { + clicked = Some(*w); + } + } + // Room for the mode's other warnings, so the dialog keeps its height as the colour changes. + for _ in warnings.len()..usize::from(shows_gamut) + usize::from(shows_web) { + ui.add_space(4.0); + ui.scope(|ui| { + ui.set_invisible(); + warning_chip(ui, WEB_WARNING, &Color::WHITE) + }); + } + }); }); + let mut mode = mode; + if let Some(w) = clicked { + match corrected(app, w, mode, &color) { + Ok(Some((c, m))) => { + mode = m; + d.fields.insert("mode".into(), json!(mode_id(m))); + new = Some((c, components(m, &c))); + } + Ok(None) => {} + Err(e) => app.status(e), + } + } let Some((c, comps)) = new else { return false }; set_color(d, c); d.fields.insert("__compsKey".into(), json!(format!("{}|{}", mode_id(mode), serde_json::to_string(&c).unwrap_or_default()))); d.fields.insert("__comps".into(), json!(comps)); + // The warnings above were drawn for the colour before the change. + ui.ctx().request_repaint(); true } @@ -277,9 +347,122 @@ fn hex_field(ui: &mut egui::Ui, hex: &str) -> Option { } #[cfg(test)] -mod tests { +pub(super) mod tests { use super::*; + /// A test context with the application's fonts and default theme. + pub(crate) fn context() -> egui::Context { + let ctx = egui::Context::default(); + crate::theme::install_fonts(&ctx); + crate::theme::apply(&ctx, Default::default()); + ctx + } + + /// Runs one frame of the open dialog with `events` and returns the rectangles it paints. + pub(crate) fn draw(ctx: &egui::Context, app: &mut VectorcraftApp, events: Vec) -> Vec { + fn collect(s: &egui::Shape, out: &mut Vec) { + match s { + egui::Shape::Rect(r) => out.push(r.rect), + egui::Shape::Vec(v) => v.iter().for_each(|s| collect(s, out)), + _ => {} + } + } + let input = + egui::RawInput { screen_rect: Some(egui::Rect::from_min_size(egui::Pos2::ZERO, vec2(1280.0, 900.0))), events, ..Default::default() }; + let mut out = ctx.run_ui(input, |ui| super::super::show(app, ui.ctx())); + out.textures_delta.clear(); + let mut boxes = vec![]; + out.shapes.iter().for_each(|c| collect(&c.shape, &mut boxes)); + boxes + } + + /// Lets the auto-sized dialog settle and returns the rectangles of the next frame. + pub(crate) fn settled(ctx: &egui::Context, app: &mut VectorcraftApp) -> Vec { + for _ in 0..6 { + draw(ctx, app, vec![]); + } + draw(ctx, app, vec![]) + } + + /// A primary-button press and release at `at`, in two frames. + pub(crate) fn click_at(ctx: &egui::Context, app: &mut VectorcraftApp, at: egui::Pos2) { + for pressed in [true, false] { + let button = egui::Event::PointerButton { pos: at, button: egui::PointerButton::Primary, pressed, modifiers: Default::default() }; + draw(ctx, app, vec![egui::Event::PointerMoved(at), button]); + } + } + + /// The warning rows under the dialog's 44-point colour chip, top first: the centre of each + /// row's icon and the rectangle of its corrected colour. + pub(crate) fn warning_rows(boxes: &[egui::Rect]) -> Vec<(egui::Pos2, egui::Rect)> { + let near = |a: f32, b: f32| (a - b).abs() < 0.5; + let chip = boxes.iter().find(|r| near(r.width(), 44.0) && near(r.height(), 44.0)).copied().unwrap(); + let mut rows: Vec = boxes + .iter() + .filter(|r| near(r.width(), 16.0) && near(r.height(), 16.0)) + .filter(|r| r.top() >= chip.bottom() && r.left() >= chip.left() - 1.0 && r.right() <= chip.right() + 1.0) + .copied() + .collect(); + rows.sort_by(|a, b| a.top().total_cmp(&b.top())); + rows.dedup_by(|a, b| near(a.top(), b.top())); // The tile's fill and border share one rectangle. + rows.into_iter().map(|r| (r.center() - vec2(19.0, 0.0), r)).collect() + } + + fn dialog(app: &VectorcraftApp) -> &Dialog { + app.ui.dialog.as_ref().unwrap() + } + + #[test] + fn swatch_options_shows_and_corrects_both_warnings() { + let (ctx, mut app) = (context(), VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default())); + app.run("file.new", json!({"width": 100, "height": 100})).unwrap(); + app.run("swatch.new", json!({"name": "Sky", "color": "#0000fe", "spot": true})).unwrap(); + app.run("ui.swatchOptions", json!({"name": "Sky"})).unwrap(); + let rows = warning_rows(&settled(&ctx, &mut app)); + assert_eq!(rows.len(), 2, "out of gamut and out of web colors"); + // The cube's icon shifts to the nearest web-safe colour, in the same mode. + click_at(&ctx, &mut app, rows[1].0); + assert_eq!((color_of(dialog(&app)).to_hex(), dialog(&app).str("mode")), ("#0000ff".to_string(), "rgb".to_string())); + let rows = warning_rows(&settled(&ctx, &mut app)); + assert_eq!(rows.len(), 1, "web-safe blue is still out of gamut"); + // The triangle's colour shifts to the CMYK equivalent, edited in CMYK. + let ink = corrected(&mut app, Warning::Gamut, Mode::Rgb, &Color::rgb8(0, 0, 255)).unwrap().unwrap().0; + click_at(&ctx, &mut app, rows[0].1.center()); + assert_eq!((color_of(dialog(&app)), dialog(&app).str("mode")), (ink, "cmyk".to_string())); + assert!(app.ui.dialog.is_some(), "a correction only edits the fields"); + super::super::confirm(&mut app).unwrap(); + let sw = app.session.active().unwrap().doc.swatch("Sky").cloned().unwrap(); + assert_eq!((sw.paint.color(), sw.spot, sw.global), (Some(ink), true, true), "still a spot colour"); + app.run("edit.undo", json!({})).unwrap(); + let sw = app.session.active().unwrap().doc.swatch("Sky").cloned().unwrap(); + assert_eq!(sw.paint.color().map(|c| c.to_hex()), Some("#0000fe".into()), "one undo step"); + } + + #[test] + fn swatch_warnings_follow_the_mode() { + let (ctx, mut app) = (context(), VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default())); + app.run("file.new", json!({"width": 100, "height": 100})).unwrap(); + app.run("swatch.new", json!({"name": "Mid", "color": "#808080"})).unwrap(); + app.run("ui.swatchOptions", json!({"name": "Mid"})).unwrap(); + let mut rows_in = |mode: &str, c: Color| { + let d = app.ui.dialog.as_mut().unwrap(); + d.fields.insert("mode".into(), json!(mode)); + set_color(d, c); + warning_rows(&settled(&ctx, &mut app)).len() + }; + assert_eq!(rows_in("gray", Color::gray(0.5)), 1, "a gray off the web palette, never out of gamut"); + let cyan = Color::cmyk(1.0, 0.0, 0.0, 0.0); + assert_eq!(rows_in("cmyk", cyan), usize::from(!is_web_safe(&cyan)), "CMYK is never out of gamut"); + assert_eq!(rows_in("web", Color::rgb8(0, 0, 255)), 0, "Web Safe RGB shows no warning"); + assert_eq!(rows_in("rgb", Color::rgb8(0, 0, 255)), 1, "RGB blue is out of gamut"); + assert_eq!(rows_in("lab", Color::lab(30.0, 60.0, -100.0)), 2, "Lab shows both"); + // A web correction of a Lab colour is edited in RGB. + let rows = warning_rows(&settled(&ctx, &mut app)); + click_at(&ctx, &mut app, rows[1].0); + assert_eq!(dialog(&app).str("mode"), "rgb"); + assert!(is_web_safe(&color_of(dialog(&app)))); + } + #[test] fn fields_round_trip_modes_and_colours() { for (m, id) in MODES { diff --git a/crates/ui-egui/src/panels/color.rs b/crates/ui-egui/src/panels/color.rs index 28fb618dc9..c6a96b62d1 100644 --- a/crates/ui-egui/src/panels/color.rs +++ b/crates/ui-egui/src/panels/color.rs @@ -231,19 +231,23 @@ pub(crate) const WEB_WARNING: (&str, &str) = ("dc-cube", "Out of Web Color Warni /// The out-of-gamut warning: its icon and tooltip. pub(crate) const GAMUT_WARNING: (&str, &str) = ("dc-gamut", "Out of Gamut Warning"); -/// A warning icon with the corrected colour beside it. Returns true when the colour is clicked. +/// A warning icon with the corrected colour beside it. Returns true when the icon or the colour is +/// clicked. pub(crate) fn warning_chip(ui: &mut Ui, (icon, warning): (&str, &str), fix: &Color) -> bool { let t = Tokens::get(ui.ctx()); + let tip = crate::i18n::fmt( + tl!("{warning}: click to correct to the closest color ({hex})"), + &[("warning", tl!(warning)), ("hex", &format!("#{}", hex_digits(fix).to_ascii_lowercase()))], + ); ui.horizontal(|ui| { ui.spacing_mut().item_spacing.x = 3.0; - icons::icon(ui, icon, 16.0, t.icon).on_hover_text(tl!(warning)); + let icon = icons::icon(ui, icon, 16.0, t.icon).interact(Sense::click()); + icon.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, true, tl!(warning))); let (r, resp) = ui.allocate_exact_size(vec2(16.0, 16.0), Sense::click()); - widgets::swatch_tile(ui, r, &Paint::solid(*fix), false, resp.hovered()); - resp.on_hover_text(crate::i18n::fmt( - tl!("{warning}: click to correct to the closest color ({hex})"), - &[("warning", tl!(warning)), ("hex", &format!("#{}", hex_digits(fix).to_ascii_lowercase()))], - )) - .clicked() + resp.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, true, &tip)); + widgets::swatch_tile(ui, r, &Paint::solid(*fix), false, resp.hovered() || icon.hovered()); + let icon = icon.on_hover_text(&tip).clicked(); + resp.on_hover_text(&tip).clicked() || icon }) .inner } diff --git a/docs/control-protocol.md b/docs/control-protocol.md index adac088a13..12c0ddfa64 100644 --- a/docs/control-protocol.md +++ b/docs/control-protocol.md @@ -131,7 +131,10 @@ the two can still win that race. Swatch editors: `engine.execute` with `ui.swatchOptions {name}` opens the `swatchOptions` dialog for a colour swatch (fields `name`, `spot`, `global`, `mode`: `gray`/`rgb`/`hsb`/`lab`/`cmyk`/`web`, `color`: `"#rrggbb"` or a colour object, `preview`), which previews on the canvas while open; `ui.dialog.confirm` applies it with `swatch.edit` as one undo -step and `ui.dialog.cancel` rolls the preview back. For a gradient swatch the dialog has `name` only (it shows the +step and `ui.dialog.cancel` rolls the preview back. Under the colour it shows the out-of-gamut warning (in RGB, HSB +and Lab) and the out-of-web-color warning (in every mode but `web`); a click on one sets `color` to the correction +and `mode` to `cmyk` for the gamut correction, or to `rgb` for a web correction of a `gray`, `lab` or `cmyk` colour. +The warnings are not fields: set `color` and `mode` to apply a correction from a script. For a gradient swatch the dialog has `name` only (it shows the gradient) and OK renames it; pattern swatches open pattern editing instead. Dropping a gradient (or colour) on a swatch of its kind in the Swatches panel with Alt held replaces it (`swatch.edit {name, paint}`), unless that is a tint swatch. A swatch dragged from the panel with Alt held also replaces the swatch of its kind it is dropped on, diff --git a/docs/mcp.md b/docs/mcp.md index 61c4bb417f..746dd074e9 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -1811,8 +1811,8 @@ preferences (the folder the desktop app uses, so both see the same ones; `VECTOR `file.new`, `document.open`, `document.activate`, `file.close`, `file.revert`, `edit.undo`, `edit.redo` and a failed `command.batch` too; with none assigned, or no document open, the working spaces are. The `workingCmyk` target of `view.proofSetup` simulates the working CMYK space in such a document too. `color.convert`'s - `outOfGamut` and `deltaE`, `color.gamutCheck`, and the out-of-gamut warning of the Color panel and Color Picker - check against the assigned CMYK profile, else the working CMYK space; the warning updates when either changes. + `outOfGamut` and `deltaE`, `color.gamutCheck`, and the out-of-gamut warning of the Color panel, the Color Picker, + Swatch Options and New Swatch check against the assigned CMYK profile, else the working CMYK space; the warning updates when either changes. Not remembered: the document, anything else. Nothing is read or written when `VECTORCRAFT_NO_PREFS` is set, and a server confined with `--automation-read-root` or diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 3b3911ea84..14a4f4e107 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -812,6 +812,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - **Canvas through the display's profile on Windows and X11:** Preferences › Performance › Use Monitor Profile for Canvas (on by default) converts the canvas's art, artboard paper and transparency grid from sRGB into the ICC profile of the display that shows most of the main window, after any proof, as the help page describes the monitor's profile translating the document's colors for the monitor ([the help page](https://help.adobe.com/archive/en_US/illustrator/cs4/illustrator_cs4_help.pdf#page=151)). Windows gives the display's default profile, and a display with Advanced Color on is left to Windows ([Microsoft Learn](https://learn.microsoft.com/en-us/windows/win32/wcs/advanced-color-icc-profiles)); X11 gives colord's profile for the output or the `_ICC_PROFILE` property. macOS converts the window itself, and a Wayland session stays sRGB. `ui.inspect` reports `displayProfile`. Tests in `color/src/cms/display.rs`, `ui-egui/src/display_profile.rs` and `canvas::tests::the_canvas_is_drawn_through_the_display_profile_while_the_preference_is_on`. - **Translucent art blended before the display profile:** with Use Monitor Profile for Canvas converting, translucent art and the anti-aliased edges of art over an artboard's paper, a colored artboard or the transparency grid are blended with it in sRGB and the blend is converted, so the monitor's profile translates the document's colors as they are composited ([the help page](https://help.adobe.com/archive/en_US/illustrator/cs4/illustrator_cs4_help.pdf#page=151)). The frame rendered whole, the part an edit renders again, the render worker's frame, the pan fill and the other windows' panes do the same; over the pasteboard and in Outline the art is converted on its own, and with no profile to convert into nothing changes. Tests `display_profile::tests::translucent_pixels_over_the_paper_are_blended_before_they_are_converted`, `the_transparency_grid_is_blended_cell_by_cell`, `the_backdrop_is_found_through_the_view` and `canvas::tests::translucent_art_over_the_paper_is_blended_before_the_display_profile`. - **Out-of-gamut warning after a profile change:** the out-of-gamut warning and its closest-color correction in the Color panel and Color Picker ([the help page](https://helpx.adobe.com/illustrator/using/adjusting-colors.html)) check the color against the document's assigned CMYK profile, else the working CMYK space, and update when Edit › Assign Profile… or Edit › Color Settings… changes that space or a loaded profile changes, without a change of color. Which CMYK space the warning uses is VectorCraft's own rule. Tests: `gamut_warning_follows_a_profile_change` and `gamut_warning_follows_a_profile_loaded_again` in `dialogs/color_picker/tests.rs`. +- **Swatch Options and New Swatch color warnings:** both dialogs show the out-of-gamut triangle and the out-of-web-color cube under the color, each with its correction beside it, and a click on the icon or the correction shifts the color to the closest printable or web-safe color ([the archived user guide](https://web.archive.org/web/20210601162814/https://helpx.adobe.com/pdf/illustrator_reference.pdf#page=236), Swatch options; [the help page](https://helpx.adobe.com/illustrator/using/adjusting-colors.html)). The icons in the Color panel and the Color Picker correct the color too. VectorCraft's own rules: the triangle shows in RGB, HSB and Lab and the cube in every mode but Web Safe RGB, both can show at once, a web correction of a Grayscale, Lab or CMYK color is edited in RGB, a gamut correction keeps the CMYK equivalent and is edited in CMYK, and a correction keeps the name, the color type and Global and changes the dialog's fields only, so OK records one undo step. Tests: `swatch_options_shows_and_corrects_both_warnings` and `swatch_warnings_follow_the_mode` in `dialogs/swatch_options.rs`, `a_warning_corrects_the_new_colour_only_until_ok` in `dialogs/new_swatch.rs`. - **Assign Profile and the working spaces:** Edit › Assign Profile… tags the document and leaves the working spaces of Edit › Color Settings… as they are, in Color Settings, the Separations panel and the settings saved for the next start. Colors show and convert through the profiles assigned; a change in Color Settings keeps the profiles the document in front is assigned in use, and removing an assigned profile in use puts the working space back in its place. The profiles in use follow the document in front: a new, opened or reverted document, a switch to another tab, a close, Undo and Redo of Assign Profile, a failed batch, each step of a batch, Export All Open and the update of placed documents put that document's profiles in use, and the working spaces where it is assigned none or no document is open. With Window › Arrange › Tile or floating document windows, each document behind the front one draws its art, paper and transparency grid through its own assigned profiles, and loading or removing a profile redraws the documents assigned it; placed documents inside it still draw through the front document's profiles. How documents behind the front one draw is VectorCraft's own rule. View › Proof Setup › Working CMYK simulates the working CMYK space of Color Settings in Proof Colors and Separations Preview, also in a document assigned another CMYK profile. Public references: [Changing the color profile for a document and About color working spaces](https://help.adobe.com/archive/en_US/illustrator/cs3/illustrator_cs3_help.pdf#page=150) and [Soft-proof presets](https://help.adobe.com/archive/en_US/illustrator/cs3/illustrator_cs3_help.pdf#page=134). Tests in `engine/tests/color_settings.rs`. - **Color management policies:** Edit › Color Settings… (the Separations panel's Color Settings section and `edit.colorSettings`) has an RGB and a CMYK policy: Off, Preserve Embedded Profiles and Convert to Working Space, and Preserve Numbers for CMYK. When a document tagged with a profile other than the working space is opened, reverted or opened as a template, the policy keeps the profile, takes it off with the color numbers kept, or converts that model's colors into the working space, with black point compensation as Color Settings set it, and takes it off. The policies are kept in `Color Settings.json`. Preserve Embedded Profiles as the default for both, and the per-model policy for a document tagged with both an RGB and a CMYK profile, are VectorCraft's own rules; placed images and the Profile Mismatches and Missing Profiles prompts are not covered. Public reference: [Color management policy options](https://help.adobe.com/archive/en_US/illustrator/cs4/illustrator_cs4_help.pdf#page=157). Tests in `engine/tests/color_settings.rs`, `color/src/cms/tests.rs` and `color/src/cms/tests_icc.rs`. - **New Document's units:** the dialog opens in Preferences › Units › General, also on a Recent entry made in other units (an entry in pixels, or a saved preset in the units it was saved in, keeps its units), so File › New and New Without Dialog make documents in the General unit. Units chosen in the Units menu stay when another tab or preset is chosen and when a card is clicked or double-clicked; without such a choice, clicking another Recent or Saved card brings back the units that card was made in (#7944). These are VectorCraft's own rules. Tests: `the_dialog_opens_in_the_general_units_over_a_recent_entry`, `a_recent_saved_preset_keeps_its_units_and_name`, `units_chosen_in_the_menu_survive_tabs_and_presets` and `units_set_over_a_popup_stay_chosen` in `dialogs/new_document.rs`; `a_recent_card_keeps_the_units_chosen_in_the_menu` and `a_double_clicked_card_keeps_the_units_chosen_in_the_menu` in `panels/tests_units.rs`.