Fix Outline Stroke eligibility for nonpainting point strokes

Reject plain butt-capped paths whose used segment points all coincide, without expanding stroke geometry at menu time.
Retain dimension and compound-root protections plus conservative brush, profile, arrowhead and geometry-effect handling.
Add real context-menu coverage for open/closed point paths with butt, round and square caps, asserting resulting filled area.
This commit is contained in:
Taha-Mahmoodi committed 2026-11-26 14:23:29 +04:30
1 parent bd24c61a5a
commit 8607a4d195
4 files changed
+68 -3

No files matched your search

+29 -1
View File
@@ -1147,6 +1147,21 @@ pub(crate) fn outlinable(st: &StrokeLayer) -> bool {
st.visible && !st.paint.is_none() && st.width > 0.0
}
/// Whether any segment can paint a butt-capped stroke. Check only used control points:
/// coincident endpoints can still describe a curve, but unused open-end handles cannot.
fn may_paint_butt_stroke(n: &Node) -> bool {
match &n.kind {
NodeKind::Path { path, .. } => path.subpaths.iter().any(|sp| {
(0..sp.segment_count()).any(|i| {
let c = sp.segment(i);
c.p0 != c.p3 || c.p0 != c.p1 || c.p0 != c.p2
})
}),
NodeKind::Compound { children, .. } => children.iter().any(|c| may_paint_butt_stroke(c)),
_ => false,
}
}
/// Does Outline Stroke have a stroke to turn into art under `n`, outside the dimension subtrees
/// the command will keep? Guides, clipping paths and type are not outlined.
fn has_outlinable_stroke(n: &Node, kept: &[NodeId]) -> bool {
@@ -1156,7 +1171,20 @@ fn has_outlinable_stroke(n: &Node, kept: &[NodeId]) -> bool {
match &n.kind {
NodeKind::Path { guide: true, .. } | NodeKind::Path { clipping: true, .. } => false,
NodeKind::Path { .. } | NodeKind::Compound { .. } => {
n.appearance.items.iter().any(|i| matches!(i, AppearanceItem::Stroke(st) if outlinable(st)))
let geometry = std::cell::LazyCell::new(|| may_paint_butt_stroke(n));
n.appearance.items.iter().any(|i| {
let AppearanceItem::Stroke(st) = i else { return false };
// Brushes, arrowheads, profiles and geometry effects can make a point paint.
outlinable(st)
&& (st.cap != vectorcraft_doc::LineCap::Butt
|| st.brush.is_some()
|| st.start_arrow.is_some()
|| st.end_arrow.is_some()
|| st.profile.is_some()
|| vectorcraft_render::effects::has_geometry(&n.appearance.effects)
|| vectorcraft_render::effects::has_geometry(&st.effects)
|| *geometry)
})
}
NodeKind::Group { children, .. } | NodeKind::Layer { children, .. } => children.iter().any(|c| has_outlinable_stroke(c, kept)),
_ => false,
+37
View File
@@ -570,6 +570,43 @@ fn the_canvas_context_menu_offers_outline_stroke_for_a_stroked_selection() {
assert!(canvas.outline_item().is_none(), "no stroke, no rendered outline item");
}
#[test]
fn outline_stroke_menu_ignores_a_point_with_a_nonpainting_cap() {
for (cap, closed) in [("butt", false), ("round", false), ("square", false), ("butt", true), ("round", true), ("square", true)] {
let mut app = app();
let point = NodeId(
app.run("path.create", json!({"closed": closed, "anchors": [{"x": 250, "y": 200}, {"x": 250, "y": 200}]})).unwrap()["id"].as_u64().unwrap(),
);
app.run("paint.setFill", json!({"none": true})).unwrap();
app.run("paint.setStroke", json!({"color": "#000000"})).unwrap();
app.run("stroke.set", json!({"weight": 8, "cap": cap})).unwrap();
let visible = rect(&mut app, 50.0, 50.0);
app.run("paint.setFill", json!({"color": "#ff8010"})).unwrap();
app.run("paint.setStroke", json!({"none": true})).unwrap();
app.run("select.set", json!({"ids": [point.0, visible.0]})).unwrap();
let selected = app.session.active().unwrap().selection.objects.clone();
let mut canvas = CanvasMenu::new(app);
canvas.right_click(100.0, 100.0);
assert_eq!(canvas.app.borrow().session.active().unwrap().selection.objects, selected);
if cap == "butt" {
assert!(canvas.outline_item().is_none(), "the point paints nothing with a butt cap");
} else {
canvas.click_outline();
let app = canvas.app.borrow();
let st = app.session.active().unwrap();
assert!(st.doc.node(point).is_none(), "{cap} cap was outlined");
assert!(st.doc.node(visible).is_some(), "the fill-only object is unchanged");
let outlined = st.selection.objects.iter().find(|&&id| id != visible).and_then(|&id| st.doc.node(id)).expect("selected outline art");
assert!(
outlined.appearance.items.iter().any(|i| matches!(i, vectorcraft_doc::AppearanceItem::Fill(f) if f.visible && !f.paint.is_none())),
"{cap} cap becomes filled art"
);
let bounds = outlined.geometric_bounds().expect("the cap outline has geometry");
assert!(bounds.width() > 0.0 && bounds.height() > 0.0, "{cap} cap paints an area");
}
}
}
/// A compound path of two rectangles, filled and stroked with `weight`, isolated, with a member
/// right-clicked. The member stays selected and has no appearance of its own: the compound holds
/// the paint.
+1 -1
View File
@@ -2,7 +2,7 @@
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-20 · **Change:** minor (Pencil Edit Selected Paths follows lifted strokes, carves, loops, closes and redraws compound paths; Layers: a targeted item with an appearance of its own keeps its inner ring visible around a smaller appearance dot, so the target circle's four looks differ, #8711; scores and estimates unchanged; previously: G12: Asset Export tile context menus; scores and estimates unchanged; previously: M14/G12: Appearance panel: right-click item context menus for rows (Duplicate, Delete, Hide/Show, Edit Effect, Clear Appearance, Reduce to Basic Appearance) with selection handling, #8809; previously: Text styles panel: right-click item context menus for Character Styles and Paragraph Styles with Options, Duplicate, Delete, Redefine, Clear Overrides; scores and estimates unchanged; previously: G12: Actions panel item context menus for action sets (New Action…, New Set…, Duplicate Set, Delete Set, Set Options…) and actions (Play, Record, Duplicate, Delete, Action Options…, Batch…) with selection handling; clicking Duplicate on an action duplicates that action; headless tests in `crates/ui-egui/src/panels/actions.rs`; scores and estimates unchanged; previously: Layers: a targeted item with an appearance of its own keeps its inner ring visible around a smaller appearance dot, so the target circle's four looks differ, #8711; scores and estimates unchanged; previously: Trim View hides the ruler guides, guide paths and the grid while it is on and greys out Show/Hide Guides and Show/Hide Grid, #8363; scores and estimates unchanged; previously: Scissors shows the actual proposed cut point while hovering, using its existing snapping and cut target (#8655); scores and estimates unchanged; previously: G12: Brushes panel: item right-click context menu (Brush Options, Duplicate Brush, Delete Brush) with selection handling; scores and estimates unchanged; previously: Graphic Styles panel: right-click item context menu for tiles and rows with Options, Duplicate, Delete, Redefine, Break Link; scores and estimates unchanged; previously: In the web build, an edit while the view of a heavy document moves (a tool drag held at an edge of the canvas, #8551, or a wheel scroll during a drag) draws only the part it changed into the last frame, which stays drawn moved with the view, instead of rendering the whole canvas each frame, and edits that go on once the view is still don't put off its render (#8688); scores and estimates unchanged; previously: G12: Links panel row context menu (Relink…, Go To Link, Update Link, Edit Original, Show in Folder, Embed Image / Unembed…) with selection handling; scores and estimates unchanged; previously: Artboard tool: Shift held once a move or Alt-copy drag is under way keeps it to the level, upright or 45° line, #8580; scores and estimates unchanged; previously: Image Trace Ignore Color keeps the canvas View and stays armed on a missed pixel (#8068); a tool drag held near an edge of the canvas scrolls the view, #8551; scores and estimates unchanged; previously: G12: Place: show progress window with Cancel for slow placed files exceeding 0.4 s, part of #5930; scores and estimates unchanged; previously: All Tools drawer: a tool the toolbar holds is dimmed in the readable dim text colour, not the disabled colour that was unreadable against the panel, and a hovered dimmed row takes the panel's darker fill so it stays readable, #8294; scores and estimates unchanged; previously: Layers: selected guide rows stay highlighted after the pointer leaves (#7344); scores and estimates unchanged; previously: PDF import: type filled and stroked after a page of type filled only comes in filled and stroked, #8549 follow-up; scores and estimates unchanged; previously: selected Dimension extension-line color and weight in Properties (#7078; four focused UI regressions passed); scores and estimates unchanged; previously: Brush Options Key Color: restore canvas input for the existing one-shot pick, then resume the retained draft and previous tool (#8284; six full-app input regressions passed); scores and estimates unchanged; previously: #8200: `.ai` and EPS import: an Art brush in Tints of a swatch-linked stroke color comes in brushed, its tints linked to the swatch; scores and estimates unchanged; previously: Ellipse: Up/Down changes Anchors while drawing (#7840); scores and estimates unchanged; previously: Windows/Linux menu access keys and localized cues (#6596); previously: Backquote/~ arrow pattern nudges (#7717); scores and estimates unchanged; previously: Window > Toolbars > Compact Tools offers optional denser main Tools spacing (#7234); default layout, scores and estimates unchanged; previously: Direct Selection: Space during an ordinary path's handle drag repositions its anchor and handles, including a Pen loan (#7237, request 3 only; scores and estimates unchanged); previously: SVG export preserves document units on rootLine truncated
>
> Outline Stroke is available in the canvas context menu when the selection has an outlinable stroke (#5267). Scores and estimates unchanged.
> Outline Stroke is available in the canvas context menu when the selection has an outlinable stroke (#5267), excluding the command's protected linked dimensions and plain butt-capped paths that paint no area. Painting round and square caps remain eligible. Scores and estimates unchanged.
>
> Tech Circuit update (2026-11-14): three original procedural brushes; ten built-in brush libraries (G5).
>
+1 -1
View File
@@ -2,7 +2,7 @@
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-20 · **Change:** minor (Pencil Edit Selected Paths follows lifted strokes, carves, loops, closes and redraws compound paths; Layers: a targeted item with an appearance of its own keeps its inner ring visible around a smaller appearance dot, so the target circle's four looks differ, #8711; scores and estimates unchanged; previously: G12: Asset Export tile context menus; scores and estimates unchanged; previously: Properties panel per context (G12): contextual text Quick Actions (Create Outlines, Retype, Find and Replace…); scores and estimates unchanged; previously: Layers: a targeted item with an appearance of its own keeps its inner ring visible around a smaller appearance dot, so the target circle's four looks differ, #8711; scores and estimates unchanged; previously: Trim View hides the ruler guides, guide paths and the grid while it is on and greys out Show/Hide Guides and Show/Hide Grid, #8363; scores and estimates unchanged; previously: Scissors shows the actual proposed cut point while hovering, using its existing snapping and cut target (#8655); scores and estimates unchanged; previously: Graphic Styles panel: right-click item context menu for tiles and rows with Options, Duplicate, Delete, Redefine, Break Link; scores and estimates unchanged; previously: Artboard tool: Shift held once a move or Alt-copy drag is under way keeps it to the level, upright or 45° line, #8580; scores and estimates unchanged; previously: Image Trace Ignore Color keeps the canvas View and stays armed on a missed pixel (#8068); Canvas context menu: a right-click on a path offers Simplify… next to Smooth…, opening the Simplify slider, or the Simplify dialog kept for next time, as Object › Path › Simplify… does, #8344; scores and estimates unchanged; previously: a tool drag held near an edge of the canvas scrolls the view, #8551; scores and estimates unchanged; previously: G12: Place: show progress window with Cancel for slow placed files exceeding 0.4 s, part of #5930; scores and estimates unchanged; previously: All Tools drawer: a tool the toolbar holds is dimmed in the readable dim text colour, not the disabled colour that was unreadable against the panel, and a hovered dimmed row takes the panel's darker fill so it stays readable, #8294; scores and estimates unchanged; previously: : selected guide rows stay highlighted after the pointer leaves (#7344); scores and estimates unchanged; previously: Layersselected Dimension extension-line color and weight in Properties (#7078; four focused UI regressions passed); scores and estimates unchanged; previously: Brush Options Key Color: restore canvas input for the existing one-shot pick, then resume the retained draft and previous tool (#8284; six full-app input regressions passed); scores and estimates unchanged; previously: Ellipse: Up/Down changes Anchors while drawing (#7840); scores and estimates unchanged; previously: Windows/Linux menu access keys and localized cues (#6596); previously: Backquote/~ arrow pattern nudges (#7717); scores and estimates unchanged; previously: Window > Toolbars > Compact Tools offers optional denser main Tools spacing (#7234); default layout, scores and estimates unchanged; previously: Direct Selection: Space during an ordinary path's handle drag repositions its anchor and handles, including a Pen loan (#7237, request 3 only; scores and estimates unchanged); previously: Floating panels keep their window level while focus moves between the app's windows, so a press on one panel's bar no longer hands the keyboard to another, #6986; scores and estimates unchanged; previously minor: Lock Guides: a selection marquee (Selection, Direct Selection, Group Selection, Enclosing Lasso) leaves out paths made into guides inside groups and compound paths too, as clicks do (#3074), so a group is no longer selected by a locked guide in it; an enclosing marquee measures a group without its locked or hidden guides, and Direct Selection takes no anchor or segment of a guide that can't be picked; a guide in a group still moves with its group (#8538); scores and estimates unchanged; previously: Production Preflight: output-aware fonts, text overflow, linked files and effective image resolution, clickable findings and automatic rechecking; scores and estimates unchanged; previously: Layers panel: an Alt-drag copies a row above or below itself, so the top layer dragged up, the bottom layer dragged down and a lone layer are copied, #8237; scores and estimates unchanged; previously: Layers panel: Alt over the list shows the copy cursor while rows or the selected-art square are dragged, #8217; scores and estimates unchanged; previously: Gradient panel: the add-stop strip under the ramp shows the white arrow with a plus on Windows and X11, #8241; scores and estimates unchanged; previously: Recolor Artwork follow-up (#8031, remaining #4028): native Lab input, picker swatch libraries and Assign-row meLine truncated
>
> Outline Stroke is available in the canvas context menu when the selection has an outlinable stroke (#5267). A linked dimension selected with its source keeps its lines; those protected lines do not make a fill-only source eligible, including inside a group. Scores and estimates unchanged.
> Outline Stroke is available in the canvas context menu when the selection has an outlinable stroke (#5267). A linked dimension selected with its source keeps its lines; those protected lines do not make a fill-only source eligible, including inside a group. Coincident-point paths with a plain butt-capped stroke do not make the selection eligible either; round and square caps still paint and can be outlined. Scores and estimates unchanged.
>
> Tech Circuit update (2026-11-14): three original procedural brushes; ten built-in brush libraries (G5).
>