diff --git a/crates/engine/src/cmd/buildcmds.rs b/crates/engine/src/cmd/buildcmds.rs index 0f7cac48fb..36e04ff23b 100644 --- a/crates/engine/src/cmd/buildcmds.rs +++ b/crates/engine/src/cmd/buildcmds.rs @@ -38,7 +38,7 @@ mod shape_builder; mod trace; pub use live_paint::live_paint_gaps; -pub(crate) use live_paint::{LivePaintMove, check_part_name, clear_part_name, isolated_live_paint, merge_drawn_in_isolation}; +pub(crate) use live_paint::{LivePaintMove, check_part_name, clear_part_name, isolated_live_paints, merge_drawn_in_isolation}; use live_paint::{lp_expand, lp_fill, lp_gap_options, lp_info, lp_make, lp_merge, lp_release, lp_stroke_edge}; use shape_builder::{sb_merge, sb_regions}; pub(crate) use trace::TracePresetChanges; diff --git a/crates/engine/src/cmd/buildcmds/live_paint.rs b/crates/engine/src/cmd/buildcmds/live_paint.rs index c71e1d6f32..116ea0c929 100644 --- a/crates/engine/src/cmd/buildcmds/live_paint.rs +++ b/crates/engine/src/cmd/buildcmds/live_paint.rs @@ -265,19 +265,22 @@ pub(super) fn lp_merge(s: &mut Session, p: &Value) -> Result { Ok(json!({ "id": id.0, "faces": faces, "edges": edges })) } -/// The Live Paint group whose drawn art is added when isolation mode leaves `isolated`: the innermost -/// Live Paint group that is `isolated` or holds it, such as a group drawn in an isolated Live Paint -/// group and then isolated itself. None when `isolated` is not in a Live Paint group. -pub(crate) fn isolated_live_paint(d: &Document, isolated: NodeId) -> Option { - d.ancestry(isolated)?.into_iter().rev().find(|id| d.node(*id).is_some_and(is_live_paint)) +/// The Live Paint groups whose drawn art can be added when isolation mode leaves `isolated`, innermost +/// first: every Live Paint group that is `isolated` or holds it, such as a group drawn in an isolated +/// Live Paint group and then isolated itself, and the group it was drawn in. Empty when `isolated` is +/// not in a Live Paint group. +pub(crate) fn isolated_live_paints(d: &Document, isolated: NodeId) -> Vec { + d.ancestry(isolated).unwrap_or_default().into_iter().rev().filter(|id| d.node(*id).is_some_and(is_live_paint)).collect() } /// The children of Live Paint group `g` besides its parts ([`others_in`]) that Live Paint takes /// ([`b::live_paint_takes`]) and that are shown and unlocked with everything in them, back to -/// front: the paths drawn in it in isolation mode. +/// front: the paths drawn in it in isolation mode. A Live Paint group's sources group, which is +/// always hidden, does not count. fn drawn_in(g: &Node) -> Vec { fn open(n: &Node) -> bool { - n.visible && !n.locked && n.children().is_none_or(|ch| ch.iter().all(|c| open(c))) + let src = b::sources(n).filter(|_| is_live_paint(n)).map(|s| s.id); + n.visible && !n.locked && n.children().is_none_or(|ch| ch.iter().filter(|c| Some(c.id) != src).all(|c| open(c))) } others_in(g).filter(|c| open(c) && b::live_paint_takes(c)).map(|c| c.id).collect() } diff --git a/crates/engine/src/cmd/object/arrange.rs b/crates/engine/src/cmd/object/arrange.rs index 17568d50b9..3700dd2e9e 100644 --- a/crates/engine/src/cmd/object/arrange.rs +++ b/crates/engine/src/cmd/object/arrange.rs @@ -371,16 +371,21 @@ pub(super) fn isolate(s: &mut Session, p: &Value) -> Result { } /// Leaving isolation mode in `isolated` for `next` (None: out of isolation mode) adds the paths drawn -/// in the Live Paint group isolation put new art in to that group, as `livePaint.merge` does, in one -/// undo step ([`crate::cmd::buildcmds::merge_drawn_in_isolation`]), unless `next` is that group or is -/// inside it; → the group when paths were added. +/// in each Live Paint group that is `isolated` or holds it to that group, as `livePaint.merge` does, +/// innermost group first, one undo step per group ([`crate::cmd::buildcmds::merge_drawn_in_isolation`]). +/// A group that `next` is or is inside is skipped, since isolation stays in it. → the outermost group +/// that paths were added to. fn add_drawn_live_paint(s: &mut Session, isolated: NodeId, next: Option) -> Result> { let d = &s.doc()?.doc; - let Some(g) = crate::cmd::buildcmds::isolated_live_paint(d, isolated) else { return Ok(None) }; - if next.is_some_and(|n| d.ancestry(n).is_some_and(|a| a.contains(&g))) { - return Ok(None); + let stays = next.and_then(|n| d.ancestry(n)).unwrap_or_default(); + let left: Vec = crate::cmd::buildcmds::isolated_live_paints(d, isolated).into_iter().filter(|g| !stays.contains(g)).collect(); + let mut added = None; + for g in left { + if crate::cmd::buildcmds::merge_drawn_in_isolation(s, g)? { + added = Some(g); + } } - Ok(crate::cmd::buildcmds::merge_drawn_in_isolation(s, g)?.then_some(g)) + Ok(added) } pub(super) fn exit_isolation(s: &mut Session, p: &Value) -> Result { diff --git a/crates/engine/src/cmd/object/commands.rs b/crates/engine/src/cmd/object/commands.rs index fe9c3dd533..0576dc00d9 100644 --- a/crates/engine/src/cmd/object/commands.rs +++ b/crates/engine/src/cmd/object/commands.rs @@ -250,7 +250,7 @@ pub fn specs() -> Vec { "Exit Isolation Mode", [], None, - "{} leave isolation mode; leaving an isolated Live Paint group adds the paths, compound paths and groups of them drawn in it (shown and unlocked with everything in them) to the group as livePaint.merge does, in one undo step, and leaves type, images and other objects in it as they are; object.isolate on a level outside the group does the same", + "{} leave isolation mode; leaving an isolated Live Paint group adds the paths, compound paths and groups of them drawn in it (shown and unlocked with everything in them) to the group as livePaint.merge does, in one undo step, and leaves type, images and other objects in it as they are; object.isolate on a level outside the group does the same. Leaving a Live Paint group drawn in another isolated Live Paint group, and that group too, does this for each, innermost first, one undo step each", has_doc, exit_isolation ), diff --git a/crates/engine/src/tests/build.rs b/crates/engine/src/tests/build.rs index 61a4414599..a3272f6fa9 100644 --- a/crates/engine/src/tests/build.rs +++ b/crates/engine/src/tests/build.rs @@ -5102,6 +5102,55 @@ fn live_paint_isolation_adds_a_drawn_group_isolated_inside_it() { } } +/// With Live Paint group `inner` made in isolated Live Paint group `outer` and then isolated itself, +/// leaving both levels (`object.exitIsolation`, or `object.isolate` on the layer) adds the path drawn +/// in `inner` to it and then `inner` and the path drawn directly in `outer` to `outer`, one undo step +/// each. Isolating `outer` from `inner` adds only `inner`'s drawn path, and `outer` keeps its own. +#[test] +fn live_paint_isolation_merges_nested_live_paint_groups_it_leaves() { + use vectorcraft_tools::builder::{faces, sources}; + for to in ["exit", "layer", "outer"] { + let mut s = session(); + let outer = live(&mut s); + let layer = s.doc().unwrap().doc.parent_of(outer).unwrap(); + s.execute("object.isolate", &json!({"id": outer.0})).unwrap(); + let a = line_across(&mut s, 50.0); + assert_eq!(s.doc().unwrap().doc.parent_of(a), Some(outer)); + let inner = live(&mut s); + assert_eq!(s.doc().unwrap().doc.parent_of(inner), Some(outer), "the inner group is drawn in the outer one"); + s.execute("object.isolate", &json!({"id": inner.0})).unwrap(); + let b = line_across(&mut s, 30.0); + assert_eq!(s.doc().unwrap().doc.parent_of(b), Some(inner)); + let steps = s.doc().unwrap().history.undo.len(); + match to { + "exit" => s.execute("object.exitIsolation", &json!({})).unwrap(), + "layer" => s.execute("object.isolate", &json!({"id": layer.0})).unwrap(), + _ => s.execute("object.isolate", &json!({"id": outer.0})).unwrap(), + }; + let d = &s.doc().unwrap().doc; + if to == "outer" { + assert_eq!(s.doc().unwrap().isolation, Some(outer)); + assert_eq!(s.doc().unwrap().history.undo.len(), steps + 1, "only the inner group's path joins"); + let n = node(&s, inner); + assert_eq!(d.parent_of(b), Some(sources(&n).unwrap().id), "the path drawn in the inner group joined it"); + assert_eq!(d.parent_of(inner), Some(outer), "the inner group stays drawn in the outer one"); + assert_eq!(d.parent_of(a), Some(outer), "the path drawn in the outer group stays as drawn"); + continue; + } + assert_eq!(s.doc().unwrap().history.undo.len(), steps + 2, "{to}: one undo step for each group"); + assert!(d.node(inner).is_none(), "{to}: the inner group joined the outer one"); + let n = node(&s, outer); + let src = sources(&n).unwrap().id; + assert_eq!(d.parent_of(a), Some(src), "{to}: the path drawn in the outer group joined it"); + assert!(d.ancestry(b).unwrap().contains(&src), "{to}: the path drawn in the inner group is among the outer group's paths"); + assert!(n.children().unwrap().iter().all(|c| c.id == src || c.path_data().is_some()), "{to}: only parts are left in the outer group"); + assert!(faces(&n).len() > 3, "{to}: the added paths cut the outer group's faces"); + if to == "exit" { + assert_eq!(s.doc().unwrap().selection.objects, vec![outer]); + } + } +} + /// A line from left of the [`live`] group to its right face, so it cuts the two faces left of it. fn line_to_right_face(s: &mut Session, y: f64) -> NodeId { let r = s.execute("path.create", &json!({"anchors": [{"x": -10, "y": y}, {"x": 105, "y": y}]})).unwrap(); diff --git a/docs/mcp.md b/docs/mcp.md index 1d24ac803a..30fb854f19 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -5435,7 +5435,8 @@ and `layerRows`, the rows highlighted in the panel. Paint group (`object.exitIsolation`, or `object.isolate` on a level outside it) adds the paths, compound paths and groups of them drawn in it, shown and unlocked with everything in them, to the group as `livePaint.merge` does, in one undo step; type, images and other objects stay in it as they are, and with nothing drawn no undo step is - recorded. Face and Edge are the names of a Live Paint group's faces and edges: `layer.setProps` and + recorded. When the isolated Live Paint group was drawn in another isolated Live Paint group, leaving both does this + for each group, innermost first, one undo step each, so the inner group joins the outer one. Face and Edge are the names of a Live Paint group's faces and edges: `layer.setProps` and `object.setProps` return an error when they would give either name to another path directly in the group, and a path pasted directly into the group under either name loses its name. - **Dialogs and panel state** (control channel and the app's MCP): `ui.layerOptions {ids?}` and `ui.newLayer diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 47c5b83267..af36070752 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1688,7 +1688,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - Create Strokes decides stroke or fill per feature, as the [help page](https://helpx.adobe.com/illustrator/desktop/manage-objects/traces-mockups-symbols/image-trace-panel-options.html) describes the Strokes width: the widest feature of the image that can become a stroke. A shape wider than Stroke somewhere keeps as its area every disc wider than Stroke that fits in it, and each piece outside those discs that reaches out of them at least one and a half times its own width (and 3 px) is traced as a stroked center line, its end at the area carried to the cut so the line's cap closes the join. Corners and edge slivers stay in the area. Which pieces count as features is VectorCraft's own rule. Each line still has one width; without Fills, the area is a 1 px outline as before. Tests: `thin_features_of_a_wide_shape_are_strokes_and_its_body_a_fill`, `wide_shapes_without_thin_features_stay_one_fill` and `distances_to_seeds_equal_brute_force` in `vectorcraft-trace`. The Image Trace score and estimates are unchanged. - The ignored centre-lines class measures that split on a mixed-width body scene: one disc with arms of 2, 3 and 5 px, at Stroke 6 px, traces as three stroked paths and one filled path in both the anti-aliased and hard input, with 100.0% of the arms' center samples found and 99.3% (anti-aliased) and 98.3% (hard) of the disc's pixels filled ([quality notes](image-trace-quality.md#centre-lines)). Test: `mixed_width_body_is_one_shape_traced_as_a_fill_and_strokes` in `vectorcraft-trace`. The Image Trace score and estimates are unchanged. Object › Live Paint › Merge adds the other selected paths and Live Paint groups to the bottom selected Live Paint group ([Live Paint groups](https://web.archive.org/web/20241230205225/https://helpx.adobe.com/illustrator/using/live-paint-groups.html)), which keeps its id, the paint of its faces and edges, and its name, lock, visibility, transparency, appearance, opacity mask and graphic style link. Object › Live Paint › Make with a Live Paint group selected, and a Live Paint Bucket click on a selected path beside a selected Live Paint group, add the paths to that group the same way. Make, Merge and the Live Paint Bucket take paths, compound paths and groups of them; with type, an image or another object among the selection they report that it has to be converted to paths first and change nothing, as type and raster images can't go into a Live Paint group directly ([Create Live Paint groups](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/learn-painting-basics/create-live-paint-groups.html)); before, such an object went among the group's hidden sources and vanished from the canvas. Evidence: `tests_build::live_paint_refuses_type_and_images_and_changes_nothing`. - Paths drawn in an isolated Live Paint group join it when isolation mode ends, as the [help page](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/learn-painting-basics/modify-live-paint-groups.html) describes: drawing paths in the isolated group and pressing Esc adds them. `object.exitIsolation` (Esc, the Control bar and isolation bar exits, a double-click outside, the Layers panel and the canvas context menu) adds the shown, unlocked paths, compound paths and groups of them drawn in the group as Merge does, in one undo step, and `object.isolate` on a level outside the group does the same. As VectorCraft's own rules, type, images, hidden and locked objects drawn there, and groups holding one, stay in the group as they are, and Gap Options, Merge and Release keep them; an exit with nothing drawn records no undo step. Evidence: `tests::build::{live_paint_isolation_adds_drawn_paths_on_exit, live_paint_isolation_adds_only_paths_it_takes, live_paint_isolation_leaves_a_group_holding_a_locked_path, live_paint_isolation_adds_drawn_paths_when_isolating_a_level_outside, live_paint_isolation_adds_a_drawn_group_isolated_inside_it, live_paint_isolation_keeps_art_named_like_its_parts, live_paint_keeps_type_drawn_in_it_through_gap_options_merge_and_release}`. + Paths drawn in an isolated Live Paint group join it when isolation mode ends, as the [help page](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/learn-painting-basics/modify-live-paint-groups.html) describes: drawing paths in the isolated group and pressing Esc adds them. `object.exitIsolation` (Esc, the Control bar and isolation bar exits, a double-click outside, the Layers panel and the canvas context menu) adds the shown, unlocked paths, compound paths and groups of them drawn in the group as Merge does, in one undo step, and `object.isolate` on a level outside the group does the same. As VectorCraft's own rules, type, images, hidden and locked objects drawn there, and groups holding one, stay in the group as they are, and Gap Options, Merge and Release keep them; an exit with nothing drawn records no undo step; leaving a Live Paint group drawn in another isolated Live Paint group, and that group too, adds the drawn paths to each, innermost first, one undo step each. Evidence: `tests::build::{live_paint_isolation_adds_drawn_paths_on_exit, live_paint_isolation_adds_only_paths_it_takes, live_paint_isolation_leaves_a_group_holding_a_locked_path, live_paint_isolation_adds_drawn_paths_when_isolating_a_level_outside, live_paint_isolation_adds_a_drawn_group_isolated_inside_it, live_paint_isolation_merges_nested_live_paint_groups_it_leaves, live_paint_isolation_keeps_art_named_like_its_parts, live_paint_keeps_type_drawn_in_it_through_gap_options_merge_and_release}`. Paths dragged into a Live Paint group in the Layers panel join it, as the [help page](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/learn-painting-basics/modify-live-paint-groups.html) describes for adding paths to a group; older guides ([CS6, page 192](https://helpx.adobe.com/pdf/cs6/illustrator_reference.pdf#page=192)) say several paths can be dragged at once. A drop inside the group, or above or below one of its rows (`layer.move`, and `node.move` into the group), adds the paths, compound paths, groups of them and Live Paint groups to it as Merge does, in one "Merge Live Paint" undo step that selects the group; an Alt-drag adds copies. As VectorCraft's own rules, type, an image or another object among the dragged rows refuses the whole drop with Merge's message, and a row dragged into or out of the group's hidden sources makes its faces and edges again, keeping the paint of those that stay; with no path left the group has no faces until a path joins it. Evidence: `tests::build::{layers_drag_adds_paths_to_a_live_paint_group, layers_drag_copy_and_drop_beside_a_part_add_to_a_live_paint_group, layers_drag_refuses_type_into_a_live_paint_group, layers_drag_out_of_a_live_paint_group_makes_its_faces_again}`. With the Live Paint Bucket selected, Alt-click on vector art samples its fill, stroke and stroke weight into the paint defaults ([Paint with the Live Paint Bucket tool](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/learn-painting-basics/paint-with-the-live-paint-bucket-tool.html)). On a placed image it samples the image pixel as a solid fill with no stroke. Alt+Shift-click samples only the color under the pointer, including an intermediate gradient color or image pixels, into the active fill or stroke ([Default keyboard shortcuts](https://helpx.adobe.com/illustrator/using/default-keyboard-shortcuts.html)). Neither click paints or changes the selection or selected art, and the next Bucket click paints with the sampled paint. Evidence: `tests_build::live_paint_bucket_alt_sample_paints_next_face_without_changing_selection`. Double-clicking the Live Paint Bucket opens Live Paint Bucket Options ([Paint with the Live Paint Bucket tool](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/learn-painting-basics/paint-with-the-live-paint-bucket-tool.html)): Paint Fills (on) and Paint Strokes (off) set whether a click paints faces, edges or both, Highlight turns the outline of the face or edge under the pointer on or off, and Color and Width set it (red and 4 px by default). Faces are outlined at the Width and edges at half of it, as the page says faces are highlighted with a thick line and edges with a thin line. With both on, a click paints the edge within 4 px of the pointer, else the face, and Shift switches to Paint Fills only; with one on, Shift switches to the other. The options last across tool switches and are saved with the preferences (`tool.setOption {tool: "livePaintBucket"}`). Evidence: `builder::tests::{bucket_options_choose_what_a_click_paints, bucket_options_set_the_highlight, bucket_highlights_an_edge_thinner_than_a_face}`, `dialogs::live_paint_bucket::tests::double_clicking_the_tool_opens_its_options_and_ok_sets_them`.