From 73459a662c39f3730ac92ffaa6aa66346eb2a4de Mon Sep 17 00:00:00 2001 From: Higgs32584 Date: Thu, 15 Oct 2026 21:44:21 -0400 Subject: [PATCH 1/6] Artboards: layers outside the boards stay visible over the pasteboard (#5712) Adding an artboard next to earlier work made that work vanish: the canvas painted the opaque pasteboard over the whole image outside the boards, hiding layers that are not in an artboard. Photoshop shows them, so the pasteboard now leaves out where visible loose layers draw (their composite bounds). Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/artboard_ui.rs | 79 +++++++++++++++++++++++++++++-- 1 file changed, 75 insertions(+), 4 deletions(-) diff --git a/crates/ui-egui/src/artboard_ui.rs b/crates/ui-egui/src/artboard_ui.rs index 1ff452a829..ef4e080f6a 100644 --- a/crates/ui-egui/src/artboard_ui.rs +++ b/crates/ui-egui/src/artboard_ui.rs @@ -11,9 +11,20 @@ use crate::canvas::ViewXform; use crate::theme::Tokens; /// Screen rects covering the document image minus every artboard (vertical slabs between the -/// boards' x edges, split around the boards they cross). +/// boards' x edges, split around the boards they cross), and minus where visible layers outside +/// the boards draw: Photoshop shows those over the pasteboard, so a board added next to earlier +/// work must not paint over it (#5712). pub fn pasteboard_rects(xf: &ViewXform, doc: &Document) -> Vec { let canvas = doc.bounds(); + let mut loose = Vec::new(); + for l in doc.layers.iter().filter(|l| l.visible && !is_artboard(l)) { + match photocraft_compose::composite_bounds(l, canvas) { + // It may draw anywhere: no pasteboard shows. + None => return Vec::new(), + Some(b) if !b.is_empty() => loose.push(b), + Some(_) => {} + } + } let boards: Vec = doc.artboards().iter().map(|b| b.2.rect.intersect(&canvas)).filter(|r| !r.is_empty()).collect(); let mut xs: Vec = vec![canvas.x0, canvas.x1]; for b in &boards { @@ -29,17 +40,45 @@ pub fn pasteboard_rects(xf: &ViewXform, doc: &Document) -> Vec { let mut y = canvas.y0; for (a, b) in spans { if a > y { - out.push(xf.doc_rect(photocraft_geom::Rect::new(x0, y, x1, a))); + out.extend(subtract(photocraft_geom::Rect::new(x0, y, x1, a), &loose).into_iter().map(|r| xf.doc_rect(r))); } y = y.max(b); } if y < canvas.y1 { - out.push(xf.doc_rect(photocraft_geom::Rect::new(x0, y, x1, canvas.y1))); + out.extend(subtract(photocraft_geom::Rect::new(x0, y, x1, canvas.y1), &loose).into_iter().map(|r| xf.doc_rect(r))); } } out } +fn is_artboard(l: &Layer) -> bool { + matches!(&l.content, photocraft_doc::LayerContent::Group(g) if g.artboard.is_some()) +} + +/// `r` minus every hole, as disjoint rects (each hole splits a piece into at most four). +fn subtract(r: photocraft_geom::Rect, holes: &[photocraft_geom::Rect]) -> Vec { + let mut pieces = vec![r]; + for h in holes { + let mut next = Vec::with_capacity(pieces.len()); + for p in pieces { + let i = p.intersect(h); + if i.is_empty() { + next.push(p); + continue; + } + let parts = [ + photocraft_geom::Rect::new(p.x0, p.y0, p.x1, i.y0), + photocraft_geom::Rect::new(p.x0, i.y1, p.x1, p.y1), + photocraft_geom::Rect::new(p.x0, i.y0, i.x0, i.y1), + photocraft_geom::Rect::new(i.x1, i.y0, p.x1, i.y1), + ]; + next.extend(parts.into_iter().filter(|q| !q.is_empty())); + } + pieces = next; + } + pieces +} + /// Board outlines and names (the active board's name is highlighted, as in Photoshop). pub fn draw_frames(app: &PhotocraftApp, painter: &egui::Painter, xf: &ViewXform) { let Some(st) = app.session.active() else { return }; @@ -169,7 +208,7 @@ mod tests { fn app() -> (PhotocraftApp, egui::Context) { let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default()); - app.run("file.new", json!({"width": 100, "height": 50})).unwrap(); + app.run("file.new", json!({"width": 100, "height": 50, "background": "transparent"})).unwrap(); app.sync_views(); (app, egui::Context::default()) } @@ -195,6 +234,38 @@ mod tests { assert!(rects.iter().all(|r| !r.intersects(Rect::from_min_max(Pos2::new(0.5, 0.5), Pos2::new(39.5, 49.5))))); } + #[test] + fn layers_outside_the_boards_show_over_the_pasteboard() { + // #5712: a board drawn left of earlier work must not cover it with pasteboard. + let (mut app, _) = app(); + app.run("layer.new.artboard", json!({"rect": [0, 0, 40, 50]})).unwrap(); + let mut doc = (*app.session.active().unwrap().doc).clone(); + let mut px = photocraft_doc::Layer::raster("Work", doc.pixel_format()); + px.surface_mut().unwrap().fill_rect(photocraft_geom::Rect::new(60, 10, 80, 30), &[1.0, 0.0, 0.0, 1.0]); + doc.layers.insert(0, px); + let xf = ViewXform { + rect: Rect::from_min_size(Pos2::ZERO, egui::vec2(100.0, 50.0)), + zoom: 1.0, + center: [50.0, 25.0], + flip: false, + rotation: 0.0, + aspect: 1.0, + }; + let rects = pasteboard_rects(&xf, &doc); + let area: f32 = rects.iter().map(|r| r.area()).sum(); + // 100×50 canvas − the 40×50 board − the 20×20 loose pixels. + assert!((area - (5000.0 - 2000.0 - 400.0)).abs() < 0.5, "{rects:?}"); + assert!(rects.iter().all(|r| !r.intersects(Rect::from_min_max(Pos2::new(60.5, 10.5), Pos2::new(79.5, 29.5))))); + } + + #[test] + fn subtract_splits_around_holes() { + let r = photocraft_geom::Rect::new(0, 0, 10, 10); + let parts = subtract(r, &[photocraft_geom::Rect::new(2, 2, 4, 4), photocraft_geom::Rect::new(20, 20, 30, 30)]); + assert_eq!(parts.iter().map(|p| i64::from(p.width()) * i64::from(p.height())).sum::(), 96); + assert!(subtract(r, &[photocraft_geom::Rect::new(-5, -5, 50, 50)]).is_empty()); + } + #[test] fn fit_artboard_and_menu_items() { let (mut app, ctx) = app(); From b6be26a490ed9aa773e75ecca4aae621af4715bd Mon Sep 17 00:00:00 2001 From: Higgs32584 Date: Thu, 15 Oct 2026 22:28:54 -0400 Subject: [PATCH 2/6] rustfmt; merge main (CI Format step) Co-Authored-By: Claude Opus 5.5 --- crates/automation/tests/smart_filter_authorization.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/crates/automation/tests/smart_filter_authorization.rs b/crates/automation/tests/smart_filter_authorization.rs index a5c1681a52..30f17b795b 100644 --- a/crates/automation/tests/smart_filter_authorization.rs +++ b/crates/automation/tests/smart_filter_authorization.rs @@ -230,11 +230,9 @@ fn a_refresh_outside_command_execution_surfaces_the_denial_instead_of_rendering_ let before = h.session.active().unwrap().doc.clone(); // Session::edit is the outside-execute mutation path (an edit closure the UI or a // linked-file change runs); the stored filter must be denied there too. - assert_denied(h.session.edit("Re-render", |d, _| { - match smart_cmds::refresh(d, layer) { - Ok(_) => Ok(()), - Err(e) => Err(e), - } + assert_denied(h.session.edit("Re-render", |d, _| match smart_cmds::refresh(d, layer) { + Ok(_) => Ok(()), + Err(e) => Err(e), })); assert!(Arc::ptr_eq(&before, &h.session.active().unwrap().doc)); // A trusted session (no gate) still renders the same document. From 17c9cda345a5f40a6c816d94bc89842eea258fa6 Mon Sep 17 00:00:00 2001 From: Higgs32584 Date: Sun, 18 Oct 2026 09:19:39 -0400 Subject: [PATCH 3/6] Artboards: the Background and full-canvas layers keep the pasteboard (#5712) Review on #6410: any visible layer covering the whole canvas (the default white Background, or a fill layer whose bounds are unbounded) removed the pasteboard entirely. Those are backdrop, not loose work: pasteboard_rects now skips the document's Background and any layer whose composite bounds are unbounded or contain the canvas. The test helper is back to the default white document, and full_canvas_layers_keep_the_pasteboard covers it. Merging main also drops the rustfmt-only change to smart_filter_authorization.rs from the PR diff. Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/artboard_ui.rs | 46 +++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 11 deletions(-) diff --git a/crates/ui-egui/src/artboard_ui.rs b/crates/ui-egui/src/artboard_ui.rs index ef4e080f6a..da97fc7d4c 100644 --- a/crates/ui-egui/src/artboard_ui.rs +++ b/crates/ui-egui/src/artboard_ui.rs @@ -13,18 +13,19 @@ use crate::theme::Tokens; /// Screen rects covering the document image minus every artboard (vertical slabs between the /// boards' x edges, split around the boards they cross), and minus where visible layers outside /// the boards draw: Photoshop shows those over the pasteboard, so a board added next to earlier -/// work must not paint over it (#5712). +/// work must not paint over it (#5712). The Background and any layer that covers the whole +/// canvas (or may draw anywhere, such as a fill layer) are backdrop, not loose work: they keep +/// the pasteboard. pub fn pasteboard_rects(xf: &ViewXform, doc: &Document) -> Vec { let canvas = doc.bounds(); - let mut loose = Vec::new(); - for l in doc.layers.iter().filter(|l| l.visible && !is_artboard(l)) { - match photocraft_compose::composite_bounds(l, canvas) { - // It may draw anywhere: no pasteboard shows. - None => return Vec::new(), - Some(b) if !b.is_empty() => loose.push(b), - Some(_) => {} - } - } + let background = doc.background().map(|b| b.id); + let loose: Vec = doc + .layers + .iter() + .filter(|l| l.visible && !is_artboard(l) && Some(l.id) != background) + .filter_map(|l| photocraft_compose::composite_bounds(l, canvas)) + .filter(|b| !b.is_empty() && !b.contains_rect(&canvas)) + .collect(); let boards: Vec = doc.artboards().iter().map(|b| b.2.rect.intersect(&canvas)).filter(|r| !r.is_empty()).collect(); let mut xs: Vec = vec![canvas.x0, canvas.x1]; for b in &boards { @@ -208,7 +209,7 @@ mod tests { fn app() -> (PhotocraftApp, egui::Context) { let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default()); - app.run("file.new", json!({"width": 100, "height": 50, "background": "transparent"})).unwrap(); + app.run("file.new", json!({"width": 100, "height": 50})).unwrap(); app.sync_views(); (app, egui::Context::default()) } @@ -258,6 +259,29 @@ mod tests { assert!(rects.iter().all(|r| !r.intersects(Rect::from_min_max(Pos2::new(60.5, 10.5), Pos2::new(79.5, 29.5))))); } + #[test] + fn full_canvas_layers_keep_the_pasteboard() { + // The white Background (from `app()`) and a loose layer filling the whole canvas are + // backdrop: the pasteboard still shows outside the board. + let (mut app, _) = app(); + app.run("layer.new.artboard", json!({"rect": [0, 0, 40, 50]})).unwrap(); + let mut doc = (*app.session.active().unwrap().doc).clone(); + assert!(doc.background().is_some()); + let mut px = photocraft_doc::Layer::raster("Wash", doc.pixel_format()); + px.surface_mut().unwrap().fill_rect(doc.bounds(), &[0.0, 0.0, 1.0, 1.0]); + doc.layers.push(px); + let xf = ViewXform { + rect: Rect::from_min_size(Pos2::ZERO, egui::vec2(100.0, 50.0)), + zoom: 1.0, + center: [50.0, 25.0], + flip: false, + rotation: 0.0, + aspect: 1.0, + }; + let area: f32 = pasteboard_rects(&xf, &doc).iter().map(|r| r.area()).sum(); + assert!((area - (5000.0 - 2000.0)).abs() < 0.5); + } + #[test] fn subtract_splits_around_holes() { let r = photocraft_geom::Rect::new(0, 0, 10, 10); From c8f7cfaae6ff883a7c3882edc495d6993b011573 Mon Sep 17 00:00:00 2001 From: Higgs32584 Date: Sun, 18 Oct 2026 09:45:11 -0400 Subject: [PATCH 4/6] Artboards: paint pasteboard pieces as quads so a rotated view keeps the holes (#5712) pasteboard_rects returned each piece's screen bounding box, which in a rotated view covers the loose layers (and boards) it was cut around. pasteboard_quads returns each piece's four screen corners and the canvas paints them as meshes. Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/artboard_ui.rs | 77 +++++++++++++++++++++++++------ crates/ui-egui/src/canvas.rs | 28 +++++++---- 2 files changed, 81 insertions(+), 24 deletions(-) diff --git a/crates/ui-egui/src/artboard_ui.rs b/crates/ui-egui/src/artboard_ui.rs index da97fc7d4c..63939fa9f3 100644 --- a/crates/ui-egui/src/artboard_ui.rs +++ b/crates/ui-egui/src/artboard_ui.rs @@ -10,13 +10,15 @@ use crate::PhotocraftApp; use crate::canvas::ViewXform; use crate::theme::Tokens; -/// Screen rects covering the document image minus every artboard (vertical slabs between the +/// Screen quads covering the document image minus every artboard (vertical slabs between the /// boards' x edges, split around the boards they cross), and minus where visible layers outside /// the boards draw: Photoshop shows those over the pasteboard, so a board added next to earlier /// work must not paint over it (#5712). The Background and any layer that covers the whole /// canvas (or may draw anywhere, such as a fill layer) are backdrop, not loose work: they keep -/// the pasteboard. -pub fn pasteboard_rects(xf: &ViewXform, doc: &Document) -> Vec { +/// the pasteboard. Each piece is returned as its four screen corners rather than a screen +/// bounding box, so in a rotated view the pieces keep their shape and do not cover the boards +/// or the loose layers they were cut around. +pub fn pasteboard_quads(xf: &ViewXform, doc: &Document) -> Vec<[Pos2; 4]> { let canvas = doc.bounds(); let background = doc.background().map(|b| b.id); let loose: Vec = doc @@ -41,17 +43,23 @@ pub fn pasteboard_rects(xf: &ViewXform, doc: &Document) -> Vec { let mut y = canvas.y0; for (a, b) in spans { if a > y { - out.extend(subtract(photocraft_geom::Rect::new(x0, y, x1, a), &loose).into_iter().map(|r| xf.doc_rect(r))); + out.extend(subtract(photocraft_geom::Rect::new(x0, y, x1, a), &loose).into_iter().map(|r| quad(xf, r))); } y = y.max(b); } if y < canvas.y1 { - out.extend(subtract(photocraft_geom::Rect::new(x0, y, x1, canvas.y1), &loose).into_iter().map(|r| xf.doc_rect(r))); + out.extend(subtract(photocraft_geom::Rect::new(x0, y, x1, canvas.y1), &loose).into_iter().map(|r| quad(xf, r))); } } out } +/// The corners of a document rect on screen, in order (a parallelogram when the view is rotated). +fn quad(xf: &ViewXform, r: photocraft_geom::Rect) -> [Pos2; 4] { + let (x0, y0, x1, y1) = (r.x0 as f32, r.y0 as f32, r.x1 as f32, r.y1 as f32); + [xf.to_screen(x0, y0), xf.to_screen(x1, y0), xf.to_screen(x1, y1), xf.to_screen(x0, y1)] +} + fn is_artboard(l: &Layer) -> bool { matches!(&l.content, photocraft_doc::LayerContent::Group(g) if g.artboard.is_some()) } @@ -228,11 +236,11 @@ mod tests { rotation: 0.0, aspect: 1.0, }; - let rects = pasteboard_rects(&xf, &doc); - let area: f32 = rects.iter().map(|r| r.area()).sum(); + let quads = pasteboard_quads(&xf, &doc); + let area: f32 = quads.iter().map(quad_area).sum(); // 100×50 canvas − 40×50 − 40×30 boards. - assert!((area - (5000.0 - 2000.0 - 1200.0)).abs() < 0.5, "{rects:?}"); - assert!(rects.iter().all(|r| !r.intersects(Rect::from_min_max(Pos2::new(0.5, 0.5), Pos2::new(39.5, 49.5))))); + assert!((area - (5000.0 - 2000.0 - 1200.0)).abs() < 0.5, "{quads:?}"); + assert!(quads.iter().all(|q| !Rect::from_points(q).intersects(Rect::from_min_max(Pos2::new(0.5, 0.5), Pos2::new(39.5, 49.5))))); } #[test] @@ -252,11 +260,11 @@ mod tests { rotation: 0.0, aspect: 1.0, }; - let rects = pasteboard_rects(&xf, &doc); - let area: f32 = rects.iter().map(|r| r.area()).sum(); + let quads = pasteboard_quads(&xf, &doc); + let area: f32 = quads.iter().map(quad_area).sum(); // 100×50 canvas − the 40×50 board − the 20×20 loose pixels. - assert!((area - (5000.0 - 2000.0 - 400.0)).abs() < 0.5, "{rects:?}"); - assert!(rects.iter().all(|r| !r.intersects(Rect::from_min_max(Pos2::new(60.5, 10.5), Pos2::new(79.5, 29.5))))); + assert!((area - (5000.0 - 2000.0 - 400.0)).abs() < 0.5, "{quads:?}"); + assert!(quads.iter().all(|q| !Rect::from_points(q).intersects(Rect::from_min_max(Pos2::new(60.5, 10.5), Pos2::new(79.5, 29.5))))); } #[test] @@ -278,10 +286,51 @@ mod tests { rotation: 0.0, aspect: 1.0, }; - let area: f32 = pasteboard_rects(&xf, &doc).iter().map(|r| r.area()).sum(); + let area: f32 = pasteboard_quads(&xf, &doc).iter().map(quad_area).sum(); assert!((area - (5000.0 - 2000.0)).abs() < 0.5); } + fn quad_area(q: &[Pos2; 4]) -> f32 { + (0..4).map(|i| q[i].x * q[(i + 1) % 4].y - q[(i + 1) % 4].x * q[i].y).sum::().abs() / 2.0 + } + + /// Whether `p` lies strictly inside the convex quad `q` (either winding). + fn inside(q: &[Pos2; 4], p: Pos2) -> bool { + let side = |i: usize| (q[(i + 1) % 4] - q[i]).x * (p - q[i]).y - (q[(i + 1) % 4] - q[i]).y * (p - q[i]).x; + let s: Vec = (0..4).map(side).collect(); + s.iter().all(|&v| v > 0.0) || s.iter().all(|&v| v < 0.0) + } + + #[test] + fn rotated_view_keeps_the_holes_around_loose_layers() { + // A loose layer in the middle of the pasteboard, seen at 45°: the strips around it must + // not cover it (their screen bounding boxes would). + let (mut app, _) = app(); + app.run("layer.new.artboard", json!({"rect": [0, 0, 20, 50]})).unwrap(); + let mut doc = (*app.session.active().unwrap().doc).clone(); + let mut px = photocraft_doc::Layer::raster("Work", doc.pixel_format()); + px.surface_mut().unwrap().fill_rect(photocraft_geom::Rect::new(50, 15, 70, 35), &[1.0, 0.0, 0.0, 1.0]); + doc.layers.insert(0, px); + let xf = ViewXform { + rect: Rect::from_min_size(Pos2::ZERO, egui::vec2(200.0, 200.0)), + zoom: 1.0, + center: [50.0, 25.0], + flip: true, + rotation: 45.0, + aspect: 1.0, + }; + let quads = pasteboard_quads(&xf, &doc); + let area: f32 = quads.iter().map(quad_area).sum(); + // Rotation keeps areas: 100×50 canvas − the 20×50 board − the 20×20 loose pixels. + assert!((area - (5000.0 - 1000.0 - 400.0)).abs() < 0.5, "{quads:?}"); + for (x, y) in [(60.0, 25.0), (51.0, 16.0), (69.0, 34.0), (10.0, 25.0)] { + let p = xf.to_screen(x, y); + assert!(quads.iter().all(|q| !inside(q, p)), "({x}, {y}) is covered"); + } + // Pasteboard still shows next to the hole. + assert!(quads.iter().any(|q| inside(q, xf.to_screen(80.0, 25.0)))); + } + #[test] fn subtract_splits_around_holes() { let r = photocraft_geom::Rect::new(0, 0, 10, 10); diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs index 91644b5f73..538fb08ac3 100644 --- a/crates/ui-egui/src/canvas.rs +++ b/crates/ui-egui/src/canvas.rs @@ -3174,21 +3174,29 @@ pub fn canvas_view(app: &mut PhotocraftApp, ui: &mut egui::Ui, idx: usize, rect: let t = crate::theme::Tokens::get(&ctx); let pasteboard = crate::prefs_ui::pasteboard_color(app); let dot_tex = dots(&ctx, &t); - for r in crate::artboard_ui::pasteboard_rects(&xf, &doc) { - let r = r.intersect(rect); - if !r.is_positive() { + // Each piece is painted as its own quad (the painter clips to the canvas), so a + // rotated view does not paint a piece's bounding box over the boards or loose work. + let fill = |q: &[Pos2; 4], tex: Option, color: Color32| { + let mut mesh = tex.map_or_else(egui::Mesh::default, egui::Mesh::with_texture); + for &p in q { + // Same phase as the dots around the document. + let uv = if tex.is_some() { ((p - rect.min) / 22.0).to_pos2() } else { egui::epaint::WHITE_UV }; + mesh.vertices.push(egui::epaint::Vertex { pos: p, uv, color }); + } + mesh.add_triangle(0, 1, 2); + mesh.add_triangle(0, 2, 3); + painter.add(mesh); + }; + for q in crate::artboard_ui::pasteboard_quads(&xf, &doc) { + if !Rect::from_points(&q).intersects(rect) { continue; } match pasteboard { - Some(c) => { - painter.rect_filled(r, 0.0, c); - } + Some(c) => fill(&q, None, c), None => { - painter.rect_filled(r, 0.0, t.canvas); + fill(&q, None, t.canvas); if let Some(id) = dot_tex { - // Same phase as the dots around the document. - let uv = Rect::from_min_max(((r.min - rect.min) / 22.0).to_pos2(), ((r.max - rect.min) / 22.0).to_pos2()); - painter.image(id, r, uv, Color32::WHITE); + fill(&q, Some(id), Color32::WHITE); } } } From bd5e5ed781ba13c1d691dd7e70bdd34fafe6f23b Mon Sep 17 00:00:00 2001 From: Higgs32584 Date: Sun, 18 Oct 2026 18:24:39 -0400 Subject: [PATCH 5/6] Artboards: move egui::Rect import into the tests (unused-import Clippy error) Since pasteboard_quads returns [Pos2; 4], only mod tests uses egui::Rect, so the non-test build failed clippy -D warnings with an unused import. Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/artboard_ui.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/artboard_ui.rs b/crates/ui-egui/src/artboard_ui.rs index 63939fa9f3..eac9fe77aa 100644 --- a/crates/ui-egui/src/artboard_ui.rs +++ b/crates/ui-egui/src/artboard_ui.rs @@ -2,7 +2,7 @@ //! View › Fit Artboard on Screen, and the Properties panel section (X/Y/W/H, preset, //! background). Everything that changes the document is `layer.artboard.set` and friends. -use egui::{Align2, Color32, Pos2, Rect, Stroke}; +use egui::{Align2, Color32, Pos2, Stroke}; use photocraft_doc::{ArtboardBackground, Document, Layer}; use serde_json::{Value, json}; @@ -214,6 +214,7 @@ pub fn properties(app: &mut PhotocraftApp, ui: &mut egui::Ui, layer: &Layer) { mod tests { use super::*; use crate::menus::{invoke as menu, is_live, menu_items}; + use egui::Rect; fn app() -> (PhotocraftApp, egui::Context) { let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default()); From df7c4350eb298cac9ef573f347540dab9f50d7b8 Mon Sep 17 00:00:00 2001 From: Higgs32584 Date: Tue, 20 Oct 2026 21:32:59 -0400 Subject: [PATCH 6/6] Artboard pasteboard: cut around the layers as they are shown The canvas draws `display_doc` (a Move drag's moved layers, a transform or fill preview, ...), but the pasteboard holes for loose layers came from the committed document, so a loose layer dragged over the pasteboard was covered at its new position until the move was committed. Cut the holes from the displayed document instead. Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/canvas.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs index b912d0606d..33c740dc09 100644 --- a/crates/ui-egui/src/canvas.rs +++ b/crates/ui-egui/src/canvas.rs @@ -3240,6 +3240,9 @@ pub fn canvas_view(app: &mut PhotocraftApp, ui: &mut egui::Ui, idx: usize, rect: let t = crate::theme::Tokens::get(&ctx); let pasteboard = crate::prefs_ui::pasteboard_color(app); let dot_tex = dots(&ctx, &t); + // Cut around the layers as they are shown, so a loose layer dragged with the Move tool + // (or otherwise previewed) is not covered where it now draws. + let shown = display_doc(app, idx).0; // Each piece is painted as its own quad (the painter clips to the canvas), so a // rotated view does not paint a piece's bounding box over the boards or loose work. let fill = |q: &[Pos2; 4], tex: Option, color: Color32| { @@ -3253,7 +3256,7 @@ pub fn canvas_view(app: &mut PhotocraftApp, ui: &mut egui::Ui, idx: usize, rect: mesh.add_triangle(0, 2, 3); painter.add(mesh); }; - for q in crate::artboard_ui::pasteboard_quads(&xf, &doc) { + for q in crate::artboard_ui::pasteboard_quads(&xf, &shown) { if !Rect::from_points(&q).intersects(rect) { continue; }