diff --git a/crates/print/src/ui/dialog.rs b/crates/print/src/ui/dialog.rs index 6fa567568c..c955c2300a 100644 --- a/crates/print/src/ui/dialog.rs +++ b/crates/print/src/ui/dialog.rs @@ -337,14 +337,19 @@ pub(super) struct PrintPreviewStyle { ink: StyleColor, } +/// What a grayscale job's pictures are multiplied by: the light grey of production's preview. The vertex colour only +/// scales the picture's channels; the picture itself is rendered grey by the app. +// design: allow[raw-colour/const](the tint of printed paper in grayscale, not of the interface) +const GRAYSCALE_TINT: Color32 = Color32::from_gray(235); + /// The textured quad of a page: `corners` (screen points) are the picture's top-left, top-right, bottom-right and /// bottom-left, paired in that order with `uv`'s corners, so a turned placement turns the picture with it. -fn page_quad(texture: TextureId, corners: [Pos2; 4], uv: Rect) -> Mesh { +fn page_quad(texture: TextureId, corners: [Pos2; 4], uv: Rect, tint: Color32) -> Mesh { let mut mesh = Mesh::with_texture(texture); let uvs = [uv.left_top(), uv.right_top(), uv.right_bottom(), uv.left_bottom()]; for (pos, uv) in corners.into_iter().zip(uvs) { // White leaves the picture's own colours: the vertex colour multiplies the texture. - mesh.vertices.push(egui::epaint::Vertex { pos, uv, color: Color32::WHITE }); + mesh.vertices.push(egui::epaint::Vertex { pos, uv, color: tint }); } mesh.add_triangle(0, 1, 2); mesh.add_triangle(0, 2, 3); @@ -360,10 +365,10 @@ fn centred_text(painter: &ContentPainterCx<'_>, run: &TextRun<'_>, centre: Pos2, } /// Paints `page` at `place`: its picture as a textured quad, or a stand-in with its number centred. -fn paint_page(painter: &ContentPainterCx<'_>, style: &PrintPreviewStyle, place: Placement, page: &SheetPage) { +fn paint_page(painter: &ContentPainterCx<'_>, style: &PrintPreviewStyle, place: Placement, page: &SheetPage, tint: Color32) { let corners = page.corners.map(|corner| place.point(corner)); match page.picture { - Some(texture) => painter.data_shapes([Shape::mesh(page_quad(texture, corners, page.uv))]), + Some(texture) => painter.data_shapes([Shape::mesh(page_quad(texture, corners, page.uv, tint))]), None => { painter.data_shapes([Shape::mesh(fill_polygon(&corners, style.stand_in.egui(), 0.0))]); let centre = Pos2::ZERO + corners.iter().fold(Vec2::ZERO, |sum, corner| sum + corner.to_vec2()) / 4.0; @@ -384,14 +389,27 @@ pub(super) struct PrintPreview<'a> { sheet: &'a PrintSheet, /// The image box's top-left corner on the paper, in paper points. position: Bind<'a, Pos2>, + /// The job prints in grayscale: the pictures are tinted grey. + grayscale: bool, } impl<'a> PrintPreview<'a> { pub(super) fn new(label: impl Into