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.
This commit is contained in:
dotCooCoo
2026-11-13 20:43:43 -08:00
parent 01043c05cd
commit c7dacd432e
3 changed files with 25 additions and 4 deletions
+6 -2
View File
@@ -530,7 +530,11 @@ fn edit_gradient(s: &mut Session, p: &Value) -> Result<Value> {
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<Value> {
Ok(())
})?;
if let Some(m) = mode
&& ids.is_empty()
&& !selected
&& p.get("ids").is_none()
&& let Some(st) = s.new_art_stroke_mut()
{
+14
View File
@@ -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]
+5 -2
View File
@@ -512,7 +512,10 @@ fn stroke_advanced(s: &mut Session, p: &Value) -> Result<Value> {
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<Value> {
}
};
// 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()
{