Fix #1450: the Pathfinder panel works on a group selected alone

This commit is contained in:
bflatastic
2026-10-13 02:54:08 +07:00
parent e74cb01ecc
commit 7625feea08
16 changed files with 53 additions and 4 deletions
+3 -1
View File
@@ -343,10 +343,12 @@ fn run_pf(s: &mut Session, op: PathfinderOp) -> Result<Value> {
continue;
}
if shape_mode
&& roots.len() > 1
&& lv.len() > 1
&& let Some(top) = lv.last()
{
// A group acts as one shape (the union of its leaves) with its top leaf's style.
// Among other objects, a group acts as one shape (the union of its leaves) with
// its top leaf's style. Selected alone, its members are the shapes (#1450).
let parts: Vec<(PathData, FillRule)> = lv.iter().filter_map(node_path).collect();
let refs: Vec<(&PathData, FillRule)> = parts.iter().map(|(p, r)| (p, *r)).collect();
let name = n.name.clone().or_else(|| lv.iter().find_map(|l| l.name.clone()));
+14
View File
@@ -191,6 +191,20 @@ fn pathfinder_undo_restores() {
assert!(s.doc().unwrap().selection.contains(a) && s.doc().unwrap().selection.contains(b));
}
/// #1450: a group selected alone gives the shape modes its members to work on.
#[test]
fn a_group_selected_alone_is_combined_member_by_member() {
let mut s = session();
let a = rect(&mut s, 0.0, 0.0, 20.0, 20.0);
let b = rect(&mut s, 10.0, 0.0, 20.0, 20.0);
s.execute("select.set", &json!({"ids": [a.0, b.0]})).unwrap();
s.execute("object.group", &json!({})).unwrap();
assert_eq!(s.doc().unwrap().selection.len(), 1);
let id = s.execute("object.pathfinder.minusFront", &json!({})).unwrap()["ids"][0].as_u64().unwrap();
let bounds = s.doc().unwrap().doc.node(NodeId(id)).unwrap().geometric_bounds().unwrap();
assert_eq!((bounds.x0, bounds.x1), (0.0, 10.0), "the back member less the front one");
}
#[test]
fn unite_with_group() {
let mut s = session();