Pathfinder panel: a group selected alone counts its nested shapes, so an expanded stroke keeps the Shape Modes enabled (fixes #1635)

This commit is contained in:
Marco Arnulfo
2026-10-14 02:09:07 +07:00
committed by bflatastic
parent 359d9bb833
commit 7ea75b01ba
3 changed files with 45 additions and 4 deletions
+3
View File
@@ -493,6 +493,9 @@ pub use flatten::FlattenOptions;
/// A built-in or saved flattener preset ([`crate::Prefs::flattener_presets`]).
pub use flatten::FlattenerPreset;
/// The shapes a group selected alone gives the Pathfinder panel.
pub use pathops::shape_count;
/// Command ids kept only so older scripts keep working: `(alias, the command it duplicates)`.
/// They run as before but the command palette leaves them out (it lists the command once).
pub const ALIASES: &[(&str, &str)] = &[("object.convertDocumentColorMode", "file.documentColorMode")];
+8
View File
@@ -258,6 +258,14 @@ fn leaves(n: &Node, out: &mut Vec<Node>) {
}
}
/// How many shapes a Pathfinder operation takes from `n` selected alone: its leaf shapes, however
/// deep its groups nest (an expanded stroke is a group inside the group, #1635).
pub fn shape_count(n: &Node) -> usize {
let mut lv = vec![];
leaves(n, &mut lv);
lv.len()
}
/// A node for `path`: a plain path for one subpath, else a compound path.
pub(crate) fn shape_node(d: &mut Document, path: PathData, style_src: Option<&Node>) -> Node {
let id = d.alloc_id();