UI: exclude protected dimensions from Outline Stroke eligibility

Use the same linked-dimension roots as the command lift operation without cloning the document.
Exercise the real context menu for separate and grouped selections: fill-only sources have no action, stroked sources outline while dimension artwork survives.
This commit is contained in:
Taha-Mahmoodi committed 2026-11-21 18:33:28 +04:30
1 parent 38f175c679
commit 441994e52d
3 files changed
+58 -11

No files matched your search

+18 -10
View File
@@ -1143,21 +1143,29 @@ pub(crate) fn outlinable(st: &StrokeLayer) -> bool {
st.visible && !st.paint.is_none() && st.width > 0.0
}
/// Does Outline Stroke have a stroke to turn into art somewhere under `n`: a visible stroke of
/// some paint and weight on a path or compound path (type is not outlined by it)?
fn has_outlinable_stroke(n: &Node) -> bool {
let mut found = false;
each_leaf(n, &mut |l| {
found |= !matches!(l.kind, NodeKind::Text(_)) && l.appearance.items.iter().any(|i| matches!(i, AppearanceItem::Stroke(st) if outlinable(st)));
});
found
/// 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 {
if kept.contains(&n.id) {
return false;
}
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)))
}
NodeKind::Group { children, .. } | NodeKind::Layer { children, .. } => children.iter().any(|c| has_outlinable_stroke(c, kept)),
_ => false,
}
}
/// Does `object.path.outlineStroke` have a stroke to outline in `st`'s selection? It acts on the
/// selection's roots (a compound path's member stands for its compound, which holds the
/// appearance), so eligibility looks at those same roots, not at the selected nodes themselves.
/// appearance), excluding the linked dimensions that the command lifts while outlining their art.
pub fn can_outline_stroke(st: &crate::DocState) -> bool {
selection_roots(st).into_iter().filter_map(|id| st.doc.node(id)).any(has_outlinable_stroke)
let roots = selection_roots(st);
let kept = super::dimension::with_their_art(&st.doc, &roots);
roots.into_iter().filter_map(|id| st.doc.node(id)).any(|n| has_outlinable_stroke(n, &kept))
}
/// `n` with `opacity` and `blend` applied: set on it when it has none of its own, else on a
+39
View File
@@ -821,6 +821,45 @@ fn outline_stroke_is_offered_for_a_member_of_a_stroked_compound_path() {
assert!(app.session.active().unwrap().doc.node(compound).is_none(), "the stroked compound path was replaced by its outline");
}
#[test]
fn outline_stroke_ignores_a_linked_dimensions_lines_when_its_source_is_selected() {
for grouped in [false, true] {
let mut app = app();
let source = rect(&mut app, 50.0, 50.0);
app.run("paint.setFill", json!({"color": "#ff8010"})).unwrap();
app.run("paint.setStroke", json!({"none": true})).unwrap();
let dimension = NodeId(
app.run("dimension.create", json!({"source": {"kind": "segment", "edge": {"node": source.0, "subpath": 0, "segment": 0}}}))
.unwrap()["id"]
.as_u64()
.unwrap(),
);
app.run("select.set", json!({"ids": [source.0, dimension.0]})).unwrap();
if grouped {
app.run("object.group", json!({})).unwrap();
}
let selected = app.session.active().unwrap().selection.objects.clone();
let ctx = egui::Context::default();
frame(&mut app, &ctx, vec![]);
let p = screen(&app, 100.0, 125.0);
let texts = click(&mut app, &ctx, p, PointerButton::Secondary);
assert_eq!(app.session.active().unwrap().selection.objects, selected, "grouped: {grouped}");
assert!(has(&texts, "Arrange"), "the menu opened: {texts:?}");
assert!(!has(&texts, "Outline Stroke"), "only the protected dimension has strokes: {texts:?}");
click(&mut app, &ctx, pos2(10.0, 590.0), PointerButton::Primary);
app.run("paint.setStroke", json!({"ids": [source.0], "color": "#000000"})).unwrap();
app.run("stroke.set", json!({"ids": [source.0], "weight": 6})).unwrap();
let dimension_art = app.session.active().unwrap().doc.node(dimension).unwrap().children().unwrap().to_vec();
let texts = click(&mut app, &ctx, p, PointerButton::Secondary);
assert!(has(&texts, "Outline Stroke"), "the source has a stroke to outline: {texts:?}");
click(&mut app, &ctx, at(&texts, "Outline Stroke"), PointerButton::Primary);
let st = app.session.active().unwrap();
assert!(st.doc.node(source).is_none(), "the source was replaced by filled outlines");
assert_eq!(st.doc.node(dimension).unwrap().children().unwrap(), dimension_art.as_slice(), "the dimension keeps its own art");
}
}
/// Point type holding `t` at (20, 60), with Auto Spell Check on.
fn spelled(app: &mut VectorcraftApp, t: &str) -> NodeId {
let id = NodeId(app.run("text.create", json!({"x": 20, "y": 60, "text": t, "size": 24})).unwrap()["id"].as_u64().unwrap());
+1 -1
View File
@@ -2,7 +2,7 @@
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-19 · **Change:** minor (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 menus; UI interaction regression coverage; scores and estimates unchanged; previously: Eraser review: hidden Rasterize and Along/Across stroke rows do not block preserving visible gradients; scores and estimates unchanged; previously: Eraser review: ordinary Group/Layer paints and reproducible evaluated gradient placements are preserved; other placements retain existing fitting; scores and estimates unchanged; previously: Eraser: shared fill-only area cutting for fixed and varied tips and the Alt-drag marquee, #6582; scores and estimates unchanged; previously: #8005: the Color spectrum fills a resized panel; scores and estimates unchanged; previously: Pencil continuation, straight-line and closing cursors; scores and estimates unchanged; previously: Graphic Styles list fills a taller panel, #2992; scores and estimates unchanged; previously: library panels' lists fill a taller panel, #2992; scores and estimates unchanged; previously: Swatches list fills a taller panel, #1638; scores and estimates unchanged; previously: icon-strip flyouts also resize from the top edge and the canvas-side top corner, keeping the moved top in workspaces (storytold/craft-libs#1094); scores and estimates unchanged; previously: macOS: the canvas cursor stays after theLine 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). 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.
>
> Tech Circuit update (2026-11-14): three original procedural brushes; ten built-in brush libraries (G5).
>