mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-19 05:35:49 +00:00
#8538 review: drop kept guides on transform, finish the marquee rule
A transform no longer leaves locked guide paths in place: a guide in a group moves with its group again, as on main. Keeping them put made Align, Transform Each, the pixel-grid snap and Objects on Path measure or place art the transform did not move. Scaling::keep_guides and its engine wiring and test are removed. The marquee rule now covers the rest of the selection side, while guides are locked or hidden: - the guide rule goes down the walk as an explicit Rules value instead of a thread-local guard; - an Enclosing Lasso loop does not take a compound path for its guide contours; - an enclosing marquee measures a group without its guide paths (Node::without_guides); - Direct Selection's marquee takes no anchor or crossed segment of a guide path. Docs: the Guides area row, its evidence entry and the M1 row describe the marquee behaviour; status lines and revision rows say a guide in a group still moves with it.
This commit is contained in:
@@ -375,10 +375,6 @@ pub struct Scaling {
|
||||
/// a point (no area left), as a Transform effect leaves them, instead of being fixed to their
|
||||
/// fit and flattened to one color with the object.
|
||||
pub keep_fit_when_flat: bool,
|
||||
/// The paths made into guides inside a transformed group, layer or Intertwine group stay
|
||||
/// where they are, as a ruler guide in a transformed layer does: View › Guides › Lock Guides
|
||||
/// is on (#8538). A guide transformed by itself still moves.
|
||||
pub keep_guides: bool,
|
||||
}
|
||||
|
||||
impl Scaling {
|
||||
|
||||
@@ -90,6 +90,42 @@ impl Node {
|
||||
matches!(self.kind, NodeKind::RulerGuide { .. } | NodeKind::Path { guide: true, .. })
|
||||
}
|
||||
|
||||
/// This object without the paths made into guides among the members of its groups, layers,
|
||||
/// Intertwine groups and compound paths, at any depth, for measuring the art around them while
|
||||
/// Lock Guides or Hide Guides leaves them out (#8538). The clipping path of a clip group or
|
||||
/// layer and the original shapes of a Shaper group stay, guides or not, so the object keeps
|
||||
/// its structure. `None` when it holds no such guide.
|
||||
pub fn without_guides(&self) -> Option<Node> {
|
||||
let (NodeKind::Layer { children, .. }
|
||||
| NodeKind::Group { children, .. }
|
||||
| NodeKind::Intertwine { children }
|
||||
| NodeKind::Compound { children, .. }) = &self.kind
|
||||
else {
|
||||
return None;
|
||||
};
|
||||
let keep = usize::from(self.clips() || self.extras().shaper.is_some());
|
||||
let mut changed = false;
|
||||
let mut out = Vec::with_capacity(children.len());
|
||||
for (i, c) in children.iter().enumerate() {
|
||||
if i >= keep && matches!(c.kind, NodeKind::Path { guide: true, .. }) {
|
||||
changed = true;
|
||||
} else if let Some(stripped) = c.without_guides() {
|
||||
changed = true;
|
||||
out.push(Arc::new(stripped));
|
||||
} else {
|
||||
out.push(c.clone());
|
||||
}
|
||||
}
|
||||
if !changed {
|
||||
return None;
|
||||
}
|
||||
let mut n = self.clone();
|
||||
if let Some(c) = n.children_mut() {
|
||||
*c = out;
|
||||
}
|
||||
Some(n)
|
||||
}
|
||||
|
||||
/// A template layer (Layer Options → Template).
|
||||
pub fn is_template(&self) -> bool {
|
||||
matches!(self.kind, NodeKind::Layer { template: true, .. })
|
||||
@@ -527,13 +563,10 @@ impl Node {
|
||||
}
|
||||
}
|
||||
}
|
||||
NodeKind::Layer { children, .. } | NodeKind::Group { children, .. } | NodeKind::Intertwine { children } => {
|
||||
// Locked guides stay where they are ([`Scaling::keep_guides`]).
|
||||
for c in children.iter_mut().filter(|c| !(sc.keep_guides && matches!(c.kind, NodeKind::Path { guide: true, .. }))) {
|
||||
Arc::make_mut(c).transform_scaled(a, sc);
|
||||
}
|
||||
}
|
||||
NodeKind::Compound { children, .. } => {
|
||||
NodeKind::Layer { children, .. }
|
||||
| NodeKind::Group { children, .. }
|
||||
| NodeKind::Compound { children, .. }
|
||||
| NodeKind::Intertwine { children } => {
|
||||
for c in children.iter_mut() {
|
||||
Arc::make_mut(c).transform_scaled(a, sc);
|
||||
}
|
||||
|
||||
@@ -227,15 +227,8 @@ fn assert_round_corners(n: &Node, back: Affine, r: f64) {
|
||||
}
|
||||
}
|
||||
|
||||
const KEEP_CORNERS: Scaling = Scaling {
|
||||
strokes: false,
|
||||
effects: None,
|
||||
keep_type_strokes: false,
|
||||
keep_corners: true,
|
||||
patterns: false,
|
||||
keep_fit_when_flat: false,
|
||||
keep_guides: false,
|
||||
};
|
||||
const KEEP_CORNERS: Scaling =
|
||||
Scaling { strokes: false, effects: None, keep_type_strokes: false, keep_corners: true, patterns: false, keep_fit_when_flat: false };
|
||||
|
||||
#[test]
|
||||
fn uneven_scales_keep_live_corners_circular() {
|
||||
|
||||
Reference in New Issue
Block a user