From f20fc32c3db720174003d4ffd2204f004968081b Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 14 Nov 2026 18:23:06 -0800 Subject: [PATCH] Graphs: a fill or stroke added to a label or axis line keeps the other kind its kind keeps graphicStyle.apply with add, and appearance.copyFrom with append, stored both the fill and stroke rows a graph label or axis line showed, so a fill-only style added to one axis line replaced the stroke the axis lines kept from another line with the line's own black stroke. They now store only the kinds of row they add; the row of the other kind keeps its paint and its place relative to the characters as the kind keeps them. appearance.moveItem of the Contents row stored the rows of every label it was given, so a move that changed nothing on a label replaced what its kind kept from another label. It now stores rows only for the labels whose rows it changed. --- crates/engine/src/cmd/appearance.rs | 18 +++--- crates/engine/src/cmd/graph.rs | 9 +-- crates/engine/src/cmd/graph/series.rs | 80 +++++++++++++++++++++--- crates/engine/src/cmd/graph/tests.rs | 90 +++++++++++++++++++++++++++ crates/engine/src/cmd/style.rs | 12 ++-- docs/mcp.md | 13 ++-- 6 files changed, 191 insertions(+), 31 deletions(-) diff --git a/crates/engine/src/cmd/appearance.rs b/crates/engine/src/cmd/appearance.rs index fd4e072537..fcc0147d04 100644 --- a/crates/engine/src/cmd/appearance.rs +++ b/crates/engine/src/cmd/appearance.rs @@ -129,7 +129,7 @@ pub fn specs() -> Vec { "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 when transparency is applied, 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, and when transparency is applied its object opacity and blend mode, for every line of its kind (a pick of some attributes without `append`: only what it changes) → {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 when transparency is applied, and with `append` its topmost visible fill and stroke rows of the kinds it adds; on a graph's axis line, tick mark or radar ring, its topmost visible fill and stroke rows, and when transparency is applied its object opacity and blend mode, for every line of its kind (a pick of some attributes without `append`: only what it changes; with `append`: only the kinds of row it adds) → {ids}", has_doc, copy_from ), @@ -1473,8 +1473,8 @@ fn move_contents(s: &mut Session, ids: &[NodeId], to: usize) -> Result { slot.get_or_insert(n.appearance.contents_at()); } slot.ok_or_else(|| bad("appearance.moveItem", "only groups, layers, type and images have a Contents (Characters) row"))?; - // A graph label's kind keeps where its rows paint relative to the characters. - let labels = capture_row_edits(&before, d, ids); + // A graph label's kind keeps where its rows paint relative to the characters, from the labels the move changed. + let labels = capture_row_edits(&before, d, &shown_rows_edited(&before, d, ids.to_vec(), |_| false)); Ok(count_changed(d, &before, ids) + usize::from(labels)) })?; Ok(json!({ "contents": slot })) @@ -1742,12 +1742,13 @@ fn copy_from(s: &mut Session, p: &Value) -> Result { // Graph labels keep their new rows, characters and paragraphs per kind of label. // On type, only `append` adds rows and a transparency pick changes the object's opacity and blend mode; the other // attributes go to the characters. Without a transparency pick, the object opacity and blend mode a kind keeps stay, - // also when the label or line picked onto still shows other ones until the graph is drawn again. + // also when the label or line picked onto still shows other ones until the graph is drawn again. `append` keeps + // only the kinds of row it added; a row of the other kind stays as the kind keeps it. let transparency = attrs.appearance.transparency; - let rows = match (append, transparency) { - (true, true) => super::graph::capture_label_rows(d, &targets), - (true, false) => super::graph::capture_label_fill_stroke_rows(d, &targets), - (false, _) => transparency && super::graph::capture_label_object_opacity(d, &targets), + let rows = if append { + super::graph::capture_label_kind_rows(d, &targets, paints, transparency) + } else { + transparency && super::graph::capture_label_object_opacity(d, &targets) }; // `append` adds rows and leaves the characters as they were. let text = !append && super::graph::capture_label_text(d, &targets, kept_text, kept_para)?; @@ -1755,6 +1756,7 @@ fn copy_from(s: &mut Session, p: &Value) -> Result { // changed, and the rest stay as its kind keeps them, which the line may not show yet. Row attributes the graph // does not keep (overprint, caps, joins, miter limit, dashes) leave what its kind keeps as it is. let lines = match (rows_written, transparency) { + _ if append => super::graph::capture_line_kind_rows(d, &targets, paints, transparency), (true, true) => super::graph::capture_line_rows(d, &targets), (true, false) => super::graph::capture_line_fill_stroke_rows(d, &targets), (false, _) => super::graph::capture_line_changes(&before, d, &targets), diff --git a/crates/engine/src/cmd/graph.rs b/crates/engine/src/cmd/graph.rs index 3bdaa4e875..c008507581 100644 --- a/crates/engine/src/cmd/graph.rs +++ b/crates/engine/src/cmd/graph.rs @@ -46,11 +46,12 @@ use generate::generate; #[cfg(test)] use series::default_series_color; pub(crate) use series::{ - LabelTextChange, capture_label_anti_alias, capture_label_changes, capture_label_fill_stroke_rows, capture_label_object_opacity, + LabelTextChange, capture_label_anti_alias, capture_label_changes, capture_label_kind_rows, capture_label_object_opacity, capture_label_paragraphs, capture_label_rows, capture_label_styles, capture_label_styles_given, capture_label_text, capture_line_changes, - capture_line_fill_stroke_rows, capture_line_paint_writes, capture_line_rows, capture_series_object_opacity, capture_series_opacity, - capture_series_top_paints, graph_part_members, is_design_art, is_graph_line, label_object_opacity_differs, label_rows, labels_in, paint_targets, - series_group_marks, series_group_marks_where, series_groups_among, series_marks_in, series_object_opacity_differs, shown_paint, + capture_line_fill_stroke_rows, capture_line_kind_rows, capture_line_paint_writes, capture_line_rows, capture_series_object_opacity, + capture_series_opacity, capture_series_top_paints, graph_part_members, is_design_art, is_graph_line, label_object_opacity_differs, label_rows, + labels_in, paint_targets, series_group_marks, series_group_marks_where, series_groups_among, series_marks_in, series_object_opacity_differs, + shown_paint, }; #[cfg(test)] diff --git a/crates/engine/src/cmd/graph/series.rs b/crates/engine/src/cmd/graph/series.rs index e979fd13d0..42fc640809 100644 --- a/crates/engine/src/cmd/graph/series.rs +++ b/crates/engine/src/cmd/graph/series.rs @@ -864,6 +864,46 @@ enum Keep { Object, /// The fill and stroke rows; the object opacity and blend mode stay as the kind keeps them. Rows, + /// The fill row with `fill`, the stroke row with `stroke`, and the object opacity and blend mode with `object`; the + /// others stay as the kind keeps them. Each row keeps its place relative to the characters; a row taken from the + /// label or line paints above a kept row on the same side of them, unless the label or line shows it below its own row + /// of that kind. + Kinds { fill: bool, stroke: bool, object: bool }, +} + +/// The kinds (true: fill) of the rows in `rows` from the bottom up, each with whether it paints below the characters. +fn row_places(rows: &vectorcraft_doc::LabelRows) -> Vec<(bool, bool)> { + let order = if rows.stroke_under { [false, true] } else { [true, false] }; + let has = |fill: bool| if fill { rows.paint.fill.is_some() } else { rows.paint.stroke.is_some() }; + let below = usize::from(rows.below.unwrap_or(0)); + order.into_iter().filter(|k| has(*k)).enumerate().map(|(i, k)| (k, i < below)).collect() +} + +/// Where the rows paint when the row of kind `taken` (true: fill) comes from `shown` and the row of the other kind from +/// `kept`, each keeping its place relative to the characters: `below` and `stroke_under` of [`vectorcraft_doc::LabelRows`]. +fn merged_places(kept: &vectorcraft_doc::LabelRows, shown: &vectorcraft_doc::LabelRows, taken: bool) -> (Option, bool) { + let in_shown = row_places(shown); + let t = in_shown.iter().copied().find(|p| p.0 == taken); + let o = row_places(kept).into_iter().find(|p| p.0 != taken); + let order = match (t, o) { + (Some(t), Some(o)) => { + // Rows on different sides of the characters: the one below them is lower. On the same side: as the label or + // line shows them, else the taken row on top. + let at = |kind: bool| in_shown.iter().position(|p| p.0 == kind); + let o_first = if t.1 != o.1 { + o.1 + } else { + match (at(!taken), at(taken)) { + (Some(o_at), Some(t_at)) => o_at < t_at, + _ => true, + } + }; + if o_first { vec![o, t] } else { vec![t, o] } + } + (t, o) => t.into_iter().chain(o).collect(), + }; + let below = order.iter().filter(|p| p.1).fold(0u8, |k, _| k + 1); + ((below > 0).then_some(below), order.len() == 2 && !order[0].0) } /// `shown` with the parts of the rows `kept` keeps that `keep` leaves as they are. @@ -880,6 +920,27 @@ fn keep_rows(kept: vectorcraft_doc::LabelRows, shown: vectorcraft_doc::LabelRows (shown.paint.opacity, shown.paint.blend) = (kept.paint.opacity, kept.paint.blend); shown } + Keep::Kinds { fill, stroke, object } => { + let places = match (fill, stroke) { + (true, true) => (shown.below, shown.stroke_under), + (false, false) => (kept.below, kept.stroke_under), + (taken, _) => merged_places(&kept, &shown, taken), + }; + let mut rows = shown; + (rows.below, rows.stroke_under) = places; + let (r, k) = (&mut rows.paint, kept.paint); + if !object { + (r.opacity, r.blend) = (k.opacity, k.blend); + } + if !fill { + (r.fill, r.fill_opacity, r.fill_blend, r.fill_unit_box) = (k.fill, k.fill_opacity, k.fill_blend, k.fill_unit_box); + } + if !stroke { + (r.stroke, r.stroke_width, r.stroke_opacity, r.stroke_blend, r.stroke_unit_box) = + (k.stroke, k.stroke_width, k.stroke_opacity, k.stroke_blend, k.stroke_unit_box); + } + rows + } } } @@ -1038,12 +1099,17 @@ pub(crate) fn capture_label_object_opacity(doc: &mut Document, ids: &[NodeId]) - store_label_rows(doc, ids, Keep::Object) } -/// Keep the fill and stroke rows of graph labels and graph lines `ids` for every label or line of their kind, as -/// [`capture_label_rows`] keeps them, for an edit that left their object opacity and blend mode alone: those stay as the -/// kind keeps them, also when a label or line still shows other ones until the graph is drawn again. Returns whether what -/// the graph keeps changed. -pub(crate) fn capture_label_fill_stroke_rows(doc: &mut Document, ids: &[NodeId]) -> bool { - store_label_rows(doc, ids, Keep::Rows) +/// Keep, for every label or line of their kind, the fill row (with `fill`) and the stroke row (with `stroke`) that graph +/// labels and graph lines `ids` show, and with `object` their object opacity and blend mode, as [`capture_label_rows`] +/// keeps them, for an edit that wrote only those: a row of the other kind stays as the kind keeps it, also when a label or +/// line still shows its own one until the graph is drawn again. Returns whether what the graph keeps changed. +pub(crate) fn capture_label_kind_rows(doc: &mut Document, ids: &[NodeId], (fill, stroke): (bool, bool), object: bool) -> bool { + store_label_rows(doc, ids, Keep::Kinds { fill, stroke, object }) +} + +/// [`capture_label_kind_rows`] for the graph lines among `ids` alone. +pub(crate) fn capture_line_kind_rows(doc: &mut Document, ids: &[NodeId], (fill, stroke): (bool, bool), object: bool) -> bool { + store_line_rows(doc, ids, Keep::Kinds { fill, stroke, object }) } /// Would [`capture_label_object_opacity`] change what a graph keeps for labels `ids`? Reads the document without copying @@ -1061,7 +1127,7 @@ pub(crate) fn label_object_opacity_differs(doc: &Document, ids: &[NodeId]) -> bo }) } -/// [`capture_label_rows`], [`capture_label_object_opacity`] or [`capture_label_fill_stroke_rows`], as `keep` says. +/// [`capture_label_rows`], [`capture_label_object_opacity`] or [`capture_label_kind_rows`], as `keep` says. fn store_label_rows(doc: &mut Document, ids: &[NodeId], keep: Keep) -> bool { let mut changed = store_line_rows(doc, ids, keep); for (graph, role, rows) in label_rows_of(doc, ids) { diff --git a/crates/engine/src/cmd/graph/tests.rs b/crates/engine/src/cmd/graph/tests.rs index 6626b46051..4f3b05cfa1 100644 --- a/crates/engine/src/cmd/graph/tests.rs +++ b/crates/engine/src/cmd/graph/tests.rs @@ -6997,6 +6997,96 @@ fn a_graphic_style_added_to_a_label_or_axis_line_keeps_the_opacity_its_kind_keep } } +/// A fill-only graphic style added on top of a graph label or axis line, or a fill-only source appended to one with the +/// Eyedropper, keeps the stroke its kind keeps from another label or line, though the one it is added to still shows its +/// own. +#[test] +fn a_fill_added_to_a_label_or_axis_line_keeps_the_stroke_its_kind_keeps() { + let cases = [(false, false), (false, true), (true, false), (true, true)]; + every_case(cases, |&(label, append)| { + let mut s = Session::new(); + s.execute("file.new", &json!({"width": 800, "height": 800})).unwrap(); + let id = graph(&mut s, "column"); + let (rect, _) = blue_style(&mut s, "Blue", false); + let (first, second) = if label { + (text_id(&s, id, "Axes", "Q1"), text_id(&s, id, "Axes", "Q2")) + } else { + let lines = line_nodes(&s, id); + (lines[0].id, lines[1].id) + }; + if label { + s.execute("appearance.addStroke", &json!({"ids": [first.0]})).unwrap(); + s.execute("appearance.setItem", &json!({"ids": [first.0], "index": top_row(&s, first, false), "color": "#ff0000"})).unwrap(); + } else { + s.execute("paint.setStroke", &json!({"ids": [first.0], "color": "#ff0000"})).unwrap(); + } + if append { + let pick = json!({"source": rect.0, "ids": [second.0], "apply": every_row_attribute_without_transparency(), "append": true}); + s.execute("appearance.copyFrom", &pick).unwrap(); + } else { + s.execute("graphicStyle.apply", &json!({"name": "Blue", "ids": [second.0], "add": true})).unwrap(); + } + if label { + let looks = redrawn_label_rows(&mut s, id); + for q in ["Q1", "Q2", "Q3"] { + let (rows, _) = rows_of(&looks, q); + let shows = |fill: bool, hex: &str| rows.iter().any(|r| r.0 == fill && r.1 == hex); + assert!(shows(false, "#ff0000") && shows(true, "#0000ff"), "{q}: {rows:?}"); + } + } else { + let looks = redrawn_line_looks(&mut s, id); + assert!(looks.iter().all(|l| l.0 == "#ff0000"), "{looks:?}"); + } + }); +} + +/// A stroke a label's kind keeps below the characters stays below them when a fill-only graphic style is added on top of +/// another label of the kind, or a fill-only source appended to it, and the new fill paints above the characters. +#[test] +fn a_fill_added_to_a_label_keeps_the_kept_stroke_below_the_characters() { + every_case([false, true], |&append| { + let mut s = Session::new(); + s.execute("file.new", &json!({"width": 800, "height": 800})).unwrap(); + let id = graph(&mut s, "column"); + let (rect, _) = blue_style(&mut s, "Blue", false); + let (q1, q2) = (text_id(&s, id, "Axes", "Q1"), text_id(&s, id, "Axes", "Q2")); + s.execute("appearance.addStroke", &json!({"ids": [q1.0]})).unwrap(); + s.execute("appearance.moveItem", &json!({"ids": [q1.0], "from": "contents", "to": 1})).unwrap(); + if append { + let pick = json!({"source": rect.0, "ids": [q2.0], "apply": every_row_attribute_without_transparency(), "append": true}); + s.execute("appearance.copyFrom", &pick).unwrap(); + } else { + s.execute("graphicStyle.apply", &json!({"name": "Blue", "ids": [q2.0], "add": true})).unwrap(); + } + redrawn_label_rows(&mut s, id); + let look = |ap: &vectorcraft_doc::Appearance| (ap.contents_at(), ap.items.iter().map(|it| it.is_fill()).collect::>()); + for q in ["Q1", "Q2", "Q3"] { + assert_eq!(look(&label_node(&s, id, "Axes", q).appearance), (1, vec![false, true]), "append {append}: {q}"); + } + }); +} + +/// A Contents (Characters) row move that leaves a graph label as it was keeps the rows its kind keeps from another label +/// and is no edit. +#[test] +fn a_contents_move_that_changes_nothing_on_a_label_keeps_the_rows_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 (q1, q2) = (text_id(&s, id, "Axes", "Q1"), text_id(&s, id, "Axes", "Q2")); + s.execute("appearance.addStroke", &json!({"ids": [q1.0]})).unwrap(); + s.execute("appearance.setItem", &json!({"ids": [q1.0], "index": top_row(&s, q1, false), "color": "#ff0000"})).unwrap(); + let at = s.doc().unwrap().doc.node(q2).unwrap().appearance.contents_at(); + let undo = s.doc().unwrap().history.undo.len(); + s.execute("appearance.moveItem", &json!({"ids": [q2.0], "from": "contents", "to": at})).unwrap(); + assert_eq!(s.doc().unwrap().history.undo.len(), undo, "nothing changed"); + let looks = redrawn_label_rows(&mut s, id); + for q in ["Q1", "Q2", "Q3"] { + let (rows, _) = rows_of(&looks, q); + assert!(rows.iter().any(|r| !r.0 && r.1 == "#ff0000"), "{q}: {rows:?}"); + } +} + /// An Eyedropper pick with `append` and without the object's transparency on a graph label keeps the object opacity its /// kind keeps from another label, though the label it is applied to still shows 100%. #[test] diff --git a/crates/engine/src/cmd/style.rs b/crates/engine/src/cmd/style.rs index d415d6b4f1..914ad2b8bf 100644 --- a/crates/engine/src/cmd/style.rs +++ b/crates/engine/src/cmd/style.rs @@ -31,7 +31,7 @@ pub fn specs() -> Vec { "Apply Graphic Style", ["Window", "Graphic Styles"], None, - "{name, add?: bool, ids?|id? (layers too), target?: \"object\"|\"contents\"} give the objects (default: the selection; a group or layer itself, its fills and strokes painting its members and its effects applying to them as one piece; target contents: the objects inside instead) the style's appearance, opacity, blend mode, isolate and knockout, and link them to it (placed gradients land at the same place relative to each object's bounds); add: true (Alt-click) adds its fills, strokes and effects on top of the existing appearance instead and unlinks. On a path directly in a graph series (a series group's id stands for those paths), the graph also stores the paint, weight, opacity and blend mode of the topmost visible fill and stroke (with `add`: of the kinds of row the style shows) and, without `add`, the object's opacity and blend mode (exceptions: docs/mcp.md); on a graph label, or a graph's axis line, tick mark or radar ring (a graph's Axes group stands for the lines and labels directly in it, its Legend group for the labels), the graph stores that object's topmost visible fill and stroke rows and, without `add`, its object opacity and blend mode for every label or line of its kind. With nothing selected (and no ids) the next object drawn takes the style instead (see appearance.newArt) → {newArt: true}", + "{name, add?: bool, ids?|id? (layers too), target?: \"object\"|\"contents\"} give the objects (default: the selection; a group or layer itself, its fills and strokes painting its members and its effects applying to them as one piece; target contents: the objects inside instead) the style's appearance, opacity, blend mode, isolate and knockout, and link them to it (placed gradients land at the same place relative to each object's bounds); add: true (Alt-click) adds its fills, strokes and effects on top of the existing appearance instead and unlinks. On a path directly in a graph series (a series group's id stands for those paths), the graph also stores the paint, weight, opacity and blend mode of the topmost visible fill and stroke (with `add`: of the kinds of row the style shows) and, without `add`, the object's opacity and blend mode (exceptions: docs/mcp.md); on a graph label, or a graph's axis line, tick mark or radar ring (a graph's Axes group stands for the lines and labels directly in it, its Legend group for the labels), the graph stores that object's topmost visible fill and stroke rows (with `add`: of the kinds of row the style shows) and, without `add`, its object opacity and blend mode for every label or line of its kind. With nothing selected (and no ids) the next object drawn takes the style instead (see appearance.newArt) → {newArt: true}", has_doc, style_apply ), @@ -364,6 +364,9 @@ fn style_apply(s: &mut Session, p: &Value) -> Result { let shows = |kind: bool| g.appearance.items.iter().any(|it| it.is_fill() == kind && it.visible()); let kinds = (shows(true), shows(false)); super::appearance::capture_series_writes(&before, d, &ids, kinds, kinds, false, false); + // A label or graph line keeps its new rows of those kinds for its kind. The other kind, the object opacity and + // the blend mode stay as the kind keeps them. + super::graph::capture_label_kind_rows(d, &ids, kinds, false); } else { d.graphic_style_id(i); let g = d.graphic_styles[i].clone(); @@ -373,12 +376,7 @@ fn style_apply(s: &mut Session, p: &Value) -> Result { } super::appearance::clear_stood_for(d, &groups); super::appearance::capture_series_writes(&before, d, &ids, (true, true), (true, true), false, true); - } - // A label or graph line keeps its new rows for its kind. A style added on top leaves the object opacity and blend - // mode, so the kind keeps its own. - if add { - super::graph::capture_label_fill_stroke_rows(d, &ids); - } else { + // A label or graph line keeps its new rows for its kind. super::graph::capture_label_rows(d, &ids); } Ok(()) diff --git a/docs/mcp.md b/docs/mcp.md index 591f40334e..049423aae3 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -905,11 +905,13 @@ The `appearance.*` commands, `graphicStyle.apply` and `graphicStyle.redefine`, a transparency commands given an `item` (or the Appearance panel's active row) store a graph label's object rows for its kind of label: the paint, weight, opacity and blend mode of its topmost visible fill and stroke row, their order and their place relative to the Characters row, and the label's object opacity and blend mode. They store them even when the -label already showed them, but an edit of a hidden row that leaves the topmost visible rows as they were stores nothing. `transparency.set` without an `item`, `object.setProps` with an opacity or blend mode, and +label already showed them, but an edit of a hidden row that leaves the topmost visible rows as they were, and an +`appearance.moveItem` of the Contents row that leaves them in place, store nothing. `transparency.set` without an `item`, `object.setProps` with an opacity or blend mode, and an `appearance.copyFrom` (Eyedropper) pick of transparency store only the label's object opacity and blend mode; -`appearance.copyFrom` with `append` stores the rows, and the object opacity and blend mode only when it also applies -the object's transparency. `graphicStyle.apply` with `add` stores the rows and leaves the object opacity and blend -mode the kind keeps. When the graph is drawn again, every label of that kind gets what is stored, with a placed +`appearance.copyFrom` with `append` stores the rows of the kinds it adds (fill, stroke or both), and the object opacity +and blend mode only when it also applies the object's transparency. `graphicStyle.apply` with `add` stores the rows of +the kinds the style shows. Both leave a row of the other kind as the kind keeps it, and `graphicStyle.apply` with `add` +also leaves the object opacity and blend mode the kind keeps. When the graph is drawn again, every label of that kind gets what is stored, with a placed gradient fitted to each label, and the graph saves it as `valuesRows`, `categoriesRows` and `legendRows` in its label styles. Rows below the topmost one of each kind, a row's effects, other stroke options (caps, joins, dashes) and effects applied with `effect.*` are not stored. When labels of one kind are edited together, the last one in the order of the targets (`ids` as given, otherwise paint order) sets what the kind keeps. @@ -929,7 +931,8 @@ The other commands store them when given the line itself, and the `appearance.*` `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.clear`, `appearance.transfer`, `graphicStyle.apply`, `graphicStyle.redefine`, and `appearance.copyFrom` with every attribute picked up and applied or -with `append`, store a line's rows even when the line already showed them. The other commands, an `appearance.copyFrom` +with `append`, store a line's rows even when the line already showed them; `graphicStyle.apply` with `add` and +`appearance.copyFrom` with `append` store only the kinds of row they add. The other commands, an `appearance.copyFrom` of some attributes included, store only what they change on a line's rows; the kind keeps its other attributes, also when the line still shows different ones until the graph is drawn again. `paint.setFill`, `paint.setStroke`, `addon.color.fillToStroke` and `addon.color.strokeToFill` also store the paint they write on a line's topmost visible