#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:
HassanKhan
2026-11-18 16:15:04 +05:00
parent 799d95f900
commit 41f7d4e06a
18 changed files with 181 additions and 162 deletions
-1
View File
@@ -637,7 +637,6 @@ fn transform_each_as(s: &mut Session, p: &Value, label: &str) -> Result<Value> {
let mut rng = Rng(whole_or(p, "seed", 0x9E37_79B9_7F4A_7C15, "object.transformEach")?.max(1));
let mut sc = if !relative || sh != Some(100.0) || sv != Some(100.0) { super::object::scaling(s, p) } else { Default::default() };
sc.patterns = super::object::transform_patterns(s, p, &roots)?;
sc.keep_guides = super::object::keeps_guides(s, copy);
// With no object to transform, or without a copy when nothing would change (both scales 100%
// or, with Absolute, the size each object already has, and no move, rotation or reflection,
// with or without Random), the document and its undo history stay as they are.
+1 -1
View File
@@ -41,5 +41,5 @@ pub(crate) use pixelgrid::{
snap_if_aligned, snap_symbol_art,
};
pub(super) use shape::recut;
pub(crate) use transform::{apply_transform, keeps_guides, preview_copies, scaling, transform_node, transform_patterns, transforms_objects};
pub(crate) use transform::{apply_transform, preview_copies, scaling, transform_node, transform_patterns, transforms_objects};
pub use transform::{reflect_axis, scale_factors, shear_tangent};
+2 -3
View File
@@ -1,4 +1,4 @@
use super::transform::{keeps_guides, transform_patterns};
use super::transform::transform_patterns;
use super::{
Affine, Document, EngineError, NodeId, OrientedBox, Point, Rect, Result, Scaling, Session, Value, Vec2, bad, check_numbers, check_switches,
effects, has_multi, ok, selected_roots, str_param,
@@ -107,8 +107,7 @@ fn items_bounds(d: &Document, ids: &[NodeId], m: Measure) -> Vec<(NodeId, Rect)>
/// so for `ids`. When every move is a rounding error (1e-9 pt or less on both axes), the document
/// and its undo history stay as they are.
fn apply_moves(s: &mut Session, label: &str, p: &Value, ids: &[NodeId], moves: &[(NodeId, Vec2)], guides: &[(NodeId, f64)]) -> Result<Value> {
// Locked guides inside the groups moved stay where they are, as a move leaves them (#8538).
let sc = Scaling { patterns: transform_patterns(s, p, ids)?, keep_guides: keeps_guides(s, false), ..Scaling::default() };
let sc = Scaling { patterns: transform_patterns(s, p, ids)?, ..Scaling::default() };
let guides: Vec<(NodeId, f64)> = {
let d = &s.doc()?.doc;
guides.iter().copied().filter(|&(i, pos)| d.ruler_guide(i).is_some_and(|g| (g.pos - pos).abs() > 1e-9)).collect()
@@ -65,13 +65,6 @@ pub(crate) fn transforms_objects(p: &Value) -> bool {
bool_or(p, "objects", true)
}
/// Do the locked guides inside the groups a transform moves stay where they are
/// ([`Scaling::keep_guides`])? While View › Guides › Lock Guides is on, unless the transform makes
/// copies: the original guides stay then, and the copies go with the copied art (#8538).
pub(crate) fn keeps_guides(s: &Session, copy: bool) -> bool {
s.menu.guides_locked && !copy
}
/// The on/off params of the transform commands that [`apply_transform`], [`scaling`],
/// [`transform_patterns`] and [`transforms_objects`] read. The transform commands in this file
/// check them with [`check_switches`] before they change anything.
@@ -118,7 +111,6 @@ fn apply_transform_moving_guides(
let objects = transforms_objects(p);
let mut sc = if Scaling::factor(xf).is_some() { scaling(s, p) } else { Scaling::default() };
sc.patterns = transform_patterns(s, p, &ids)?;
sc.keep_guides = keeps_guides(s, copy);
let c = xf.as_coeffs();
let is_translation = (c[0] - 1.0).abs() < 1e-9 && c[1].abs() < 1e-9 && c[2].abs() < 1e-9 && (c[3] - 1.0).abs() < 1e-9;
let delta = guides.unwrap_or(Vec2::new(c[4], c[5]));
-47
View File
@@ -4442,53 +4442,6 @@ fn locked_guides_lock_guide_paths() {
assert_eq!(selected(&s), vec![b]);
}
/// #8538: while guides are locked, a transform of a group leaves the guide paths in it where they
/// are and transforms its other members: a move, Transform Each and Align. A copy leaves the
/// original guide and takes a copy of it with the copied group. With guides unlocked, the guide
/// moves with its group.
#[test]
fn transforming_a_group_leaves_its_locked_guide_paths_in_place() {
let mut s = session();
let (guide, x) = (rect(&mut s, 0.0, 0.0, 10.0, 10.0), rect(&mut s, 20.0, 0.0, 10.0, 10.0));
sel(&mut s, &[guide, x]);
let g = id_of(&s.execute("object.group", &json!({})).unwrap());
sel(&mut s, &[guide]);
s.execute("view.guides.make", &json!({})).unwrap();
s.execute("view.guides.lock", &json!({"locked": true})).unwrap();
sel(&mut s, &[g]);
assert_eq!(selected(&s), vec![g], "the group stays selected");
let x0 = |s: &Session| (bounds(s, guide).x0, bounds(s, x).x0);
s.execute("object.move", &json!({"dx": 50, "dy": 0})).unwrap();
assert_eq!(x0(&s), (0.0, 70.0), "a move");
s.execute("object.transformEach", &json!({"moveH": 10})).unwrap();
assert_eq!(x0(&s), (0.0, 80.0), "Transform Each");
s.execute("object.align", &json!({"horizontal": "right", "to": "artboard"})).unwrap();
assert_eq!(bounds(&s, guide).x0, 0.0, "Align");
let after_align = bounds(&s, x).x0;
assert_ne!(after_align, 80.0, "Align moves the art");
// A copy: the original guide stays, the copy's guide goes with the copied group.
let guides = |s: &Session| {
let mut out = vec![];
for l in &s.doc().unwrap().doc.layers {
l.walk(&mut |n| {
if matches!(n.kind, NodeKind::Path { guide: true, .. }) {
out.push(n.id);
}
});
}
out
};
s.execute("object.move", &json!({"dx": 0, "dy": 50, "copy": true})).unwrap();
let copied: Vec<NodeId> = guides(&s).into_iter().filter(|id| *id != guide).collect();
assert_eq!(copied.len(), 1);
assert_eq!((bounds(&s, guide).y0, bounds(&s, copied[0]).y0), (0.0, 50.0), "a copy");
// Unlocked, the guide moves with its group.
s.execute("view.guides.lock", &json!({"locked": false})).unwrap();
sel(&mut s, &[g]);
s.execute("object.move", &json!({"dx": 5, "dy": 0})).unwrap();
assert_eq!(x0(&s), (5.0, after_align + 5.0), "unlocked");
}
/// A rectangle at (`x`, 0), 10 pt wide, made into a guide; nothing is selected after.
fn guide_path(s: &mut Session, x: f64) -> NodeId {
let g = rect(s, x, 0.0, 10.0, 10.0);