From c7dacd432e5ab23f9eda67f23060c4cbe302ea22 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Fri, 13 Nov 2026 20:43:43 -0800 Subject: [PATCH] Graphs: stroke edits of a design's art alone leave the new-art stroke as it is stroke.setAdvanced and the strokeMode of paint.editGradient decided whether they were edits for new art after the art of a graph design in a series had been left out, so a selection holding only that art changed the stroke the next object drawn takes. Both now decide it from the objects given or selected, as stroke.set does. --- crates/engine/src/cmd/gradient.rs | 8 ++++++-- crates/engine/src/cmd/graph/tests.rs | 14 ++++++++++++++ crates/engine/src/cmd/stroke.rs | 7 +++++-- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/crates/engine/src/cmd/gradient.rs b/crates/engine/src/cmd/gradient.rs index 30590d5364..d23906b6bb 100644 --- a/crates/engine/src/cmd/gradient.rs +++ b/crates/engine/src/cmd/gradient.rs @@ -530,7 +530,11 @@ fn edit_gradient(s: &mut Session, p: &Value) -> Result { check_switches(p, &["reverse", "dither"], C)?; check_numbers(p, &["angle"], C)?; let item = item.of_kind(s, !stroke); - let ids = super::appearance::drop_design_art(&s.doc()?.doc, item.targets(s, p)?); + let ids = item.targets(s, p)?; + // Objects were given or selected, even when all of them are graph design art left out below: the stroke mode is then + // not one for new art. + let selected = !ids.is_empty(); + let ids = super::appearance::drop_design_art(&s.doc()?.doc, ids); // How the gradient lies on a stroke (the panel's Stroke buttons). let mode = match str_param(p, "strokeMode") { None => None, @@ -605,7 +609,7 @@ fn edit_gradient(s: &mut Session, p: &Value) -> Result { Ok(()) })?; if let Some(m) = mode - && ids.is_empty() + && !selected && p.get("ids").is_none() && let Some(st) = s.new_art_stroke_mut() { diff --git a/crates/engine/src/cmd/graph/tests.rs b/crates/engine/src/cmd/graph/tests.rs index 8464f6d0b4..4e9d0c07b5 100644 --- a/crates/engine/src/cmd/graph/tests.rs +++ b/crates/engine/src/cmd/graph/tests.rs @@ -493,6 +493,20 @@ fn paint_commands_leave_a_graph_designs_art_out() { refused_on_design_art(&mut s, "paint.freeform.addPoint", json!({"ids": [art.0], "at": [0, 0]})); } +/// With only the art of a graph design selected, `stroke.setAdvanced` and the stroke mode of `paint.editGradient` act +/// as edits of a selection, not of the stroke the next object drawn takes. +#[test] +fn stroke_edits_of_selected_design_art_leave_the_new_art_stroke() { + let (mut s, _, _, art, _) = design_art(); + s.execute("select.set", &json!({"ids": [art.0]})).unwrap(); + let was = format!("{:?}", s.new_art_stroke()); + s.execute("stroke.setAdvanced", &json!({"arrowScale": [200, 200], "swapArrows": true})).unwrap(); + assert_eq!(format!("{:?}", s.new_art_stroke()), was, "stroke.setAdvanced"); + let mode = s.new_art_stroke().gradient_mode; + s.execute("paint.editGradient", &json!({"kind": "linear", "stroke": true, "strokeMode": "along"})).unwrap(); + assert_eq!(s.new_art_stroke().gradient_mode, mode, "paint.editGradient"); +} + /// `transparency.set` without `item` refuses the art of a graph design in a series, and given it with other objects /// sets only theirs. #[test] diff --git a/crates/engine/src/cmd/stroke.rs b/crates/engine/src/cmd/stroke.rs index 74aff88fdf..2a0159930d 100644 --- a/crates/engine/src/cmd/stroke.rs +++ b/crates/engine/src/cmd/stroke.rs @@ -512,7 +512,10 @@ fn stroke_advanced(s: &mut Session, p: &Value) -> Result { return Err(bad(C, "nothing to change")); } let item = item_target(s, p, C)?.of_kind(s, false); - let ids = super::appearance::drop_design_art(&s.doc()?.doc, item.targets(s, p)?); + let ids = item.targets(s, p)?; + let new_art = no_targets(&ids, p); + // The art of a graph design in a series keeps the design's stroke. + let ids = super::appearance::drop_design_art(&s.doc()?.doc, ids); let arrows_and_profile = |st: &mut StrokeLayer| { if let Some(sc) = scale { st.arrow_scale = sc; @@ -526,7 +529,7 @@ fn stroke_advanced(s: &mut Session, p: &Value) -> Result { } }; // As stroke.set: with nothing selected, for the next object drawn. - if no_targets(&ids, p) + if new_art && (scale.is_some() || swap || flip.is_some()) && let Some(st) = s.new_art_stroke_mut() {