LightCraft: An open-source non-destructive photo editor written by scratch in pure Rust
LRC-PRINT-JOB: Print Job colour controls in the Print dialog
Atmik Shetty64e0395c956e
diff --git a/crates/ui-egui/src/print_view.rs b/crates/ui-egui/src/print_view.rsindex 245c126ae..b7f6d44aa 100644--- a/crates/ui-egui/src/print_view.rs+++ b/crates/ui-egui/src/print_view.rs@@ -11,6 +11,7 @@ use lightcraft_engine::export::ExportOptions;use lightcraft_engine::print::compose::{self, place};use lightcraft_engine::print::layout::{self, Snap, Style, Unit};use lightcraft_engine::print::template::PrintSettings;+use lightcraft_engine::print_color::{ManagedSpace, PrintColorSettings, PrintIntent, PrintMedia, PrintProfile, PrintSharpen};use serde_json::{Value, json};use crate::LightcraftApp;@@ -428,7 +429,90 @@ fn settings(app: &mut LightcraftApp, ui: &mut Ui, t: &Tokens, pu: &mut PrintUi,patch(app, &ctx, json!({"job": {"ppi": ppi}}));}});- ui.label(egui::RichText::new(crate::i18n::tr("PDF · sRGB · current edits")).color(t.text_dim));+ print_job_color(app, ui, t, &st.job.color);+}++/// Send one colour setting of the print job (the rest stay as they are).+fn patch_color(app: &mut LightcraftApp, ctx: &egui::Context, key: &str, value: Value) {+ patch(app, ctx, json!({"job": {"color": {(key): value}}}));+}++fn to_value<V: serde::Serialize>(v: V) -> Value {+ serde_json::to_value(v).unwrap_or(Value::Null)+}++/// The Print Job panel's colour management, print adjustment, print sharpening and depth.+fn print_job_color(app: &mut LightcraftApp, ui: &mut Ui, t: &Tokens, color: &PrintColorSettings) {+ let ctx = ui.ctx().clone();+ let managed = |space| PrintProfile::Managed { space };+ let shown = match &color.profile {+ PrintProfile::Managed { space: ManagedSpace::Srgb } => crate::i18n::tr("Managed by Printer (sRGB)").to_string(),+ PrintProfile::Managed { space: ManagedSpace::AdobeRgb } => crate::i18n::tr("Managed by Printer (Adobe RGB)").to_string(),+ PrintProfile::Icc { path } => path.file_stem().map_or_else(|| path.display().to_string(), |n| n.to_string_lossy().into_owned()),+ };+ let mut pick = false;+ row(ui, t, "Profile", |ui| {+ let c = egui::ComboBox::from_id_salt("print-profile").width(190.0).selected_text(shown.clone()).show_ui(ui, |ui| {+ for (space, label) in [(ManagedSpace::Srgb, "Managed by Printer (sRGB)"), (ManagedSpace::AdobeRgb, "Managed by Printer (Adobe RGB)")] {+ let r = ui.selectable_label(color.profile == managed(space), crate::i18n::tr(label));+ register(ui.ctx(), format!("item:printProfile-{}", to_value(space).as_str().unwrap_or_default()), r.rect);+ if r.clicked() && color.profile != managed(space) {+ patch_color(app, &ctx, "profile", to_value(managed(space)));+ }+ }+ if let PrintProfile::Icc { .. } = &color.profile {+ let _ = ui.selectable_label(true, shown.as_str());+ }+ if app.services.pick_display_profile.is_some() {+ let r = ui.selectable_label(false, crate::i18n::tr("Other…"));+ register(ui.ctx(), "item:printProfile-other", r.rect);+ pick |= r.clicked();+ }+ });+ register(ui.ctx(), "combo:printProfile", c.response.rect);+ });+ if pick && let Some(path) = app.services.pick_display_profile.as_mut().and_then(|pick| pick().into_iter().next()) {+ patch_color(app, &ctx, "profile", json!({"kind": "icc", "path": path}));+ }+ row(ui, t, "Intent", |ui| {+ if let Some(v) = choice(ui, "printIntent", &[(PrintIntent::Perceptual, "Perceptual"), (PrintIntent::Relative, "Relative")], color.intent) {+ patch_color(app, &ctx, "intent", to_value(v));+ }+ });+ ui.add_enabled_ui(color.intent == PrintIntent::Relative, |ui| {+ if let Some(v) = check(ui, "printBpc", "Black Point Compensation", color.black_point_compensation) {+ patch_color(app, &ctx, "blackPointCompensation", json!(v));+ }+ });+ for (key, label, value) in [("brightness", "Brightness", color.brightness), ("contrast", "Contrast", color.contrast)] {+ row(ui, t, label, |ui| {+ let mut v = value;+ let r = ui.add(egui::DragValue::new(&mut v).range(-100.0..=100.0).speed(0.5).max_decimals(0));+ register(ui.ctx(), format!("drag:print{label}"), r.rect);+ if r.changed() {+ patch_color(app, &ctx, key, json!(v));+ }+ });+ }+ row(ui, t, "Sharpening", |ui| {+ let options = [(PrintSharpen::Off, "Off"), (PrintSharpen::Low, "Low"), (PrintSharpen::Standard, "Standard"), (PrintSharpen::High, "High")];+ if let Some(v) = choice(ui, "printSharpen", &options, color.sharpen) {+ patch_color(app, &ctx, "sharpen", to_value(v));+ }+ });+ ui.add_enabled_ui(color.sharpen != PrintSharpen::Off, |ui| {+ row(ui, t, "Media", |ui| {+ if let Some(v) = choice(ui, "printMedia", &[(PrintMedia::Matte, "Matte"), (PrintMedia::Glossy, "Glossy")], color.media) {+ patch_color(app, &ctx, "media", to_value(v));+ }+ });+ });+ if let Some(v) = check(ui, "print16bit", "16 bits per channel", color.sixteen_bit) {+ patch_color(app, &ctx, "sixteenBit", json!(v));+ }+ let bits = if color.sixteen_bit { "16-bit" } else { "8-bit" };+ let summary = format!("PDF · {shown} · {bits} · {}", crate::i18n::tr("current edits"));+ ui.label(egui::RichText::new(summary).color(t.text_dim));}fn trim(v: f64) -> String {diff --git a/crates/ui-egui/src/tests_print.rs b/crates/ui-egui/src/tests_print.rsindex a75191d03..29c214e47 100644--- a/crates/ui-egui/src/tests_print.rs+++ b/crates/ui-egui/src/tests_print.rs@@ -299,6 +299,63 @@ fn the_print_dialog_fits_the_window_with_its_buttons_on_screen() {}}+#[test]+fn print_job_colour_controls_reach_the_job_and_the_pdf() {+ use lightcraft_engine::print_color::{PrintIntent, PrintMedia, PrintProfile, PrintSharpen};+ let dir = std::env::temp_dir().join(format!("lightcraft-print-ui-{}", std::process::id()));+ std::fs::create_dir_all(&dir).unwrap();+ let icc = dir.join("Baryta Paper.icc");+ std::fs::write(&icc, lightcraft_codecs::icc::write_named(lightcraft_codecs::NamedSpace::AdobeRgb)).unwrap();+ let picked = icc.to_string_lossy().into_owned();+ let services = Services { png: None, pick_display_profile: Some(Box::new(move || vec![picked.clone()])), ..Default::default() };+ let mut h = demo(services);+ open_print(&mut h);+ // the Print Job panel is at the bottom of the settings column: scroll down to it, as a person would+ let r = h.request("ui.hoverWidget", json!({"id": "combo:printPaper"}), T);+ assert_eq!(r["ok"], true, "{r}");+ for _ in 0..4 {+ h.request("ui.scroll", json!({"dy": -600.0}), T);+ h.settle(T);+ }+ let job = |h: &Headless| h.app.session.print.job.color.clone();+ assert_eq!(job(&h).intent, PrintIntent::Perceptual);+ assert!(!has(&h, "item:printProfile-other"), "the menu is closed");++ click(&mut h, "button:printIntent-1");+ assert_eq!(job(&h).intent, PrintIntent::Relative);+ click(&mut h, "check:printBpc");+ assert!(!job(&h).black_point_compensation);+ click(&mut h, "button:printSharpen-3");+ click(&mut h, "button:printMedia-0");+ assert_eq!((job(&h).sharpen, job(&h).media), (PrintSharpen::High, PrintMedia::Matte));+ click(&mut h, "check:print16bit");+ assert!(!job(&h).sixteen_bit);+ drag(&mut h, "drag:printBrightness", 30.0, 0.0);+ assert!(job(&h).brightness > 0.0, "{}", job(&h).brightness);++ // a printer profile from the picker+ click(&mut h, "combo:printProfile");+ click(&mut h, "item:printProfile-other");+ assert_eq!(job(&h).profile, PrintProfile::Icc { path: icc.clone() });++ // the PDF uses it: converted pages, the profile named as the output intent, 8 bits+ cmd(+ &mut h,+ "print.set",+ json!({"layout": {"style": "contactSheet", "grid": {"columns": 1, "rows": 1}, "page": {"paper": "4x6"}}, "job": {"ppi": 72.0}}),+ );+ let ids: Vec<u64> = h.app.session.catalog.photos().take(1).map(|p| p.id.0).collect();+ let out = dir.join("colour.pdf");+ cmd(&mut h, "print.exportPdf", json!({"path": out, "ids": ids}));+ let text = String::from_utf8_lossy(&std::fs::read(&out).unwrap()).into_owned();+ assert!(text.contains("/OutputIntents") && text.contains("/BitsPerComponent 8") && text.contains("/ICCBased"));++ // back to Managed by Printer+ click(&mut h, "combo:printProfile");+ click(&mut h, "item:printProfile-adobeRgb");+ assert_eq!(job(&h).profile, PrintProfile::Managed { space: lightcraft_engine::print_color::ManagedSpace::AdobeRgb });+}+#[test]fn the_print_preview_does_not_rebuild_thumbnails_every_frame() {let mut h = demo(Services { png: None, ..Default::default() });diff --git a/docs/parity-checklist.md b/docs/parity-checklist.mdindex 010506b9f..2fe882e49 100644--- a/docs/parity-checklist.md+++ b/docs/parity-checklist.md@@ -753,7 +753,7 @@ From `08-lightroom-classic-extras.md` (Classic-only features) and part 2 of `06-| LRC-PRINT-GUIDES | Print guides | P2 | ✅ | `cmd:print.set`, `cmd:print.cell.move`, `crates/ui-egui/src/print_view.rs` | rulers in in/cm/mm/pt, snap off/cells/grid with a grid size, and Page Margins / Page Bleed (a fixed 0.125 in outline) / Page Grid / Image Cells / Dimensions guides drawn on the preview || LRC-PRINT-CELLS | Picture-package cells | P2 | ✅ | `cmd:print.cell.add`, `cmd:print.cell.move`, `cmd:print.cell.resize`, `cmd:print.cell.delete`, `cmd:print.cell.stack`, `cmd:print.cell.photo`, `cmd:print.cell.page`, `cmd:print.layout.autoLayout`, `crates/ui-egui/src/print_view.rs` | add cells at standard or custom sizes, drag and resize them on the page preview (snap to cells, grid or off), Send to Back / Backward / Forward / Bring to Front, a photo per cell (Custom Package), Auto Layout packing, New Page, Clear Layout; no Auto Layout for Custom Package || LRC-PRINT-PAGE | Print page options | P2 | 🟡 | `cmd:print.set`, `cmd:export.contactSheet`, `crates/engine/src/print/compose.rs`, `crates/ui-egui/src/print_view.rs` | page background colour and margins in the Print dialog; filename captions in the contact-sheet PDF; no identity plate, watermark, page numbers, crop marks or photo info |-| LRC-PRINT-JOB | Print job & colour management | P2 | 🟡 | `cmd:print.set`, `cmd:print.exportPdf`, `crates/engine/src/print_color.rs`, `crates/codecs/src/print.rs`, `crates/engine/src/pdf.rs`, `cmd:export.contactSheet` | print resolution 72–720 ppi; colour management: Managed by Printer (sRGB / Adobe RGB, profile embedded) or a printer / paper ICC profile (RGB, CMYK or grey) converted here and named as the PDF's output intent; perceptual / relative colorimetric with black point compensation; Print Adjustment brightness / contrast; print sharpening Low / Standard / High for Matte / Glossy; 16-bit (or 8-bit) ICC-tagged lossless page images; a bad profile fails before rendering (`tests_print::export_pdf_with_a_printer_profile`). The contact sheet keeps its fixed 150 dpi sRGB JPEG PDF. Missing: printing to a printer (OS print dialog), JPEG file output, Draft Mode |+| LRC-PRINT-JOB | Print job & colour management | P2 | 🟡 | `cmd:print.set`, `cmd:print.exportPdf`, `crates/ui-egui/src/print_view.rs`, `crates/engine/src/print_color.rs`, `crates/codecs/src/print.rs`, `crates/engine/src/pdf.rs`, `cmd:export.contactSheet` | the Print dialog's Print Job panel and `print.set {job}`: print resolution 72–720 ppi; colour management: Managed by Printer (sRGB / Adobe RGB, profile embedded) or a printer / paper ICC profile (RGB, CMYK or grey) converted here and named as the PDF's output intent; perceptual / relative colorimetric with black point compensation; Print Adjustment brightness / contrast; print sharpening Low / Standard / High for Matte / Glossy; 16-bit (or 8-bit) ICC-tagged lossless page images; a bad profile fails before rendering (`tests_print::export_pdf_with_a_printer_profile`). The contact sheet keeps its fixed 150 dpi sRGB JPEG PDF. Missing: printing to a printer (OS print dialog), JPEG file output, Draft Mode || LRC-PRINT-TEMPLATES | Print templates | P2 | 🟡 | `cmd:print.template.save`, `cmd:print.template.apply`, `cmd:print.template.list`, `cmd:print.template.delete`, `crates/ui-egui/src/print_view.rs` | save, apply and delete named templates (layout, image settings, page, job) at the top of the Print dialog, kept with the library; no built-in templates, no folders, no import / export of template files || LRC-WEB-LAYOUT | Web gallery layouts | OOS | 🚫 | | || LRC-WEB-SITEINFO | Web gallery site info | OOS | 🚫 | | |@@ -787,6 +787,7 @@ Latin stays upright. Advanced Japanese composition remains open. Regression cove| Date | Change | Summary ||---|---|---|+| 2026-10-12 | minor | LRC-PRINT-JOB: the Print dialog's Print Job panel sets the profile (Managed by Printer or a printer / paper profile picked from disk), intent, black point compensation, print adjustment, print sharpening and depth || 2026-10-12 | minor | LRC-PRINT-JOB: print colour management (printer / paper ICC profiles or Managed by Printer, intent, black point compensation, print adjustment, print sharpening) and a 16-bit ICC-tagged PDF with an output intent; still 🟡 (no OS print dialog or JPEG output) || 2026-10-12 | minor | LRC-PRINT-GUIDES, LRC-PRINT-CELLS, LRC-PRINT-LAYOUTSTYLE, LRC-PRINT-IMAGESETTINGS (✅), LRC-PRINT-LAYOUT, LRC-PRINT-PAGE, LRC-PRINT-TEMPLATES (🟡): File → Print… opens the Print dialog with a scaled page preview, rulers and guides, cells dragged and resized with snapping, image settings, page setup and templates, and prints to PDF in the background || 2026-10-12 | minor | LRC-PRINT-LAYOUTSTYLE, LRC-PRINT-IMAGESETTINGS, LRC-PRINT-LAYOUT, LRC-PRINT-CELLS, LRC-PRINT-PAGE, LRC-PRINT-TEMPLATES: the Print module is reachable as 18 `print.*` commands (settings, cells, Auto Layout, PDF, templates saved in prefs.json) from the CLI, control channel and MCP; 🟡 until the Print UI lands, LRC-PRINT-GUIDES stays ⬜ |