Outline view: a group measures a Preview-off sublayer in the sublayer's mode

A layer whose Preview is off draws a placed document in it as the crossed
box, and effects that change geometry reshape that box. Two cull-bounds
paths measured such a sublayer in the mode around it instead:

- A group with effects of its own (a drop shadow, for example) is measured
  by fx::cull_bounds, which did not enter each layer's own mode. The group
  was culled where the sublayer's moved crossed box was in view. Each layer
  in that walk is now measured in the mode its Layer Options give it.
- A group's cached bounds were keyed only on whether placed documents are
  crossed. Turning Show Images in Outline Mode on or off changes a
  Preview-off sublayer's mode without changing that, so the group kept its
  old bounds. Every object other than a path is now keyed on the full
  layer mode.
This commit is contained in:
dotCooCoo committed 2026-11-28 00:54:53 -08:00
1 parent 3c7a3c7904
commit e8ab35ad0c
3 files changed
+60 -10

No files matched your search

+3
View File
@@ -672,6 +672,9 @@ pub(crate) fn path_cull_bounds(symbols: &SymbolBoxes, n: &Node, visual: impl FnO
/// linear part. With `brush` true, the members of a group or layer are measured with the room
/// their brushed strokes leave for brush art ([`member_cull_bounds`]).
fn cull_bounds_in(symbols: &SymbolBoxes, n: &Node, after_reshape: bool, brush: bool) -> Option<Rect> {
// A layer is measured in the mode its Layer Options draw it in, as the renderer measures the
// members of a group or layer without effects ([`crate::Renderer::bounds_of`]).
let _mode = crate::placed_document::enter_layer(n);
let inner = |c: &Node| cull_bounds_in(symbols, c, after_reshape, false);
let member = |c: &Node| member_cull_bounds(symbols, c, after_reshape, brush);
// The art that a group's or layer's crop marks or Vector Halftone draw holds its members. The
+6 -10
View File
@@ -7,22 +7,18 @@ use super::{
use crate::kept_paths::{self, KeptPath};
use crate::node_checks::{holds_measured_three_d, measures_three_d};
use crate::placed_document::{InMode, LayerMode, enter_layer};
use vectorcraft_doc::placed_document::crossed;
/// The key of `a`'s cull bounds in [`Renderer::geom`]: its address, and in its lowest bits what the
/// bounds depend on besides `a`. For a layer that is the mode its sublayers are measured in
/// ([`LayerMode`], [`enter_layer`]); for an object other than a path, whether placed documents are
/// crossed ([`vectorcraft_doc::placed_document::Crossed`]), since the art its effects make from a
/// placed document in it is the crossed box then. A node's address is aligned to 8 bytes, so no
/// other node has that key.
/// bounds depend on besides `a`. For an object other than a path that is the mode it is measured in
/// ([`LayerMode`]): it sets the mode of the layers in it ([`enter_layer`]), a group's included, and
/// whether placed documents are crossed ([`vectorcraft_doc::placed_document::Crossed`]), since the
/// art its effects make from a placed document in it is the crossed box then. Placed documents are
/// crossed only in a mode. A node's address is aligned to 8 bytes, so no other node has that key.
fn geom_key(a: &Node) -> usize {
let at = std::ptr::from_ref(a) as usize;
match a.kind {
NodeKind::Path { .. } | NodeKind::Compound { .. } => at,
NodeKind::Layer { .. } => {
at | LayerMode::now().map_or(0, |m| usize::from(m.options) | usize::from(m.outline) << 1 | usize::from(m.images) << 2)
}
_ => at | usize::from(crossed()),
_ => at | LayerMode::now().map_or(0, |m| usize::from(m.options) | usize::from(m.outline) << 1 | usize::from(m.images) << 2),
}
}
@@ -335,6 +335,57 @@ fn outline_mode_draws_the_crossed_box_its_effects_move_into_view_after_a_preview
assert!(r.pixel(30, 5)[0] < 200, "the moved box is drawn crossed in a sublayer whose Preview is off");
}
#[test]
fn a_group_is_measured_again_when_show_images_in_outline_mode_changes_for_a_sublayer_in_it() {
// As above, in a sublayer whose Preview is off, held in a group. With Show Images in Outline
// Mode the file that can't be read draws nothing; turned off, the sublayer draws the moved box
// crossed, and the same renderer measures the group again.
let mut d = doc_with("outline-cull-2", b"bad");
let params = serde_json::json!({"moveV": 40});
d.node_mut(NodeId(50)).unwrap().appearance.effects.push(vectorcraft_doc::Effect { id: "distort.transform".into(), params, visible: true });
let placed = d.remove(NodeId(50)).unwrap();
let mut sub = Node::layer(NodeId(90), "Sublayer", vectorcraft_doc::LayerColor::Preset(1));
if let NodeKind::Layer { children, preview, .. } = &mut sub.kind {
children.push(placed);
*preview = false;
}
let l = d.layers[0].id;
d.insert(Some(l), 0, Node::group(NodeId(91), vec![Arc::new(sub)])).unwrap();
let view = Affine::translate((0.0, -55.0));
let preview = RenderOptions { background: Some([255, 255, 255, 255]), ..Default::default() };
let mut r = Renderer::new();
d.setup.outline_images = true;
r.render(&d, 100, 100, view, &preview);
d.setup.outline_images = false;
let crossed = r.render(&d, 100, 100, view, &preview);
assert!(crossed.pixel(30, 5)[0] < 200, "the moved box is drawn crossed");
assert!(crossed.pixels == Renderer::new().render(&d, 100, 100, view, &preview).pixels, "as a new renderer draws it");
}
#[test]
fn a_group_with_a_drop_shadow_measures_a_sublayer_in_it_in_the_sublayers_own_mode() {
// As above, in a sublayer whose Preview is off, held in a group with a Drop Shadow effect: the
// sublayer draws the moved box crossed, and the group's cull bounds reach it.
let mut d = doc_with("outline-cull-3", b"bad");
let params = serde_json::json!({"moveV": 40});
d.node_mut(NodeId(50)).unwrap().appearance.effects.push(vectorcraft_doc::Effect { id: "distort.transform".into(), params, visible: true });
let placed = d.remove(NodeId(50)).unwrap();
let mut sub = Node::layer(NodeId(90), "Sublayer", vectorcraft_doc::LayerColor::Preset(1));
if let NodeKind::Layer { children, preview, .. } = &mut sub.kind {
children.push(placed);
*preview = false;
}
let shadow = serde_json::json!({"x": 0, "y": 0, "blur": 0, "opacity": 0});
let mut g = Node::group(NodeId(91), vec![Arc::new(sub)]);
g.appearance.effects.push(vectorcraft_doc::Effect { id: "stylize.dropShadow".into(), params: shadow, visible: true });
let l = d.layers[0].id;
d.insert(Some(l), 0, g).unwrap();
let view = Affine::translate((0.0, -55.0));
let preview = RenderOptions { background: Some([255, 255, 255, 255]), ..Default::default() };
let r = Renderer::new().render(&d, 100, 100, view, &preview);
assert!(r.pixel(30, 5)[0] < 200, "the moved box is drawn crossed in a group with a drop shadow");
}
#[test]
fn an_edit_in_outline_mode_redraws_where_the_effects_move_the_crossed_box() {
// A file that can't be read, in the box (10, 10)–(90, 50): a Transform effect added to it moves