From 86eed6b47dd963d2f83669c04f9db063d73e89e1 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 22 Nov 2026 03:41:21 -0800 Subject: [PATCH 1/8] Selection: a selected linked image is crossed from corner to corner A selected linked image or placed document now shows two lines in its layer's color from corner to corner of its frame, in the current pane and in other panes of the same document. A selected embedded image shows its outline alone. An image is outlined along its frame, so a turned or distorted image's outline follows its corners. The lines are selection marks: View > Hide Edges hides them, the hover highlight does not draw them, and output is unchanged. The overlay's point limit counts their ends where they are drawn. Fixes #9080 --- crates/ui-egui/src/canvas/outline.rs | 70 ++++++++++++++++--- crates/ui-egui/src/canvas/overlays.rs | 4 +- crates/ui-egui/src/canvas/panes.rs | 8 ++- crates/ui-egui/src/canvas/panes/tests.rs | 28 +++++++- crates/ui-egui/src/canvas/selection_marks.rs | 4 +- .../src/canvas/selection_marks/tests.rs | 68 ++++++++++++++++++ crates/ui-egui/src/canvas/tests.rs | 26 +++++++ docs/target-app-parity.md | 1 + 8 files changed, 194 insertions(+), 15 deletions(-) diff --git a/crates/ui-egui/src/canvas/outline.rs b/crates/ui-egui/src/canvas/outline.rs index c2ab7945be..33e9553c2c 100644 --- a/crates/ui-egui/src/canvas/outline.rs +++ b/crates/ui-egui/src/canvas/outline.rs @@ -39,8 +39,8 @@ pub(super) fn c32(rgb: [u8; 3]) -> Color32 { Color32::from_rgb(rgb[0], rgb[1], rgb[2]) } -/// Outline of a node for highlighting (paths, compound children, area type frames, other -/// text/image bounds, symbol instances' bounds measured by their art from `symbols`; a clip +/// Outline of a node for highlighting (paths, compound children, area type frames, other text +/// bounds, images' frames, symbol instances' bounds measured by their art from `symbols`; a clip /// group's clipping path only, as [`walk_drawn`] visits it). pub(super) fn node_outline(n: &Node, symbols: &SymbolBoxes) -> BezPath { let mut bp = BezPath::new(); @@ -62,7 +62,13 @@ pub(super) fn node_outline(n: &Node, symbols: &SymbolBoxes) -> BezPath { bp.extend(vectorcraft_geom::shapes::rectangle(b).to_bezpath()); } } - NodeKind::Image(_) | NodeKind::SymbolInstance { .. } => { + // An image shows its frame, turned or distorted with it. + NodeKind::Image(_) => { + if let Some(frame) = c.image_frame() { + bp.extend(frame); + } + } + NodeKind::SymbolInstance { .. } => { if let Some(b) = c.geometric_bounds_with(symbols) { bp.extend(vectorcraft_geom::shapes::rectangle(b).to_bezpath()); } @@ -87,6 +93,41 @@ pub(super) fn node_outline(n: &Node, symbols: &SymbolBoxes) -> BezPath { bp } +/// Whether `n` is a linked image or a placed document, which the selection marks cross. +fn is_linked(n: &Node) -> bool { + match &n.kind { + NodeKind::Image(im) => im.link.is_some(), + NodeKind::PlacedDocument(_) => true, + _ => false, + } +} + +/// The corners (top left, top right, bottom right, bottom left) of a linked image's frame or of a +/// placed document's box. `None` for an embedded image and for anything else. +fn linked_corners(n: &Node) -> Option<[Point; 4]> { + match &n.kind { + NodeKind::Image(_) if is_linked(n) => n.image_corners(), + NodeKind::PlacedDocument(p) => Some(p.corners()), + _ => None, + } +} + +/// The lines that cross each linked image and placed document of `n` that [`walk_drawn`] visits, +/// from corner to corner of its frame or box (#9080). The selection marks draw them; the hover +/// highlight does not. +pub(super) fn linked_crosses(n: &Node) -> BezPath { + let mut bp = BezPath::new(); + walk_drawn(n, &mut |c| { + if let Some([tl, tr, br, bl]) = linked_corners(c) { + bp.move_to(tl); + bp.line_to(br); + bp.move_to(tr); + bp.line_to(bl); + } + }); + bp +} + /// The width of the key object's outline (Align to Key Object), thicker than the selection's. pub(super) const KEY_OUTLINE: f32 = 2.5; @@ -100,19 +141,32 @@ pub(super) const OVERLAY_MAX_ANCHORS: usize = 100_000; /// Whether `nodes` have more than [`OVERLAY_MAX_ANCHORS`] points to outline ([`overlay_points`]; /// counting stops there). pub(super) fn too_many_anchors<'a>(nodes: impl IntoIterator) -> bool { - fn over(n: &Node, left: &mut usize) -> bool { - match left.checked_sub(overlay_points(n)) { + over_limit(nodes, false) +} + +/// Whether `nodes` have more than [`OVERLAY_MAX_ANCHORS`] points to outline and to cross where they +/// are linked images or placed documents ([`linked_crosses`]), as the selection marks draw them. +pub(super) fn too_many_marks<'a>(nodes: impl IntoIterator) -> bool { + over_limit(nodes, true) +} + +/// Whether `nodes` have more than [`OVERLAY_MAX_ANCHORS`] points ([`overlay_points`], with the +/// ends of the crossing lines when `crosses`); counting stops there. +fn over_limit<'a>(nodes: impl IntoIterator, crosses: bool) -> bool { + fn over(n: &Node, left: &mut usize, crosses: bool) -> bool { + let ends = if crosses && is_linked(n) { 4 } else { 0 }; + match left.checked_sub(overlay_points(n) + ends) { Some(l) => *left = l, None => return true, } // A clip group counts only its clipping path, the one child `walk_drawn` visits. if n.clips() { - return n.children().and_then(|children| children.first()).is_some_and(|clip| over(clip, left)); + return n.children().and_then(|children| children.first()).is_some_and(|clip| over(clip, left, crosses)); } - !matches!(n.kind, NodeKind::Envelope { .. }) && n.editing_children().iter().any(|c| over(c, left)) + !matches!(n.kind, NodeKind::Envelope { .. }) && n.editing_children().iter().any(|c| over(c, left, crosses)) } let mut left = OVERLAY_MAX_ANCHORS; - nodes.into_iter().any(|n| over(n, &mut left)) + nodes.into_iter().any(|n| over(n, &mut left, crosses)) } /// The points counted for `n` itself, without its children, toward [`OVERLAY_MAX_ANCHORS`]: a diff --git a/crates/ui-egui/src/canvas/overlays.rs b/crates/ui-egui/src/canvas/overlays.rs index b4d2d44aac..9d5808e249 100644 --- a/crates/ui-egui/src/canvas/overlays.rs +++ b/crates/ui-egui/src/canvas/overlays.rs @@ -6,7 +6,7 @@ use egui::epaint::{TessellationOptions, Tessellator}; use super::artboards::names_an_artboard; use super::input::marquee_through; -use super::outline::{KEY_OUTLINE, c32, node_outline, selection_hit_at, stroke_path, to_screen_path, too_many_anchors}; +use super::outline::{KEY_OUTLINE, c32, node_outline, selection_hit_at, stroke_path, to_screen_path, too_many_anchors, too_many_marks}; use super::selection_marks::{MarkOptions, SelectionMarks}; use super::{BezPath, Color32, CornerRadius, NodeKind, Overlay, Pos2, Shape, Stroke, StrokeKind, Tokens, VectorcraftApp, Xf, vec2}; @@ -161,7 +161,7 @@ pub(super) fn selection_overlay(app: &mut VectorcraftApp, p: &egui::Painter, xf: }; let st = app.session.active(); let show_marks = !crate::dialogs::halftone::previewing(app); - let big = show_marks && st.is_some_and(|st| too_many_anchors(st.selection.objects.iter().filter_map(|id| st.doc.node(*id)))); + let big = show_marks && st.is_some_and(|st| too_many_marks(st.selection.objects.iter().filter_map(|id| st.doc.node(*id)))); let big_bounds = if big { app.selection_bounds() } else { None }; let app = &*app; let Some(st) = app.session.active() else { return }; diff --git a/crates/ui-egui/src/canvas/panes.rs b/crates/ui-egui/src/canvas/panes.rs index 63d89f2be2..69c6940c25 100644 --- a/crates/ui-egui/src/canvas/panes.rs +++ b/crates/ui-egui/src/canvas/panes.rs @@ -10,7 +10,7 @@ use std::collections::HashMap; use std::sync::Arc; use super::grid::LineLook; -use super::outline::{c32, node_outline, to_screen_path, too_many_anchors}; +use super::outline::{c32, linked_crosses, node_outline, to_screen_path, too_many_marks}; use super::view::fit_zoom; use super::{ Affine, BezPath, CacheKey, Point, Rect, RulerScale, Sense, Stroke, StrokeKind, Tokens, Ui, VectorcraftApp, View, Xf, artboard_edges, backdrop, @@ -639,7 +639,7 @@ fn outline_shapes(st: &vectorcraft_engine::DocState, xf: &Xf) -> Vec Vec Vec Vec [bool; 4] { + let picture = picture(&ctx, 1.0, |p| paint(&mut SelectionMarks::default(), app, p, &view, false)); + let drawn = |q: Point| { + let s = view.to_screen(q); + (-1..=1).any(|dy| { + (-1..=1).any(|dx| { + let (x, y) = ((s.x.round() as i64 + dx) as usize, (s.y.round() as i64 + dy) as usize); + picture.pixels[y * picture.size.0 + x][3] > 0.0 + }) + }) + }; + let [tl, tr, br, bl] = corners; + assert!([(tl, tr), (tr, br), (br, bl), (bl, tl)].into_iter().all(|(a, b)| drawn(a.midpoint(b))), "the outline runs along the frame"); + [tl.lerp(br, 0.25), tl.lerp(br, 0.75), tr.lerp(bl, 0.25), tr.lerp(bl, 0.75)].map(drawn) + }; + let corners = |app: &VectorcraftApp, id: NodeId| { + let n = app.session.active().unwrap().doc.node(id).unwrap(); + match &n.kind { + NodeKind::PlacedDocument(p) => p.corners(), + _ => n.image_corners().unwrap(), + } + }; + app.run("select.all", json!({})).unwrap(); + assert_eq!(crossed(&app, corners(&app, linked)), [true; 4], "a linked image"); + assert_eq!(crossed(&app, corners(&app, document)), [true; 4], "a placed document"); + assert_eq!(crossed(&app, corners(&app, embedded)), [false; 4], "an embedded image"); + assert_matches_plain(&ctx, &mut SelectionMarks::default(), &app, &view, 1.0, "linked and embedded images"); + app.run("select.set", json!({"ids": [linked.0]})).unwrap(); + app.run("object.rotate", json!({"angle": 30})).unwrap(); + assert_eq!(crossed(&app, corners(&app, linked)), [true; 4], "a turned linked image, along its frame"); + let doc = &app.session.active().unwrap().doc; + let [tl, tr, br, bl] = corners(&app, linked); + let bounds = doc.node(linked).unwrap().geometric_bounds().unwrap(); + let out = vectorcraft_testkit::raster::render_region(doc, bounds, 1.0); + let pixel = |q: Point| out.pixel((q.x - bounds.x0).round() as u32, (q.y - bounds.y0).round() as u32); + // Halfway between the middle of the left side and the centre: clear of both diagonals. + let clear = pixel(tl.midpoint(bl).midpoint(tl.midpoint(br))); + assert!(clear[0] > 150 && clear[1] < 100 && clear[3] == 255, "the render shows the image: {clear:?}"); + let on_lines = [tl.lerp(br, 0.25), tl.lerp(br, 0.75), tr.lerp(bl, 0.25), tr.lerp(bl, 0.75)]; + assert!(on_lines.iter().all(|q| pixel(*q) == clear), "output of a selected linked image is not crossed"); +} + /// A frame of the whole canvas keeps entries for the selected objects only. #[test] fn the_canvas_drops_entries_it_does_not_draw() { diff --git a/crates/ui-egui/src/canvas/tests.rs b/crates/ui-egui/src/canvas/tests.rs index d5244aa234..d5238029d7 100644 --- a/crates/ui-egui/src/canvas/tests.rs +++ b/crates/ui-egui/src/canvas/tests.rs @@ -776,6 +776,32 @@ fn a_clip_group_over_a_huge_path_shows_its_clipping_path() { assert_eq!((anchors, hovered), (4, true), "the square's four anchors, and the hover highlight"); } +/// The selection marks count the ends of the lines that cross linked images toward the overlay's +/// limit; the hover highlight and the key object's outline, which draw no such lines, do not +/// (#9080). +#[test] +fn the_overlay_limit_counts_crossing_lines_only_where_they_are_drawn() { + use super::outline::{too_many_anchors, too_many_marks}; + let image = |link: Option| { + let im = vectorcraft_doc::ImageObject { + key: "k".into(), + width: 10, + height: 10, + xf: vectorcraft_geom::Affine::IDENTITY, + link, + placement: Default::default(), + pixels: None, + }; + vectorcraft_doc::Node::new(vectorcraft_doc::NodeId(1), NodeKind::Image(Box::new(im))) + }; + // Four corners each fit; with the four ends of the crossing lines they do not. + let count = OVERLAY_MAX_ANCHORS / 6; + let linked = vec![image(Some(vectorcraft_doc::LinkInfo { path: "/a.png".into(), ..Default::default() })); count]; + let embedded = vec![image(None); count]; + assert!(!too_many_anchors(&linked) && too_many_marks(&linked), "linked images"); + assert!(!too_many_anchors(&embedded) && !too_many_marks(&embedded), "embedded images"); +} + /// #2422: the art inside a clip group still shows its whole outline when it is picked on its /// own: by Edit Contents, by a Direct Selection or Group Selection click, and in isolation mode; /// so does its Group Selection hover highlight. diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 3da663c191..dd61b03ce9 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -661,6 +661,7 @@ since 2026-10-01. - **Selection — disconnected path deletion (#3380, deletion only):** Clear/Delete and Cut turn surviving disconnected pieces of an ordinary contour into independent selected sibling objects. The first keeps its ID; all keep appearance, baked transforms and stacking order. `deletion_split_preserves_gradient_placement` compares rendered survivors with the original paint space and checks linear/radial fill/stroke vectors, already placed gradients and atomic Undo/Redo; connected remainders keep automatic fitting. Existing multi-subpath paths and explicit compound members retain their semantics. Original synthetic regressions in `crates/engine/tests/it/delete_path_pieces.rs` cover styled/transformed rectangles, cubic handles, compound preservation and atomic Undo/Redo; `crates/ui-egui/src/tests/removeanchors.rs` covers real-frame Delete/Backspace and a second Delete removing all survivors. Segment endpoint highlighting remains open. Scores and hours unchanged. - **Selection: deletion on paths with many subpaths:** Clear/Delete, `path.deleteAnchors`, Copy, Cut and Cut Path read each subpath's selected anchors or segments directly from the path's ordered selection, instead of scanning every selected anchor or segment of the path once per subpath. The result is unchanged: `crates/engine/tests/it/delete_path_pieces.rs` checks exact surviving subpaths and their order, open and closed contours, an untouched subpath, references to missing subpaths and indexes, one Undo/Redo step and a second Delete, for anchor and segment selections on one path. Scores and hours unchanged. +- **Selection: linked images are crossed (#9080):** a selected linked image or placed document shows two lines in its layer's color from corner to corner of its frame, in the current pane and in other panes of the same document. A selected embedded image shows its outline alone. A selected or highlighted image of either kind is outlined along its frame, so a turned or distorted image's outline follows its corners instead of the box square to the page around it. The lines are part of the selection marks, so View › Hide Edges hides them and output does not draw them. `a_selected_linked_image_is_crossed_and_an_embedded_one_is_not` in `crates/ui-egui/src/canvas/selection_marks/tests.rs` covers a linked image, a turned one, a placed document, an embedded image and a render of the document; `other_panes_cross_a_selected_linked_image` in `crates/ui-egui/src/canvas/panes/tests.rs` covers another pane. Scores and hours unchanged. - **Panel collapse controls (#5925, in part):** The small » in a floating tab-group header moves that group into the side icon rail, reusing the existing rail or creating one. An opened rail panel has the same control to fold its flyout back into the rail, including after a tab switch. Both controls preserve the tab group and its menu; other floating groups and full-width docked headers stay as they were. Pointer regressions in `crates/ui-egui/src/panel_docking/tests.rs` cover grouped tabs, reopening, separate groups, a missing rail, the menu and flyout closure after switching tabs; `native_tests.rs` covers the native-window click and removal of the empty palette. Scores and estimates unchanged. - 3D lighting presets: `crates/effects/src/lighting_presets.rs`, `crates/engine/src/cmd/effectcmd/lighting_presets_tests.rs` and the pointer tests in `crates/ui-egui/src/dialogs/revolve/tests.rs` cover recognition, atomic targeting, native round trips, preview, Cancel, reset and Undo. From d4ca49b7c6bac597597a6f3b3b26dd25e5e89ace Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 22 Nov 2026 05:13:41 -0800 Subject: [PATCH 2/8] Tests: linked image crosses on distorted images, key, hover, Hide Edges The selection marks test now also checks a distorted linked image and a turned or distorted embedded image, the key object's outline alone and the hover highlight, each along the image's frame and without lines across it. A new test checks that the first canvas frame after View > Hide Edges draws nothing in the layer's color for a selected linked image. The render check comment uses American spelling. --- .../src/canvas/selection_marks/tests.rs | 70 +++++++++++++++---- crates/ui-egui/src/canvas/tests.rs | 41 +++++++++++ docs/target-app-parity.md | 2 +- 3 files changed, 97 insertions(+), 16 deletions(-) diff --git a/crates/ui-egui/src/canvas/selection_marks/tests.rs b/crates/ui-egui/src/canvas/selection_marks/tests.rs index a0ea0f7328..b0fcbc5658 100644 --- a/crates/ui-egui/src/canvas/selection_marks/tests.rs +++ b/crates/ui-egui/src/canvas/selection_marks/tests.rs @@ -586,8 +586,8 @@ fn an_edit_of_a_symbol_outlines_its_instance_again() { } /// A selected linked image and a selected placed document are crossed from corner to corner, on a -/// turned image along its frame; a selected embedded image shows its outline alone, and output of -/// the linked image shows no cross (#9080). +/// turned or distorted image along its frame; a selected embedded image shows its outline alone, +/// along its frame when turned or distorted. A render of the document is not crossed (#9080). #[test] fn a_selected_linked_image_is_crossed_and_an_embedded_one_is_not() { use craft_image_codecs::{ChannelLayout, EncodeOptions, Format, Image, SampleType}; @@ -608,10 +608,9 @@ fn a_selected_linked_image_is_crossed_and_an_embedded_one_is_not() { let document = place(&mut app, &placed, true, [200.0, 230.0]); let ctx = egui::Context::default(); let view = xf(1.0, VIEW, 0.0); - // Whether the marks draw within a pixel of each of the points a quarter and three quarters of + // Whether `picture` draws within a pixel of each of the points a quarter and three quarters of // the way along each diagonal of `corners`, clear of the outline. - let crossed = |app: &VectorcraftApp, corners: [Point; 4]| -> [bool; 4] { - let picture = picture(&ctx, 1.0, |p| paint(&mut SelectionMarks::default(), app, p, &view, false)); + let crossed_in = |picture: &Picture, corners: [Point; 4]| -> [bool; 4] { let drawn = |q: Point| { let s = view.to_screen(q); (-1..=1).any(|dy| { @@ -625,6 +624,10 @@ fn a_selected_linked_image_is_crossed_and_an_embedded_one_is_not() { assert!([(tl, tr), (tr, br), (br, bl), (bl, tl)].into_iter().all(|(a, b)| drawn(a.midpoint(b))), "the outline runs along the frame"); [tl.lerp(br, 0.25), tl.lerp(br, 0.75), tr.lerp(bl, 0.25), tr.lerp(bl, 0.75)].map(drawn) }; + // The same for the selection marks. + let crossed = |app: &VectorcraftApp, corners: [Point; 4]| { + crossed_in(&picture(&ctx, 1.0, |p| paint(&mut SelectionMarks::default(), app, p, &view, false)), corners) + }; let corners = |app: &VectorcraftApp, id: NodeId| { let n = app.session.active().unwrap().doc.node(id).unwrap(); match &n.kind { @@ -637,19 +640,56 @@ fn a_selected_linked_image_is_crossed_and_an_embedded_one_is_not() { assert_eq!(crossed(&app, corners(&app, document)), [true; 4], "a placed document"); assert_eq!(crossed(&app, corners(&app, embedded)), [false; 4], "an embedded image"); assert_matches_plain(&ctx, &mut SelectionMarks::default(), &app, &view, 1.0, "linked and embedded images"); - app.run("select.set", json!({"ids": [linked.0]})).unwrap(); + app.run("select.set", json!({"ids": [linked.0, embedded.0]})).unwrap(); app.run("object.rotate", json!({"angle": 30})).unwrap(); assert_eq!(crossed(&app, corners(&app, linked)), [true; 4], "a turned linked image, along its frame"); + assert_eq!(crossed(&app, corners(&app, embedded)), [false; 4], "a turned embedded image, outlined along its frame"); + { + let doc = &app.session.active().unwrap().doc; + let [tl, tr, br, bl] = corners(&app, linked); + let bounds = doc.node(linked).unwrap().geometric_bounds().unwrap(); + let out = vectorcraft_testkit::raster::render_region(doc, bounds, 1.0); + let pixel = |q: Point| out.pixel((q.x - bounds.x0).round() as u32, (q.y - bounds.y0).round() as u32); + // Halfway between the middle of the left side and the center: clear of both diagonals. + let clear = pixel(tl.midpoint(bl).midpoint(tl.midpoint(br))); + assert!(clear[0] > 150 && clear[1] < 100 && clear[3] == 255, "the render shows the image: {clear:?}"); + let on_lines = [tl.lerp(br, 0.25), tl.lerp(br, 0.75), tr.lerp(bl, 0.25), tr.lerp(bl, 0.75)]; + assert!(on_lines.iter().all(|q| pixel(*q) == clear), "output of a selected linked image is not crossed"); + } + // Move each image's bottom right corner up its right side, so its corners no longer make a + // parallelogram and one diagonal turns away from where it ran. + app.session + .edit("Distort", |doc, _| { + for id in [linked, embedded] { + if let Some(n) = doc.node_mut(id) + && let Some([tl, tr, br, bl]) = n.image_corners() + { + n.set_image_corners([tl, tr, br.lerp(tr, 0.4), bl]).map_err(|e| vectorcraft_engine::EngineError::Other(format!("{e:?}")))?; + } + } + Ok(()) + }) + .unwrap(); let doc = &app.session.active().unwrap().doc; - let [tl, tr, br, bl] = corners(&app, linked); - let bounds = doc.node(linked).unwrap().geometric_bounds().unwrap(); - let out = vectorcraft_testkit::raster::render_region(doc, bounds, 1.0); - let pixel = |q: Point| out.pixel((q.x - bounds.x0).round() as u32, (q.y - bounds.y0).round() as u32); - // Halfway between the middle of the left side and the centre: clear of both diagonals. - let clear = pixel(tl.midpoint(bl).midpoint(tl.midpoint(br))); - assert!(clear[0] > 150 && clear[1] < 100 && clear[3] == 255, "the render shows the image: {clear:?}"); - let on_lines = [tl.lerp(br, 0.25), tl.lerp(br, 0.75), tr.lerp(bl, 0.25), tr.lerp(bl, 0.75)]; - assert!(on_lines.iter().all(|q| pixel(*q) == clear), "output of a selected linked image is not crossed"); + assert!([linked, embedded].iter().all(|id| doc.node(*id).unwrap().is_distorted_image()), "both images are distorted"); + assert_eq!(crossed(&app, corners(&app, linked)), [true; 4], "a distorted linked image, corner to corner"); + assert_eq!(crossed(&app, corners(&app, embedded)), [false; 4], "a distorted embedded image, outlined along its frame"); + // The key object's outline alone, with no other selection marks. + for id in [linked, embedded] { + let st = app.session.active_mut().unwrap(); + st.selection.objects.clear(); + st.selection.key = Some(id); + let key = picture(&ctx, 1.0, |p| paint(&mut SelectionMarks::default(), &app, p, &view, false)); + assert_eq!(crossed_in(&key, corners(&app, id)), [false; 4], "the key object's outline of a distorted image, {id:?}"); + } + // The hover highlight outlines a linked image along its frame and does not cross it. + app.run("select.set", json!({"ids": []})).unwrap(); + for id in [linked, embedded] { + let [tl, tr, br, bl] = corners(&app, id); + app.hover_doc = Some(tl.midpoint(tr).midpoint(bl.midpoint(br))); + let hovered = picture(&ctx, 1.0, |p| super::super::overlays::hover_highlight(&app, p, &view)); + assert_eq!(crossed_in(&hovered, [tl, tr, br, bl]), [false; 4], "the hover highlight of a distorted image, {id:?}"); + } } /// A frame of the whole canvas keeps entries for the selected objects only. diff --git a/crates/ui-egui/src/canvas/tests.rs b/crates/ui-egui/src/canvas/tests.rs index d5238029d7..e80d331bdb 100644 --- a/crates/ui-egui/src/canvas/tests.rs +++ b/crates/ui-egui/src/canvas/tests.rs @@ -802,6 +802,47 @@ fn the_overlay_limit_counts_crossing_lines_only_where_they_are_drawn() { assert!(!too_many_anchors(&embedded) && !too_many_marks(&embedded), "embedded images"); } +/// View › Hide Edges hides the lines across a selected linked image along with its outline +/// (#9080). +#[test] +fn hide_edges_hides_the_lines_across_a_linked_image() { + use craft_image_codecs::{ChannelLayout, EncodeOptions, Format, Image, SampleType}; + let dir = vectorcraft_testkit::temp_dir("hide-edges-linked"); + let png = dir.join("red.png"); + let image = Image::from_raw(40, 40, ChannelLayout::Rgba, SampleType::U8, [200u8, 40, 40, 255].repeat(40 * 40)).unwrap(); + std::fs::write(&png, craft_image_codecs::encode(&image, Format::Png, &EncodeOptions::default()).unwrap()).unwrap(); + let mut app = VectorcraftApp::new(Session::new(), Default::default()); + app.run("file.new", json!({"width": 400, "height": 300})).unwrap(); + let mut place = + |link: bool, at: [f64; 2]| app.run("file.place", json!({"path": png, "link": link, "at": at})).unwrap()["ids"][0].as_u64().unwrap(); + let (linked, embedded) = (place(true, [100.0, 120.0]), place(false, [250.0, 120.0])); + let ctx = egui::Context::default(); + let select = |app: &mut VectorcraftApp, id: u64| { + app.run("select.set", json!({"ids": [id]})).unwrap(); + frame(app, &ctx, vec![]); + }; + // The vertices the next canvas frame draws in the layer color of `id`. + let marks = |app: &mut VectorcraftApp, id: u64| { + let raw = egui::RawInput { screen_rect: Some(egui::Rect::from_min_size(Pos2::ZERO, vec2(800.0, 600.0))), ..Default::default() }; + let mut out = ctx.run_ui(raw, |ui| show(app, ui)); + out.textures_delta.clear(); + let color = c32(app.session.active().unwrap().doc.layer_color(vectorcraft_doc::NodeId(id))); + let mesh = |p: &egui::ClippedPrimitive| match &p.primitive { + egui::epaint::Primitive::Mesh(m) => m.vertices.iter().filter(|v| v.color == color).count(), + egui::epaint::Primitive::Callback(_) => 0, + }; + ctx.tessellate(out.shapes, out.pixels_per_point).iter().map(mesh).sum::() + }; + select(&mut app, embedded); + let shown_embedded = marks(&mut app, embedded); + select(&mut app, linked); + let shown_linked = marks(&mut app, linked); + assert!(shown_linked > shown_embedded, "the lines across the linked image draw: {shown_linked} > {shown_embedded}"); + // The linked image stays selected, and the first frame after edges are hidden is checked. + app.ui.view.edges = false; + assert_eq!(marks(&mut app, linked), 0, "with edges hidden, a selected linked image draws nothing in its layer's color"); +} + /// #2422: the art inside a clip group still shows its whole outline when it is picked on its /// own: by Edit Contents, by a Direct Selection or Group Selection click, and in isolation mode; /// so does its Group Selection hover highlight. diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index dd61b03ce9..d15f17cd5c 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -661,7 +661,7 @@ since 2026-10-01. - **Selection — disconnected path deletion (#3380, deletion only):** Clear/Delete and Cut turn surviving disconnected pieces of an ordinary contour into independent selected sibling objects. The first keeps its ID; all keep appearance, baked transforms and stacking order. `deletion_split_preserves_gradient_placement` compares rendered survivors with the original paint space and checks linear/radial fill/stroke vectors, already placed gradients and atomic Undo/Redo; connected remainders keep automatic fitting. Existing multi-subpath paths and explicit compound members retain their semantics. Original synthetic regressions in `crates/engine/tests/it/delete_path_pieces.rs` cover styled/transformed rectangles, cubic handles, compound preservation and atomic Undo/Redo; `crates/ui-egui/src/tests/removeanchors.rs` covers real-frame Delete/Backspace and a second Delete removing all survivors. Segment endpoint highlighting remains open. Scores and hours unchanged. - **Selection: deletion on paths with many subpaths:** Clear/Delete, `path.deleteAnchors`, Copy, Cut and Cut Path read each subpath's selected anchors or segments directly from the path's ordered selection, instead of scanning every selected anchor or segment of the path once per subpath. The result is unchanged: `crates/engine/tests/it/delete_path_pieces.rs` checks exact surviving subpaths and their order, open and closed contours, an untouched subpath, references to missing subpaths and indexes, one Undo/Redo step and a second Delete, for anchor and segment selections on one path. Scores and hours unchanged. -- **Selection: linked images are crossed (#9080):** a selected linked image or placed document shows two lines in its layer's color from corner to corner of its frame, in the current pane and in other panes of the same document. A selected embedded image shows its outline alone. A selected or highlighted image of either kind is outlined along its frame, so a turned or distorted image's outline follows its corners instead of the box square to the page around it. The lines are part of the selection marks, so View › Hide Edges hides them and output does not draw them. `a_selected_linked_image_is_crossed_and_an_embedded_one_is_not` in `crates/ui-egui/src/canvas/selection_marks/tests.rs` covers a linked image, a turned one, a placed document, an embedded image and a render of the document; `other_panes_cross_a_selected_linked_image` in `crates/ui-egui/src/canvas/panes/tests.rs` covers another pane. Scores and hours unchanged. +- **Selection: linked images are crossed (#9080):** a selected linked image or placed document shows two lines in its layer's color from corner to corner of its frame, in the current pane and in other panes of the same document. A selected embedded image shows its outline alone. A selected or highlighted image of either kind is outlined along its frame, so a turned or distorted image's outline follows its corners instead of the box square to the page around it. The lines are part of the selection marks, so View › Hide Edges hides them and output does not draw them. `a_selected_linked_image_is_crossed_and_an_embedded_one_is_not` in `crates/ui-egui/src/canvas/selection_marks/tests.rs` covers a linked image, a placed document and an embedded image, each image also turned and distorted, the key object's outline, the hover highlight and a render of the document; `other_panes_cross_a_selected_linked_image` in `crates/ui-egui/src/canvas/panes/tests.rs` covers another pane; `hide_edges_hides_the_lines_across_a_linked_image` in `crates/ui-egui/src/canvas/tests.rs` covers View › Hide Edges. Scores and hours unchanged. - **Panel collapse controls (#5925, in part):** The small » in a floating tab-group header moves that group into the side icon rail, reusing the existing rail or creating one. An opened rail panel has the same control to fold its flyout back into the rail, including after a tab switch. Both controls preserve the tab group and its menu; other floating groups and full-width docked headers stay as they were. Pointer regressions in `crates/ui-egui/src/panel_docking/tests.rs` cover grouped tabs, reopening, separate groups, a missing rail, the menu and flyout closure after switching tabs; `native_tests.rs` covers the native-window click and removal of the empty palette. Scores and estimates unchanged. - 3D lighting presets: `crates/effects/src/lighting_presets.rs`, `crates/engine/src/cmd/effectcmd/lighting_presets_tests.rs` and the pointer tests in `crates/ui-egui/src/dialogs/revolve/tests.rs` cover recognition, atomic targeting, native round trips, preview, Cancel, reset and Undo. From e79aa9836a7d86657ed6d66a05b5ad449fde71ea Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 22 Nov 2026 05:45:22 -0800 Subject: [PATCH 3/8] Docs: linked image crosses above the outline point limit The progress-doc entry now says that above the 100,000-point overlay limit, counting 4 points for each linked image's or placed document's lines, both the current pane and other panes draw one rectangle around the selection instead of outlines and crossing lines. --- docs/target-app-parity.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index d15f17cd5c..d6006c9e7e 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -661,7 +661,7 @@ since 2026-10-01. - **Selection — disconnected path deletion (#3380, deletion only):** Clear/Delete and Cut turn surviving disconnected pieces of an ordinary contour into independent selected sibling objects. The first keeps its ID; all keep appearance, baked transforms and stacking order. `deletion_split_preserves_gradient_placement` compares rendered survivors with the original paint space and checks linear/radial fill/stroke vectors, already placed gradients and atomic Undo/Redo; connected remainders keep automatic fitting. Existing multi-subpath paths and explicit compound members retain their semantics. Original synthetic regressions in `crates/engine/tests/it/delete_path_pieces.rs` cover styled/transformed rectangles, cubic handles, compound preservation and atomic Undo/Redo; `crates/ui-egui/src/tests/removeanchors.rs` covers real-frame Delete/Backspace and a second Delete removing all survivors. Segment endpoint highlighting remains open. Scores and hours unchanged. - **Selection: deletion on paths with many subpaths:** Clear/Delete, `path.deleteAnchors`, Copy, Cut and Cut Path read each subpath's selected anchors or segments directly from the path's ordered selection, instead of scanning every selected anchor or segment of the path once per subpath. The result is unchanged: `crates/engine/tests/it/delete_path_pieces.rs` checks exact surviving subpaths and their order, open and closed contours, an untouched subpath, references to missing subpaths and indexes, one Undo/Redo step and a second Delete, for anchor and segment selections on one path. Scores and hours unchanged. -- **Selection: linked images are crossed (#9080):** a selected linked image or placed document shows two lines in its layer's color from corner to corner of its frame, in the current pane and in other panes of the same document. A selected embedded image shows its outline alone. A selected or highlighted image of either kind is outlined along its frame, so a turned or distorted image's outline follows its corners instead of the box square to the page around it. The lines are part of the selection marks, so View › Hide Edges hides them and output does not draw them. `a_selected_linked_image_is_crossed_and_an_embedded_one_is_not` in `crates/ui-egui/src/canvas/selection_marks/tests.rs` covers a linked image, a placed document and an embedded image, each image also turned and distorted, the key object's outline, the hover highlight and a render of the document; `other_panes_cross_a_selected_linked_image` in `crates/ui-egui/src/canvas/panes/tests.rs` covers another pane; `hide_edges_hides_the_lines_across_a_linked_image` in `crates/ui-egui/src/canvas/tests.rs` covers View › Hide Edges. Scores and hours unchanged. +- **Selection: linked images are crossed (#9080):** a selected linked image or placed document shows two lines in its layer's color from corner to corner of its frame, in the current pane and in other panes of the same document. A selected embedded image shows its outline alone. A selected or highlighted image of either kind is outlined along its frame, so a turned or distorted image's outline follows its corners instead of the box square to the page around it. The lines are part of the selection marks, so View › Hide Edges hides them and output does not draw them. When the selection has more than VectorCraft's own limit of 100,000 outline points (each linked image or placed document adds 4 for the ends of its lines), the current pane and other panes draw one rectangle around the selected objects instead of their outlines and lines; the current pane still draws the key object's thicker outline. `a_selected_linked_image_is_crossed_and_an_embedded_one_is_not` in `crates/ui-egui/src/canvas/selection_marks/tests.rs` covers a linked image, a placed document and an embedded image, each image also turned and distorted, the key object's outline, the hover highlight and a render of the document; `other_panes_cross_a_selected_linked_image` in `crates/ui-egui/src/canvas/panes/tests.rs` covers another pane; `hide_edges_hides_the_lines_across_a_linked_image` in `crates/ui-egui/src/canvas/tests.rs` covers View › Hide Edges. Scores and hours unchanged. - **Panel collapse controls (#5925, in part):** The small » in a floating tab-group header moves that group into the side icon rail, reusing the existing rail or creating one. An opened rail panel has the same control to fold its flyout back into the rail, including after a tab switch. Both controls preserve the tab group and its menu; other floating groups and full-width docked headers stay as they were. Pointer regressions in `crates/ui-egui/src/panel_docking/tests.rs` cover grouped tabs, reopening, separate groups, a missing rail, the menu and flyout closure after switching tabs; `native_tests.rs` covers the native-window click and removal of the empty palette. Scores and estimates unchanged. - 3D lighting presets: `crates/effects/src/lighting_presets.rs`, `crates/engine/src/cmd/effectcmd/lighting_presets_tests.rs` and the pointer tests in `crates/ui-egui/src/dialogs/revolve/tests.rs` cover recognition, atomic targeting, native round trips, preview, Cancel, reset and Undo. From 4f6e1515b46f52a71b7e2b79fe1b709bf2e0ebef Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 22 Nov 2026 17:16:18 -0800 Subject: [PATCH 4/8] Selection: a selected group leaves its hidden members unmarked The selection marks walked every member of a selected group or layer, so a hidden member, and the art inside a hidden group or a hidden sublayer, showed its outline, its anchors and the lines across a linked image, although the canvas does not draw hidden objects. The walk now skips hidden members, so the selection marks, the hover highlight and the outlines in other panes leave them out, and the overlay point limit no longer counts their points. The same holds for the members of a blend, a repeat and an intertwine. A compound path keeps every path, since it draws all of them, and an Image Trace object keeps its hidden source image in the views that show it. A hidden object that is itself selected keeps its marks. --- crates/doc/src/node/ops.rs | 3 +- crates/ui-egui/src/canvas/outline.rs | 24 +++++- .../src/canvas/selection_marks/tests.rs | 64 ++++++++++++++ crates/ui-egui/src/canvas/tests.rs | 84 ++++++++++++++++++- docs/target-app-parity.md | 1 + 5 files changed, 170 insertions(+), 6 deletions(-) diff --git a/crates/doc/src/node/ops.rs b/crates/doc/src/node/ops.rs index 20dae6ec4b..42bece8844 100644 --- a/crates/doc/src/node/ops.rs +++ b/crates/doc/src/node/ops.rs @@ -361,7 +361,8 @@ impl Node { } /// Children that contribute to a container's editing bounds and selection highlights. A live trace retains a - /// hidden bitmap for re-tracing/release; only source-image views measure that bitmap. + /// hidden bitmap for re-tracing/release; only source-image views measure that bitmap. The canvas's selection + /// highlights also leave out hidden members, except a compound path's paths. pub fn editing_children(&self) -> &[Arc] { let children = self.children().map(Vec::as_slice).unwrap_or_default(); let trace_source = self.extras().trace.is_some() diff --git a/crates/ui-egui/src/canvas/outline.rs b/crates/ui-egui/src/canvas/outline.rs index 33e9553c2c..fbb2241f3d 100644 --- a/crates/ui-egui/src/canvas/outline.rs +++ b/crates/ui-egui/src/canvas/outline.rs @@ -1,3 +1,5 @@ +use std::sync::Arc; + use super::{BezPath, Color32, Node, NodeKind, PathEl, Point, Pos2, Shape, Stroke, SymbolBoxes, VectorcraftApp, Xf, pos2}; pub(super) fn to_screen_path(bp: &BezPath, xf: &Xf) -> Vec> { @@ -163,7 +165,7 @@ fn over_limit<'a>(nodes: impl IntoIterator, crosses: bool) -> b if n.clips() { return n.children().and_then(|children| children.first()).is_some_and(|clip| over(clip, left, crosses)); } - !matches!(n.kind, NodeKind::Envelope { .. }) && n.editing_children().iter().any(|c| over(c, left, crosses)) + !matches!(n.kind, NodeKind::Envelope { .. }) && drawn_children(n).any(|c| over(c, left, crosses)) } let mut left = OVERLAY_MAX_ANCHORS; nodes.into_iter().any(|n| over(n, &mut left, crosses)) @@ -193,9 +195,23 @@ fn overlay_points(n: &Node) -> usize { } } +/// The children of `n` that [`walk_drawn`] visits: [`Node::editing_children`], without the hidden +/// members, which the canvas does not draw. An Image Trace object's hidden source image stays when +/// the object's view shows it. Every path of a compound path stays, since the compound path draws +/// all of them. +fn drawn_children(n: &Node) -> impl Iterator> { + let members = !matches!(n.kind, NodeKind::Compound { .. }); + let source = (n.extras().trace.is_some() && n.trace_view().shows_source()) + .then(|| n.children().and_then(|children| children.first())) + .flatten() + .filter(|c| matches!(c.kind, NodeKind::Image(_))); + n.editing_children().iter().filter(move |c| !members || c.visible || source.is_some_and(|s| Arc::ptr_eq(s, c))) +} + /// [`Node::walk`] over what a selection highlight shows: an envelope's content is left out (the -/// envelope shows its mesh instead), and a clip group or clipping layer shows only its clipping -/// path, its first child, not the art the path clips (#2422). +/// envelope shows its mesh instead), a clip group or clipping layer shows only its clipping path, +/// its first child, not the art the path clips (#2422), and hidden members are left out +/// ([`drawn_children`]). pub(super) fn walk_drawn<'a>(n: &'a Node, f: &mut impl FnMut(&'a Node)) { f(n); if matches!(n.kind, NodeKind::Envelope { .. }) { @@ -207,7 +223,7 @@ pub(super) fn walk_drawn<'a>(n: &'a Node, f: &mut impl FnMut(&'a Node)) { } return; } - for c in n.editing_children().iter() { + for c in drawn_children(n) { walk_drawn(c, f); } } diff --git a/crates/ui-egui/src/canvas/selection_marks/tests.rs b/crates/ui-egui/src/canvas/selection_marks/tests.rs index b0fcbc5658..32459a5825 100644 --- a/crates/ui-egui/src/canvas/selection_marks/tests.rs +++ b/crates/ui-egui/src/canvas/selection_marks/tests.rs @@ -692,6 +692,70 @@ fn a_selected_linked_image_is_crossed_and_an_embedded_one_is_not() { } } +/// A selected group outlines, marks and crosses only the members the canvas draws: a hidden member +/// and the members of a hidden group inside it leave no outline, anchors or crossing lines. +#[test] +fn a_selected_group_leaves_its_hidden_members_unmarked() { + use craft_image_codecs::{ChannelLayout, EncodeOptions, Format, Image, SampleType}; + let dir = vectorcraft_testkit::temp_dir("selection-marks-hidden"); + let png = dir.join("red.png"); + let pixels = [200u8, 40, 40, 255].repeat(40 * 40); + let image = Image::from_raw(40, 40, ChannelLayout::Rgba, SampleType::U8, pixels).unwrap(); + std::fs::write(&png, craft_image_codecs::encode(&image, Format::Png, &EncodeOptions::default()).unwrap()).unwrap(); + let mut app = VectorcraftApp::new(Session::new(), Default::default()); + app.run("file.new", json!({"width": 400, "height": 300})).unwrap(); + let left = id_of(&app.run("shape.rectangle", json!({"x": 40, "y": 40, "width": 20, "height": 20})).unwrap()); + let right = id_of(&app.run("shape.rectangle", json!({"x": 330, "y": 230, "width": 20, "height": 20})).unwrap()); + let hidden = id_of(&app.run("shape.rectangle", json!({"x": 120, "y": 100, "width": 40, "height": 40})).unwrap()); + let linked = NodeId(app.run("file.place", json!({"path": png, "link": true, "at": [240.0, 150.0]})).unwrap()["ids"][0].as_u64().unwrap()); + app.run("select.set", json!({"ids": [linked.0]})).unwrap(); + let inner = id_of(&app.run("object.group", json!({})).unwrap()); + app.run("select.set", json!({"ids": [left.0, right.0, hidden.0, inner.0]})).unwrap(); + let group = id_of(&app.run("object.group", json!({})).unwrap()); + app.session + .edit("Hide", |doc, _| { + for id in [hidden, inner] { + if let Some(n) = doc.node_mut(id) { + n.visible = false; + } + } + Ok(()) + }) + .unwrap(); + app.run("select.set", json!({"ids": [group.0]})).unwrap(); + let ctx = egui::Context::default(); + let view = xf(1.0, VIEW, 0.0); + let marks = picture(&ctx, 1.0, |p| paint(&mut SelectionMarks::default(), &app, p, &view, false)); + // Whether the marks draw within a pixel of document point `q`. + let drawn = |q: Point| { + let s = view.to_screen(q); + (-1..=1).any(|dy| { + (-1..=1).any(|dx| { + let (x, y) = ((s.x.round() as i64 + dx) as usize, (s.y.round() as i64 + dy) as usize); + marks.pixels[y * marks.size.0 + x][3] > 0.0 + }) + }) + }; + let doc = &app.session.active().unwrap().doc; + let sides = |id: NodeId| { + let b = doc.node(id).unwrap().geometric_bounds().unwrap(); + [Point::new(b.x0, b.y0), Point::new(b.x1, b.y0), Point::new(b.x1, b.y1), Point::new(b.x0, b.y1)] + }; + for id in [left, right] { + let [tl, tr, br, bl] = sides(id); + assert!([tl, tr, br, bl, tl.midpoint(tr), br.midpoint(bl)].into_iter().all(drawn), "a visible member is outlined and marked"); + } + let [tl, tr, br, bl] = doc.node(linked).unwrap().image_corners().unwrap(); + assert!( + ![tl.lerp(br, 0.25), tl.lerp(br, 0.75), tr.lerp(bl, 0.25), tr.lerp(bl, 0.75)].into_iter().any(drawn), + "the lines across a linked image in a hidden group" + ); + assert!(![tl.midpoint(tr), tr.midpoint(br)].into_iter().any(drawn), "the outline of a linked image in a hidden group"); + let [tl, tr, br, bl] = sides(hidden); + assert!(![tl, tr, br, bl, tl.midpoint(tr), tr.midpoint(br), br.midpoint(bl), bl.midpoint(tl)].into_iter().any(drawn), "a hidden member"); + assert_matches_plain(&ctx, &mut SelectionMarks::default(), &app, &view, 1.0, "a group with hidden members"); +} + /// A frame of the whole canvas keeps entries for the selected objects only. #[test] fn the_canvas_drops_entries_it_does_not_draw() { diff --git a/crates/ui-egui/src/canvas/tests.rs b/crates/ui-egui/src/canvas/tests.rs index e80d331bdb..af4281cbbb 100644 --- a/crates/ui-egui/src/canvas/tests.rs +++ b/crates/ui-egui/src/canvas/tests.rs @@ -802,6 +802,41 @@ fn the_overlay_limit_counts_crossing_lines_only_where_they_are_drawn() { assert!(!too_many_anchors(&embedded) && !too_many_marks(&embedded), "embedded images"); } +/// The overlay's limit counts the points of the members the highlight outlines: a hidden member of +/// a group, and the art of a hidden sublayer, do not count toward it. +#[test] +fn the_overlay_limit_leaves_out_hidden_members() { + use super::outline::{too_many_anchors, too_many_marks}; + use std::sync::Arc; + use vectorcraft_doc::{Appearance, LayerColor, NodeId}; + use vectorcraft_geom::{PathData, SubPath}; + let points: Vec = (0..=OVERLAY_MAX_ANCHORS).map(|i| Point::new(i as f64, 0.0)).collect(); + let many = Arc::new(Node::path(NodeId(2), PathData::single(SubPath::polyline(&points, false)), Appearance::default())); + let few = Arc::new(Node::path( + NodeId(3), + vectorcraft_geom::shapes::rectangle(vectorcraft_geom::Rect::new(0.0, 0.0, 10.0, 10.0)), + Appearance::default(), + )); + for visible in [true, false] { + let mut member = (*many).clone(); + member.visible = visible; + let group = Node::group(NodeId(1), vec![Arc::new(member), few.clone()]); + let mut sublayer = Node::layer(NodeId(5), "Sublayer", LayerColor::Preset(1)); + sublayer.visible = visible; + if let Some(children) = sublayer.children_mut() { + children.push(many.clone()); + } + let mut layer = Node::layer(NodeId(4), "Layer", LayerColor::Preset(0)); + if let Some(children) = layer.children_mut() { + children.extend([Arc::new(sublayer), few.clone()]); + } + for (n, what) in [(&group, "a group"), (&layer, "a layer")] { + assert_eq!(too_many_anchors([n]), visible, "{what}, member visible: {visible}"); + assert_eq!(too_many_marks([n]), visible, "{what}, member visible: {visible}"); + } + } +} + /// View › Hide Edges hides the lines across a selected linked image along with its outline /// (#9080). #[test] @@ -13466,8 +13501,55 @@ fn live_trace_selection_highlight_excludes_the_retained_source_rectangle() { }; assert_eq!(node_outline(&group, &symbols).bounding_box(), want); } + // Without a trace the image is an ordinary hidden member, which the canvas does not draw. group.extras_mut().trace = None; - assert_eq!(node_outline(&group, &symbols).bounding_box(), vectorcraft_geom::Rect::new(0.0, 0.0, 200.0, 200.0)); + assert_eq!(node_outline(&group, &symbols).bounding_box(), vectorcraft_geom::Rect::new(20.0, 30.0, 80.0, 90.0)); + // A hidden path sent to the back of a trace is not its source image, in any view. + let mut path = + Node::path(NodeId(4), vectorcraft_geom::shapes::rectangle(vectorcraft_geom::Rect::new(0.0, 0.0, 200.0, 200.0)), Appearance::default()); + path.visible = false; + let art = Node::path(NodeId(3), vectorcraft_geom::shapes::rectangle(vectorcraft_geom::Rect::new(20.0, 30.0, 80.0, 90.0)), Appearance::default()); + let mut group = Node::group(NodeId(1), vec![Arc::new(path), Arc::new(art)]); + for view in TraceView::ALL { + group.extras_mut().trace = Some(Box::new(json!({"view":view.id()}))); + assert_eq!(node_outline(&group, &symbols).bounding_box(), vectorcraft_geom::Rect::new(20.0, 30.0, 80.0, 90.0), "{view:?}"); + } +} + +/// A compound path draws every path it holds, hidden ones included, so its highlight outlines them +/// all; a group, a blend, an intertwine and a layer leave out a hidden member, and a layer the art +/// of a hidden sublayer. +#[test] +fn a_compound_path_outlines_its_hidden_paths_and_a_group_does_not() { + use std::sync::Arc; + use vectorcraft_doc::{Appearance, LayerColor, NodeId}; + use vectorcraft_geom::FillRule; + let rect = |id: u64, r: vectorcraft_geom::Rect, visible: bool| { + let mut n = Node::path(NodeId(id), vectorcraft_geom::shapes::rectangle(r), Appearance::default()); + n.visible = visible; + Arc::new(n) + }; + let children = || { + vec![rect(2, vectorcraft_geom::Rect::new(0.0, 0.0, 100.0, 100.0), true), rect(3, vectorcraft_geom::Rect::new(30.0, 30.0, 70.0, 70.0), false)] + }; + let doc = vectorcraft_doc::Document::new(300.0, 300.0); + let symbols = doc.symbol_boxes(); + let contours = |n: &Node| node_outline(n, &symbols).elements().iter().filter(|e| matches!(e, PathEl::MoveTo(_))).count(); + assert_eq!(contours(&Node::new(NodeId(1), NodeKind::Compound { children: children(), rule: FillRule::EvenOdd })), 2, "a compound path"); + assert_eq!(contours(&Node::new(NodeId(1), NodeKind::Blend { children: children(), spec: Default::default() })), 1, "a blend"); + assert_eq!(contours(&Node::group(NodeId(1), children())), 1, "a group"); + assert_eq!(contours(&Node::new(NodeId(1), NodeKind::Intertwine { children: children() })), 1, "an intertwine"); + let mut layer = Node::layer(NodeId(1), "Layer", LayerColor::Preset(0)); + let mut sublayer = Node::layer(NodeId(4), "Sublayer", LayerColor::Preset(1)); + sublayer.visible = false; + if let Some(c) = sublayer.children_mut() { + c.push(rect(5, vectorcraft_geom::Rect::new(150.0, 150.0, 200.0, 200.0), true)); + } + if let Some(c) = layer.children_mut() { + c.extend(children()); + c.push(Arc::new(sublayer)); + } + assert_eq!(contours(&layer), 1, "a layer"); } /// Hovering over point type shows only its baseline (not the transform bounding box), while diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index d6006c9e7e..446f395823 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -662,6 +662,7 @@ since 2026-10-01. - **Selection — disconnected path deletion (#3380, deletion only):** Clear/Delete and Cut turn surviving disconnected pieces of an ordinary contour into independent selected sibling objects. The first keeps its ID; all keep appearance, baked transforms and stacking order. `deletion_split_preserves_gradient_placement` compares rendered survivors with the original paint space and checks linear/radial fill/stroke vectors, already placed gradients and atomic Undo/Redo; connected remainders keep automatic fitting. Existing multi-subpath paths and explicit compound members retain their semantics. Original synthetic regressions in `crates/engine/tests/it/delete_path_pieces.rs` cover styled/transformed rectangles, cubic handles, compound preservation and atomic Undo/Redo; `crates/ui-egui/src/tests/removeanchors.rs` covers real-frame Delete/Backspace and a second Delete removing all survivors. Segment endpoint highlighting remains open. Scores and hours unchanged. - **Selection: deletion on paths with many subpaths:** Clear/Delete, `path.deleteAnchors`, Copy, Cut and Cut Path read each subpath's selected anchors or segments directly from the path's ordered selection, instead of scanning every selected anchor or segment of the path once per subpath. The result is unchanged: `crates/engine/tests/it/delete_path_pieces.rs` checks exact surviving subpaths and their order, open and closed contours, an untouched subpath, references to missing subpaths and indexes, one Undo/Redo step and a second Delete, for anchor and segment selections on one path. Scores and hours unchanged. - **Selection: linked images are crossed (#9080):** a selected linked image or placed document shows two lines in its layer's color from corner to corner of its frame, in the current pane and in other panes of the same document. A selected embedded image shows its outline alone. A selected or highlighted image of either kind is outlined along its frame, so a turned or distorted image's outline follows its corners instead of the box square to the page around it. The lines are part of the selection marks, so View › Hide Edges hides them and output does not draw them. When the selection has more than VectorCraft's own limit of 100,000 outline points (each linked image or placed document adds 4 for the ends of its lines), the current pane and other panes draw one rectangle around the selected objects instead of their outlines and lines; the current pane still draws the key object's thicker outline. `a_selected_linked_image_is_crossed_and_an_embedded_one_is_not` in `crates/ui-egui/src/canvas/selection_marks/tests.rs` covers a linked image, a placed document and an embedded image, each image also turned and distorted, the key object's outline, the hover highlight and a render of the document; `other_panes_cross_a_selected_linked_image` in `crates/ui-egui/src/canvas/panes/tests.rs` covers another pane; `hide_edges_hides_the_lines_across_a_linked_image` in `crates/ui-egui/src/canvas/tests.rs` covers View › Hide Edges. Scores and hours unchanged. +- **Selection: hidden members are not marked:** a selected group, layer, blend or intertwine draws no outline, anchors or lines across a linked image for its hidden members or for the art of a hidden sublayer, and neither do the hover highlight and other panes; the points of those members do not count toward the 100,000-point limit. Every path of a compound path, and an Image Trace object's source image in the views that show it, are still outlined. `a_selected_group_leaves_its_hidden_members_unmarked` in `crates/ui-egui/src/canvas/selection_marks/tests.rs`; `a_compound_path_outlines_its_hidden_paths_and_a_group_does_not`, `the_overlay_limit_leaves_out_hidden_members` and `live_trace_selection_highlight_excludes_the_retained_source_rectangle` in `crates/ui-egui/src/canvas/tests.rs`. Scores and hours unchanged. - **Panel collapse controls (#5925, in part):** The small » in a floating tab-group header moves that group into the side icon rail, reusing the existing rail or creating one. An opened rail panel has the same control to fold its flyout back into the rail, including after a tab switch. Both controls preserve the tab group and its menu; other floating groups and full-width docked headers stay as they were. Pointer regressions in `crates/ui-egui/src/panel_docking/tests.rs` cover grouped tabs, reopening, separate groups, a missing rail, the menu and flyout closure after switching tabs; `native_tests.rs` covers the native-window click and removal of the empty palette. Scores and estimates unchanged. - 3D lighting presets: `crates/effects/src/lighting_presets.rs`, `crates/engine/src/cmd/effectcmd/lighting_presets_tests.rs` and the pointer tests in `crates/ui-egui/src/dialogs/revolve/tests.rs` cover recognition, atomic targeting, native round trips, preview, Cancel, reset and Undo. From b232fd8e96e4b1f7423510f55a7f76102377649d Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 22 Nov 2026 18:48:21 -0800 Subject: [PATCH 5/8] Tests: hidden members in a repeat, a clip group, hover and other panes The tests now cover the repeat, whose hidden source members are not outlined, a clip group, whose clipping path stays outlined whether or not it is hidden, a hidden object that is itself selected, the hover highlight of a group with hidden members and another pane's outlines of one. The overlay limit test reports the group and the layer case separately. The comment on editing_children is back to main's text, and the progress line lists the repeat and the new tests. --- crates/doc/src/node/ops.rs | 3 +- crates/ui-egui/src/canvas/panes/tests.rs | 30 +++++++++++++++++++ .../src/canvas/selection_marks/tests.rs | 25 ++++++++++++++++ crates/ui-egui/src/canvas/tests.rs | 28 ++++++++++++++--- docs/target-app-parity.md | 2 +- 5 files changed, 81 insertions(+), 7 deletions(-) diff --git a/crates/doc/src/node/ops.rs b/crates/doc/src/node/ops.rs index 42bece8844..20dae6ec4b 100644 --- a/crates/doc/src/node/ops.rs +++ b/crates/doc/src/node/ops.rs @@ -361,8 +361,7 @@ impl Node { } /// Children that contribute to a container's editing bounds and selection highlights. A live trace retains a - /// hidden bitmap for re-tracing/release; only source-image views measure that bitmap. The canvas's selection - /// highlights also leave out hidden members, except a compound path's paths. + /// hidden bitmap for re-tracing/release; only source-image views measure that bitmap. pub fn editing_children(&self) -> &[Arc] { let children = self.children().map(Vec::as_slice).unwrap_or_default(); let trace_source = self.extras().trace.is_some() diff --git a/crates/ui-egui/src/canvas/panes/tests.rs b/crates/ui-egui/src/canvas/panes/tests.rs index b0f68367cc..5d664096b0 100644 --- a/crates/ui-egui/src/canvas/panes/tests.rs +++ b/crates/ui-egui/src/canvas/panes/tests.rs @@ -968,6 +968,36 @@ fn other_panes_cross_a_selected_linked_image() { assert_eq!(linked, embedded + 2, "the outline of a linked image and its two crossing lines; an embedded image's outline alone"); } +/// Another pane outlines a selected group's visible members only: hiding a member draws the same +/// outlines as deleting it. +#[test] +fn other_panes_leave_out_a_selected_groups_hidden_members() { + let mut app = app_with(2); + app.run("document.activate", json!({"index": 1})).unwrap(); + app.run("window.arrange.tile", json!({})).unwrap(); + let ctx = egui::Context::default(); + let shown = in_first(&mut app, "shape.rectangle", json!({"x": 50, "y": 50, "width": 100, "height": 80}))["id"].clone(); + let hidden = in_first(&mut app, "shape.ellipse", json!({"x": 200, "y": 100, "width": 90, "height": 60}))["id"].clone(); + in_first(&mut app, "select.set", json!({"ids": [shown, hidden]})); + let group = in_first(&mut app, "object.group", json!({}))["id"].clone(); + let outlines = |app: &mut VectorcraftApp| { + in_first(app, "select.set", json!({"ids": [group]})); + frame(app, &ctx, vec![]); + let drawn = frame(app, &ctx, vec![]); + kept_outlines(app, &ctx, &drawn).to_vec() + }; + let both = outlines(&mut app); + in_first(&mut app, "select.set", json!({"ids": [hidden]})); + in_first(&mut app, "edit.clear", json!({})); + let without = outlines(&mut app); + in_first(&mut app, "edit.undo", json!({})); + in_first(&mut app, "select.set", json!({"ids": [hidden]})); + in_first(&mut app, "object.hide", json!({})); + let with_hidden = outlines(&mut app); + assert_ne!(both, without, "the outlines show both members"); + assert_eq!(with_hidden, without, "a hidden member is not outlined"); +} + #[test] fn other_panes_keep_their_selected_outlines_until_the_document_selection_or_view_changes() { let mut app = app_with(2); diff --git a/crates/ui-egui/src/canvas/selection_marks/tests.rs b/crates/ui-egui/src/canvas/selection_marks/tests.rs index 32459a5825..408b7c8ec0 100644 --- a/crates/ui-egui/src/canvas/selection_marks/tests.rs +++ b/crates/ui-egui/src/canvas/selection_marks/tests.rs @@ -754,6 +754,31 @@ fn a_selected_group_leaves_its_hidden_members_unmarked() { let [tl, tr, br, bl] = sides(hidden); assert!(![tl, tr, br, bl, tl.midpoint(tr), tr.midpoint(br), br.midpoint(bl), bl.midpoint(tl)].into_iter().any(drawn), "a hidden member"); assert_matches_plain(&ctx, &mut SelectionMarks::default(), &app, &view, 1.0, "a group with hidden members"); + // The hover highlight of the group outlines its visible members only. + let (left_sides, right_sides, hidden_sides, image) = + (sides(left), sides(right), sides(hidden), doc.node(linked).unwrap().image_corners().unwrap()); + app.run("select.set", json!({"ids": []})).unwrap(); + app.hover_doc = Some(left_sides[0].midpoint(left_sides[2])); + let hovered = picture(&ctx, 1.0, |p| super::super::overlays::hover_highlight(&app, p, &view)); + let lit = |q: Point| { + let s = view.to_screen(q); + (-1..=1).any(|dy| { + (-1..=1).any(|dx| { + let (x, y) = ((s.x.round() as i64 + dx) as usize, (s.y.round() as i64 + dy) as usize); + hovered.pixels[y * hovered.size.0 + x][3] > 0.0 + }) + }) + }; + for [tl, tr, br, bl] in [left_sides, right_sides] { + assert!([tl.midpoint(tr), br.midpoint(bl)].into_iter().all(lit), "the hover highlight outlines a visible member"); + } + let [tl, tr, br, bl] = hidden_sides; + assert!(![tl.midpoint(tr), tr.midpoint(br), br.midpoint(bl), bl.midpoint(tl)].into_iter().any(lit), "the hover highlight of a hidden member"); + let [tl, tr, br, bl] = image; + assert!( + ![tl.midpoint(tr), tr.midpoint(br), tl.lerp(br, 0.25), tr.lerp(bl, 0.25)].into_iter().any(lit), + "the hover highlight of a linked image in a hidden group" + ); } /// A frame of the whole canvas keeps entries for the selected objects only. diff --git a/crates/ui-egui/src/canvas/tests.rs b/crates/ui-egui/src/canvas/tests.rs index af4281cbbb..3e7d629b75 100644 --- a/crates/ui-egui/src/canvas/tests.rs +++ b/crates/ui-egui/src/canvas/tests.rs @@ -817,6 +817,7 @@ fn the_overlay_limit_leaves_out_hidden_members() { vectorcraft_geom::shapes::rectangle(vectorcraft_geom::Rect::new(0.0, 0.0, 10.0, 10.0)), Appearance::default(), )); + let mut wrong = vec![]; for visible in [true, false] { let mut member = (*many).clone(); member.visible = visible; @@ -831,10 +832,12 @@ fn the_overlay_limit_leaves_out_hidden_members() { children.extend([Arc::new(sublayer), few.clone()]); } for (n, what) in [(&group, "a group"), (&layer, "a layer")] { - assert_eq!(too_many_anchors([n]), visible, "{what}, member visible: {visible}"); - assert_eq!(too_many_marks([n]), visible, "{what}, member visible: {visible}"); + if too_many_anchors([n]) != visible || too_many_marks([n]) != visible { + wrong.push(format!("{what}, member visible: {visible}")); + } } } + assert!(wrong.is_empty(), "the limit is crossed only by visible points: {wrong:?}"); } /// View › Hide Edges hides the lines across a selected linked image along with its outline @@ -13517,8 +13520,9 @@ fn live_trace_selection_highlight_excludes_the_retained_source_rectangle() { } /// A compound path draws every path it holds, hidden ones included, so its highlight outlines them -/// all; a group, a blend, an intertwine and a layer leave out a hidden member, and a layer the art -/// of a hidden sublayer. +/// all; a group, a blend, a repeat, an intertwine and a layer leave out a hidden member, and a +/// layer the art of a hidden sublayer. A clip group shows its clipping path whether or not it is +/// hidden, and a hidden object on its own keeps its outline. #[test] fn a_compound_path_outlines_its_hidden_paths_and_a_group_does_not() { use std::sync::Arc; @@ -13539,6 +13543,22 @@ fn a_compound_path_outlines_its_hidden_paths_and_a_group_does_not() { assert_eq!(contours(&Node::new(NodeId(1), NodeKind::Blend { children: children(), spec: Default::default() })), 1, "a blend"); assert_eq!(contours(&Node::group(NodeId(1), children())), 1, "a group"); assert_eq!(contours(&Node::new(NodeId(1), NodeKind::Intertwine { children: children() })), 1, "an intertwine"); + let repeat = |source: Vec>| contours(&Node::new(NodeId(1), NodeKind::Repeat(vectorcraft_doc::RepeatSpec::grid(source, 0.0, 0.0)))); + let visible = children().into_iter().take(1).collect(); + assert_eq!(repeat(children()), repeat(visible), "a repeat"); + // A clip group shows its clipping path, hidden or not, and none of the art it clips. + let clip = |visible: bool| { + let mut members = children(); + members.insert(0, rect(6, vectorcraft_geom::Rect::new(10.0, 10.0, 90.0, 90.0), visible)); + let mut n = Node::group(NodeId(1), members); + if let NodeKind::Group { clip, .. } = &mut n.kind { + *clip = true; + } + contours(&n) + }; + assert_eq!((clip(true), clip(false)), (1, 1), "a clip group"); + // A hidden object that is itself selected keeps its outline. + assert_eq!(contours(&rect(7, vectorcraft_geom::Rect::new(0.0, 0.0, 10.0, 10.0), false)), 1, "a hidden object"); let mut layer = Node::layer(NodeId(1), "Layer", LayerColor::Preset(0)); let mut sublayer = Node::layer(NodeId(4), "Sublayer", LayerColor::Preset(1)); sublayer.visible = false; diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 446f395823..af0e9a73d6 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -662,7 +662,7 @@ since 2026-10-01. - **Selection — disconnected path deletion (#3380, deletion only):** Clear/Delete and Cut turn surviving disconnected pieces of an ordinary contour into independent selected sibling objects. The first keeps its ID; all keep appearance, baked transforms and stacking order. `deletion_split_preserves_gradient_placement` compares rendered survivors with the original paint space and checks linear/radial fill/stroke vectors, already placed gradients and atomic Undo/Redo; connected remainders keep automatic fitting. Existing multi-subpath paths and explicit compound members retain their semantics. Original synthetic regressions in `crates/engine/tests/it/delete_path_pieces.rs` cover styled/transformed rectangles, cubic handles, compound preservation and atomic Undo/Redo; `crates/ui-egui/src/tests/removeanchors.rs` covers real-frame Delete/Backspace and a second Delete removing all survivors. Segment endpoint highlighting remains open. Scores and hours unchanged. - **Selection: deletion on paths with many subpaths:** Clear/Delete, `path.deleteAnchors`, Copy, Cut and Cut Path read each subpath's selected anchors or segments directly from the path's ordered selection, instead of scanning every selected anchor or segment of the path once per subpath. The result is unchanged: `crates/engine/tests/it/delete_path_pieces.rs` checks exact surviving subpaths and their order, open and closed contours, an untouched subpath, references to missing subpaths and indexes, one Undo/Redo step and a second Delete, for anchor and segment selections on one path. Scores and hours unchanged. - **Selection: linked images are crossed (#9080):** a selected linked image or placed document shows two lines in its layer's color from corner to corner of its frame, in the current pane and in other panes of the same document. A selected embedded image shows its outline alone. A selected or highlighted image of either kind is outlined along its frame, so a turned or distorted image's outline follows its corners instead of the box square to the page around it. The lines are part of the selection marks, so View › Hide Edges hides them and output does not draw them. When the selection has more than VectorCraft's own limit of 100,000 outline points (each linked image or placed document adds 4 for the ends of its lines), the current pane and other panes draw one rectangle around the selected objects instead of their outlines and lines; the current pane still draws the key object's thicker outline. `a_selected_linked_image_is_crossed_and_an_embedded_one_is_not` in `crates/ui-egui/src/canvas/selection_marks/tests.rs` covers a linked image, a placed document and an embedded image, each image also turned and distorted, the key object's outline, the hover highlight and a render of the document; `other_panes_cross_a_selected_linked_image` in `crates/ui-egui/src/canvas/panes/tests.rs` covers another pane; `hide_edges_hides_the_lines_across_a_linked_image` in `crates/ui-egui/src/canvas/tests.rs` covers View › Hide Edges. Scores and hours unchanged. -- **Selection: hidden members are not marked:** a selected group, layer, blend or intertwine draws no outline, anchors or lines across a linked image for its hidden members or for the art of a hidden sublayer, and neither do the hover highlight and other panes; the points of those members do not count toward the 100,000-point limit. Every path of a compound path, and an Image Trace object's source image in the views that show it, are still outlined. `a_selected_group_leaves_its_hidden_members_unmarked` in `crates/ui-egui/src/canvas/selection_marks/tests.rs`; `a_compound_path_outlines_its_hidden_paths_and_a_group_does_not`, `the_overlay_limit_leaves_out_hidden_members` and `live_trace_selection_highlight_excludes_the_retained_source_rectangle` in `crates/ui-egui/src/canvas/tests.rs`. Scores and hours unchanged. +- **Selection: hidden members are not marked:** a selected group, layer, blend, repeat or intertwine draws no outline, anchors or lines across a linked image for its hidden members or for the art of a hidden sublayer, and neither do the hover highlight and other panes; the points of those members do not count toward the 100,000-point limit. Every path of a compound path, and an Image Trace object's source image in the views that show it, are still outlined. `a_selected_group_leaves_its_hidden_members_unmarked` in `crates/ui-egui/src/canvas/selection_marks/tests.rs` (with the hover highlight); `other_panes_leave_out_a_selected_groups_hidden_members` in `crates/ui-egui/src/canvas/panes/tests.rs`; `a_compound_path_outlines_its_hidden_paths_and_a_group_does_not`, `the_overlay_limit_leaves_out_hidden_members` and `live_trace_selection_highlight_excludes_the_retained_source_rectangle` in `crates/ui-egui/src/canvas/tests.rs`. Scores and hours unchanged. - **Panel collapse controls (#5925, in part):** The small » in a floating tab-group header moves that group into the side icon rail, reusing the existing rail or creating one. An opened rail panel has the same control to fold its flyout back into the rail, including after a tab switch. Both controls preserve the tab group and its menu; other floating groups and full-width docked headers stay as they were. Pointer regressions in `crates/ui-egui/src/panel_docking/tests.rs` cover grouped tabs, reopening, separate groups, a missing rail, the menu and flyout closure after switching tabs; `native_tests.rs` covers the native-window click and removal of the empty palette. Scores and estimates unchanged. - 3D lighting presets: `crates/effects/src/lighting_presets.rs`, `crates/engine/src/cmd/effectcmd/lighting_presets_tests.rs` and the pointer tests in `crates/ui-egui/src/dialogs/revolve/tests.rs` cover recognition, atomic targeting, native round trips, preview, Cancel, reset and Undo. From 1612f363c5b565debd606dd392cffa9de97f85b4 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 22 Nov 2026 19:21:52 -0800 Subject: [PATCH 6/8] Selection: the hidden-member rule sits next to editing_children The rule for which children a selection highlight outlines moves from the canvas into Node::drawn_children in vectorcraft-doc, next to Node::editing_children. Both now read the Image Trace source image through one private helper, and editing_children's doc comment says it gives the editing bounds and that highlights outline drawn_children. The highlight's behavior is unchanged. - the_overlay_limit_leaves_out_hidden_members also covers a blend, a repeat and an intertwine. - The repeat case of the compound-path test asserts its contour count. - a_selected_group_leaves_its_hidden_members_unmarked reports every failed check together, so the hover highlight checks run even when an earlier check fails. - The docs line now states which marks are tested for blends, repeats and intertwines, and that the rectangle drawn above the point limit and the Show Center mark still use the selection's bounds, which include a group's hidden members. --- crates/doc/src/node/ops.rs | 25 ++++++++++--- crates/ui-egui/src/canvas/outline.rs | 21 ++--------- .../src/canvas/selection_marks/tests.rs | 37 ++++++++++++------- crates/ui-egui/src/canvas/tests.rs | 15 +++++--- docs/target-app-parity.md | 2 +- 5 files changed, 57 insertions(+), 43 deletions(-) diff --git a/crates/doc/src/node/ops.rs b/crates/doc/src/node/ops.rs index 20dae6ec4b..aaa45c0c6f 100644 --- a/crates/doc/src/node/ops.rs +++ b/crates/doc/src/node/ops.rs @@ -360,17 +360,32 @@ impl Node { self.geometric(Some(symbols)) } - /// Children that contribute to a container's editing bounds and selection highlights. A live trace retains a - /// hidden bitmap for re-tracing/release; only source-image views measure that bitmap. + /// Children that contribute to a container's editing bounds. A live trace retains a hidden bitmap for + /// re-tracing/release; only source-image views measure that bitmap. Selection highlights outline + /// [`Node::drawn_children`]. pub fn editing_children(&self) -> &[Arc] { let children = self.children().map(Vec::as_slice).unwrap_or_default(); - let trace_source = self.extras().trace.is_some() - && !self.trace_view().shows_source() - && children.first().is_some_and(|n| !n.visible && matches!(n.kind, NodeKind::Image(_))); + let trace_source = !self.trace_view().shows_source() && self.trace_source().is_some_and(|n| !n.visible); let skip = usize::from(self.extras().shaper.is_some() || trace_source); children.get(skip..).unwrap_or_default() } + /// The children a selection highlight outlines: [`Node::editing_children`] without the hidden + /// members, which the canvas does not draw. An Image Trace object's hidden source image stays + /// when the object's view shows it, and every path of a compound path stays, since the compound + /// path draws all of them. + pub fn drawn_children(&self) -> impl Iterator> { + let members = !matches!(self.kind, NodeKind::Compound { .. }); + let source = self.trace_source().filter(|_| self.trace_view().shows_source()); + self.editing_children().iter().filter(move |c| !members || c.visible || source.is_some_and(|s| Arc::ptr_eq(s, c))) + } + + /// The first child of an Image Trace object when it is an image: the bitmap the trace keeps. + fn trace_source(&self) -> Option<&Arc> { + self.extras().trace.as_ref()?; + self.children()?.first().filter(|n| matches!(n.kind, NodeKind::Image(_))) + } + /// The box of [`Node::geometric_bounds`], or of [`Node::geometric_bounds_with`] when `symbols` /// is given. pub(crate) fn geometric(&self, symbols: Option<&SymbolBoxes>) -> Option { diff --git a/crates/ui-egui/src/canvas/outline.rs b/crates/ui-egui/src/canvas/outline.rs index fbb2241f3d..e96cf2abcc 100644 --- a/crates/ui-egui/src/canvas/outline.rs +++ b/crates/ui-egui/src/canvas/outline.rs @@ -1,5 +1,3 @@ -use std::sync::Arc; - use super::{BezPath, Color32, Node, NodeKind, PathEl, Point, Pos2, Shape, Stroke, SymbolBoxes, VectorcraftApp, Xf, pos2}; pub(super) fn to_screen_path(bp: &BezPath, xf: &Xf) -> Vec> { @@ -165,7 +163,7 @@ fn over_limit<'a>(nodes: impl IntoIterator, crosses: bool) -> b if n.clips() { return n.children().and_then(|children| children.first()).is_some_and(|clip| over(clip, left, crosses)); } - !matches!(n.kind, NodeKind::Envelope { .. }) && drawn_children(n).any(|c| over(c, left, crosses)) + !matches!(n.kind, NodeKind::Envelope { .. }) && n.drawn_children().any(|c| over(c, left, crosses)) } let mut left = OVERLAY_MAX_ANCHORS; nodes.into_iter().any(|n| over(n, &mut left, crosses)) @@ -195,23 +193,10 @@ fn overlay_points(n: &Node) -> usize { } } -/// The children of `n` that [`walk_drawn`] visits: [`Node::editing_children`], without the hidden -/// members, which the canvas does not draw. An Image Trace object's hidden source image stays when -/// the object's view shows it. Every path of a compound path stays, since the compound path draws -/// all of them. -fn drawn_children(n: &Node) -> impl Iterator> { - let members = !matches!(n.kind, NodeKind::Compound { .. }); - let source = (n.extras().trace.is_some() && n.trace_view().shows_source()) - .then(|| n.children().and_then(|children| children.first())) - .flatten() - .filter(|c| matches!(c.kind, NodeKind::Image(_))); - n.editing_children().iter().filter(move |c| !members || c.visible || source.is_some_and(|s| Arc::ptr_eq(s, c))) -} - /// [`Node::walk`] over what a selection highlight shows: an envelope's content is left out (the /// envelope shows its mesh instead), a clip group or clipping layer shows only its clipping path, /// its first child, not the art the path clips (#2422), and hidden members are left out -/// ([`drawn_children`]). +/// ([`Node::drawn_children`]). pub(super) fn walk_drawn<'a>(n: &'a Node, f: &mut impl FnMut(&'a Node)) { f(n); if matches!(n.kind, NodeKind::Envelope { .. }) { @@ -223,7 +208,7 @@ pub(super) fn walk_drawn<'a>(n: &'a Node, f: &mut impl FnMut(&'a Node)) { } return; } - for c in drawn_children(n) { + for c in n.drawn_children() { walk_drawn(c, f); } } diff --git a/crates/ui-egui/src/canvas/selection_marks/tests.rs b/crates/ui-egui/src/canvas/selection_marks/tests.rs index 408b7c8ec0..171a0a2df7 100644 --- a/crates/ui-egui/src/canvas/selection_marks/tests.rs +++ b/crates/ui-egui/src/canvas/selection_marks/tests.rs @@ -741,18 +741,25 @@ fn a_selected_group_leaves_its_hidden_members_unmarked() { let b = doc.node(id).unwrap().geometric_bounds().unwrap(); [Point::new(b.x0, b.y0), Point::new(b.x1, b.y0), Point::new(b.x1, b.y1), Point::new(b.x0, b.y1)] }; + // Every check runs, and the failures are reported together. + let mut wrong = vec![]; for id in [left, right] { let [tl, tr, br, bl] = sides(id); - assert!([tl, tr, br, bl, tl.midpoint(tr), br.midpoint(bl)].into_iter().all(drawn), "a visible member is outlined and marked"); + if ![tl, tr, br, bl, tl.midpoint(tr), br.midpoint(bl)].into_iter().all(drawn) { + wrong.push("a visible member is not outlined and marked"); + } } let [tl, tr, br, bl] = doc.node(linked).unwrap().image_corners().unwrap(); - assert!( - ![tl.lerp(br, 0.25), tl.lerp(br, 0.75), tr.lerp(bl, 0.25), tr.lerp(bl, 0.75)].into_iter().any(drawn), - "the lines across a linked image in a hidden group" - ); - assert!(![tl.midpoint(tr), tr.midpoint(br)].into_iter().any(drawn), "the outline of a linked image in a hidden group"); + if [tl.lerp(br, 0.25), tl.lerp(br, 0.75), tr.lerp(bl, 0.25), tr.lerp(bl, 0.75)].into_iter().any(drawn) { + wrong.push("the lines across a linked image in a hidden group"); + } + if [tl.midpoint(tr), tr.midpoint(br)].into_iter().any(drawn) { + wrong.push("the outline of a linked image in a hidden group"); + } let [tl, tr, br, bl] = sides(hidden); - assert!(![tl, tr, br, bl, tl.midpoint(tr), tr.midpoint(br), br.midpoint(bl), bl.midpoint(tl)].into_iter().any(drawn), "a hidden member"); + if [tl, tr, br, bl, tl.midpoint(tr), tr.midpoint(br), br.midpoint(bl), bl.midpoint(tl)].into_iter().any(drawn) { + wrong.push("a hidden member"); + } assert_matches_plain(&ctx, &mut SelectionMarks::default(), &app, &view, 1.0, "a group with hidden members"); // The hover highlight of the group outlines its visible members only. let (left_sides, right_sides, hidden_sides, image) = @@ -770,15 +777,19 @@ fn a_selected_group_leaves_its_hidden_members_unmarked() { }) }; for [tl, tr, br, bl] in [left_sides, right_sides] { - assert!([tl.midpoint(tr), br.midpoint(bl)].into_iter().all(lit), "the hover highlight outlines a visible member"); + if ![tl.midpoint(tr), br.midpoint(bl)].into_iter().all(lit) { + wrong.push("the hover highlight does not outline a visible member"); + } } let [tl, tr, br, bl] = hidden_sides; - assert!(![tl.midpoint(tr), tr.midpoint(br), br.midpoint(bl), bl.midpoint(tl)].into_iter().any(lit), "the hover highlight of a hidden member"); + if [tl.midpoint(tr), tr.midpoint(br), br.midpoint(bl), bl.midpoint(tl)].into_iter().any(lit) { + wrong.push("the hover highlight of a hidden member"); + } let [tl, tr, br, bl] = image; - assert!( - ![tl.midpoint(tr), tr.midpoint(br), tl.lerp(br, 0.25), tr.lerp(bl, 0.25)].into_iter().any(lit), - "the hover highlight of a linked image in a hidden group" - ); + if [tl.midpoint(tr), tr.midpoint(br), tl.lerp(br, 0.25), tr.lerp(bl, 0.25)].into_iter().any(lit) { + wrong.push("the hover highlight of a linked image in a hidden group"); + } + assert!(wrong.is_empty(), "drawn where it should not be, or missing: {wrong:?}"); } /// A frame of the whole canvas keeps entries for the selected objects only. diff --git a/crates/ui-egui/src/canvas/tests.rs b/crates/ui-egui/src/canvas/tests.rs index 3e7d629b75..e4dd0af97c 100644 --- a/crates/ui-egui/src/canvas/tests.rs +++ b/crates/ui-egui/src/canvas/tests.rs @@ -803,7 +803,8 @@ fn the_overlay_limit_counts_crossing_lines_only_where_they_are_drawn() { } /// The overlay's limit counts the points of the members the highlight outlines: a hidden member of -/// a group, and the art of a hidden sublayer, do not count toward it. +/// a group, a blend, a repeat or an intertwine, and the art of a hidden sublayer, do not count +/// toward it. #[test] fn the_overlay_limit_leaves_out_hidden_members() { use super::outline::{too_many_anchors, too_many_marks}; @@ -821,7 +822,11 @@ fn the_overlay_limit_leaves_out_hidden_members() { for visible in [true, false] { let mut member = (*many).clone(); member.visible = visible; - let group = Node::group(NodeId(1), vec![Arc::new(member), few.clone()]); + let members = || vec![Arc::new(member.clone()), few.clone()]; + let group = Node::group(NodeId(1), members()); + let blend = Node::new(NodeId(6), NodeKind::Blend { children: members(), spec: Default::default() }); + let repeat = Node::new(NodeId(7), NodeKind::Repeat(vectorcraft_doc::RepeatSpec::grid(members(), 0.0, 0.0))); + let intertwine = Node::new(NodeId(8), NodeKind::Intertwine { children: members() }); let mut sublayer = Node::layer(NodeId(5), "Sublayer", LayerColor::Preset(1)); sublayer.visible = visible; if let Some(children) = sublayer.children_mut() { @@ -831,7 +836,7 @@ fn the_overlay_limit_leaves_out_hidden_members() { if let Some(children) = layer.children_mut() { children.extend([Arc::new(sublayer), few.clone()]); } - for (n, what) in [(&group, "a group"), (&layer, "a layer")] { + for (n, what) in [(&group, "a group"), (&blend, "a blend"), (&repeat, "a repeat"), (&intertwine, "an intertwine"), (&layer, "a layer")] { if too_many_anchors([n]) != visible || too_many_marks([n]) != visible { wrong.push(format!("{what}, member visible: {visible}")); } @@ -13543,9 +13548,7 @@ fn a_compound_path_outlines_its_hidden_paths_and_a_group_does_not() { assert_eq!(contours(&Node::new(NodeId(1), NodeKind::Blend { children: children(), spec: Default::default() })), 1, "a blend"); assert_eq!(contours(&Node::group(NodeId(1), children())), 1, "a group"); assert_eq!(contours(&Node::new(NodeId(1), NodeKind::Intertwine { children: children() })), 1, "an intertwine"); - let repeat = |source: Vec>| contours(&Node::new(NodeId(1), NodeKind::Repeat(vectorcraft_doc::RepeatSpec::grid(source, 0.0, 0.0)))); - let visible = children().into_iter().take(1).collect(); - assert_eq!(repeat(children()), repeat(visible), "a repeat"); + assert_eq!(contours(&Node::new(NodeId(1), NodeKind::Repeat(vectorcraft_doc::RepeatSpec::grid(children(), 0.0, 0.0)))), 1, "a repeat"); // A clip group shows its clipping path, hidden or not, and none of the art it clips. let clip = |visible: bool| { let mut members = children(); diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index af0e9a73d6..43c7fc1cb9 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -662,7 +662,7 @@ since 2026-10-01. - **Selection — disconnected path deletion (#3380, deletion only):** Clear/Delete and Cut turn surviving disconnected pieces of an ordinary contour into independent selected sibling objects. The first keeps its ID; all keep appearance, baked transforms and stacking order. `deletion_split_preserves_gradient_placement` compares rendered survivors with the original paint space and checks linear/radial fill/stroke vectors, already placed gradients and atomic Undo/Redo; connected remainders keep automatic fitting. Existing multi-subpath paths and explicit compound members retain their semantics. Original synthetic regressions in `crates/engine/tests/it/delete_path_pieces.rs` cover styled/transformed rectangles, cubic handles, compound preservation and atomic Undo/Redo; `crates/ui-egui/src/tests/removeanchors.rs` covers real-frame Delete/Backspace and a second Delete removing all survivors. Segment endpoint highlighting remains open. Scores and hours unchanged. - **Selection: deletion on paths with many subpaths:** Clear/Delete, `path.deleteAnchors`, Copy, Cut and Cut Path read each subpath's selected anchors or segments directly from the path's ordered selection, instead of scanning every selected anchor or segment of the path once per subpath. The result is unchanged: `crates/engine/tests/it/delete_path_pieces.rs` checks exact surviving subpaths and their order, open and closed contours, an untouched subpath, references to missing subpaths and indexes, one Undo/Redo step and a second Delete, for anchor and segment selections on one path. Scores and hours unchanged. - **Selection: linked images are crossed (#9080):** a selected linked image or placed document shows two lines in its layer's color from corner to corner of its frame, in the current pane and in other panes of the same document. A selected embedded image shows its outline alone. A selected or highlighted image of either kind is outlined along its frame, so a turned or distorted image's outline follows its corners instead of the box square to the page around it. The lines are part of the selection marks, so View › Hide Edges hides them and output does not draw them. When the selection has more than VectorCraft's own limit of 100,000 outline points (each linked image or placed document adds 4 for the ends of its lines), the current pane and other panes draw one rectangle around the selected objects instead of their outlines and lines; the current pane still draws the key object's thicker outline. `a_selected_linked_image_is_crossed_and_an_embedded_one_is_not` in `crates/ui-egui/src/canvas/selection_marks/tests.rs` covers a linked image, a placed document and an embedded image, each image also turned and distorted, the key object's outline, the hover highlight and a render of the document; `other_panes_cross_a_selected_linked_image` in `crates/ui-egui/src/canvas/panes/tests.rs` covers another pane; `hide_edges_hides_the_lines_across_a_linked_image` in `crates/ui-egui/src/canvas/tests.rs` covers View › Hide Edges. Scores and hours unchanged. -- **Selection: hidden members are not marked:** a selected group, layer, blend, repeat or intertwine draws no outline, anchors or lines across a linked image for its hidden members or for the art of a hidden sublayer, and neither do the hover highlight and other panes; the points of those members do not count toward the 100,000-point limit. Every path of a compound path, and an Image Trace object's source image in the views that show it, are still outlined. `a_selected_group_leaves_its_hidden_members_unmarked` in `crates/ui-egui/src/canvas/selection_marks/tests.rs` (with the hover highlight); `other_panes_leave_out_a_selected_groups_hidden_members` in `crates/ui-egui/src/canvas/panes/tests.rs`; `a_compound_path_outlines_its_hidden_paths_and_a_group_does_not`, `the_overlay_limit_leaves_out_hidden_members` and `live_trace_selection_highlight_excludes_the_retained_source_rectangle` in `crates/ui-egui/src/canvas/tests.rs`. Scores and hours unchanged. +- **Selection: hidden members are not marked:** a selected group or layer draws no outline, anchors or lines across a linked image for its hidden members or for the art of a hidden sublayer, and neither do the hover highlight and other panes. A selected blend, repeat or intertwine draws no outline for its hidden members. The points of hidden members do not count toward the 100,000-point limit. The rectangle drawn above that limit and the Show Center mark still use the selection's bounds, which include a group's hidden members. Every path of a compound path, and an Image Trace object's source image in the views that show it, are still outlined. `a_selected_group_leaves_its_hidden_members_unmarked` in `crates/ui-egui/src/canvas/selection_marks/tests.rs` (with the hover highlight); `other_panes_leave_out_a_selected_groups_hidden_members` in `crates/ui-egui/src/canvas/panes/tests.rs`; `a_compound_path_outlines_its_hidden_paths_and_a_group_does_not`, `the_overlay_limit_leaves_out_hidden_members` and `live_trace_selection_highlight_excludes_the_retained_source_rectangle` in `crates/ui-egui/src/canvas/tests.rs`. Scores and hours unchanged. - **Panel collapse controls (#5925, in part):** The small » in a floating tab-group header moves that group into the side icon rail, reusing the existing rail or creating one. An opened rail panel has the same control to fold its flyout back into the rail, including after a tab switch. Both controls preserve the tab group and its menu; other floating groups and full-width docked headers stay as they were. Pointer regressions in `crates/ui-egui/src/panel_docking/tests.rs` cover grouped tabs, reopening, separate groups, a missing rail, the menu and flyout closure after switching tabs; `native_tests.rs` covers the native-window click and removal of the empty palette. Scores and estimates unchanged. - 3D lighting presets: `crates/effects/src/lighting_presets.rs`, `crates/engine/src/cmd/effectcmd/lighting_presets_tests.rs` and the pointer tests in `crates/ui-egui/src/dialogs/revolve/tests.rs` cover recognition, atomic targeting, native round trips, preview, Cancel, reset and Undo. From 270f7cb654e8d6d9905506e5897f3f43f4654fd4 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 22 Nov 2026 20:50:22 -0800 Subject: [PATCH 7/8] Docs: the key object's rectangle above the outline point limit The current pane draws a thicker rectangle around the key object instead of its outline when the key object alone has more than 100,000 outline points. --- docs/target-app-parity.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 43c7fc1cb9..685ab5dc4b 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -661,7 +661,7 @@ since 2026-10-01. - **Selection — disconnected path deletion (#3380, deletion only):** Clear/Delete and Cut turn surviving disconnected pieces of an ordinary contour into independent selected sibling objects. The first keeps its ID; all keep appearance, baked transforms and stacking order. `deletion_split_preserves_gradient_placement` compares rendered survivors with the original paint space and checks linear/radial fill/stroke vectors, already placed gradients and atomic Undo/Redo; connected remainders keep automatic fitting. Existing multi-subpath paths and explicit compound members retain their semantics. Original synthetic regressions in `crates/engine/tests/it/delete_path_pieces.rs` cover styled/transformed rectangles, cubic handles, compound preservation and atomic Undo/Redo; `crates/ui-egui/src/tests/removeanchors.rs` covers real-frame Delete/Backspace and a second Delete removing all survivors. Segment endpoint highlighting remains open. Scores and hours unchanged. - **Selection: deletion on paths with many subpaths:** Clear/Delete, `path.deleteAnchors`, Copy, Cut and Cut Path read each subpath's selected anchors or segments directly from the path's ordered selection, instead of scanning every selected anchor or segment of the path once per subpath. The result is unchanged: `crates/engine/tests/it/delete_path_pieces.rs` checks exact surviving subpaths and their order, open and closed contours, an untouched subpath, references to missing subpaths and indexes, one Undo/Redo step and a second Delete, for anchor and segment selections on one path. Scores and hours unchanged. -- **Selection: linked images are crossed (#9080):** a selected linked image or placed document shows two lines in its layer's color from corner to corner of its frame, in the current pane and in other panes of the same document. A selected embedded image shows its outline alone. A selected or highlighted image of either kind is outlined along its frame, so a turned or distorted image's outline follows its corners instead of the box square to the page around it. The lines are part of the selection marks, so View › Hide Edges hides them and output does not draw them. When the selection has more than VectorCraft's own limit of 100,000 outline points (each linked image or placed document adds 4 for the ends of its lines), the current pane and other panes draw one rectangle around the selected objects instead of their outlines and lines; the current pane still draws the key object's thicker outline. `a_selected_linked_image_is_crossed_and_an_embedded_one_is_not` in `crates/ui-egui/src/canvas/selection_marks/tests.rs` covers a linked image, a placed document and an embedded image, each image also turned and distorted, the key object's outline, the hover highlight and a render of the document; `other_panes_cross_a_selected_linked_image` in `crates/ui-egui/src/canvas/panes/tests.rs` covers another pane; `hide_edges_hides_the_lines_across_a_linked_image` in `crates/ui-egui/src/canvas/tests.rs` covers View › Hide Edges. Scores and hours unchanged. +- **Selection: linked images are crossed (#9080):** a selected linked image or placed document shows two lines in its layer's color from corner to corner of its frame, in the current pane and in other panes of the same document. A selected embedded image shows its outline alone. A selected or highlighted image of either kind is outlined along its frame, so a turned or distorted image's outline follows its corners instead of the box square to the page around it. The lines are part of the selection marks, so View › Hide Edges hides them and output does not draw them. When the selection has more than VectorCraft's own limit of 100,000 outline points (each linked image or placed document adds 4 for the ends of its lines), the current pane and other panes draw one rectangle around the selected objects instead of their outlines and lines; the current pane still draws the key object's thicker outline, or a thicker rectangle around the key object when it alone has more than 100,000 outline points. `a_selected_linked_image_is_crossed_and_an_embedded_one_is_not` in `crates/ui-egui/src/canvas/selection_marks/tests.rs` covers a linked image, a placed document and an embedded image, each image also turned and distorted, the key object's outline, the hover highlight and a render of the document; `other_panes_cross_a_selected_linked_image` in `crates/ui-egui/src/canvas/panes/tests.rs` covers another pane; `hide_edges_hides_the_lines_across_a_linked_image` in `crates/ui-egui/src/canvas/tests.rs` covers View › Hide Edges. Scores and hours unchanged. - **Selection: hidden members are not marked:** a selected group or layer draws no outline, anchors or lines across a linked image for its hidden members or for the art of a hidden sublayer, and neither do the hover highlight and other panes. A selected blend, repeat or intertwine draws no outline for its hidden members. The points of hidden members do not count toward the 100,000-point limit. The rectangle drawn above that limit and the Show Center mark still use the selection's bounds, which include a group's hidden members. Every path of a compound path, and an Image Trace object's source image in the views that show it, are still outlined. `a_selected_group_leaves_its_hidden_members_unmarked` in `crates/ui-egui/src/canvas/selection_marks/tests.rs` (with the hover highlight); `other_panes_leave_out_a_selected_groups_hidden_members` in `crates/ui-egui/src/canvas/panes/tests.rs`; `a_compound_path_outlines_its_hidden_paths_and_a_group_does_not`, `the_overlay_limit_leaves_out_hidden_members` and `live_trace_selection_highlight_excludes_the_retained_source_rectangle` in `crates/ui-egui/src/canvas/tests.rs`. Scores and hours unchanged. - **Panel collapse controls (#5925, in part):** The small » in a floating tab-group header moves that group into the side icon rail, reusing the existing rail or creating one. An opened rail panel has the same control to fold its flyout back into the rail, including after a tab switch. Both controls preserve the tab group and its menu; other floating groups and full-width docked headers stay as they were. Pointer regressions in `crates/ui-egui/src/panel_docking/tests.rs` cover grouped tabs, reopening, separate groups, a missing rail, the menu and flyout closure after switching tabs; `native_tests.rs` covers the native-window click and removal of the empty palette. Scores and estimates unchanged. From 272c24a119759a7acc35c27201a9b0475f51c75d Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Wed, 25 Nov 2026 22:40:11 -0800 Subject: [PATCH 8/8] Selection: a selected group leaves out guides and templates the view hides A selected group or layer outlined and marked a member made into a guide while the guides were hidden, and the art of a template sublayer while View > Hide Template was on, although the canvas does not draw them. - Node::hidden_by_view (crates/doc/src/node/ops.rs) holds the rule; the renderer's left_out now uses it too. - walk_drawn and the overlay's point limit in canvas/outline.rs leave out the members the view hides, so the selection's outlines, key outline, anchors, hover outline and point count skip them. - The selection's bounds are unchanged. --- crates/doc/src/node/ops.rs | 7 ++ crates/render/src/node_checks.rs | 4 +- crates/ui-egui/src/canvas/outline.rs | 74 +++++++++------ crates/ui-egui/src/canvas/selection.rs | 41 ++++---- crates/ui-egui/src/canvas/selection/tests.rs | 98 ++++++++++++++++++-- crates/ui-egui/src/canvas/tests.rs | 26 ++++-- 6 files changed, 188 insertions(+), 62 deletions(-) diff --git a/crates/doc/src/node/ops.rs b/crates/doc/src/node/ops.rs index aaa45c0c6f..cadfb6b7a6 100644 --- a/crates/doc/src/node/ops.rs +++ b/crates/doc/src/node/ops.rs @@ -131,6 +131,13 @@ impl Node { matches!(self.kind, NodeKind::Layer { template: true, .. }) } + /// Whether a view that hides template layers (`templates`) or guides (`guides`) leaves this + /// object out: a template layer while templates are hidden, or a path made into a guide while + /// guides are hidden. The canvas draws ruler guides apart from the art. + pub fn hidden_by_view(&self, templates: bool, guides: bool) -> bool { + (templates && self.is_template()) || (guides && matches!(self.kind, NodeKind::Path { guide: true, .. })) + } + /// The art objects of this container: its children, looking through sublayers, which are not /// objects (bottom first). With `editable`, only the visible, unlocked objects in visible, /// unlocked, non-template sublayers. diff --git a/crates/render/src/node_checks.rs b/crates/render/src/node_checks.rs index a4d9fda7af..ecba138052 100644 --- a/crates/render/src/node_checks.rs +++ b/crates/render/src/node_checks.rs @@ -112,9 +112,7 @@ pub(crate) fn holds_instance(n: &Node) -> bool { /// guide the view hides, a ruler guide (the canvas draws those), drawn hidden, or the instance its /// symbol is being edited from? pub(crate) fn left_out(opts: &crate::RenderOptions, doc: &vectorcraft_doc::Document, a: &Node) -> bool { - let view_item = a.is_ruler_guide() - || (opts.skip_templates || opts.hide_templates) && matches!(a.kind, NodeKind::Layer { template: true, .. }) - || (opts.skip_templates || opts.hide_guides) && matches!(a.kind, NodeKind::Path { guide: true, .. }); + let view_item = a.is_ruler_guide() || a.hidden_by_view(opts.skip_templates || opts.hide_templates, opts.skip_templates || opts.hide_guides); !a.visible || view_item || opts.hidden.contains(&a.id) || edited_instance(opts, doc, a.id) } diff --git a/crates/ui-egui/src/canvas/outline.rs b/crates/ui-egui/src/canvas/outline.rs index 4e83b1197b..6ebda8e24a 100644 --- a/crates/ui-egui/src/canvas/outline.rs +++ b/crates/ui-egui/src/canvas/outline.rs @@ -8,12 +8,33 @@ pub(super) fn c32(rgb: [u8; 3]) -> Color32 { Color32::from_rgb(rgb[0], rgb[1], rgb[2]) } +/// What the view hides among a selected object's members, which the selection marks leave out as +/// the canvas does ([`Node::hidden_by_view`]): template layers while View › Hide Template is on, +/// and paths made into guides while the guides are hidden. The default hides nothing. +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] +pub(super) struct ViewHides { + pub(super) templates: bool, + pub(super) guides: bool, +} + +impl ViewHides { + /// What `app`'s view hides. + pub(super) fn of(app: &VectorcraftApp) -> Self { + Self { templates: !app.ui.view.templates, guides: !app.ui.view.guides_shown() } + } + + /// Whether the view leaves `n` out. + fn hides(self, n: &Node) -> bool { + n.hidden_by_view(self.templates, self.guides) + } +} + /// Outline of a node for highlighting (paths, compound children, area type frames, other text /// bounds, images' frames, symbol instances' bounds measured by their art from `symbols`; a clip -/// group's clipping path only, as [`walk_drawn`] visits it). -pub(super) fn node_outline(n: &Node, symbols: &SymbolBoxes) -> BezPath { +/// group's clipping path only, as [`walk_drawn`] visits it, without the members `hides` leaves out). +pub(super) fn node_outline(n: &Node, symbols: &SymbolBoxes, hides: ViewHides) -> BezPath { let mut bp = BezPath::new(); - walk_drawn(n, &mut |c| match &c.kind { + walk_drawn(n, hides, &mut |c| match &c.kind { NodeKind::Path { path, .. } => bp.extend(path.to_bezpath()), // Area type shows its frame: the type area Direct Selection reshapes; type on a path its // path, which the selection tools' brackets sit on; point type shows its baseline(s). @@ -72,11 +93,11 @@ fn is_linked(n: &Node) -> bool { } /// The lines that cross each linked image and placed document of `n` that [`walk_drawn`] visits, -/// from corner to corner of its frame or box (#9080). The selection marks draw them; the hover -/// highlight does not. -pub(super) fn linked_crosses(n: &Node) -> BezPath { +/// from corner to corner of its frame or box (#9080), without the members `hides` leaves out. The +/// selection marks draw them; the hover highlight does not. +pub(super) fn linked_crosses(n: &Node, hides: ViewHides) -> BezPath { let mut bp = BezPath::new(); - walk_drawn(n, &mut |c| match &c.kind { + walk_drawn(n, hides, &mut |c| match &c.kind { NodeKind::Image(_) if is_linked(c) => { if let Some(cross) = c.image_cross() { bp.extend(cross); @@ -101,22 +122,23 @@ pub(super) fn linked_crosses(n: &Node) -> BezPath { /// #2460). pub(super) const OVERLAY_MAX_ANCHORS: usize = 100_000; -/// Whether `nodes` have more than [`OVERLAY_MAX_ANCHORS`] points to outline ([`overlay_points`]; -/// counting stops there). -pub(super) fn too_many_anchors<'a>(nodes: impl IntoIterator) -> bool { - over_limit(nodes, false) +/// Whether `nodes` have more than [`OVERLAY_MAX_ANCHORS`] points to outline ([`overlay_points`], +/// without the members `hides` leaves out; counting stops there). +pub(super) fn too_many_anchors<'a>(nodes: impl IntoIterator, hides: ViewHides) -> bool { + over_limit(nodes, false, hides) } /// Whether `nodes` have more than [`OVERLAY_MAX_ANCHORS`] points to outline and to cross where they -/// are linked images or placed documents ([`linked_crosses`]), as the selection marks draw them. -pub(super) fn too_many_marks<'a>(nodes: impl IntoIterator) -> bool { - over_limit(nodes, true) +/// are linked images or placed documents ([`linked_crosses`]), as the selection marks draw them +/// without the members `hides` leaves out. +pub(super) fn too_many_marks<'a>(nodes: impl IntoIterator, hides: ViewHides) -> bool { + over_limit(nodes, true, hides) } /// Whether `nodes` have more than [`OVERLAY_MAX_ANCHORS`] points ([`overlay_points`], with the -/// ends of the crossing lines when `crosses`); counting stops there. -fn over_limit<'a>(nodes: impl IntoIterator, crosses: bool) -> bool { - fn over(n: &Node, left: &mut usize, crosses: bool) -> bool { +/// ends of the crossing lines when `crosses`) in what [`walk_drawn`] visits; counting stops there. +fn over_limit<'a>(nodes: impl IntoIterator, crosses: bool, hides: ViewHides) -> bool { + fn over(n: &Node, left: &mut usize, crosses: bool, hides: ViewHides) -> bool { let ends = if crosses && is_linked(n) { 4 } else { 0 }; match left.checked_sub(overlay_points(n) + ends) { Some(l) => *left = l, @@ -124,12 +146,12 @@ fn over_limit<'a>(nodes: impl IntoIterator, crosses: bool) -> b } // A clip group counts only its clipping path, the one child `walk_drawn` visits. if n.clips() { - return n.children().and_then(|children| children.first()).is_some_and(|clip| over(clip, left, crosses)); + return n.children().and_then(|children| children.first()).is_some_and(|clip| over(clip, left, crosses, hides)); } - !matches!(n.kind, NodeKind::Envelope { .. }) && n.drawn_children().any(|c| over(c, left, crosses)) + !matches!(n.kind, NodeKind::Envelope { .. }) && n.drawn_children().filter(|c| !hides.hides(c)).any(|c| over(c, left, crosses, hides)) } let mut left = OVERLAY_MAX_ANCHORS; - nodes.into_iter().any(|n| over(n, &mut left, crosses)) + nodes.into_iter().any(|n| over(n, &mut left, crosses, hides)) } /// The points counted for `n` itself, without its children, toward [`OVERLAY_MAX_ANCHORS`]: a @@ -158,21 +180,21 @@ fn overlay_points(n: &Node) -> usize { /// [`Node::walk`] over what a selection highlight shows: an envelope's content is left out (the /// envelope shows its mesh instead), a clip group or clipping layer shows only its clipping path, -/// its first child, not the art the path clips (#2422), and hidden members are left out -/// ([`Node::drawn_children`]). -pub(super) fn walk_drawn<'a>(n: &'a Node, f: &mut impl FnMut(&'a Node)) { +/// its first child, not the art the path clips (#2422), and hidden members +/// ([`Node::drawn_children`]) and the members `hides` leaves out are left out. +pub(super) fn walk_drawn<'a>(n: &'a Node, hides: ViewHides, f: &mut impl FnMut(&'a Node)) { f(n); if matches!(n.kind, NodeKind::Envelope { .. }) { return; } if n.clips() { if let Some(clip) = n.children().and_then(|children| children.first()) { - walk_drawn(clip, f); + walk_drawn(clip, hides, f); } return; } - for c in n.drawn_children() { - walk_drawn(c, f); + for c in n.drawn_children().filter(|c| !hides.hides(c)) { + walk_drawn(c, hides, f); } } diff --git a/crates/ui-egui/src/canvas/selection.rs b/crates/ui-egui/src/canvas/selection.rs index 55da766408..c8e0dd5212 100644 --- a/crates/ui-egui/src/canvas/selection.rs +++ b/crates/ui-egui/src/canvas/selection.rs @@ -24,7 +24,7 @@ use vectorcraft_geom::{AnchorKind, BezPath, PathData, PathEl, Point}; use vectorcraft_tools::Mods; use super::cursor::ViewKey; -use super::outline::{c32, linked_crosses, node_outline, selection_hit_at, too_many_anchors, too_many_marks, walk_drawn}; +use super::outline::{ViewHides, c32, linked_crosses, node_outline, selection_hit_at, too_many_anchors, too_many_marks, walk_drawn}; // PLAN: `BodyKind`, `Win` and `ViewKey::from(CanvasView)` are canvas-w10's (cv.S1, S2, S5); their paths here follow the contract. use super::{BodyKind, VectorcraftApp, Win}; // PLAN: `anchors` takes `tool_points` because the Curvature tool's own points come from `session.overlays`, which only `show` may call (`&mut app`). @@ -147,9 +147,9 @@ fn hidden(app: &VectorcraftApp) -> bool { crate::dialogs::halftone::previewing(app) } -/// Whether the selection has too many points to outline and cross: its bounds stand for it. -fn too_big(st: &DocState) -> bool { - too_many_marks(st.selection.objects.iter().filter_map(|id| st.doc.node(*id))) +/// Whether the selection has too many points to outline and cross in `app`'s view: its bounds stand for it. +fn too_big(app: &VectorcraftApp, st: &DocState) -> bool { + too_many_marks(st.selection.objects.iter().filter_map(|id| st.doc.node(*id)), ViewHides::of(app)) } /// The rectangle of `bounds` as a path. @@ -174,9 +174,9 @@ pub(super) fn outlines(app: &VectorcraftApp, st: &DocState) -> Vec { if hidden(app) { return out; } - let (sel, symbols) = (&st.selection, st.doc.symbol_boxes()); + let (sel, symbols, hides) = (&st.selection, st.doc.symbol_boxes(), ViewHides::of(app)); let color_of = |id: NodeId| c32(st.doc.layer_color(id)); - if too_big(st) { + if too_big(app, st) { // The cache is warmed by `show`; a test or a miss measures again. let bounds = match app.canvas.selection_bounds { Some((key, bounds)) if key == (st.uid, st.revision) => bounds, @@ -189,7 +189,7 @@ pub(super) fn outlines(app: &VectorcraftApp, st: &DocState) -> Vec { for id in &sel.objects { let Some(node) = st.doc.node(*id) else { continue }; // Linked images and placed documents are also crossed from corner to corner. - for path in [node_outline(node, &symbols), linked_crosses(node)] { + for path in [node_outline(node, &symbols, hides), linked_crosses(node, hides)] { if !path.elements().is_empty() { group(&mut out, color_of(*id)).paths.push(path); } @@ -200,7 +200,11 @@ pub(super) fn outlines(app: &VectorcraftApp, st: &DocState) -> Vec { } } if let Some((key, node)) = sel.key.and_then(|key| Some((key, st.doc.node(key)?))) { - let path = if too_many_anchors([node]) { node.geometric_bounds_with(&symbols).map(bounds_path) } else { Some(node_outline(node, &symbols)) }; + let path = if too_many_anchors([node], hides) { + node.geometric_bounds_with(&symbols).map(bounds_path) + } else { + Some(node_outline(node, &symbols, hides)) + }; if let Some(path) = path { group(&mut out, color_of(key)).key = Some(path); } @@ -268,10 +272,10 @@ pub(super) fn anchors(app: &VectorcraftApp, st: &DocState, tool: &str, tool_poin segment_mark: SegmentMark::Line, options: path_options(prefs), }; - if hidden(app) || too_big(st) || (curvature && tool_points) { + if hidden(app) || too_big(app, st) || (curvature && tool_points) { return out; } - let sel = &st.selection; + let (sel, hides) = (&st.selection, ViewHides::of(app)); // The selected anchors by path, and the selected segment with its path. let mut chosen: Vec<(u64, Vec)> = vec![]; let mut segment: Option<(u64, KnotRef)> = None; @@ -279,7 +283,7 @@ pub(super) fn anchors(app: &VectorcraftApp, st: &DocState, tool: &str, tool_poin let Some(node) = st.doc.node(*id) else { continue }; let partial = sel.partial(*id); let color = c32(st.doc.layer_color(*id)); - walk_drawn(node, &mut |c| { + walk_drawn(node, hides, &mut |c| { let envelope = vectorcraft_doc::live::envelope_overlay(c).and_then(|(_, grid)| grid); let grid = match &c.kind { NodeKind::Mesh(m) => Some(m), @@ -371,13 +375,14 @@ pub(super) fn hover(app: &VectorcraftApp, st: &DocState, tool: &str, at: Point, if kept { return None; } - outline_of(st, id) + outline_of(st, id, ViewHides::of(app)) } -/// The hover outline of `id` in its layer colour, unless it has too many points. -fn outline_of(st: &DocState, id: NodeId) -> Option { - let node = st.doc.node(id).filter(|n| !too_many_anchors([*n]))?; - Some(Hovered { path: node_outline(node, &st.doc.symbol_boxes()), color: c32(st.doc.layer_color(id)) }) +/// The hover outline of `id` in its layer colour, without the members `hides` leaves out, unless it has too many +/// points. +fn outline_of(st: &DocState, id: NodeId, hides: ViewHides) -> Option { + let node = st.doc.node(id).filter(|n| !too_many_anchors([*n], hides))?; + Some(Hovered { path: node_outline(node, &st.doc.symbol_boxes(), hides), color: c32(st.doc.layer_color(id)) }) } /// The hover outline the canvas shows at document point `at` with the keys `held`: none while Space lends the view @@ -407,7 +412,7 @@ pub(super) fn eyedropper_hover(app: &mut VectorcraftApp, at: Point, mods: Mods, } let info = app.view_info(); let id = eyedropper_hover_object(app, at, mods, info)?; - outline_of(app.session.active()?, id) + outline_of(app.session.active()?, id, ViewHides::of(app)) } /// What the Eyedropper's hover object depends on: the point, the keys held, the document as it is, the selection and @@ -497,7 +502,7 @@ fn eyedropper_hover_object(app: &mut VectorcraftApp, at: Point, mods: Mods, view /// The dots of the selection: point type's origin, the centre of each object that shows it, and the key anchor. pub(super) fn dots(app: &VectorcraftApp, st: &DocState) -> Dots { let mut out = Dots { grow: grow(&app.session.prefs), ..Dots::default() }; - if hidden(app) || too_big(st) { + if hidden(app) || too_big(app, st) { return out; } let symbols = st.doc.symbol_boxes(); diff --git a/crates/ui-egui/src/canvas/selection/tests.rs b/crates/ui-egui/src/canvas/selection/tests.rs index 0e8dd77e45..bef89f1f41 100644 --- a/crates/ui-egui/src/canvas/selection/tests.rs +++ b/crates/ui-egui/src/canvas/selection/tests.rs @@ -243,7 +243,7 @@ fn the_key_object_has_its_own_outline() { let ids = app.session.active().unwrap().selection.objects.clone(); app.run("select.key", json!({"id": curve.0})).unwrap(); let st = app.session.active().unwrap(); - let want = node_outline(st.doc.node(curve).unwrap(), &st.doc.symbol_boxes()); + let want = node_outline(st.doc.node(curve).unwrap(), &st.doc.symbol_boxes(), ViewHides::default()); let color = c32(st.doc.layer_color(curve)); let out = outlines(&app, st); let key = out.iter().find(|o| o.color == color).and_then(|o| o.key.as_ref()).unwrap(); @@ -331,7 +331,11 @@ fn a_selected_linked_image_is_crossed_and_an_embedded_one_is_not() { let st = app.session.active().unwrap(); let key = outlines(&app, st).into_iter().find_map(|o| o.key).unwrap(); assert_eq!(key.elements(), frame_of(corners(&app, id)).as_slice(), "the key object's outline of {id:?}"); - assert_eq!(outline_of(st, id).unwrap().path.elements(), frame_of(corners(&app, id)).as_slice(), "the hover outline of {id:?}"); + assert_eq!( + outline_of(st, id, ViewHides::default()).unwrap().path.elements(), + frame_of(corners(&app, id)).as_slice(), + "the hover outline of {id:?}" + ); } } @@ -356,8 +360,9 @@ fn the_overlay_limit_counts_crossing_lines_only_where_they_are_drawn() { let count = OVERLAY_MAX_ANCHORS / 6; let linked = vec![image(Some(vectorcraft_doc::LinkInfo { path: "/a.png".into(), ..Default::default() })); count]; let embedded = vec![image(None); count]; - assert!(!too_many_anchors(&linked) && too_many_marks(&linked), "linked images"); - assert!(!too_many_anchors(&embedded) && !too_many_marks(&embedded), "embedded images"); + let all = ViewHides::default(); + assert!(!too_many_anchors(&linked, all) && too_many_marks(&linked, all), "linked images"); + assert!(!too_many_anchors(&embedded, all) && !too_many_marks(&embedded, all), "embedded images"); } /// A selected group outlines, marks and crosses only the members the canvas draws: a hidden member and a linked image @@ -385,7 +390,7 @@ fn a_selected_group_leaves_its_hidden_members_unmarked() { let st = app.session.active().unwrap(); let outlined: Vec> = outlines(app, st).into_iter().flat_map(|o| o.paths).map(|p| p.elements().to_vec()).collect(); let anchored = marks(app).paths.iter().map(|p| p.anchor_count()).collect::>(); - let hovered = outline_of(st, group).map(|h| h.path.elements().to_vec()); + let hovered = outline_of(st, group, ViewHides::of(app)).map(|h| h.path.elements().to_vec()); (outlined, anchored, hovered) }; let both = shown(&mut app, &[]); @@ -396,6 +401,87 @@ fn a_selected_group_leaves_its_hidden_members_unmarked() { assert_eq!(with_hidden, without, "hidden members are not marked"); } +/// A selected group leaves out a member made into a guide while the guides are hidden, as the canvas does: its +/// outlines, anchors and hover outline are the same as with that member deleted. With the guides shown, the guide is +/// marked too. +#[test] +fn a_selected_group_leaves_out_its_guides_while_guides_are_hidden() { + let mut app = blank(); + let path = id_of(&app.run("shape.rectangle", json!({"x": 40, "y": 40, "width": 20, "height": 20})).unwrap()); + let guide = id_of(&app.run("shape.rectangle", json!({"x": 200, "y": 150, "width": 40, "height": 40})).unwrap()); + app.run("select.set", json!({"ids": [guide.0]})).unwrap(); + app.run("view.guides.make", json!({})).unwrap(); + app.run("select.set", json!({"ids": [path.0, guide.0]})).unwrap(); + let group = id_of(&app.run("object.group", json!({})).unwrap()); + assert!( + matches!(app.session.active().unwrap().doc.node(guide).map(|n| &n.kind), Some(NodeKind::Path { guide: true, .. })), + "the group holds a guide" + ); + // With the group selected: the boxes of its outline paths, the paths that show anchors, and its hover outline's box. + let shown = |app: &mut VectorcraftApp| { + app.run("select.set", json!({"ids": [group.0]})).unwrap(); + let st = app.session.active().unwrap(); + let outlined: Vec = outlines(app, st).into_iter().flat_map(|o| o.paths).map(|p| p.bounding_box()).collect(); + let anchored = marks(app).paths.iter().map(|p| p.anchor_count()).collect::>(); + let hovered = outline_of(st, group, ViewHides::of(app)).map(|h| h.path.bounding_box()); + (outlined, anchored, hovered) + }; + let both = shown(&mut app); + app.run("view.guides", json!({})).unwrap(); + assert!(!app.ui.view.guides_shown(), "the guides are hidden"); + let guides_hidden = shown(&mut app); + app.run("view.guides", json!({})).unwrap(); + app.run("select.set", json!({"ids": [guide.0]})).unwrap(); + app.run("edit.clear", json!({})).unwrap(); + let without = shown(&mut app); + assert_eq!(both.1.len(), 2, "with the guides shown, the guide shows its anchors too: {both:?}"); + assert_ne!(both, without, "with the guides shown, the guide is marked"); + assert_eq!(guides_hidden, without, "with the guides hidden, only the path is marked"); +} + +/// A selected layer leaves out the art of a template sublayer while View › Hide Template is on, and a group a guide +/// while the guides are hidden: their outlines and the overlay's point limit count only what the canvas draws. +#[test] +fn the_marks_leave_out_template_layers_and_guides_the_view_hides() { + use super::super::outline::{node_outline, too_many_anchors, too_many_marks}; + use std::sync::Arc; + use vectorcraft_doc::{Appearance, LayerColor, Node}; + use vectorcraft_geom::SubPath; + let rect = |id: u64, r: vectorcraft_geom::Rect| Node::path(NodeId(id), vectorcraft_geom::shapes::rectangle(r), Appearance::default()); + let path = Arc::new(rect(2, vectorcraft_geom::Rect::new(0.0, 0.0, 10.0, 10.0))); + let points: Vec = (0..=OVERLAY_MAX_ANCHORS).map(|i| Point::new(i as f64, 0.0)).collect(); + let mut many = Node::path(NodeId(3), PathData::single(SubPath::polyline(&points, false)), Appearance::default()); + let mut template = Node::layer(NodeId(4), "Template", LayerColor::Preset(1)); + if let NodeKind::Layer { template: on, children, .. } = &mut template.kind { + *on = true; + children.push(Arc::new(many.clone())); + } + let mut layer = Node::layer(NodeId(5), "Layer", LayerColor::Preset(0)); + if let Some(children) = layer.children_mut() { + children.extend([Arc::new(template), path.clone()]); + } + if let NodeKind::Path { guide, .. } = &mut many.kind { + *guide = true; + } + let group = Node::group(NodeId(6), vec![Arc::new(many), path.clone()]); + let doc = vectorcraft_doc::Document::new(300.0, 300.0); + let symbols = doc.symbol_boxes(); + let alone = node_outline(&path, &symbols, ViewHides::default()).bounding_box(); + let mut wrong = vec![]; + for (n, what, hides) in [ + (&layer, "a layer with a template sublayer", ViewHides { templates: true, guides: false }), + (&group, "a group with a guide", ViewHides { templates: false, guides: true }), + ] { + for (hides, hidden) in [(ViewHides::default(), false), (hides, true)] { + let outline = node_outline(n, &symbols, hides).bounding_box(); + if (outline == alone) != hidden || too_many_anchors([n], hides) == hidden || too_many_marks([n], hides) == hidden { + wrong.push(format!("{what}, hidden by the view: {hidden}")); + } + } + } + assert!(wrong.is_empty(), "the marks count only what the view draws: {wrong:?}"); +} + /// The overlay's limit counts the points of the members the highlight outlines: a hidden member of a group, a blend, a /// repeat or an intertwine, and the art of a hidden sublayer, do not count toward it. #[test] @@ -430,7 +516,7 @@ fn the_overlay_limit_leaves_out_hidden_members() { children.extend([Arc::new(sublayer), few.clone()]); } for (n, what) in [(&group, "a group"), (&blend, "a blend"), (&repeat, "a repeat"), (&intertwine, "an intertwine"), (&layer, "a layer")] { - if too_many_anchors([n]) != visible || too_many_marks([n]) != visible { + if too_many_anchors([n], ViewHides::default()) != visible || too_many_marks([n], ViewHides::default()) != visible { wrong.push(format!("{what}, member visible: {visible}")); } } diff --git a/crates/ui-egui/src/canvas/tests.rs b/crates/ui-egui/src/canvas/tests.rs index 00c503addb..801a5c401e 100644 --- a/crates/ui-egui/src/canvas/tests.rs +++ b/crates/ui-egui/src/canvas/tests.rs @@ -11,7 +11,7 @@ use super::artboards::names_an_artboard; use super::cursor::still_wait; use super::fill::{fill_view, polygon_area}; use super::marks::{HiddenMarks, thread_overlays}; -use super::outline::{node_outline, walk_drawn}; +use super::outline::{ViewHides, node_outline, walk_drawn}; use super::raster::{frame_view, pixel_region, placed_changes, placed_key_at, placed_since, poll_worker}; use super::*; use crate::CacheKey; @@ -31,9 +31,13 @@ fn shaper_selection_highlights_only_the_visible_result() { let g = st.doc.node(st.selection.objects[0]).unwrap(); assert!(g.extras().shaper.is_some()); let symbols = st.doc.symbol_boxes(); - let bounds = node_outline(g, &symbols).bounding_box(); + let bounds = node_outline(g, &symbols, ViewHides::default()).bounding_box(); assert!((bounds.x0 - 100.0).abs() < 0.01 && (bounds.x1 - 200.0).abs() < 0.01, "{bounds:?}"); - assert_eq!(node_outline(st.doc.node(line).unwrap(), &symbols).bounding_box().x0, 50.0, "an isolated original still shows its full outline"); + assert_eq!( + node_outline(st.doc.node(line).unwrap(), &symbols, ViewHides::default()).bounding_box().x0, + 50.0, + "an isolated original still shows its full outline" + ); } #[test] @@ -50,7 +54,7 @@ fn a_symbol_instance_is_outlined_around_its_art() { inst = Some(n); } }); - assert_eq!(node_outline(inst.unwrap(), &st.doc.symbol_boxes()).bounding_box(), Rect::new(20.0, 30.0, 40.0, 50.0)); + assert_eq!(node_outline(inst.unwrap(), &st.doc.symbol_boxes(), ViewHides::default()).bounding_box(), Rect::new(20.0, 30.0, 40.0, 50.0)); } /// One headless canvas frame on an 800 × 600 window. @@ -4537,18 +4541,18 @@ fn live_trace_selection_highlight_excludes_the_retained_source_rectangle() { for view in TraceView::ALL { group.extras_mut().trace = Some(Box::new(json!({"view":view.id()}))); let mut visited = vec![]; - walk_drawn(&group, &mut |n| visited.push(n.id)); + walk_drawn(&group, ViewHides::default(), &mut |n| visited.push(n.id)); assert_eq!(visited.contains(&NodeId(2)), view.shows_source()); let want = if view.shows_source() { vectorcraft_geom::Rect::new(0.0, 0.0, 200.0, 200.0) } else { vectorcraft_geom::Rect::new(20.0, 30.0, 80.0, 90.0) }; - assert_eq!(node_outline(&group, &symbols).bounding_box(), want); + assert_eq!(node_outline(&group, &symbols, ViewHides::default()).bounding_box(), want); } // Without a trace the image is an ordinary hidden member, which the canvas does not draw. group.extras_mut().trace = None; - assert_eq!(node_outline(&group, &symbols).bounding_box(), vectorcraft_geom::Rect::new(20.0, 30.0, 80.0, 90.0)); + assert_eq!(node_outline(&group, &symbols, ViewHides::default()).bounding_box(), vectorcraft_geom::Rect::new(20.0, 30.0, 80.0, 90.0)); // A hidden path sent to the back of a trace is not its source image, in any view. let mut path = Node::path(NodeId(4), vectorcraft_geom::shapes::rectangle(vectorcraft_geom::Rect::new(0.0, 0.0, 200.0, 200.0)), Appearance::default()); @@ -4557,7 +4561,11 @@ fn live_trace_selection_highlight_excludes_the_retained_source_rectangle() { let mut group = Node::group(NodeId(1), vec![Arc::new(path), Arc::new(art)]); for view in TraceView::ALL { group.extras_mut().trace = Some(Box::new(json!({"view":view.id()}))); - assert_eq!(node_outline(&group, &symbols).bounding_box(), vectorcraft_geom::Rect::new(20.0, 30.0, 80.0, 90.0), "{view:?}"); + assert_eq!( + node_outline(&group, &symbols, ViewHides::default()).bounding_box(), + vectorcraft_geom::Rect::new(20.0, 30.0, 80.0, 90.0), + "{view:?}" + ); } } @@ -4580,7 +4588,7 @@ fn a_compound_path_outlines_its_hidden_paths_and_a_group_does_not() { }; let doc = vectorcraft_doc::Document::new(300.0, 300.0); let symbols = doc.symbol_boxes(); - let contours = |n: &Node| node_outline(n, &symbols).elements().iter().filter(|e| matches!(e, PathEl::MoveTo(_))).count(); + let contours = |n: &Node| node_outline(n, &symbols, ViewHides::default()).elements().iter().filter(|e| matches!(e, PathEl::MoveTo(_))).count(); assert_eq!(contours(&Node::new(NodeId(1), NodeKind::Compound { children: children(), rule: FillRule::EvenOdd })), 2, "a compound path"); assert_eq!(contours(&Node::new(NodeId(1), NodeKind::Blend { children: children(), spec: Default::default() })), 1, "a blend"); assert_eq!(contours(&Node::group(NodeId(1), children())), 1, "a group");