Graphs: an Eyedropper pick of stroke options leaves the rows axis lines keep

A pick of only overprint, caps, joins, miter limit or dashes on an axis
line or radar ring no longer stores the line's paint and weight for its
kind, since the graph keeps none of those options.
This commit is contained in:
dotCooCoo
2026-11-13 22:33:58 -08:00
parent 13c5df3aeb
commit db1dd67818
3 changed files with 28 additions and 31 deletions
+6 -15
View File
@@ -129,7 +129,7 @@ pub fn specs() -> Vec<CommandSpec> {
"Eyedropper",
[],
None,
"{source: id, ids?, pickUp?, apply? (trees as eyedropper.setOptions, merged over the Eyedropper Options for this call), reverse?: bool, append?: bool, defaultsOnly?: bool} copy the attributes both picked up and applied (by default the whole appearance stack, opacity and blend mode, and from type to type the character and paragraph attributes using effective character dimensions while preserving target transforms) from `source` to ids (default: highlighted characters while editing type, after Select All in a frame of threaded text the text of the story's frames, leaving out `source`, otherwise the object selection; highlighted characters reject enabled non-neutral object transparency), the fill, stroke and weight also to the paint defaults; `defaultsOnly` updates only paint defaults and cannot be combined with ids, reverse or append; `reverse` (Alt-click) copies from the first selected object (or ids) onto `source` instead, or with nothing selected what the Eyedropper picked up last (a click without Alt); `append` (Shift+Alt-click) adds the source's fills, strokes and effects on top of each target's stack; placed gradients land at the same place relative to each target's bounds (defaults: fitted to new art); with an object of a dynamic symbol instance selected by Direct Selection and no ids, reverse, append or defaultsOnly, that object takes the source's fill and stroke (solid, none, gradient or pattern) for this instance only, as the Eyedropper Options allow, and a source that is not a path, compound path or type, or options that pick up neither color, are refused. On a path directly in a graph series, the graph also stores the paint, weight, opacity and blend mode of the topmost visible fill and stroke and the object's opacity and blend mode (exceptions: docs/mcp.md); on a graph label, the graph stores, for every label of its kind, the character attributes the pick gives all of its text, its object opacity and blend mode, and with `append` its topmost visible fill and stroke rows; on a graph's axis line, tick mark or radar ring, its topmost visible fill and stroke rows (not for a pick of only the object's transparency) and object opacity and blend mode for every line of its kind → {ids}",
"{source: id, ids?, pickUp?, apply? (trees as eyedropper.setOptions, merged over the Eyedropper Options for this call), reverse?: bool, append?: bool, defaultsOnly?: bool} copy the attributes both picked up and applied (by default the whole appearance stack, opacity and blend mode, and from type to type the character and paragraph attributes using effective character dimensions while preserving target transforms) from `source` to ids (default: highlighted characters while editing type, after Select All in a frame of threaded text the text of the story's frames, leaving out `source`, otherwise the object selection; highlighted characters reject enabled non-neutral object transparency), the fill, stroke and weight also to the paint defaults; `defaultsOnly` updates only paint defaults and cannot be combined with ids, reverse or append; `reverse` (Alt-click) copies from the first selected object (or ids) onto `source` instead, or with nothing selected what the Eyedropper picked up last (a click without Alt); `append` (Shift+Alt-click) adds the source's fills, strokes and effects on top of each target's stack; placed gradients land at the same place relative to each target's bounds (defaults: fitted to new art); with an object of a dynamic symbol instance selected by Direct Selection and no ids, reverse, append or defaultsOnly, that object takes the source's fill and stroke (solid, none, gradient or pattern) for this instance only, as the Eyedropper Options allow, and a source that is not a path, compound path or type, or options that pick up neither color, are refused. On a path directly in a graph series, the graph also stores the paint, weight, opacity and blend mode of the topmost visible fill and stroke and the object's opacity and blend mode (exceptions: docs/mcp.md); on a graph label, the graph stores, for every label of its kind, the character attributes the pick gives all of its text, its object opacity and blend mode, and with `append` its topmost visible fill and stroke rows; on a graph's axis line, tick mark or radar ring, its topmost visible fill and stroke rows (when the pick takes a paint, a stroke weight or a row's opacity and blend mode, or appends) and object opacity and blend mode for every line of its kind → {ids}",
has_doc,
copy_from
),
@@ -1734,20 +1734,11 @@ fn copy_from(s: &mut Session, p: &Value) -> Result<Value> {
};
// `append` adds rows and leaves the characters as they were.
let text = !append && super::graph::capture_label_text(d, &targets, kept_text, kept_para)?;
// A graph line is a path: a pick of fill or stroke attributes writes its rows. A pick of only the object's
// opacity and blend mode leaves the fill and stroke its kind keeps, as `capture_label_object_opacity` keeps them.
let to_rows = append
|| fill.color
|| fill.transparency
|| fill.overprint
|| stroke.color
|| stroke.transparency
|| stroke.overprint
|| stroke.weight
|| stroke.cap
|| stroke.join
|| stroke.miter
|| stroke.dash;
// A graph line is a path: a pick of a paint, a weight or a row's opacity and blend mode writes the rows its kind
// keeps. A pick of only the object's opacity and blend mode, or of row attributes the graph does not keep (overprint,
// caps, joins, miter limit, dashes), leaves the fill and stroke its kind keeps, as `capture_label_object_opacity`
// keeps them.
let to_rows = append || fill.color || fill.transparency || stroke.color || stroke.transparency || stroke.weight;
let lines = to_rows && super::graph::capture_line_rows(d, &targets);
Ok(count_changed(d, &before, &targets) + usize::from(kept || painted || object || rows || text || lines))
})?;
+20 -14
View File
@@ -6349,23 +6349,29 @@ fn an_edit_of_a_hidden_row_of_an_axis_line_keeps_what_its_kind_keeps() {
});
}
/// An Eyedropper pick of only the object's opacity on an axis line keeps the stroke its kind keeps from another line,
/// though the line it is given still shows the default stroke.
/// An Eyedropper pick of only the object's opacity, or of only stroke options the graph does not keep, on an axis line
/// keeps the stroke its kind keeps from another line, though the line it is given still shows the default stroke.
#[test]
fn an_eyedropper_pick_of_only_the_opacity_keeps_the_stroke_its_kind_keeps() {
let mut s = Session::new();
s.execute("file.new", &json!({"width": 800, "height": 800})).unwrap();
let id = graph(&mut s, "column");
let rect = NodeId(s.execute("shape.rectangle", &json!({"x": 600, "y": 600, "width": 10, "height": 10})).unwrap()["id"].as_u64().unwrap());
s.execute("object.setProps", &json!({"ids": [rect.0], "opacity": 50})).unwrap();
let lines = line_nodes(&s, id);
s.execute("paint.setStroke", &json!({"ids": [lines[0].id.0], "color": "#ff0000"})).unwrap();
let fill = json!({"color": false, "transparency": false, "overprint": false});
let stroke = json!({"color": false, "transparency": false, "overprint": false, "weight": false, "cap": false, "join": false, "miter": false, "dash": false});
let opacity_only = json!({"appearance": {"transparency": true, "fill": fill, "stroke": stroke}});
s.execute("appearance.copyFrom", &json!({"source": rect.0, "ids": [lines[1].id.0], "pickUp": opacity_only})).unwrap();
let looks = redrawn_line_looks(&mut s, id);
assert!(looks.iter().all(|l| l.0 == "#ff0000" && (l.2 - 0.5).abs() < 1e-6), "{looks:?}");
let stroke = |dash: bool| json!({"color": false, "transparency": false, "overprint": false, "weight": false, "cap": false, "join": false, "miter": false, "dash": dash});
let cases = [
(json!({"appearance": {"transparency": true, "fill": fill, "stroke": stroke(false)}}), 0.5),
(json!({"appearance": {"transparency": false, "fill": fill, "stroke": stroke(true)}}), 1.0),
];
every_case(cases, |(pick, opacity)| {
let mut s = Session::new();
s.execute("file.new", &json!({"width": 800, "height": 800})).unwrap();
let id = graph(&mut s, "column");
let rect = NodeId(s.execute("shape.rectangle", &json!({"x": 600, "y": 600, "width": 10, "height": 10})).unwrap()["id"].as_u64().unwrap());
s.execute("object.setProps", &json!({"ids": [rect.0], "opacity": 50})).unwrap();
s.execute("stroke.set", &json!({"ids": [rect.0], "dash": [4, 2]})).unwrap();
let lines = line_nodes(&s, id);
s.execute("paint.setStroke", &json!({"ids": [lines[0].id.0], "color": "#ff0000"})).unwrap();
s.execute("appearance.copyFrom", &json!({"source": rect.0, "ids": [lines[1].id.0], "pickUp": pick})).unwrap();
let looks = redrawn_line_looks(&mut s, id);
assert!(looks.iter().all(|l| l.0 == "#ff0000" && (l.2 - *opacity).abs() < 1e-6), "{pick}: {looks:?}");
});
}
/// Default Fill and Stroke on a label or an axis line that already shows the default paint is kept for its kind, in
+2 -2
View File
@@ -893,8 +893,8 @@ graph, its Axes group or a group that holds the graph, so the lines keep the pai
The other commands store them when given the line itself, and the `appearance.*` and graphic style commands and
`transparency.set` with an `item` also when given the Axes group, as described above. `transparency.set` without an
`item` and `object.setProps` store only the object opacity and blend mode. `appearance.copyFrom` stores the rows when it
picks up a fill or stroke attribute or adds rows with `append`; a pick of only the object's transparency stores only the
object opacity and blend mode. The recolor commands and `paint.swap` store a line's rows when they change them. The
picks up a paint, a stroke weight or a row's opacity and blend mode, or adds rows with `append`; any other pick stores
only the object opacity and blend mode, when it picks them up. The recolor commands and `paint.swap` store a line's rows when they change them. The
other commands store them even when the line already showed them, except that rows equal to a kind's default stroke
(0.5 pt black for axis lines and tick marks, 0.25 pt gray for rings) are not saved, and an edit of a hidden row that
leaves the topmost visible rows as they were stores nothing. When one command reaches several lines of one kind, the frontmost line in