From 06bf6397c72ea24976237bdc366ca8ba62c6f9ef Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 14 Nov 2026 13:29:29 -0800 Subject: [PATCH] =?UTF-8?q?View:=20Proof=20Setup=20=E2=80=BA=20Customize?= =?UTF-8?q?=E2=80=A6=20opens=20a=20dialog=20for=20the=20device=20to=20simu?= =?UTF-8?q?late?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit View › Proof Setup › Customize… opened the Separations Preview panel. It now opens a Proof Setup dialog: Device to Simulate (the working CMYK space or any CMYK or RGB profile), Preserve CMYK Numbers or Preserve RGB Numbers, Rendering intent (off while the numbers are preserved), Simulate Paper Color, Simulate Black Ink and Preview. OK sets the proof setup and turns Proof Colors on; Cancel puts the earlier proof back. view.proofSetup takes an "rgb:" target, preserveNumbers and simulateBlack, and its reply carries both. Simulate Black Ink shows the device's black without black-point compensation. With Preserve Numbers the renderer proofs each color from its own numbers as it paints it, placed CMYK images from their own inks, and the inks a CMYK document blends; the paper under the art takes Simulate Paper Color's tint. --- crates/color/src/cms.rs | 104 +++++++- crates/color/src/cms/tests.rs | 77 ++++++ crates/engine/src/cmd/colormgmt.rs | 19 +- crates/engine/src/tests/colormgmt.rs | 38 +++ crates/engine/tests/color_settings.rs | 57 +++- crates/mcp/src/ui_catalog.rs | 6 + crates/render/src/brush_fx.rs | 27 ++ crates/render/src/ink.rs | 126 ++++++++- crates/render/src/pattern.rs | 5 +- crates/render/src/proof.rs | 76 +++++- crates/render/src/renderer.rs | 40 ++- crates/render/src/renderer/nodes.rs | 5 +- crates/ui-egui/src/dialogs.rs | 5 + crates/ui-egui/src/dialogs/proof_setup.rs | 301 ++++++++++++++++++++++ crates/ui-egui/src/i18n/bg.tsv | 4 + crates/ui-egui/src/i18n/bs.tsv | 4 + crates/ui-egui/src/i18n/ca.tsv | 4 + crates/ui-egui/src/i18n/cs.tsv | 4 + crates/ui-egui/src/i18n/da.tsv | 4 + crates/ui-egui/src/i18n/de.tsv | 4 + crates/ui-egui/src/i18n/el.tsv | 4 + crates/ui-egui/src/i18n/es.tsv | 4 + crates/ui-egui/src/i18n/fi.tsv | 4 + crates/ui-egui/src/i18n/fr.tsv | 4 + crates/ui-egui/src/i18n/gu.tsv | 4 + crates/ui-egui/src/i18n/hi.tsv | 4 + crates/ui-egui/src/i18n/hu.tsv | 4 + crates/ui-egui/src/i18n/id.tsv | 4 + crates/ui-egui/src/i18n/it.tsv | 4 + crates/ui-egui/src/i18n/ja.tsv | 4 + crates/ui-egui/src/i18n/ka.tsv | 4 + crates/ui-egui/src/i18n/ko.tsv | 4 + crates/ui-egui/src/i18n/nl.tsv | 4 + crates/ui-egui/src/i18n/pl.tsv | 4 + crates/ui-egui/src/i18n/pt-br.tsv | 4 + crates/ui-egui/src/i18n/ru.tsv | 4 + crates/ui-egui/src/i18n/sv.tsv | 4 + crates/ui-egui/src/i18n/tests.rs | 19 ++ crates/ui-egui/src/i18n/tr.tsv | 4 + crates/ui-egui/src/i18n/uk.tsv | 4 + crates/ui-egui/src/i18n/vi.tsv | 4 + crates/ui-egui/src/i18n/zh-hans.tsv | 4 + crates/ui-egui/src/i18n/zh-hant.tsv | 4 + crates/ui-egui/src/menus/run.rs | 4 + crates/ui-egui/src/menus/state.rs | 7 + crates/ui-egui/src/menus/tree.rs | 2 +- crates/ui-egui/src/menus/ui_commands.rs | 6 + docs/mcp.md | 9 + docs/target-app-parity.md | 1 + 49 files changed, 1007 insertions(+), 39 deletions(-) create mode 100644 crates/ui-egui/src/dialogs/proof_setup.rs diff --git a/crates/color/src/cms.rs b/crates/color/src/cms.rs index 7fd8707a99..d1c21335ef 100644 --- a/crates/color/src/cms.rs +++ b/crates/color/src/cms.rs @@ -552,32 +552,106 @@ impl Cms { ProofTarget::Tritanopia => TRITANOPIA.simulate(srgb), ProofTarget::WorkingCmyk => { let working = self.working_cms(); - let cmyk = working.srgb_to_cmyk(srgb, proof.intent); - working.cmyk_to_srgb(cmyk, proof.simulate_paper) + let cmyk = if proof.preserve_numbers { self.preserved_cmyk(srgb) } else { working.srgb_to_cmyk(srgb, proof.intent) }; + self.proof_cmyk_to_srgb(cmyk, proof) } ProofTarget::Cmyk(name) => match cmyk_space(name) { Ok(sp) => { - let cmyk = Self::srgb_to_cmyk_in(&sp, srgb, proof.intent, self.settings.bpc); - Self::cmyk_to_srgb_in(&sp, cmyk, proof.simulate_paper, self.settings.bpc) + let cmyk = if proof.preserve_numbers { + self.preserved_cmyk(srgb) + } else { + Self::srgb_to_cmyk_in(&sp, srgb, proof.intent, self.settings.bpc) + }; + self.proof_cmyk_to_srgb(cmyk, proof) + } + Err(_) => srgb, + }, + ProofTarget::Rgb(name) => match rgb_space(canonical_name(name)) { + Ok(RgbSpace::Srgb) if !proof.preserve_numbers => srgb, + Ok(RgbSpace::Srgb) => self.srgb_to_rgb(srgb).map(|v| v.clamp(0.0, 1.0)), + Ok(RgbSpace::Icc(p)) => { + // The device's own numbers for the color: the document's RGB numbers unchanged, + // or the color converted into the device's space with the proof's intent. + let numbers = if proof.preserve_numbers { + self.srgb_to_rgb(srgb) + } else { + p.from_srgb(srgb, proof.intent).and_then(|v| Some([*v.first()?, *v.get(1)?, *v.get(2)?])).unwrap_or(srgb) + }; + p.to_srgb(&numbers, Intent::RelativeColorimetric).unwrap_or(srgb) } Err(_) => srgb, }, } } + /// Display sRGB of color `c` proofed with Preserve Numbers on a CMYK or RGB device: its own + /// numbers go to the device unchanged. A CMYK device takes a CMYK color's inks as they are, a + /// gray as K only and another color's inks in this context's CMYK space (relative + /// colorimetric); an RGB device takes an RGB color's numbers as they are and another color's + /// numbers in this context's RGB space. Other targets proof the color's display sRGB + /// ([`Self::proof_srgb`]). + pub fn proof_color(&self, c: &Color, proof: &ProofSetup) -> [f32; 3] { + if !proof.preserve_numbers { + return self.proof_srgb(self.display_rgb(c), proof); + } + match &proof.target { + ProofTarget::WorkingCmyk | ProofTarget::Cmyk(_) => self.proof_cmyk_to_srgb(self.to_cmyk(c, Intent::RelativeColorimetric), proof), + ProofTarget::Rgb(name) => { + // A CMYK color converts straight into the RGB space, so a wide space keeps it. + let numbers = match self.convert(c, Model::Rgb, Intent::RelativeColorimetric) { + Color::Rgb { r, g, b } => [r, g, b], + other => self.srgb_to_rgb(self.display_rgb(&other)), + } + .map(|v| v.clamp(0.0, 1.0)); + match rgb_space(canonical_name(name)) { + Ok(RgbSpace::Srgb) => numbers, + Ok(RgbSpace::Icc(p)) => p.to_srgb(&numbers, Intent::RelativeColorimetric).unwrap_or(numbers), + Err(_) => self.display_rgb(c), + } + } + _ => self.proof_srgb(self.display_rgb(c), proof), + } + } + + /// The CMYK numbers display sRGB `srgb` has in this context's CMYK space (relative + /// colorimetric), which Preserve CMYK Numbers sends to the simulated device unchanged: for + /// pixels whose own numbers are not known (an RGB image's pixels, art drawn over other art). + /// A color whose numbers are known proofs through [`Self::proof_color`]. + fn preserved_cmyk(&self, srgb: [f32; 3]) -> [f32; 4] { + self.srgb_to_cmyk(srgb, Intent::RelativeColorimetric) + } + /// Display sRGB of CMYK inks in the proof's CMYK space (this context's CMYK space for RGB - /// targets). + /// targets). Simulate Paper Color shows the paper's color and the press black (absolute + /// colorimetric); else Simulate Black Ink shows the press black as the dark gray it prints + /// (media-relative, without black-point compensation). pub fn proof_cmyk_to_srgb(&self, cmyk: [f32; 4], proof: &ProofSetup) -> [f32; 3] { + let black = proof.simulate_black && !proof.simulate_paper; match &proof.target { ProofTarget::Cmyk(name) => match cmyk_space(name) { + Ok(sp) if black => Self::black_ink_srgb(&sp, cmyk), Ok(sp) => Self::cmyk_to_srgb_in(&sp, cmyk, proof.simulate_paper, self.settings.bpc), Err(_) => self.cmyk_to_srgb(cmyk, proof.simulate_paper), }, + ProofTarget::WorkingCmyk if black => Self::black_ink_srgb(&self.working_cms().cmyk, cmyk), ProofTarget::WorkingCmyk => self.working_cms().cmyk_to_srgb(cmyk, proof.simulate_paper), _ => self.cmyk_to_srgb(cmyk, proof.simulate_paper), } } + /// Display sRGB of `cmyk` in `space`, media-relative and without black-point compensation, so + /// the darkest ink the space prints shows as the gray it is rather than as black. + fn black_ink_srgb(space: &CmykSpace, cmyk: [f32; 4]) -> [f32; 3] { + let cmyk = cmyk.map(|v| v.clamp(0.0, 1.0)); + if let CmykSpace::Icc(p) = space + && let Some(srgb) = builtin_rgb_cache(SRGB) + && let Some(v) = p.to_rgb_of(&srgb, &cmyk, Intent::RelativeColorimetric, false) + { + return v; + } + Self::cmyk_to_srgb_in(space, cmyk, false, false) + } + /// The context of the working settings: the one [`use_document_profiles`] put a document's /// profiles in place of, else this one. fn working_cms(&self) -> &Cms { @@ -587,7 +661,10 @@ impl Cms { /// A cached 3-D lookup table implementing [`Cms::proof_srgb`] for 8-bit pixels. pub fn proof_lut(&self, proof: &ProofSetup) -> Arc { let working = self.working.as_ref().map(|w| &w.settings); - let key = format!("{:?}|{working:?}|{:?}|{:?}|{}", self.settings, proof.target, proof.intent, proof.simulate_paper); + let key = format!( + "{:?}|{working:?}|{:?}|{:?}|{}|{}|{}", + self.settings, proof.target, proof.intent, proof.simulate_paper, proof.preserve_numbers, proof.simulate_black + ); let mut cache = PROOF_CACHE.lock().unwrap_or_else(|e| e.into_inner()); if let Some((_, l)) = cache.iter().find(|(k, _)| *k == key) { return l.clone(); @@ -736,6 +813,8 @@ pub enum ProofTarget { WorkingCmyk, /// A specific CMYK profile (Customize…). Cmyk(String), + /// A specific RGB profile (Customize…): the color as that RGB device shows it. + Rgb(String), /// Legacy Macintosh RGB (Gamma 1.8). LegacyMacRgb, /// Internet Standard RGB (sRGB). @@ -755,6 +834,9 @@ impl ProofTarget { if let Some(p) = s.strip_prefix("cmyk:") { return Some(ProofTarget::Cmyk(p.to_string())); } + if let Some(p) = s.strip_prefix("rgb:") { + return Some(ProofTarget::Rgb(p.to_string())); + } Some(match s { "workingCmyk" | "cmyk" => ProofTarget::WorkingCmyk, "legacyMacRgb" | "macRgb" => ProofTarget::LegacyMacRgb, @@ -770,6 +852,7 @@ impl ProofTarget { match self { ProofTarget::WorkingCmyk => "workingCmyk".into(), ProofTarget::Cmyk(p) => format!("cmyk:{p}"), + ProofTarget::Rgb(p) => format!("rgb:{p}"), ProofTarget::LegacyMacRgb => "legacyMacRgb".into(), ProofTarget::Srgb => "srgb".into(), ProofTarget::MonitorRgb => "monitorRgb".into(), @@ -793,6 +876,15 @@ pub struct ProofSetup { /// Simulate Paper Color (absolute colorimetric display of the press). #[serde(default)] pub simulate_paper: bool, + /// Preserve CMYK Numbers (a CMYK device) or Preserve RGB Numbers (an RGB device): the colors' + /// numbers go to the device unchanged instead of being converted into its space with + /// `intent`. + #[serde(default)] + pub preserve_numbers: bool, + /// Simulate Black Ink: the press black shows as the dark gray it prints (a CMYK device; implied + /// by `simulate_paper`). + #[serde(default)] + pub simulate_black: bool, /// Separations Preview: names of the visible plates ("Cyan", "Magenta", "Yellow", "Black", /// spot swatch names). `None` = normal composite proof. #[serde(default, skip_serializing_if = "Option::is_none")] diff --git a/crates/color/src/cms/tests.rs b/crates/color/src/cms/tests.rs index 7b22163525..d98152fd4f 100644 --- a/crates/color/src/cms/tests.rs +++ b/crates/color/src/cms/tests.rs @@ -194,6 +194,83 @@ fn colour_blindness_proofs() { assert_eq!(ProofTarget::parse(&ProofTarget::Cmyk("X".into()).id()), Some(ProofTarget::Cmyk("X".into()))); } +/// Proof Setup › Customize: Simulate Black Ink shows the press black of a CMYK device as the dark +/// gray it prints, where the proof otherwise shows it as black; Simulate Paper Color shows it so +/// as well, on the paper's color. +#[test] +fn simulate_black_ink_shows_the_press_black_as_gray() { + let c = cms(); + let device = ProofSetup { target: ProofTarget::Cmyk(GENERIC_CMYK.into()), ..Default::default() }; + let black = ProofSetup { simulate_black: true, ..device.clone() }; + let paper = ProofSetup { simulate_paper: true, ..device.clone() }; + let plain = c.proof_srgb([0.0; 3], &device); + let gray = c.proof_srgb([0.0; 3], &black); + assert!(plain.iter().all(|v| *v < 0.02), "black stays black: {plain:?}"); + assert!(gray.iter().all(|v| *v > 0.05), "the press black shows as a gray: {gray:?}"); + assert_eq!(c.proof_srgb([1.0; 3], &black), [1.0; 3], "the paper stays white"); + assert!(c.proof_srgb([0.0; 3], &paper).iter().all(|v| *v > 0.05)); + // The working CMYK target, and the inks Separations Preview shows, follow it too. + let working = ProofSetup { target: ProofTarget::WorkingCmyk, simulate_black: true, ..Default::default() }; + assert_eq!(c.proof_srgb([0.0; 3], &working), gray); + assert!(c.proof_cmyk_to_srgb([0.0, 0.0, 0.0, 1.0], &black)[0] > c.proof_cmyk_to_srgb([0.0, 0.0, 0.0, 1.0], &device)[0] + 0.05); + // The table the canvas draws through is made for each setting. + assert!(de(c.proof_lut(&black).apply([0.0; 3]), gray) < 2.5); + assert!(de(c.proof_lut(&device).apply([0.0; 3]), plain) < 2.5); +} + +/// Preserve CMYK Numbers sends the color's CMYK numbers in the document's space to the simulated +/// device unchanged: with Device CMYK as the working space, K50 shows as the simulated press +/// prints K50 (darker, with its dot gain). Without it the color is converted into the device's +/// space with the intent, and the gray looks as it does on screen. +#[test] +fn preserve_cmyk_numbers_sends_the_numbers_unchanged() { + let dev = Cms::new(&ColorSettings { cmyk: DEVICE_CMYK.into(), ..Default::default() }).unwrap(); + let press = Cms::new(&ColorSettings::default()).unwrap(); + let k50 = [0.0, 0.0, 0.0, 0.5]; + let gray = dev.cmyk_to_srgb(k50, false); + let device = ProofSetup { target: ProofTarget::Cmyk(GENERIC_CMYK.into()), ..Default::default() }; + let preserved = dev.proof_srgb(gray, &ProofSetup { preserve_numbers: true, ..device.clone() }); + let want = press.cmyk_to_srgb(k50, false); + assert!(de(preserved, want) < 0.5, "{preserved:?} vs {want:?}"); + let converted = dev.proof_srgb(gray, &device); + assert!(de(converted, gray) < 1.5, "{converted:?} vs {gray:?}"); + assert!(de(converted, preserved) > 3.0, "{converted:?} vs {preserved:?}"); + // With the numbers preserved the intent is not used. + let perceptual = ProofSetup { intent: Intent::Perceptual, preserve_numbers: true, ..device }; + assert_eq!(dev.proof_srgb(gray, &perceptual), preserved); +} + +/// An RGB profile as the device to simulate: with Preserve RGB Numbers the document's RGB numbers +/// show as that device shows them (sRGB numbers on a Display P3 device look more saturated); +/// without it a color the device can show looks the same, and one it can't show is clipped. +#[test] +fn rgb_device_proofs_show_the_device_numbers() { + let c = cms(); + let p3 = ProofSetup { target: ProofTarget::Rgb(DISPLAY_P3.into()), ..Default::default() }; + assert_eq!(ProofTarget::parse(&p3.target.id()), Some(p3.target.clone())); + assert_eq!(p3.target.id(), format!("rgb:{DISPLAY_P3}")); + assert!(!p3.target.is_cmyk()); + let red = [0.7, 0.3, 0.25]; + let converted = c.proof_srgb(red, &p3); + assert!(de(converted, red) < 1.0, "{converted:?}"); + let preserved = c.proof_srgb(red, &ProofSetup { preserve_numbers: true, ..p3.clone() }); + assert!(preserved[0] > red[0] + 0.02 && preserved[1] < red[1] - 0.02, "{preserved:?}"); + // An RGB color's own numbers give the same proof. + let own = c.proof_color(&Color::rgb(red[0], red[1], red[2]), &ProofSetup { preserve_numbers: true, ..p3.clone() }); + assert!(de(own, preserved) < 0.01, "{own:?} vs {preserved:?}"); + // sRGB numbers on an sRGB device: as they are either way. + let srgb = ProofSetup { target: ProofTarget::Rgb(SRGB.into()), preserve_numbers: true, ..Default::default() }; + assert!(de(c.proof_srgb(red, &srgb), red) < 0.01); + // A wider working space's numbers on an sRGB device: its green clips to sRGB green. + let wide = Cms::new(&ColorSettings { rgb: WIDE_GAMUT_RGB.into(), ..Default::default() }).unwrap(); + let green = wide.rgb_to_srgb([0.2, 0.8, 0.2]); + let shown = wide.proof_srgb(green, &srgb); + assert!(de(shown, green) > 3.0, "the wide space's numbers show as sRGB numbers: {shown:?}"); + // A profile that is gone leaves the colors as they are. + let gone = ProofSetup { target: ProofTarget::Rgb("Nope".into()), ..Default::default() }; + assert_eq!(c.proof_srgb(red, &gone), red); +} + /// The expected colors were computed separately with NumPy from the same published inputs (linear /// sRGB to XYZ from IEC 61966-2-1, Smith & Pokorny's XYZ to LMS, Judd-Vos XYZ at 485 nm and 660 nm), /// following Brettel, Viénot & Mollon (1997) with the display's white as the neutral axis. diff --git a/crates/engine/src/cmd/colormgmt.rs b/crates/engine/src/cmd/colormgmt.rs index 4e4da57f9c..2f43f4a791 100644 --- a/crates/engine/src/cmd/colormgmt.rs +++ b/crates/engine/src/cmd/colormgmt.rs @@ -100,7 +100,7 @@ pub fn specs() -> Vec { "Proof Setup", ["View", "Proof Setup"], None, - "{target?: \"workingCmyk\"|\"cmyk:\"|\"legacyMacRgb\"|\"srgb\"|\"monitorRgb\"|\"protanopia\"|\"deuteranopia\"|\"tritanopia\", intent?, simulatePaper?, proof?: bool (also turn Proof Colors on)} → proof state", + "{target?: \"workingCmyk\"|\"cmyk:\"|\"rgb:\"|\"legacyMacRgb\"|\"srgb\"|\"monitorRgb\"|\"protanopia\"|\"deuteranopia\"|\"tritanopia\" (cmyk: and rgb: name a CMYK or RGB profile of color.loadProfile or the built-in ones: the device to simulate), intent? (used while preserveNumbers is off), simulatePaper?: bool, preserveNumbers?: bool (Preserve CMYK or RGB Numbers: the colors' numbers in the document's space go to the device unchanged), simulateBlack?: bool (Simulate Black Ink: the device's black shows as the dark gray it prints; simulatePaper does this too; CMYK devices only, as simulatePaper), proof?: bool (also turn Proof Colors on)} → proof state", always, proof_setup ), @@ -235,7 +235,7 @@ fn load_profile(s: &mut Session, p: &Value) -> Result { use_front_profiles(s); touch_all(s); } else if proof_targets(&info.name) { - // A new file of the CMYK profile View → Proof Setup targets: redraw. + // A new file of the profile View → Proof Setup targets: redraw. touch_all(s); } else { // Documents behind the front one draw through their own profiles: those assigned it redraw. @@ -266,7 +266,7 @@ fn remove_profile(s: &mut Session, p: &Value) -> Result { if active.rgb == name || active.cmyk == name { use_front_profiles(s); } - // The CMYK profile View → Proof Setup targets: redraw. + // The profile View → Proof Setup targets: redraw. if proof_targets(&info.name) { touch_all(s); } @@ -285,9 +285,9 @@ fn touch_assigned(s: &mut Session, name: &str) { } } -/// Whether View → Proof Setup targets the CMYK profile `name`. +/// Whether View → Proof Setup targets the CMYK or RGB profile `name`. fn proof_targets(name: &str) -> bool { - matches!(proof::view().setup.target, ProofTarget::Cmyk(t) if t == name) + matches!(proof::view().setup.target, ProofTarget::Cmyk(t) | ProofTarget::Rgb(t) if t == name) } #[cfg(target_arch = "wasm32")] @@ -799,6 +799,8 @@ fn view_json(v: &proof::ProofView) -> Value { "target": v.setup.target.id(), "intent": v.setup.intent.id(), "simulatePaper": v.setup.simulate_paper, + "preserveNumbers": v.setup.preserve_numbers, + "simulateBlack": v.setup.simulate_black, "proofColors": v.proof_colors, "overprintPreview": v.overprint, "separations": v.separations, @@ -815,12 +817,19 @@ fn proof_setup(s: &mut Session, p: &Value) -> Result { { return Err(bad(C, format!("unknown CMYK profile `{name}`"))); } + if let ProofTarget::Rgb(name) = &t + && !cms::profile(name).is_some_and(|k| k.kind == cms::ProfileKind::Rgb) + { + return Err(bad(C, format!("unknown RGB profile `{name}`"))); + } v.setup.target = t; } if let Some(i) = intent_param(p, C)? { v.setup.intent = i; } v.setup.simulate_paper = switch_or(p, "simulatePaper", v.setup.simulate_paper, C)?; + v.setup.preserve_numbers = switch_or(p, "preserveNumbers", v.setup.preserve_numbers, C)?; + v.setup.simulate_black = switch_or(p, "simulateBlack", v.setup.simulate_black, C)?; if let Some(on) = on_param(p, "proof", C)? { v.proof_colors = on; } diff --git a/crates/engine/src/tests/colormgmt.rs b/crates/engine/src/tests/colormgmt.rs index 2d024f552b..6bbe174e93 100644 --- a/crates/engine/src/tests/colormgmt.rs +++ b/crates/engine/src/tests/colormgmt.rs @@ -610,6 +610,44 @@ fn proof_setup_simulates_tritanopia() { s.execute("view.proofSetup", &json!({"target": "workingCmyk", "proof": false})).unwrap(); } +/// View › Proof Setup › Customize's settings: an RGB profile as the device, Preserve Numbers and +/// Simulate Black Ink, kept in the proof view, read back and drawn; bad values are refused and +/// leave the view as it was. +#[test] +fn proof_setup_takes_the_custom_proof_settings() { + let _g = GLOBAL.lock().unwrap_or_else(|e| e.into_inner()); + let _v = DefaultView::new(); + let mut s = session(); + rect(&mut s, 0.0, 0.0, 100.0, 100.0, json!("#000000")); + let r = s.execute("view.proofSetup", &json!({})).unwrap(); + assert_eq!((r["preserveNumbers"].as_bool(), r["simulateBlack"].as_bool()), (Some(false), Some(false))); + let device = format!("cmyk:{}", cms::GENERIC_CMYK); + let r = s.execute("view.proofSetup", &json!({"target": device, "simulateBlack": true, "proof": true})).unwrap(); + assert_eq!((r["target"].as_str(), r["simulateBlack"].as_bool(), r["proofColors"].as_bool()), (Some(device.as_str()), Some(true), Some(true))); + let setup = vectorcraft_render::proof::active_proof().unwrap(); + assert!(setup.simulate_black && !setup.preserve_numbers); + let doc = s.doc().unwrap().doc.clone(); + let gray = render(&doc, RenderOptions { proof: Some(setup.clone()), ..Default::default() }).pixel(50, 50); + let black = render(&doc, RenderOptions { proof: Some(ProofSetup { simulate_black: false, ..setup }), ..Default::default() }).pixel(50, 50); + assert!(gray[0] > black[0] + 10, "the press black shows as a gray: {gray:?} vs {black:?}"); + let rgb = format!("rgb:{}", cms::DISPLAY_P3); + let r = s.execute("view.proofSetup", &json!({"target": rgb, "preserveNumbers": true})).unwrap(); + assert_eq!((r["target"].as_str(), r["preserveNumbers"].as_bool()), (Some(rgb.as_str()), Some(true))); + assert_eq!(vectorcraft_render::proof::view().setup.target, ProofTarget::Rgb(cms::DISPLAY_P3.into())); + // Unchanged settings leave the revision alone. + let rev = s.doc().unwrap().revision; + s.execute("view.proofSetup", &json!({"target": rgb, "preserveNumbers": true, "simulateBlack": true})).unwrap(); + assert_eq!(s.doc().unwrap().revision, rev); + let view = vectorcraft_render::proof::view(); + refused(&mut s, "view.proofSetup", json!({"target": "rgb:Nope"}), "unknown RGB profile `Nope`"); + refused(&mut s, "view.proofSetup", json!({"target": format!("rgb:{}", cms::GENERIC_CMYK)}), "unknown RGB profile"); + refused(&mut s, "view.proofSetup", json!({"target": "rgb:"}), "unknown RGB profile"); + refused(&mut s, "view.proofSetup", json!({"target": "workingCmyk", "preserveNumbers": "yes"}), "`preserveNumbers` must be true or false"); + refused(&mut s, "view.proofSetup", json!({"simulateBlack": 1}), "`simulateBlack` must be true or false"); + assert_eq!(vectorcraft_render::proof::view(), view, "the proof view is unchanged"); + assert_eq!(s.doc().unwrap().revision, rev, "nothing redraws"); +} + /// Whether the content has a DeviceCMYK fill/stroke operator (`c m y k k` / `K`). fn has_cmyk_op(pdf: &str) -> bool { let toks: Vec<&str> = pdf.split_ascii_whitespace().collect(); diff --git a/crates/engine/tests/color_settings.rs b/crates/engine/tests/color_settings.rs index b02e34690b..a7acb1c8e5 100644 --- a/crates/engine/tests/color_settings.rs +++ b/crates/engine/tests/color_settings.rs @@ -6,7 +6,7 @@ use std::sync::{Mutex, MutexGuard}; use serde_json::json; -use vectorcraft_color::cms; +use vectorcraft_color::{Color, cms}; use vectorcraft_engine::Session; use vectorcraft_engine::cmd::colormgmt::{PROFILES_KEY, doc_profiles}; use vectorcraft_engine::store::MAX_PRESET_FILE; @@ -865,3 +865,58 @@ fn saved_color_settings_that_cannot_be_used_leave_the_defaults() { assert!(!saved.bpc && saved.cmyk == cms::GENERIC_CMYK, "written over by the next change: {saved:?}"); } } + +/// View › Proof Setup › Customize's Preserve CMYK Numbers proofs each color from its own inks: +/// with Device CMYK as the working space, C50 M50 Y50 and K50 show as the same gray, and on +/// VectorCraft Generic CMYK they print, and so proof, as different grays; a pattern's tile art +/// proofs the same way. Without it the proof starts from the drawn pixels, which are the same. +#[test] +fn preserve_cmyk_numbers_proofs_each_color_from_its_inks() { + let _g = settings(); + let old = cms::active_settings(); + let mut s = session(); + s.execute("edit.colorSettings", &json!({"cmyk": cms::DEVICE_CMYK})).unwrap(); + let k50 = json!({"c": 0, "m": 0, "y": 0, "k": 50}); + let cmy = rect(&mut s, 0.0, 0.0, 100.0, 100.0); + exec(&mut s, "paint.setFill", json!({"ids": [cmy.0], "color": {"c": 50, "m": 50, "y": 50, "k": 0}})); + let k = rect(&mut s, 100.0, 0.0, 100.0, 100.0); + exec(&mut s, "paint.setFill", json!({"ids": [k.0], "color": k50})); + // A pattern whose tile is all K50, filling a band below the squares. + let tile = rect(&mut s, 300.0, 0.0, 10.0, 10.0); + exec(&mut s, "paint.setFill", json!({"ids": [tile.0], "color": k50})); + exec(&mut s, "object.pattern.make", json!({"ids": [tile.0], "name": "K50 Tile", "edit": false})); + let band = rect(&mut s, 0.0, 130.0, 200.0, 40.0); + exec(&mut s, "paint.setFill", json!({"ids": [band.0], "swatch": "K50 Tile"})); + let proof = |preserve_numbers| vectorcraft_render::proof::ProofSetup { + target: vectorcraft_render::proof::ProofTarget::Cmyk(cms::GENERIC_CMYK.into()), + preserve_numbers, + ..Default::default() + }; + let doc = s.doc().unwrap().doc.clone(); + let pixel = |px: &[u8], x: usize, y: usize| [px[(y * 200 + x) * 4], px[(y * 200 + x) * 4 + 1], px[(y * 200 + x) * 4 + 2]]; + // The pixels at the centers of the two squares and in the patterned band. + let shown = |proof: Option| { + let opts = RenderOptions { proof, background: Some([255, 255, 255, 255]), ..Default::default() }; + let px = Renderer::new().render(&doc, 200, 200, Affine::IDENTITY, &opts).pixels; + (pixel(&px, 50, 50), pixel(&px, 150, 50), pixel(&px, 55, 155)) + }; + let (a, b, _) = shown(None); + let (pa, pb, _) = shown(Some(proof(false))); + let (ca, cb, cp) = shown(Some(proof(true))); + let want = |c: Color| cms::active().proof_color(&c, &proof(true)).map(|v| (v * 255.0).round() as i32); + let cmy_want = want(Color::cmyk(0.5, 0.5, 0.5, 0.0)); + let k_want = want(Color::cmyk(0.0, 0.0, 0.0, 0.5)); + // With Simulate Paper Color the art sits on the device's paper, not on white. + let paper = vectorcraft_render::proof::ProofSetup { simulate_paper: true, ..proof(true) }; + let tint = cms::active().proof_srgb([1.0; 3], &paper).map(|v| (v * 255.0).round() as i32); + let opts = RenderOptions { proof: Some(paper), background: Some([255, 255, 255, 255]), ..Default::default() }; + let bare = pixel(&Renderer::new().render(&doc, 200, 200, Affine::IDENTITY, &opts).pixels, 50, 115); + cms::set_active(&old).unwrap(); + assert_eq!(a, b, "the two builds show as one gray in Device CMYK"); + assert_eq!(pa, pb, "proofed from the pixels, they stay one gray"); + assert!(ca != cb, "proofed from their inks, they print differently: {ca:?} vs {cb:?}"); + let near = |got: [u8; 3], want: [i32; 3]| got.iter().zip(want).all(|(g, w)| (i32::from(*g) - w).abs() <= 2); + assert!(near(ca, cmy_want) && near(cb, k_want), "{ca:?} {cmy_want:?}, {cb:?} {k_want:?}"); + assert!(near(cp, k_want), "the pattern's tile proofs from its inks: {cp:?} vs {k_want:?}"); + assert!(tint != [255; 3] && near(bare, tint), "the bare page shows the paper: {bare:?} vs {tint:?}"); +} diff --git a/crates/mcp/src/ui_catalog.rs b/crates/mcp/src/ui_catalog.rs index 616a11498d..701d7d9f7a 100644 --- a/crates/mcp/src/ui_catalog.rs +++ b/crates/mcp/src/ui_catalog.rs @@ -957,6 +957,12 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[ "", "{} open Saturate for the selection (dialog `saturate`, fields `intensity` −100..100, `preview`): previews live, OK runs edit.colors.saturate as one undo step", ), + ( + "ui.proofSetupDialog", + "Customize…", + "", + "{} open View › Proof Setup › Customize (dialog `proofSetup`, fields `device` (\"workingCmyk\", \"cmyk:\" or \"rgb:\": any CMYK or RGB profile), `preserveNumbers`, `intent` (used while preserveNumbers is off), `simulatePaper` and `simulateBlack` (CMYK devices only), `preview` (on): Preview shows the proof on the canvas, OK runs view.proofSetup with these and proof: true, Cancel puts the earlier proof view back)", + ), ( "ui.indexedColorDialog", "Convert to Indexed Color…", diff --git a/crates/render/src/brush_fx.rs b/crates/render/src/brush_fx.rs index 3c6ea922d4..4bae84d9b5 100644 --- a/crates/render/src/brush_fx.rs +++ b/crates/render/src/brush_fx.rs @@ -321,6 +321,33 @@ mod tests { } } + /// A proof that preserves the colors' numbers proofs an art brush's own colors, as it proofs + /// the document's: the brush's blue shows as the simulated device shows that color's numbers. + #[test] + fn a_proof_that_preserves_numbers_proofs_brush_art() { + use vectorcraft_brush::{ArtBrush, ArtScale, Brush, BrushKind, Colorization}; + use vectorcraft_color::cms; + + let mut d = doc_with_line(Some("Blue art"), 1.0); + let blue = Color::rgb(0.0, 0.0, 1.0); + let art = + Node::path(d.alloc_id(), shapes::rectangle(Rect::new(0.0, -10.0, 10.0, 10.0)), Appearance::basic(Paint::solid(blue), Paint::None, 0.0)); + let brush = Brush { + name: "Blue art".into(), + kind: BrushKind::Art(ArtBrush { art, scale: ArtScale::Stretch, colorization: Colorization::None, ..Default::default() }), + }; + vectorcraft_brush::store(&mut d, &[brush]); + let proof = cms::ProofSetup { target: cms::ProofTarget::Cmyk(cms::DEVICE_CMYK.into()), preserve_numbers: true, ..Default::default() }; + let want = cms::active().proof_color(&blue, &proof).map(|v| (v * 255.0).round() as i32); + let opts = RenderOptions { proof: Some(proof), background: Some([255, 255, 255, 255]), ..Default::default() }; + let mut r = Renderer::new(); + for _ in 0..2 { + let px = r.render(&d, 200, 100, Affine::IDENTITY, &opts).pixel(100, 50); + assert!(want != [0, 0, 255], "{want:?}"); + assert!(px.iter().zip(want).all(|(p, w)| (i32::from(*p) - w).abs() <= 2), "{px:?} vs {want:?}"); + } + } + /// Object opacity fades a brushed stroke's art as a whole, with or without a dash and a fill: /// the same as the object at full opacity inside a group at that opacity. #[test] diff --git a/crates/render/src/ink.rs b/crates/render/src/ink.rs index 7bcc117a23..7279c73178 100644 --- a/crates/render/src/ink.rs +++ b/crates/render/src/ink.rs @@ -12,6 +12,9 @@ //! colours; RGB colours and placed images are separated into the working CMYK space first. //! //! RGB documents, and CMYK documents without transparency, draw screen colours ([`Ink::Display`]). +//! A proof that preserves the colors' numbers draws each screen colour as the proof shows it +//! ([`Ink::Proofed`]); a CMYK document that blends in CMYK keeps its ink planes, and [`compose`] +//! shows their inks through the proof. use std::cell::RefCell; use std::collections::HashMap; @@ -44,6 +47,10 @@ pub(crate) enum Ink { RichBlack, /// Source-color adjustment before the display/ink conversion. Float bits keep cache keys exact. Darkened(InkSpace, u32, bool), + /// Screen colours as a proof that preserves the colors' numbers shows them + /// ([`crate::proof::preserves`], [`Cms::proof_color`]): the proof [`proofed_ink`] registered + /// under this number, so the caches keep what each proof draws apart. + Proofed(u32), } #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] @@ -52,6 +59,68 @@ pub(crate) enum InkSpace { Cmy, K, RichBlack, + Proofed(u32), +} + +/// What [`Ink::Proofed`] paints with: its number, the color settings and the proof setup. +type Proof = (u32, Arc, vectorcraft_color::cms::ProofSetup, u64); + +/// The proofs [`proofed_ink`] registered last, the newest last: a few, for renderers drawing with +/// different ones. +static PROOFS: Mutex>> = Mutex::new(Vec::new()); +/// The last number [`proofed_ink`] gave out. +static PROOF_NUMBER: std::sync::atomic::AtomicU32 = std::sync::atomic::AtomicU32::new(0); + +thread_local! { + /// The proof [`Ink::rgb`] used last on this thread, so a frame does not look it up for each + /// color it paints. + static LAST_PROOF: RefCell>> = const { RefCell::new(None) }; +} + +/// Keeps the proof [`proofed_ink`] registered for a frame while the frame is drawn: a proof that +/// something holds stays registered. +pub(crate) struct ProofHold(#[allow(dead_code)] Arc); + +/// The ink a frame drawn with a proof that preserves the colors' numbers paints screen colours +/// with: the same [`Ink::Proofed`] number for the same proof setup, active color settings and +/// loaded profiles ([`cms::profiles_generation`]), and a new one when any of them changes. The +/// proof stays registered while the hold returned with it is kept. +pub(crate) fn proofed_ink(proof: &vectorcraft_color::cms::ProofSetup) -> (Ink, ProofHold) { + let (c, profiles) = (cms::active(), cms::profiles_generation()); + let mut proofs = PROOFS.lock().unwrap_or_else(|e| e.into_inner()); + if let Some(p) = proofs.iter().find(|p| Arc::ptr_eq(&p.1, &c) && p.2 == *proof && p.3 == profiles) { + return (Ink::Proofed(p.0), ProofHold(p.clone())); + } + let number = PROOF_NUMBER.fetch_add(1, Ordering::Relaxed).wrapping_add(1); + // Past a few, the oldest proof nothing holds (no frame, no thread's last proof) goes. + if proofs.len() >= 8 + && let Some(i) = proofs.iter().position(|p| Arc::strong_count(p) == 1) + { + proofs.remove(i); + } + let p = Arc::new((number, c, proof.clone(), profiles)); + proofs.push(p.clone()); + (Ink::Proofed(number), ProofHold(p)) +} + +/// The proof setup `ink` proofs with ([`Ink::Proofed`], darkened or not), while it is registered. +pub(crate) fn proof_of(ink: Ink) -> Option { + let Ink::Proofed(number) = ink.base() else { return None }; + PROOFS.lock().unwrap_or_else(|e| e.into_inner()).iter().find(|p| p.0 == number).map(|p| p.2.clone()) +} + +/// Display sRGB of `c` as the proof [`proofed_ink`] registered under `number` shows it; a proof +/// no longer registered shows the colour as it is. +fn proofed_rgb(number: u32, c: &Color) -> [f32; 3] { + let proof = LAST_PROOF.with(|l| l.borrow().clone().filter(|p| p.0 == number)).or_else(|| { + let p = PROOFS.lock().unwrap_or_else(|e| e.into_inner()).iter().find(|p| p.0 == number).cloned(); + LAST_PROOF.with(|l| l.borrow_mut().clone_from(&p)); + p + }); + match proof { + Some(p) => p.1.proof_color(c, &p.2), + None => c.to_rgb(), + } } impl Ink { @@ -61,6 +130,7 @@ impl Ink { Self::Darkened(InkSpace::Cmy, _, _) => Self::Cmy, Self::Darkened(InkSpace::K, _, _) => Self::K, Self::Darkened(InkSpace::RichBlack, _, _) => Self::RichBlack, + Self::Darkened(InkSpace::Proofed(n), _, _) => Self::Proofed(n), other => other, } } @@ -74,6 +144,11 @@ impl Ink { } } + /// Whether this ink adjusts the source colors first ([`Ink::Darkened`]). + pub(crate) fn is_darkened(self) -> bool { + matches!(self, Self::Darkened(..)) + } + fn darkness(self) -> Option { match self { Self::Darkened(_, bits, _) => Some(f32::from_bits(bits)), @@ -96,6 +171,7 @@ impl Ink { Self::Cmy => InkSpace::Cmy, Self::K => InkSpace::K, Self::RichBlack => InkSpace::RichBlack, + Self::Proofed(n) => InkSpace::Proofed(n), _ => InkSpace::Display, }; Self::Darkened(space, amount.to_bits(), black) @@ -151,6 +227,7 @@ impl Ink { match (self, *c) { (Ink::RichBlack, Color::Cmyk { c, m, y, k }) if is_pure_black([c, m, y, k]) => [0.0; 3], (Ink::Display | Ink::RichBlack, _) => c.to_rgb(), + (Ink::Proofed(n), _) => proofed_rgb(n, c), _ => self.plane(inks(c)), } } @@ -178,7 +255,7 @@ impl Ink { pub(crate) fn fixed8(self, [r, g, b, a]: [u8; 4]) -> [u8; 4] { match self.base() { - Ink::Display | Ink::RichBlack => [r, g, b, a], + Ink::Display | Ink::RichBlack | Ink::Proofed(_) => [r, g, b, a], _ => { let lab = lab::srgb_to_lab([r, g, b].map(|v| v as f32 / 255.0)); let [r, g, b] = self.plane(inks(&Color::Lab { l: lab.l, a: lab.a, b: lab.b })).map(q); @@ -319,6 +396,32 @@ fn cached(slot: &Cached, build: impl FnOnce(&Cms) -> T) -> (Arc, u64) { (t, g) } +/// A table [`proofed_lut`] made, with the color settings, proof setup and profiles generation it +/// was made for. +type ProofedLut = (Arc, vectorcraft_color::cms::ProofSetup, u64, Arc); + +/// The tables [`proofed_lut`] made last, the newest last. +static PROOFED: Mutex> = Mutex::new(Vec::new()); + +/// Ink amounts → their display sRGB as `proof` shows a CMYK color of those inks +/// ([`Cms::proof_color`]), for the active color settings and loaded profiles. Cached. +fn proofed_lut(proof: &vectorcraft_color::cms::ProofSetup) -> Arc { + let (c, profiles) = (cms::active(), cms::profiles_generation()); + let mut kept = PROOFED.lock().unwrap_or_else(|e| e.into_inner()); + if let Some((.., t)) = kept.iter().find(|(o, p, g, _)| Arc::ptr_eq(o, &c) && p == proof && *g == profiles) { + return t.clone(); + } + let t = Arc::new(InkLut(CmykLut::build(|[cy, m, y, k]| { + let [px, py, pz] = lab::srgb_to_xyz(c.proof_color(&Color::Cmyk { c: cy, m, y, k }, proof)); + [px, py, pz, 0.0] + }))); + if kept.len() >= KEPT_TABLES { + kept.remove(0); + } + kept.push((c, proof.clone(), profiles, t.clone())); + t +} + /// [`compose`] puts at least this many pixels in each band but the last. const BAND_PIXELS: usize = 1 << 16; @@ -331,12 +434,19 @@ const BAND_PIXELS: usize = 1 << 16; /// each other band (this thread does when that one can't start). Returns the picture and the number /// of threads that composed it. pub(crate) fn compose(cmy: &[u8], k: &[u8], opts: &RenderOptions, threads: u16) -> (Vec, usize) { - let (lut, _) = cached(&DISPLAY, InkLut::build); - let bg = opts.background.map(|b| (Ink::Cmy.fixed8(b), Ink::K.fixed8(b), b)); + // With a proof that preserves the numbers, the inks show as the proof's device shows them, + // and the background as it shows white paper. + let lut = match crate::proof::preserving(opts) { + Some(p) => proofed_lut(p), + None => cached(&DISPLAY, InkLut::build).0, + }; + let bg = opts.background.map(|b| (Ink::Cmy.fixed8(b), Ink::K.fixed8(b), crate::proof::under_art(opts, b))); let mut out = vec![0; cmy.len().min(k.len()) / 4 * 4]; let pixels = out.len() / 4; let bands = (pixels / BAND_PIXELS).clamp(1, usize::from(threads).max(1)); - let band = |o: &mut [u8], p: &[u8], q: &[u8]| compose_band(o, p, q, &lut, bg, opts.rich_black); + // A proof shows its device's black, not Appearance of Black's rich black. + let rich_black = opts.rich_black && crate::proof::preserving(opts).is_none(); + let band = |o: &mut [u8], p: &[u8], q: &[u8]| compose_band(o, p, q, &lut, bg, rich_black); if bands == 1 { band(&mut out, cmy, k); return (out, 1); @@ -469,9 +579,9 @@ fn plane_key(key: &ImageKey, plane: Ink, generation: u64) -> ImageKey { /// The key [`ink_image`] gives image pixels `key` painted with `ink`. pub(crate) fn ink_key(key: &ImageKey, ink: Ink) -> ImageKey { if ink.darkness().is_some() { - let generation = if matches!(ink.base(), Ink::Display | Ink::RichBlack) { 0 } else { separation().1 }; + let generation = if matches!(ink.base(), Ink::Display | Ink::RichBlack | Ink::Proofed(_)) { 0 } else { separation().1 }; plane_key(key, ink, generation) - } else if matches!(ink, Ink::Display | Ink::RichBlack) { + } else if matches!(ink, Ink::Display | Ink::RichBlack | Ink::Proofed(_)) { key.clone() } else { plane_key(key, ink, separation().1) @@ -489,7 +599,7 @@ fn darkened_image(key: &ImageKey, pm: &Arc, ink: Ink, amount: f32, blob: return (want, p); } let base = ink.base(); - let display = matches!(base, Ink::Display | Ink::RichBlack); + let display = matches!(base, Ink::Display | Ink::RichBlack | Ink::Proofed(_)); let raw_cmyk = key_inks(key, blob).filter(|i| (i.width, i.height) == (u32::from(pm.width()), u32::from(pm.height()))); let sep = (!display).then(separation); let shown = (display && raw_cmyk.is_some()).then(display_lut); @@ -527,7 +637,7 @@ pub(crate) fn ink_image(key: &ImageKey, pm: &Arc, ink: Ink, blob: Option if let Some(amount) = ink.darkness() { return darkened_image(key, pm, ink, amount, blob, touch); } - if matches!(ink, Ink::Display | Ink::RichBlack) { + if matches!(ink, Ink::Display | Ink::RichBlack | Ink::Proofed(_)) { return (key.clone(), pm.clone()); } let (luts, generation) = separation(); diff --git a/crates/render/src/pattern.rs b/crates/render/src/pattern.rs index 317a423681..94b8e8576e 100644 --- a/crates/render/src/pattern.rs +++ b/crates/render/src/pattern.rs @@ -191,6 +191,9 @@ fn rasterize( let symbols = doc.symbol_boxes().quick(); r.stamp += 1; let px_rect = Rect::new(0.0, 0.0, w as f64, h as f64); + // A tile drawn for a proof that preserves the colors' numbers shows its images through that + // proof too. + let plates = crate::proof::ink_plate_lut(ink, doc); for o in def.offsets_covering(region) { let v = view * def.instance_xf(o); let frame = Frame { @@ -203,7 +206,7 @@ fn rasterize( opts: &opts, ink, output: v, - plates: None, + plates: plates.as_deref(), }; for a in &def.art { r.draw_arc(&mut ctx, &frame, a); diff --git a/crates/render/src/proof.rs b/crates/render/src/proof.rs index 284ad8ce5d..29799a9a2b 100644 --- a/crates/render/src/proof.rs +++ b/crates/render/src/proof.rs @@ -2,6 +2,9 @@ //! //! * **Proof Colors** post-processes the rendered frame: every pixel goes display sRGB → proof //! space (CMYK press or RGB/colour-blindness simulation) → display, through a cached 17³ LUT. +//! With Preserve CMYK or RGB Numbers ([`preserves`]) each color is proofed from its own numbers +//! as it is painted instead ([`crate::ink::Ink::Proofed`]), and placed images from their own +//! inks or pixels ([`plate_image`]). //! * **Separations Preview** recolours the *document* before rendering: each paint colour is split //! into process inks (colour-managed), or a spot ink at the colour's tint when it's linked to a //! spot swatch (solid colours and gradient stops alike), with the process plates a gradient stop @@ -45,6 +48,21 @@ pub(crate) fn overprints(opts: &RenderOptions) -> bool { opts.overprint_preview || opts.proof.as_ref().is_some_and(|p| p.separations.is_some()) } +/// Whether Proof Colors sends the colors' own numbers to the device it simulates (Preserve CMYK +/// or RGB Numbers on a CMYK or RGB device, outside Separations Preview): each color is proofed as +/// it is painted ([`crate::ink::Ink::Proofed`]) and placed images from their own inks or pixels +/// ([`plate_image`]), and the drawn frame is not proofed again ([`post`]). +pub(crate) fn preserves(proof: &ProofSetup) -> bool { + proof.preserve_numbers + && proof.separations.is_none() + && matches!(proof.target, ProofTarget::WorkingCmyk | ProofTarget::Cmyk(_) | ProofTarget::Rgb(_)) +} + +/// The proof of [`RenderOptions::proof`] when it [`preserves`] the colors' numbers. +pub(crate) fn preserving(opts: &RenderOptions) -> Option<&ProofSetup> { + opts.proof.as_ref().filter(|p| preserves(p)) +} + /// What the `visible` plates print of `ink`, as display sRGB, without the spot inks over several /// plates: with one plate visible its ink as a grey (black = 100%), else the visible process inks /// through the proof profile. @@ -101,10 +119,26 @@ pub(crate) struct PlateLut { } impl PlateLut { - /// What the visible plates show of process inks `cmyk`, as display sRGB. + /// What the visible plates show of process inks `cmyk`, as display sRGB; with Preserve + /// Numbers outside Separations Preview, the inks as the proof's device shows them. fn shown(&self, cmyk: [f32; 4]) -> [f32; 3] { - let visible = self.proof.separations.as_deref().unwrap_or_default(); - plate_rgb(&self.cms, &self.proof, visible, &Inks { cmyk, spot: None, registration: false }) + match self.proof.separations.as_deref() { + Some(visible) => plate_rgb(&self.cms, &self.proof, visible, &Inks { cmyk, spot: None, registration: false }), + None => { + let [c, m, y, k] = cmyk; + self.cms.proof_color(&Color::Cmyk { c, m, y, k }, &self.proof) + } + } + } + + /// What display pixel `rgb` shows as: its inks separated with the proof's intent through the + /// visible plates, or with Preserve Numbers outside Separations Preview, its numbers as the + /// proof's device shows them. + fn shown_rgb(&self, rgb: [f32; 3]) -> [f32; 3] { + match self.proof.separations { + Some(_) => self.shown(self.cms.srgb_to_cmyk(rgb, self.proof.intent)), + None => self.cms.proof_srgb(rgb, &self.proof), + } } } @@ -114,10 +148,19 @@ static PLATE_LUTS: Mutex>> = Mutex::new(Vec::new()); /// The last [`PlateLut::generation`] handed out. static PLATE_GENERATION: AtomicU64 = AtomicU64::new(0); +/// The tables the placed images of `doc` show through in art drawn with `ink` apart from a frame's +/// options (a pattern's tiles): with a proof that preserves the colors' numbers +/// ([`crate::ink::Ink::Proofed`]), that proof's ([`plate_lut`]); else `None`. +pub(crate) fn ink_plate_lut(ink: crate::ink::Ink, doc: &Document) -> Option> { + let proof = crate::ink::proof_of(ink)?; + plate_lut(&RenderOptions { proof: Some(proof), ..Default::default() }, doc) +} + /// The tables the placed images of `doc` show Separations Preview's visible plates through with -/// `opts`, or `None` when it is off. +/// `opts`, or their colors as a proof that [`preserves`] the numbers shows them; `None` when +/// neither is on. pub(crate) fn plate_lut(opts: &RenderOptions, doc: &Document) -> Option> { - let proof = opts.proof.as_ref().filter(|p| p.separations.is_some())?; + let proof = opts.proof.as_ref().filter(|p| p.separations.is_some() || preserves(p))?; let (c, profiles) = (cms::active(), cms::profiles_generation()); // The spot ones are the spot plates of `vectorcraft_doc::inks::plates`; their colors are part // of the tables' identity, so a swatch edit shows. @@ -151,12 +194,17 @@ pub(crate) fn plate_image(lut: &PlateLut, key: &ImageKey, pm: &Pixmap, blob: Opt return (want, p); } // An image placed from a DCS file shows its own plates, spot plates included. - if let Some(s) = blob.filter(|b| crate::ink::shows_own_inks(key) && b.is_separated()).and_then(ImageBlob::separated) { + if let Some(s) = + blob.filter(|b| lut.proof.separations.is_some() && crate::ink::shows_own_inks(key) && b.is_separated()).and_then(ImageBlob::separated) + { let out = images::store().insert(want.clone(), Arc::new(plates_shown(lut, &s, pm))); return (want, out); } let size = (u32::from(pm.width()), u32::from(pm.height())); - let raw = crate::ink::key_inks(key, blob).filter(|i| (i.width, i.height) == size); + // A proof that preserves the numbers shows darkened pixels (a shadow's) as they are drawn, + // not the image's own inks. + let darkened = lut.proof.separations.is_none() && key.ink.is_darkened(); + let raw = crate::ink::key_inks(key, blob).filter(|i| !darkened && (i.width, i.height) == size); let mut out = pm.clone(); match raw { Some(inks) => { @@ -173,7 +221,7 @@ pub(crate) fn plate_image(lut: &PlateLut, key: &ImageKey, pm: &Pixmap, blob: Opt } } None => { - let t = lut.rgb.get_or_init(|| ProofLut::build(|rgb| lut.shown(lut.cms.srgb_to_cmyk(rgb, lut.proof.intent)))); + let t = lut.rgb.get_or_init(|| ProofLut::build(|rgb| lut.shown_rgb(rgb))); for px in out.data_mut().iter_mut().filter(|p| p.a > 0) { let a = f32::from(px.a); let un = |v: u8| (f32::from(v) / a).min(1.0); @@ -460,7 +508,7 @@ fn prepare_node(n: &Arc, earlier: Option<(&Arc, &Arc)>, how: & /// Soft-proof the rendered (premultiplied RGBA8) pixels in place. pub(crate) fn post(pixels: &mut [u8], opts: &RenderOptions) { let Some(proof) = opts.proof.as_ref() else { return }; - if proof.separations.is_some() || matches!(proof.target, ProofTarget::MonitorRgb | ProofTarget::Srgb) { + if proof.separations.is_some() || preserves(proof) || matches!(proof.target, ProofTarget::MonitorRgb | ProofTarget::Srgb) { return; } let lut = cms::active().proof_lut(proof); @@ -485,6 +533,16 @@ pub(crate) fn post(pixels: &mut [u8], opts: &RenderOptions) { } } +/// Solid color `[r, g, b, a]` (straight alpha) under the art of a frame drawn with `opts`: with a +/// proof that [`preserves`] the numbers, whose art [`prepare`] proofs before drawing, as the +/// proof's device shows it (white paper takes Simulate Paper Color's tint), so the art's +/// transparency and edges mix with it as they print; else as it is. +pub(crate) fn under_art(opts: &RenderOptions, [r, g, b, a]: [u8; 4]) -> [u8; 4] { + let Some(proof) = preserving(opts) else { return [r, g, b, a] }; + let [r, g, b] = cms::active().proof_srgb([r, g, b].map(|v| f32::from(v) / 255.0), proof).map(|v| (v.clamp(0.0, 1.0) * 255.0).round() as u8); + [r, g, b, a] +} + /// View-level proof state (View → Proof Setup / Proof Colors / Overprint Preview, Separations /// Preview panel). Process-wide: the app has one proof state for all windows. #[derive(Clone, Debug, Default, PartialEq)] diff --git a/crates/render/src/renderer.rs b/crates/render/src/renderer.rs index 500d62d5b4..e1e5da0b6b 100644 --- a/crates/render/src/renderer.rs +++ b/crates/render/src/renderer.rs @@ -147,7 +147,16 @@ impl Renderer { let inv = view.inverse(); let visible = inv.transform_rect_bbox(Rect::new(0.0, 0.0, w as f64, h as f64)); let px = 1.0 / view.determinant().abs().sqrt().max(1e-12); - let screen = if opts.rich_black { Ink::RichBlack } else { Ink::Display }; + // A proof that preserves the colors' numbers proofs each colour as it is painted; the hold + // keeps that proof registered until the frame is drawn. + let (screen, _proof) = match proof::preserving(opts) { + Some(p) => { + let (ink, hold) = ink::proofed_ink(p); + (ink, Some(hold)) + } + None if opts.rich_black => (Ink::RichBlack, None), + None => (Ink::Display, None), + }; let symbols = doc.symbol_boxes().quick(); let output = Affine::scale(1.0 / f64::from(cell.max(1))) * view; let plates = proof::plate_lut(opts, doc); @@ -167,10 +176,13 @@ impl Renderer { return Rendered { width: w as u32, height: h as u32, pixels }; } let mut pixels = if inks || self.blends_in_cmyk(doc, opts) { - // Blending in CMYK: one frame per ink plane, then their inks shown on screen. - let cmy = self.draw_frame(&Frame { ink: Ink::Cmy, ..frame }, w, h); + // Blending in CMYK: one frame per ink plane, then their inks shown on screen (through a + // proof that preserves the numbers, when one is on: the planes hold the inks as they + // are, images included). + let planes = if proof::preserving(opts).is_some() { None } else { frame.plates }; + let cmy = self.draw_frame(&Frame { ink: Ink::Cmy, plates: planes, ..frame }, w, h); let stats = self.stats; - let k = self.draw_frame(&Frame { ink: Ink::K, ..frame }, w, h); + let k = self.draw_frame(&Frame { ink: Ink::K, plates: planes, ..frame }, w, h); self.stats = stats; if inks { ink::amounts(&cmy, &k) @@ -263,9 +275,16 @@ impl Renderer { ctx.set_aliasing_threshold(opts.anti_alias.threshold()); self.raster = raster_settings(opts); if opts.artboards && !opts.outline { - // Paper: white on screen, no ink on the ink planes. + // Paper: white on screen, no ink on the ink planes; with a proof that preserves the + // colors' numbers, the device's paper. ctx.set_transform(f.view); - ctx.set_paint(peniko::Color::WHITE); + match screen_under_art(f, [255; 4]) { + [255, 255, 255, _] => ctx.set_paint(peniko::Color::WHITE), + paper => { + let [r, g, b, a] = f.ink.fixed8(paper); + ctx.set_paint(peniko::Color::from_rgba8(r, g, b, a)); + } + } for ab in &f.doc.artboards { ctx.fill_rect(&ab.rect); } @@ -290,7 +309,7 @@ impl Renderer { } let mut pixels = pm.data_as_u8_slice().to_vec(); if let Some(bg) = opts.background { - over_background(&mut pixels, f.ink.fixed8(bg)); + over_background(&mut pixels, f.ink.fixed8(screen_under_art(f, bg))); } pixels } @@ -460,6 +479,13 @@ fn raster_settings(opts: &RenderOptions) -> vello_cpu::RasterizerSettings { vello_cpu::RasterizerSettings { render_mode, ..Default::default() } } +/// Solid color `rgba` (straight alpha) under the art of frame `f`: on screen as +/// [`proof::under_art`] gives it; the ink planes paint it as it is, and [`ink::compose`] shows it +/// through the proof. +fn screen_under_art(f: &Frame, rgba: [u8; 4]) -> [u8; 4] { + if matches!(f.ink.base(), Ink::Cmy | Ink::K) { rgba } else { proof::under_art(f.opts, rgba) } +} + /// Premultiplied RGBA `pixels` drawn over the solid color `background` (`[r, g, b, a]`, straight). pub(crate) fn over_background(pixels: &mut [u8], [r, g, b, a]: [u8; 4]) { let alpha = u32::from(a); diff --git a/crates/render/src/renderer/nodes.rs b/crates/render/src/renderer/nodes.rs index 15bd354496..fbde6c08fa 100644 --- a/crates/render/src/renderer/nodes.rs +++ b/crates/render/src/renderer/nodes.rs @@ -307,7 +307,10 @@ impl Renderer { let image_left_out = self.image_left_out.replace(false); let failures = crate::paint::decode_failures(); let pattern_images_left_out = crate::pattern::images_left_out(); - self.draw_kept_node(&mut mctx, &Frame { mt: false, ink: Ink::Display, ..*f }, &m.art); + // A proof that preserves the colors' numbers leaves the mask's images as they are, as it + // leaves its colors. + let plates = if crate::proof::preserving(f.opts).is_some() { None } else { f.plates }; + self.draw_kept_node(&mut mctx, &Frame { mt: false, ink: Ink::Display, plates, ..*f }, &m.art); let incomplete = self.image_left_out.unwrap_or(false) || crate::pattern::images_left_out() > pattern_images_left_out || (!f.opts.mark_undecoded_images && crate::paint::decode_failures() > failures); diff --git a/crates/ui-egui/src/dialogs.rs b/crates/ui-egui/src/dialogs.rs index 5afad21b0d..c306137e0f 100644 --- a/crates/ui-egui/src/dialogs.rs +++ b/crates/ui-egui/src/dialogs.rs @@ -96,6 +96,7 @@ pub mod plugin; mod png_options; pub mod print; pub mod print_presets; +pub mod proof_setup; mod psd_options; pub mod raster_effects; pub mod rearrange_artboards; @@ -349,6 +350,7 @@ registry! { ColorGuideOptions: [color_guide_options::KIND] => color_guide_options::SPEC, ColorBalance: [color_balance::KIND] => color_balance::SPEC, Saturate: [saturate::KIND] => saturate::SPEC, + ProofSetup: [proof_setup::KIND] => proof_setup::SPEC, IndexedColor: [indexed_color::KIND] => indexed_color::SPEC, SaveSwatchLibrary: [save_swatch_library::KIND] => save_swatch_library::SPEC, TileEdgeColor: [tile_edge_color::KIND] => tile_edge_color::SPEC, @@ -677,6 +679,9 @@ pub fn cancel(app: &mut VectorcraftApp) { if d.kind == script_run::NOTICE_KIND { script_run::notice_cancel(app, &d); } + if d.kind == proof_setup::KIND { + proof_setup::cancel(app, &d); + } // Toolbar-only Flare options start no preview and must not cancel a gesture // that was already active before opening them. The generic parameter dialog has a spec // without a preview, yet previews some commands (Grid Repeat Options) when asked to. diff --git a/crates/ui-egui/src/dialogs/proof_setup.rs b/crates/ui-egui/src/dialogs/proof_setup.rs new file mode 100644 index 0000000000..7e534de2f4 --- /dev/null +++ b/crates/ui-egui/src/dialogs/proof_setup.rs @@ -0,0 +1,301 @@ +//! View → Proof Setup → Customize…: the device to simulate (the working CMYK space, or any CMYK or +//! RGB profile), Preserve CMYK Numbers or Preserve RGB Numbers, the rendering intent (used while +//! the numbers are not preserved), Simulate Paper Color and Simulate Black Ink (CMYK devices only). +//! Preview shows the proof on the canvas while the dialog is open; OK sets the proof setup and +//! turns Proof Colors on (`view.proofSetup`), and Cancel puts the earlier proof view back. +//! +//! Fields: `device` (`workingCmyk`, `cmyk:` or `rgb:`), `preserveNumbers`, +//! `intent`, `simulatePaper`, `simulateBlack` and `preview`. + +use serde_json::{Value, json}; +use vectorcraft_color::cms::{self, Intent, ProfileKind, ProofTarget}; +use vectorcraft_render::proof; + +use super::{DialogSpec, form}; +use crate::VectorcraftApp; +use crate::state::Dialog; +use crate::widgets; + +/// The dialog kind of Proof Setup › Customize. +pub const KIND: &str = "proofSetup"; + +const CMD: &str = "view.proofSetup"; + +/// The proof view as the dialog found it, which Cancel puts back after a preview. +const BEFORE: &str = "__before"; +/// The settings the canvas shows while Preview is on, as last sent. +const PREVIEWED: &str = "__previewed"; + +/// The device a proof target that is not a device (an RGB display or a color blindness type) +/// starts the dialog on. +const WORKING: &str = "workingCmyk"; + +const LABEL_W: f32 = 140.0; + +pub(super) const SPEC: DialogSpec = DialogSpec { heading: |_| tl!("Proof Setup").into(), body, confirm, min_width: 420.0, ..DialogSpec::FORM }; + +/// Open the dialog on the current proof setup. +pub fn open(app: &mut VectorcraftApp) { + let v = proof::view(); + let s = &v.setup; + let device = match &s.target { + ProofTarget::WorkingCmyk | ProofTarget::Cmyk(_) | ProofTarget::Rgb(_) => s.target.id(), + _ => WORKING.to_string(), + }; + let before = json!({ + "target": s.target.id(), + "intent": s.intent.id(), + "simulatePaper": s.simulate_paper, + "preserveNumbers": s.preserve_numbers, + "simulateBlack": s.simulate_black, + "proof": v.proof_colors, + }); + app.ui.dialog = Some(Dialog::new( + KIND, + json!({ + "device": device, + "preserveNumbers": s.preserve_numbers, + "intent": s.intent.id(), + "simulatePaper": s.simulate_paper, + "simulateBlack": s.simulate_black, + "preview": true, + BEFORE: before, + }), + )); +} + +/// The devices to simulate, as (`device` value, name shown): the working CMYK space, then every +/// CMYK profile and every RGB profile. +fn devices() -> Vec<(String, String)> { + let profiles = cms::profiles(); + let of = |kind: ProfileKind, prefix: &str| { + profiles.iter().filter(move |p| p.kind == kind).map(move |p| (format!("{prefix}{}", p.name), p.name.clone())).collect::>() + }; + std::iter::once((WORKING.to_string(), tl!("Working CMYK").to_string())) + .chain(of(ProfileKind::Cmyk, "cmyk:")) + .chain(of(ProfileKind::Rgb, "rgb:")) + .collect() +} + +/// Whether `device` is an RGB profile. +fn rgb_device(device: &str) -> bool { + device.starts_with("rgb:") +} + +/// What OK sends to `view.proofSetup`. +fn params(d: &Dialog) -> Value { + json!({ + "target": d.str("device"), + "preserveNumbers": d.bool("preserveNumbers"), + "intent": d.str("intent"), + "simulatePaper": d.bool("simulatePaper"), + "simulateBlack": d.bool("simulateBlack"), + "proof": true, + }) +} + +fn body(app: &mut VectorcraftApp, ui: &mut egui::Ui, d: &mut Dialog) -> bool { + let devices = devices(); + let device = d.str("device"); + // A profile that is no longer loaded shows its name as it is. + let shown = + devices.iter().find(|(id, _)| *id == device).map_or_else(|| device.split_once(':').map_or(device.as_str(), |(_, n)| n), |(_, n)| n.as_str()); + let names: Vec<&str> = devices.iter().map(|(_, n)| n.as_str()).collect(); + widgets::label_row(ui, tl!("Device to Simulate:"), LABEL_W, |ui| { + if let Some((id, _)) = widgets::dropdown_names(ui, "proof-setup-device", shown, &names, 260.0).and_then(|i| devices.get(i)) { + d.fields.insert("device".into(), json!(id)); + } + }); + ui.add_space(4.0); + let rgb = rgb_device(&d.str("device")); + let preserve = if rgb { tl!("Preserve RGB Numbers") } else { tl!("Preserve CMYK Numbers") }; + form::check(ui, d, "preserveNumbers", preserve); + let intents: Vec<(&str, &str)> = Intent::ALL.iter().map(|i| (i.id(), i.label())).collect(); + ui.add_enabled_ui(!d.bool("preserveNumbers"), |ui| form::choice(ui, d, "intent", tl!("Rendering intent:"), (LABEL_W, 200.0), &intents)); + ui.add_space(4.0); + // Paper and black ink are a printing press's: an RGB device has neither. + let paper = d.bool("simulatePaper"); + if widgets::check(ui, tl!("Simulate Paper Color"), paper && !rgb, !rgb) { + d.fields.insert("simulatePaper".into(), json!(!paper)); + } + // Simulate Paper Color shows the press black too, so the box shows checked while it is on. + let black = d.bool("simulateBlack"); + if widgets::check(ui, tl!("Simulate Black Ink"), (black || paper) && !rgb, !rgb && !paper) { + d.fields.insert("simulateBlack".into(), json!(!black)); + } + ui.add_space(8.0); + form::preview_check(ui, d); + preview(app, d); + false +} + +/// While Preview is on, the canvas shows the dialog's settings, sent again whenever they change; +/// turned off, the earlier proof view comes back. +fn preview(app: &mut VectorcraftApp, d: &mut Dialog) { + if d.bool("preview") { + let p = params(d); + if d.fields.get(PREVIEWED) != Some(&p) { + match app.run(CMD, p.clone()) { + Ok(_) => { + d.fields.insert(PREVIEWED.into(), p); + } + Err(e) => app.ui.status = e, + } + } + } else if d.fields.remove(PREVIEWED).is_some() { + restore(app, d); + } +} + +/// Put back the proof view the dialog found. +fn restore(app: &mut VectorcraftApp, d: &Dialog) { + if let Some(before) = d.fields.get(BEFORE).cloned() + && let Err(e) = app.run(CMD, before) + { + app.ui.status = e; + } +} + +fn confirm(app: &mut VectorcraftApp, d: &Dialog) -> Result { + let r = app.run(CMD, params(d))?; + app.ui.dialog = None; + Ok(r) +} + +/// Cancel: after a preview, the earlier proof view comes back. +pub(super) fn cancel(app: &mut VectorcraftApp, d: &Dialog) { + if d.fields.contains_key(PREVIEWED) { + restore(app, d); + } +} + +#[cfg(test)] +mod tests { + use super::*; + use vectorcraft_engine::Session; + + /// Proof views are process-wide: these tests take turns, and each leaves the default view. + static VIEW: std::sync::Mutex<()> = std::sync::Mutex::new(()); + + struct DefaultView<'a>(#[allow(dead_code)] std::sync::MutexGuard<'a, ()>); + + impl DefaultView<'_> { + fn new() -> Self { + let g = VIEW.lock().unwrap_or_else(|e| e.into_inner()); + proof::set_view(Default::default()); + DefaultView(g) + } + } + + impl Drop for DefaultView<'_> { + fn drop(&mut self) { + proof::set_view(Default::default()); + } + } + + fn frame(app: &mut VectorcraftApp, ctx: &egui::Context) { + let mut out = ctx.run_ui(egui::RawInput::default(), |ui| super::super::show(app, ui.ctx())); + out.textures_delta.clear(); + } + + fn app() -> (VectorcraftApp, egui::Context) { + let mut app = VectorcraftApp::new(Session::new(), Default::default()); + app.run("file.new", json!({})).unwrap(); + let ctx = egui::Context::default(); + crate::theme::install_fonts(&ctx); + (app, ctx) + } + + /// View › Proof Setup › Customize… opens the dialog on the current proof setup; OK sets the + /// device, Preserve Numbers, the intent and Simulate Black Ink, and turns Proof Colors on. + #[test] + fn customize_sets_the_proof_setup_and_turns_proof_colors_on() { + let _v = DefaultView::new(); + let (mut app, ctx) = app(); + let item = crate::menus::menu_entries(&app).into_iter().find(|e| e.path == ["View", "Proof Setup"] && e.label == "Customize…").unwrap(); + app.run(item.command.as_deref().unwrap(), item.params.clone()).unwrap(); + let d = app.ui.dialog.as_ref().unwrap(); + assert_eq!(d.kind, KIND); + assert_eq!((d.str("device"), d.str("intent"), d.bool("preserveNumbers")), (WORKING.to_string(), "relative".to_string(), false)); + frame(&mut app, &ctx); + let device = format!("cmyk:{}", cms::DEVICE_CMYK); + let d = app.ui.dialog.as_mut().unwrap(); + for (k, v) in [("device", json!(device)), ("intent", json!("perceptual")), ("simulateBlack", json!(true)), ("preview", json!(false))] { + d.fields.insert(k.into(), v); + } + super::super::confirm(&mut app).unwrap(); + assert!(app.ui.dialog.is_none()); + let v = proof::view(); + assert!(v.proof_colors); + assert_eq!(v.setup.target, ProofTarget::Cmyk(cms::DEVICE_CMYK.into())); + assert_eq!(v.setup.intent, Intent::Perceptual); + assert!(v.setup.simulate_black && !v.setup.preserve_numbers && !v.setup.simulate_paper); + // Opened again, it shows those settings, and the menu checks Customize…. + app.run("ui.proofSetupDialog", json!({})).unwrap(); + let d = app.ui.dialog.as_ref().unwrap(); + assert_eq!((d.str("device"), d.str("intent"), d.bool("simulateBlack")), (device, "perceptual".to_string(), true)); + assert_eq!(crate::menus::checked(&app, "ui.proofSetupDialog", &json!({})), Some(true)); + super::super::cancel(&mut app); + } + + /// Preview shows the dialog's settings on the canvas at once, follows their changes, and + /// Cancel (or turning Preview off) puts the earlier proof view back. + #[test] + fn preview_shows_the_settings_and_cancel_puts_the_view_back() { + let _v = DefaultView::new(); + let (mut app, ctx) = app(); + app.run("view.proofSetup", json!({"target": "protanopia"})).unwrap(); + let before = proof::view(); + app.run("ui.proofSetupDialog", json!({})).unwrap(); + assert_eq!(app.ui.dialog.as_ref().unwrap().str("device"), WORKING, "a color blindness proof starts on the working CMYK"); + let rgb = format!("rgb:{}", cms::DISPLAY_P3); + let d = app.ui.dialog.as_mut().unwrap(); + d.fields.insert("device".into(), json!(rgb)); + d.fields.insert("preserveNumbers".into(), json!(true)); + frame(&mut app, &ctx); + let v = proof::view(); + assert!(v.proof_colors, "the preview turns Proof Colors on"); + assert_eq!(v.setup.target, ProofTarget::Rgb(cms::DISPLAY_P3.into())); + assert!(v.setup.preserve_numbers); + app.ui.dialog.as_mut().unwrap().fields.insert("preview".into(), json!(false)); + frame(&mut app, &ctx); + assert_eq!(proof::view(), before, "Preview off puts the view back"); + app.ui.dialog.as_mut().unwrap().fields.insert("preview".into(), json!(true)); + frame(&mut app, &ctx); + assert_eq!(proof::view().setup.target, ProofTarget::Rgb(cms::DISPLAY_P3.into())); + super::super::cancel(&mut app); + assert!(app.ui.dialog.is_none()); + assert_eq!(proof::view(), before, "Cancel puts the view back"); + } + + /// A device the dialog can't use (a profile that is not loaded) is refused, and the dialog + /// stays open with the proof view as it was. + #[test] + fn ok_with_an_unknown_device_keeps_the_dialog_open() { + let _v = DefaultView::new(); + let (mut app, _) = app(); + app.run("ui.proofSetupDialog", json!({})).unwrap(); + let d = app.ui.dialog.as_mut().unwrap(); + d.fields.insert("device".into(), json!("cmyk:Nope")); + d.fields.insert("preview".into(), json!(false)); + assert!(super::super::confirm(&mut app).unwrap_err().contains("unknown CMYK profile")); + assert!(app.ui.dialog.is_some()); + assert_eq!(proof::view(), Default::default()); + } + + /// The device list holds the working CMYK space and every CMYK and RGB profile, each a target + /// `view.proofSetup` accepts. + #[test] + fn devices_list_every_cmyk_and_rgb_profile() { + let list = devices(); + assert_eq!(list[0].0, WORKING); + for p in cms::profiles().iter().filter(|p| p.kind != ProfileKind::Gray) { + assert!(list.iter().any(|(_, n)| *n == p.name), "{} is listed", p.name); + } + for (id, _) in &list { + let t = ProofTarget::parse(id).unwrap(); + assert_eq!(&t.id(), id); + assert!(rgb_device(id) == matches!(t, ProofTarget::Rgb(_))); + } + } +} diff --git a/crates/ui-egui/src/i18n/bg.tsv b/crates/ui-egui/src/i18n/bg.tsv index 28944173dd..fedc9ecc45 100644 --- a/crates/ui-egui/src/i18n/bg.tsv +++ b/crates/ui-egui/src/i18n/bg.tsv @@ -2525,6 +2525,10 @@ font-technology Variable Променливи Preserve Alpha Transparency Запазване на алфа прозрачността Preserve Appearance and Overprints Запазване на визията и надпечатите Preserve CMYK Numbers Запазване на CMYK стойностите + Preserve RGB Numbers Запазване на RGB стойностите + Device to Simulate: Устройство за симулиране: + Simulate Paper Color Симулиране на цвета на хартията + Simulate Black Ink Симулиране на черното мастило Preserve Editing Capabilities Запазване на възможностите за редактиране Preserve editing capabilities Запазване на възможностите за редактиране Preserve Lightness Запазване на светлината diff --git a/crates/ui-egui/src/i18n/bs.tsv b/crates/ui-egui/src/i18n/bs.tsv index 01b90e5148..b355b72557 100644 --- a/crates/ui-egui/src/i18n/bs.tsv +++ b/crates/ui-egui/src/i18n/bs.tsv @@ -2793,6 +2793,10 @@ digits Malayalam Malajalam Place the pages with the placement again Ponovo postavi stranice s postavljanjem Placement: Postavljanje: Preserve CMYK Numbers Očuvaj CMYK brojeve + Preserve RGB Numbers Očuvaj RGB brojeve + Device to Simulate: Uređaj za simulaciju: + Simulate Paper Color Simuliraj boju papira + Simulate Black Ink Simuliraj crnu tintu Previous page Prethodna stranica Print Layers: Štampaj slojeve: Print Preset: Predložak štampanja: diff --git a/crates/ui-egui/src/i18n/ca.tsv b/crates/ui-egui/src/i18n/ca.tsv index 4ddd1d5605..4208073ca5 100644 --- a/crates/ui-egui/src/i18n/ca.tsv +++ b/crates/ui-egui/src/i18n/ca.tsv @@ -3280,6 +3280,10 @@ digits Malayalam Malaiàlam Preserve Appearance Conserva l’aparença Preserve Appearance and Overprints Conserva l’aparença i les sobrempressions Preserve CMYK Numbers Conserva els valors CMYK + Preserve RGB Numbers Conserva els valors RGB + Device to Simulate: Dispositiu que se simula: + Simulate Paper Color Simula el color del paper + Simulate Black Ink Simula la tinta negra Preserve Editing Capabilities Conserva les capacitats d’edició Preserve editing capabilities Conserva les capacitats d’edició Preserve Lightness Conserva la lluminositat diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsv index 211982f086..6aa9f23fb5 100644 --- a/crates/ui-egui/src/i18n/cs.tsv +++ b/crates/ui-egui/src/i18n/cs.tsv @@ -2828,6 +2828,10 @@ digits Malayalam Malajálamské Place the pages with the placement again Znovu rozmístit stránky podle umístění Placement: Umístění: Preserve CMYK Numbers Zachovat hodnoty CMYK + Preserve RGB Numbers Zachovat hodnoty RGB + Device to Simulate: Simulované zařízení: + Simulate Paper Color Simulovat barvu papíru + Simulate Black Ink Simulovat černou barvu Previous page Předchozí stránka Print Layers: Tisknout vrstvy: Print Preset: Přednastavení tisku: diff --git a/crates/ui-egui/src/i18n/da.tsv b/crates/ui-egui/src/i18n/da.tsv index b3de0ae89a..f38ae72674 100644 --- a/crates/ui-egui/src/i18n/da.tsv +++ b/crates/ui-egui/src/i18n/da.tsv @@ -2610,6 +2610,10 @@ digits Malayalam Malayalam Place the pages with the placement again Placér siderne igen med placeringen Placement: Placering: Preserve CMYK Numbers Bevar CMYK-tal + Preserve RGB Numbers Bevar RGB-tal + Device to Simulate: Enhed, der simuleres: + Simulate Paper Color Simulér papirfarve + Simulate Black Ink Simulér sort blæk Previous page Forrige side Print Layers: Udskriv lag: Print Preset: Udskriftsforudindstilling: diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsv index d0610144ef..e63aa9d317 100644 --- a/crates/ui-egui/src/i18n/de.tsv +++ b/crates/ui-egui/src/i18n/de.tsv @@ -2567,6 +2567,10 @@ diagnostics ui Oberfläche Preserve Alpha Transparency Alphatransparenz beibehalten Preserve Appearance and Overprints Aussehen und Überdrucken beibehalten Preserve CMYK Numbers CMYK-Werte beibehalten + Preserve RGB Numbers RGB-Werte beibehalten + Device to Simulate: Zu simulierendes Gerät: + Simulate Paper Color Papierfarbe simulieren + Simulate Black Ink Schwarze Druckfarbe simulieren Preserve Editing Capabilities Bearbeitungsfunktionen beibehalten Preserve editing capabilities Bearbeitungsfunktionen beibehalten Preserve Lightness Helligkeit beibehalten diff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsv index d03f8c6958..00e32cb312 100644 --- a/crates/ui-egui/src/i18n/el.tsv +++ b/crates/ui-egui/src/i18n/el.tsv @@ -3384,6 +3384,10 @@ theme Appearance Εμφάνιση Preserve Alpha Transparency Διατήρηση διαφάνειας άλφα Preserve Appearance and Overprints Διατήρηση εμφάνισης και υπερεκτυπώσεων Preserve CMYK Numbers Διατήρηση τιμών CMYK + Preserve RGB Numbers Διατήρηση τιμών RGB + Device to Simulate: Συσκευή προς προσομοίωση: + Simulate Paper Color Προσομοίωση χρώματος χαρτιού + Simulate Black Ink Προσομοίωση μαύρης μελάνης Preserve Editing Capabilities Διατήρηση δυνατοτήτων επεξεργασίας Preserve editing capabilities Διατήρηση δυνατοτήτων επεξεργασίας Preserve Lightness Διατήρηση φωτεινότητας diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv index 3e8bd23752..25a95ecc66 100644 --- a/crates/ui-egui/src/i18n/es.tsv +++ b/crates/ui-egui/src/i18n/es.tsv @@ -2603,6 +2603,10 @@ font-technology Variable Variables Preserve Alpha Transparency Conservar transparencia alfa Preserve Appearance and Overprints Conservar apariencia y sobreimpresiones Preserve CMYK Numbers Conservar valores CMYK + Preserve RGB Numbers Conservar valores RGB + Device to Simulate: Dispositivo que simular: + Simulate Paper Color Simular color del papel + Simulate Black Ink Simular tinta negra Preserve Editing Capabilities Conservar capacidades de edición Preserve editing capabilities Conservar capacidades de edición Preserve Lightness Conservar luminosidad diff --git a/crates/ui-egui/src/i18n/fi.tsv b/crates/ui-egui/src/i18n/fi.tsv index d408220f47..964154dd92 100644 --- a/crates/ui-egui/src/i18n/fi.tsv +++ b/crates/ui-egui/src/i18n/fi.tsv @@ -2772,6 +2772,10 @@ digits Malayalam Malajalam Place the pages with the placement again Sijoita sivut uudelleen sijoittelun mukaan Placement: Sijoittelu: Preserve CMYK Numbers Säilytä CMYK-arvot + Preserve RGB Numbers Säilytä RGB-arvot + Device to Simulate: Simuloitava laite: + Simulate Paper Color Simuloi paperin väriä + Simulate Black Ink Simuloi mustaa mustetta Previous page Edellinen sivu Print Layers: Tulosta tasot: Print Preset: Tulostuksen esiasetus: diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv index 318bbbeb44..25a2ff59f9 100644 --- a/crates/ui-egui/src/i18n/fr.tsv +++ b/crates/ui-egui/src/i18n/fr.tsv @@ -2595,6 +2595,10 @@ font-technology Variable Variables Preserve Alpha Transparency Conserver la transparence alpha Preserve Appearance and Overprints Conserver l’aspect et les surimpressions Preserve CMYK Numbers Conserver les valeurs CMJN + Preserve RGB Numbers Conserver les valeurs RVB + Device to Simulate: Périphérique à simuler : + Simulate Paper Color Simuler la couleur du papier + Simulate Black Ink Simuler l’encre noire Preserve Editing Capabilities Conserver les fonctions d’édition Preserve editing capabilities Conserver les fonctions d’édition Preserve Lightness Conserver la luminosité diff --git a/crates/ui-egui/src/i18n/gu.tsv b/crates/ui-egui/src/i18n/gu.tsv index 716d851655..640337020e 100644 --- a/crates/ui-egui/src/i18n/gu.tsv +++ b/crates/ui-egui/src/i18n/gu.tsv @@ -2672,6 +2672,10 @@ Preserve Alpha Transparency આલ્ફા પારદર્શિતા જાળવો Preserve Appearance and Overprints દેખાવ અને ઓવરપ્રિન્ટ જાળવો Preserve CMYK Numbers CMYK નંબર જાળવો + Preserve RGB Numbers RGB નંબર જાળવો + Device to Simulate: અનુકરણ કરવાનું ઉપકરણ: + Simulate Paper Color કાગળના રંગનું અનુકરણ કરો + Simulate Black Ink કાળી શાહીનું અનુકરણ કરો Preserve Editing Capabilities સંપાદન ક્ષમતાઓ જાળવો Preserve Lightness તેજ જાળવો Preserve Overprints and Spot Colors ઓવરપ્રિન્ટ અને સ્પોટ રંગ જાળવો diff --git a/crates/ui-egui/src/i18n/hi.tsv b/crates/ui-egui/src/i18n/hi.tsv index 78c0a9a7eb..7340c2895d 100644 --- a/crates/ui-egui/src/i18n/hi.tsv +++ b/crates/ui-egui/src/i18n/hi.tsv @@ -3616,6 +3616,10 @@ antiAlias Sharp शार्प Preserve Appearance उपस्थिति संरक्षित करें Preserve Appearance and Overprints उपस्थिति और ओवरप्रिंट को संरक्षित करें Preserve CMYK Numbers CMYK नंबर संरक्षित करें + Preserve RGB Numbers RGB नंबर संरक्षित करें + Device to Simulate: सिम्युलेट करने के लिए डिवाइस: + Simulate Paper Color पेपर का रंग सिम्युलेट करें + Simulate Black Ink काली स्याही सिम्युलेट करें Preserve editing capabilities संपादन क्षमताओं को संरक्षित करना Preserve Editing Capabilities संपादन क्षमताओं को संरक्षित करना Preserve Lightness प्रकाश संरक्षण diff --git a/crates/ui-egui/src/i18n/hu.tsv b/crates/ui-egui/src/i18n/hu.tsv index a1f6100b2f..660a518206 100644 --- a/crates/ui-egui/src/i18n/hu.tsv +++ b/crates/ui-egui/src/i18n/hu.tsv @@ -3153,6 +3153,10 @@ diagnostics ui felület Preserve Appearance Megjelenés megőrzése Preserve Appearance and Overprints Megjelenés és felülnyomások megtartása Preserve CMYK Numbers CMYK-értékek megtartása + Preserve RGB Numbers RGB-értékek megtartása + Device to Simulate: Szimulálandó eszköz: + Simulate Paper Color Papírszín szimulálása + Simulate Black Ink Fekete festék szimulálása Preserve editing capabilities Szerkeszthetőség megtartása Preserve Editing Capabilities Szerkeszthetőség megtartása Preserve Lightness Világosság megtartása diff --git a/crates/ui-egui/src/i18n/id.tsv b/crates/ui-egui/src/i18n/id.tsv index c7c6b956db..56d034945c 100644 --- a/crates/ui-egui/src/i18n/id.tsv +++ b/crates/ui-egui/src/i18n/id.tsv @@ -2610,6 +2610,10 @@ digits Malayalam Malayalam Place the pages with the placement again Tempatkan halaman lagi dengan penempatan tersebut Placement: Penempatan: Preserve CMYK Numbers Pertahankan angka CMYK + Preserve RGB Numbers Pertahankan angka RGB + Device to Simulate: Perangkat yang disimulasikan: + Simulate Paper Color Simulasikan warna kertas + Simulate Black Ink Simulasikan tinta hitam Previous page Halaman sebelumnya Print Layers: Lapisan cetak: Print Preset: Preset cetak: diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsv index 6743704785..e0d00db691 100644 --- a/crates/ui-egui/src/i18n/it.tsv +++ b/crates/ui-egui/src/i18n/it.tsv @@ -2643,6 +2643,10 @@ diagnostics ui interfaccia Preserve Alpha Transparency Mantieni trasparenza alfa Preserve Appearance and Overprints Mantieni aspetto e sovrastampe Preserve CMYK Numbers Mantieni valori CMYK + Preserve RGB Numbers Mantieni valori RGB + Device to Simulate: Dispositivo da simulare: + Simulate Paper Color Simula colore carta + Simulate Black Ink Simula inchiostro nero Preserve Editing Capabilities Mantieni possibilità di modifica Preserve editing capabilities Mantieni possibilità di modifica Preserve Lightness Mantieni luminosità diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv index c9cdb8fcbe..84728d3f9e 100644 --- a/crates/ui-egui/src/i18n/ja.tsv +++ b/crates/ui-egui/src/i18n/ja.tsv @@ -2740,6 +2740,10 @@ diagnostics ui UI Preserve Alpha Transparency アルファ透明を保持 Preserve Appearance and Overprints アピアランスとオーバープリントを保持 Preserve CMYK Numbers CMYK 値を保持 + Preserve RGB Numbers RGB 値を保持 + Device to Simulate: シミュレートするデバイス: + Simulate Paper Color 用紙の色をシミュレート + Simulate Black Ink インキの黒をシミュレート Preserve Editing Capabilities 編集機能を保持 Preserve Lightness 明度を保持 Preserve Overprints and Spot Colors オーバープリントと特色を保持 diff --git a/crates/ui-egui/src/i18n/ka.tsv b/crates/ui-egui/src/i18n/ka.tsv index 55f726dc38..d9bd89a416 100644 --- a/crates/ui-egui/src/i18n/ka.tsv +++ b/crates/ui-egui/src/i18n/ka.tsv @@ -2532,6 +2532,10 @@ digits Malayalam მალაიალამური Place the pages with the placement again გვერდების ხელახლა განთავსება განთავსების მიხედვით Placement: განთავსება: Preserve CMYK Numbers CMYK მნიშვნელობების შენარჩუნება + Preserve RGB Numbers RGB მნიშვნელობების შენარჩუნება + Device to Simulate: სიმულირებადი მოწყობილობა: + Simulate Paper Color ქაღალდის ფერის იმიტაცია + Simulate Black Ink შავი მელნის იმიტაცია Previous page წინა გვერდი Print Layers: შრეების ბეჭდვა: Print Preset: ბეჭდვის პრესეტი: diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsv index abe2b4bc28..5ca076f907 100644 --- a/crates/ui-egui/src/i18n/ko.tsv +++ b/crates/ui-egui/src/i18n/ko.tsv @@ -2730,6 +2730,10 @@ diagnostics ui UI Preserve Alpha Transparency 알파 투명도 보존 Preserve Appearance and Overprints 모양 및 오버프린트 보존 Preserve CMYK Numbers CMYK 수치 보존 + Preserve RGB Numbers RGB 수치 보존 + Device to Simulate: 시뮬레이션할 장치: + Simulate Paper Color 용지 색상 시뮬레이션 + Simulate Black Ink 검정 잉크 시뮬레이션 Preserve Editing Capabilities 편집 기능 보존 Preserve Lightness 명도 보존 Preserve Overprints and Spot Colors 오버프린트 및 별색 보존 diff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsv index ed281382a4..5216a9225d 100644 --- a/crates/ui-egui/src/i18n/nl.tsv +++ b/crates/ui-egui/src/i18n/nl.tsv @@ -3128,6 +3128,10 @@ digits Malayalam Malayalam Place the pages with the placement again Plaats de pagina's opnieuw met de plaatsing Placement: Plaatsing: Preserve CMYK Numbers CMYK-waarden behouden + Preserve RGB Numbers RGB-waarden behouden + Device to Simulate: Te simuleren apparaat: + Simulate Paper Color Papierkleur simuleren + Simulate Black Ink Zwarte inkt simuleren Previous page Vorige pagina Print Layers: Lagen afdrukken: Print Preset: Afdrukvoorinstelling: diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsv index 08e96e6a35..0eafe4e16c 100644 --- a/crates/ui-egui/src/i18n/pl.tsv +++ b/crates/ui-egui/src/i18n/pl.tsv @@ -2741,6 +2741,10 @@ digits Malayalam Malajalam Place the pages with the placement again Ponownie rozmieść strony według położenia Placement: Położenie: Preserve CMYK Numbers Zachowaj wartości CMYK + Preserve RGB Numbers Zachowaj wartości RGB + Device to Simulate: Symulowane urządzenie: + Simulate Paper Color Symuluj kolor papieru + Simulate Black Ink Symuluj czarną farbę Previous page Poprzednia strona Print Layers: Drukuj warstwy: Print Preset: Ustawienie drukowania: diff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsv index 79c4d9dc8e..b336b50b38 100644 --- a/crates/ui-egui/src/i18n/pt-br.tsv +++ b/crates/ui-egui/src/i18n/pt-br.tsv @@ -2174,6 +2174,10 @@ antiAlias Sharp Nítido Preserve Alpha Transparency Preservar Transparência Alfa Preserve Appearance and Overprints Preservar Aparência e Sobreimpressões Preserve CMYK Numbers Preservar Números CMYK + Preserve RGB Numbers Preservar Números RGB + Device to Simulate: Dispositivo a Simular: + Simulate Paper Color Simular Cor do Papel + Simulate Black Ink Simular Tinta Preta Preserve Editing Capabilities Preservar Capacidades de Edição Preserve Lightness Preservar Luminosidade Preserve Overprints and Spot Colors Preservar Sobreimpressões e Cores Spot diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsv index 9f608618e7..16c1f5fbfd 100644 --- a/crates/ui-egui/src/i18n/ru.tsv +++ b/crates/ui-egui/src/i18n/ru.tsv @@ -2630,6 +2630,10 @@ diagnostics ui интерфейс Preserve Alpha Transparency Сохранять альфа-прозрачность Preserve Appearance and Overprints Сохранять оформление и наложения Preserve CMYK Numbers Сохранять значения CMYK + Preserve RGB Numbers Сохранять значения RGB + Device to Simulate: Имитируемое устройство: + Simulate Paper Color Имитировать цвет бумаги + Simulate Black Ink Имитировать чёрную краску Preserve Editing Capabilities Сохранять возможности редактирования Preserve editing capabilities Сохранять возможности редактирования Preserve Lightness Сохранять светлоту diff --git a/crates/ui-egui/src/i18n/sv.tsv b/crates/ui-egui/src/i18n/sv.tsv index 6156ca23d5..3d49146bde 100644 --- a/crates/ui-egui/src/i18n/sv.tsv +++ b/crates/ui-egui/src/i18n/sv.tsv @@ -2540,6 +2540,10 @@ font-technology Variable Variabla Preserve Alpha Transparency Bevara alfatransparens Preserve Appearance and Overprints Bevara utseende och övertryck Preserve CMYK Numbers Bevara CMYK-värden + Preserve RGB Numbers Bevara RGB-värden + Device to Simulate: Enhet att simulera: + Simulate Paper Color Simulera pappersfärg + Simulate Black Ink Simulera svart bläck Preserve Editing Capabilities Bevara redigeringsmöjligheter Preserve editing capabilities Bevara redigeringsmöjligheter Preserve Lightness Bevara ljushet diff --git a/crates/ui-egui/src/i18n/tests.rs b/crates/ui-egui/src/i18n/tests.rs index 602898ecce..8505346f8c 100644 --- a/crates/ui-egui/src/i18n/tests.rs +++ b/crates/ui-egui/src/i18n/tests.rs @@ -362,6 +362,25 @@ fn objects_on_path_detach_strings_are_in_complete_catalogs() { } } +/// View › Proof Setup › Customize's labels. +#[test] +fn proof_setup_dialog_labels_are_in_complete_catalogs() { + let labels = [ + "Proof Setup", + "Device to Simulate:", + "Preserve CMYK Numbers", + "Preserve RGB Numbers", + "Rendering intent:", + "Simulate Paper Color", + "Simulate Black Ink", + ]; + for lang in LANGUAGES.iter().filter(|lang| lang.complete_menus) { + for label in labels { + assert!(lang.catalog().plain(label).is_some(), "{} is missing {label}", lang.code); + } + } +} + /// The Window › Brush Libraries menu, built from the built-in library table, names each library. #[test] fn built_in_brush_library_names_are_in_complete_catalogs() { diff --git a/crates/ui-egui/src/i18n/tr.tsv b/crates/ui-egui/src/i18n/tr.tsv index 7120d44707..b4f1ff4d5f 100644 --- a/crates/ui-egui/src/i18n/tr.tsv +++ b/crates/ui-egui/src/i18n/tr.tsv @@ -2387,6 +2387,10 @@ shape Open Açık Preserve Alpha Transparency Alfa Şeffaflığını Koruyun Preserve Appearance and Overprints Görünümü ve Üst Baskıları Koru Preserve CMYK Numbers CMYK Numaralarını Koru + Preserve RGB Numbers RGB Numaralarını Koru + Device to Simulate: Simüle Edilecek Aygıt: + Simulate Paper Color Kağıt Rengini Simüle Et + Simulate Black Ink Siyah Mürekkebi Simüle Et Preserve Editing Capabilities Düzenleme Yeteneklerini Koruyun Preserve editing capabilities Düzenleme yeteneklerini koruyun Preserve Lightness Hafifliği Koruyun diff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsv index 84f296b0a6..669d1a9768 100644 --- a/crates/ui-egui/src/i18n/uk.tsv +++ b/crates/ui-egui/src/i18n/uk.tsv @@ -2635,6 +2635,10 @@ diagnostics ui інтерфейс Preserve Alpha Transparency Зберігати альфа-прозорість Preserve Appearance and Overprints Зберігати оформлення та накладення Preserve CMYK Numbers Зберігати значення CMYK + Preserve RGB Numbers Зберігати значення RGB + Device to Simulate: Імітований пристрій: + Simulate Paper Color Імітувати колір паперу + Simulate Black Ink Імітувати чорну фарбу Preserve Editing Capabilities Зберігати можливості редагування Preserve editing capabilities Зберігати можливості редагування Preserve Lightness Зберігати світлоту diff --git a/crates/ui-egui/src/i18n/vi.tsv b/crates/ui-egui/src/i18n/vi.tsv index e8b9e5758f..f8fc370b40 100644 --- a/crates/ui-egui/src/i18n/vi.tsv +++ b/crates/ui-egui/src/i18n/vi.tsv @@ -2945,6 +2945,10 @@ diagnostics ui giao diện Preserve Alpha Transparency Bảo lưu trong suốt kênh Alpha Preserve Appearance and Overprints Bảo lưu diện mạo và in chồng Preserve CMYK Numbers Bảo lưu giá trị CMYK + Preserve RGB Numbers Bảo lưu giá trị RGB + Device to Simulate: Thiết bị cần giả lập: + Simulate Paper Color Giả lập màu giấy + Simulate Black Ink Giả lập mực đen Preserve Editing Capabilities Bảo lưu khả năng chỉnh sửa Preserve editing capabilities Bảo lưu khả năng chỉnh sửa Preserve Lightness Bảo lưu độ sáng diff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsv index 719968086f..6a441a4ed9 100644 --- a/crates/ui-egui/src/i18n/zh-hans.tsv +++ b/crates/ui-egui/src/i18n/zh-hans.tsv @@ -2497,6 +2497,10 @@ diagnostics ui 界面 Preserve Alpha Transparency 保留 Alpha 透明度 Preserve Appearance and Overprints 保留外观和叠印 Preserve CMYK Numbers 保留 CMYK 数值 + Preserve RGB Numbers 保留 RGB 数值 + Device to Simulate: 要模拟的设备: + Simulate Paper Color 模拟纸张颜色 + Simulate Black Ink 模拟黑色油墨 Preserve Editing Capabilities 保留编辑功能 Preserve editing capabilities 保留编辑能力 Preserve Lightness 保留亮度 diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsv index 121a8b8c02..cc61015bb9 100644 --- a/crates/ui-egui/src/i18n/zh-hant.tsv +++ b/crates/ui-egui/src/i18n/zh-hant.tsv @@ -3715,6 +3715,10 @@ diagnostics ui 介面 Preserve Alpha Transparency 保留 Alpha 透明度 Preserve Appearance and Overprints 保留外觀與疊印 Preserve CMYK Numbers 保留 CMYK 數值 + Preserve RGB Numbers 保留 RGB 數值 + Device to Simulate: 要模擬的裝置: + Simulate Paper Color 模擬紙張顏色 + Simulate Black Ink 模擬黑色油墨 Preserve Editing Capabilities 保留編輯功能 Preserve editing capabilities 保留編輯功能 Preserve Lightness 保留亮度 diff --git a/crates/ui-egui/src/menus/run.rs b/crates/ui-egui/src/menus/run.rs index 7b7f7a6b21..9c7017e59a 100644 --- a/crates/ui-egui/src/menus/run.rs +++ b/crates/ui-egui/src/menus/run.rs @@ -816,6 +816,10 @@ fn run_ui_part8(app: &mut VectorcraftApp, id: &str, p: &Value) -> Option { + crate::dialogs::proof_setup::open(app); + Ok(Value::Null) + } "ui.indexedColorDialog" => { crate::dialogs::indexed_color::open(app); Ok(Value::Null) diff --git a/crates/ui-egui/src/menus/state.rs b/crates/ui-egui/src/menus/state.rs index 0d5775ffe9..3b29854db8 100644 --- a/crates/ui-egui/src/menus/state.rs +++ b/crates/ui-egui/src/menus/state.rs @@ -104,6 +104,13 @@ pub fn checked(app: &VectorcraftApp, id: &str, p: &Value) -> Option { "view.proofColors" => vectorcraft_render::proof::view().proof_colors, "view.overprintPreview" => vectorcraft_render::proof::view().overprint, "view.proofSetup" => p.get("target").and_then(Value::as_str) == Some(vectorcraft_render::proof::view().setup.target.id().as_str()), + // Customize… is checked while the proof simulates a profile it chose. + "ui.proofSetupDialog" => { + matches!( + vectorcraft_render::proof::view().setup.target, + vectorcraft_color::cms::ProofTarget::Cmyk(_) | vectorcraft_color::cms::ProofTarget::Rgb(_) + ) + } "perspective.grid.snap" => perspective_grid(app).is_some_and(|g| g.snap), "perspective.grid.lockStation" => perspective_grid(app).is_some_and(|g| g.lock_station), "file.documentColorMode" | "object.convertDocumentColorMode" => { diff --git a/crates/ui-egui/src/menus/tree.rs b/crates/ui-egui/src/menus/tree.rs index 4b86b4152d..abfd7e1ccc 100644 --- a/crates/ui-egui/src/menus/tree.rs +++ b/crates/ui-egui/src/menus/tree.rs @@ -550,7 +550,7 @@ pub fn menu_tree_named(english_names: bool) -> Vec<(&'static str, Vec)> { cp("Color blindness – Protanopia-type", "view.proofSetup", json!({"target": "protanopia", "proof": true})), cp("Color blindness – Deuteranopia-type", "view.proofSetup", json!({"target": "deuteranopia", "proof": true})), cp("Color blindness – Tritanopia-type", "view.proofSetup", json!({"target": "tritanopia", "proof": true})), - cp("Customize…", "window.panel", json!({"panel": "separations"})), + c("Customize…", "ui.proofSetupDialog"), ], ), c("Proof Colors", "view.proofColors"), diff --git a/crates/ui-egui/src/menus/ui_commands.rs b/crates/ui-egui/src/menus/ui_commands.rs index 52c8c2e7bf..ec2c52cfb8 100644 --- a/crates/ui-egui/src/menus/ui_commands.rs +++ b/crates/ui-egui/src/menus/ui_commands.rs @@ -958,6 +958,12 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[ "", "{} open Saturate for the selection (dialog `saturate`, fields `intensity` −100..100, `preview`): previews live, OK runs edit.colors.saturate as one undo step", ), + ( + "ui.proofSetupDialog", + "Customize…", + "", + "{} open View › Proof Setup › Customize (dialog `proofSetup`, fields `device` (\"workingCmyk\", \"cmyk:\" or \"rgb:\": any CMYK or RGB profile), `preserveNumbers`, `intent` (used while preserveNumbers is off), `simulatePaper` and `simulateBlack` (CMYK devices only), `preview` (on): Preview shows the proof on the canvas, OK runs view.proofSetup with these and proof: true, Cancel puts the earlier proof view back)", + ), ( "ui.indexedColorDialog", "Convert to Indexed Color…", diff --git a/docs/mcp.md b/docs/mcp.md index 2e43c14d0e..ea774f42ed 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -1023,6 +1023,15 @@ styles and brushes. `color.removeProfile`, `view.proofSetup`, `view.proofColors`, `view.overprintPreview`, `view.separationsPreview` and `swatch.setSpot` reject a param of the wrong type, such as `"bpc": "no"`, `"on": 1`, `"to": 5` or `"colors": "#fff"`, and change nothing. Omitting a param or giving null keeps its default. +View › Proof Setup › Customize… (`ui.proofSetupDialog`, dialog `proofSetup`) sets the custom proof through +`view.proofSetup`: `target` `"cmyk:"` or `"rgb:"` names any CMYK or RGB profile as the device to +simulate (a profile that is not loaded is an error), `preserveNumbers` sends the colors' numbers in the document's +space to the device unchanged instead of converting them with `intent` (each color as it is painted, and a placed +CMYK image's own inks; an RGB image's pixels go through their numbers in the document's space, and transparency mixes +the proofed colors on the device's paper), and +`simulateBlack` shows the device's black +as the dark gray it prints (`simulatePaper` does so too, on the paper's color; both act on CMYK devices only). The +reply carries `preserveNumbers` and `simulateBlack` with the other proof settings. SVG import keeps what the canvas edits live. `` becomes a pattern swatch. A `` with `` becomes a symbol (named after its `data-name`, else its id) with an instance per ``; a `` that shows it differently diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 8f5043993a..e51c702420 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1543,6 +1543,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur A Cmd/Ctrl-click on the Color panel's spectrum applies Complement and a Cmd/Ctrl+Shift-click applies Invert to the active Fill or Stroke (`paint.complement`, `paint.invert`); with Alt also held, the click recolors the inactive one, as the reference app's [Default keyboard shortcuts](https://web.archive.org/web/20260726060015/https://helpx.adobe.com/illustrator/using/default-keyboard-shortcuts.html) list them. A double-click right of an RGB field switches the Color panel's R, G and B between percent and 0 to 255 ([Default keyboard shortcuts](https://helpx.adobe.com/illustrator/using/default-keyboard-shortcuts.html), Color panel). In VectorCraft the color does not change, Web Safe RGB and the hex field stay in 0 to 255, and the panel keeps the choice between sessions (`ui.colorPanel {rgbPercent}`); the color mixer of the Fill and Stroke chips and the gradient stop dialog follow the same setting. Toggle RGB Percent (`ui.colorRgbPercent`) in the command palette and Keyboard Shortcuts switches the units from the keyboard. Tests: `rgb_percent_switches_the_rgb_fields_between_percent_and_0_to_255`, `rgb_percent_does_not_switch_while_the_rows_are_disabled`, `rgb_percent_comes_back_after_a_restart` and `toggle_rgb_percent_switches_the_units_from_the_keyboard` in `crates/ui-egui/src/panels/color/tests.rs`. View › Proof Setup › Color blindness – Tritanopia-type turns Proof Colors on and proofs the canvas with the tritanopia simulation of Brettel, Viénot and Mollon (1997). The Separations Preview panel's Proof Setup list offers the same target (`view.proofSetup {target: "tritanopia"}`). Grays keep their value. + View › Proof Setup › Customize… opens a Proof Setup dialog with Device to Simulate (the working CMYK space or any CMYK or RGB profile), Preserve CMYK Numbers or Preserve RGB Numbers, Rendering Intent (used while the numbers are not preserved), Simulate Paper Color and Simulate Black Ink, and Preview; OK sets the proof and turns Proof Colors on ([Soft-proof colors](https://help.adobe.com/archive/en_US/illustrator/cs4/illustrator_cs4_help.pdf#page=146), "Custom soft-proof options"). In VectorCraft, Simulate Paper Color also shows the black ink, the two simulations act on CMYK devices only, and Cancel puts the earlier proof back (`ui.proofSetupDialog`, `view.proofSetup {preserveNumbers, simulateBlack}`). Tests: `simulate_black_ink_shows_the_press_black_as_gray`, `preserve_cmyk_numbers_sends_the_numbers_unchanged` and `rgb_device_proofs_show_the_device_numbers` in `crates/color/src/cms/tests.rs`, `proof_setup_takes_the_custom_proof_settings` in `crates/engine/src/tests/colormgmt.rs`, `customize_sets_the_proof_setup_and_turns_proof_colors_on` and `preview_shows_the_settings_and_cancel_puts_the_view_back` in `crates/ui-egui/src/dialogs/proof_setup.rs`. The Separations Preview panel's Gamut Check button reports one color outside the CMYK gamut in the singular and more in the plural, in English and in each language's plural forms (`gamut_check_status_takes_the_plural_form` in `crates/ui-egui/src/i18n/tests.rs`). - **Document Color Mode outside the layers:** File › Document Color Mode (in one undo step) and `document.open {colorMode}` also convert the colors of graph designs, graphic styles, opacity-mask art, the tile that pattern editing's Cancel puts back and the art of brushes (with a Hue Shift brush's key color); a tint of a global swatch there becomes the converted swatch's color at its tint, as in the art. - **Segments dragged onto the grid (#3835):** with View › Snap to Grid (or Snap to Pixel) on, a straight segment dragged with Direct Selection or Group Selection lands its anchors on the grid, the box round them putting an edge on a gridline on each axis as a moved object's does (Shift keeps the move on its line), instead of the point it was pressed at landing on an intersection and leaving both anchors off the grid; a dragged anchor still lands on an intersection itself, and drawn points and resize handles already snapped (`direct::tests::a_dragged_segment_lands_its_anchors_on_the_grid`).