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.
This commit is contained in:
dotCooCoo committed 2026-11-22 19:21:52 -08:00
1 parent b232fd8e96
commit 1612f363c5
5 files changed
+57 -43

No files matched your search

+20 -5
View File
@@ -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<Node>] {
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<Item = &Arc<Node>> {
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<Node>> {
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<Rect> {
+3 -18
View File
@@ -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<Vec<Pos2>> {
@@ -165,7 +163,7 @@ fn over_limit<'a>(nodes: impl IntoIterator<Item = &'a Node>, 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<Item = &Arc<Node>> {
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);
}
}
@@ -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.
+9 -6
View File
@@ -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<Arc<Node>>| 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();
+1 -1
View File
@@ -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.