From 426ea942687c8005305ffaf2fd3defc7c1e97bdc Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 19 Nov 2026 15:32:07 -0800 Subject: [PATCH] Live Paint: bucket paint commands replay from the journal with any tool While the Live Paint Bucket is active, a paint or stroke command that names no objects changes only the colors the bucket paints with. The journal recorded the params as given, and the active tool is not journaled, so a replay with the Selection tool active painted the selection instead. The paint and stroke commands now take defaultsOnly: true, which keeps a command without ids, id or item to the defaults with any tool active. When the bucket routed a command, its journal entry notes defaultsOnly: true, also when the params gave false. library.use (a color, gradient or pattern) and swatch.library.add with apply note it too and pass it to the commands they run. - defaultsOnly is a bool. It is refused with ids, id or item, and in stroke.setAdvanced with brush. - With New Art Has Basic Appearance off, new-art inheritance does not replace the defaults after such a command, unless a later step of a batch selects another first object or changes its appearance. - A preview with defaultsOnly: true, and the one after it, starts from the defaults the interaction began with, and a cancel puts them back. - paint.sampleColor with a stop and defaultsOnly reads the default's gradient. Test: live_paint_bucket_commands_replay_from_the_journal_with_another_tool (engine). Docs: docs/mcp.md, the Live Paint Bucket paragraph; params text of each command. --- crates/engine/src/cmd.rs | 2 +- crates/engine/src/cmd/gradient.rs | 2 +- crates/engine/src/cmd/gradpresets.rs | 2 +- crates/engine/src/cmd/library.rs | 26 +++-- crates/engine/src/cmd/newart.rs | 43 +++++++- crates/engine/src/cmd/paint.rs | 95 ++++++++++++---- crates/engine/src/cmd/stroke.rs | 13 ++- crates/engine/src/cmd/swatchlib.rs | 6 +- crates/engine/src/cmd/xform.rs | 11 +- crates/engine/src/lib.rs | 5 + crates/engine/src/session/documents.rs | 1 + crates/engine/src/session/edit.rs | 14 ++- crates/engine/src/session/execute.rs | 11 +- crates/engine/src/tests/build.rs | 145 +++++++++++++++++++++++++ crates/ui-egui/src/i18n/cs.tsv | 2 + crates/ui-egui/src/i18n/da.tsv | 2 + crates/ui-egui/src/i18n/de.tsv | 2 + crates/ui-egui/src/i18n/es.tsv | 2 + crates/ui-egui/src/i18n/fr.tsv | 2 + crates/ui-egui/src/i18n/hi.tsv | 2 + crates/ui-egui/src/i18n/hu.tsv | 2 + crates/ui-egui/src/i18n/it.tsv | 2 + crates/ui-egui/src/i18n/ja.tsv | 2 + crates/ui-egui/src/i18n/ka.tsv | 2 + crates/ui-egui/src/i18n/ko.tsv | 2 + crates/ui-egui/src/i18n/nl.tsv | 2 + crates/ui-egui/src/i18n/pl.tsv | 2 + crates/ui-egui/src/i18n/pt-br.tsv | 2 + crates/ui-egui/src/i18n/ru.tsv | 2 + crates/ui-egui/src/i18n/sv.tsv | 2 + crates/ui-egui/src/i18n/tr.tsv | 2 + crates/ui-egui/src/i18n/uk.tsv | 2 + crates/ui-egui/src/i18n/zh-hans.tsv | 2 + crates/ui-egui/src/i18n/zh-hant.tsv | 2 + docs/mcp.md | 8 +- 35 files changed, 367 insertions(+), 57 deletions(-) diff --git a/crates/engine/src/cmd.rs b/crates/engine/src/cmd.rs index 4f0d2bad63..86b73ee159 100644 --- a/crates/engine/src/cmd.rs +++ b/crates/engine/src/cmd.rs @@ -853,7 +853,7 @@ pub(crate) use object::bounds_rewrite; pub(crate) use object::{keep_aligned_in, refresh_pixel_aligned}; /// The rules `object.scale`, `object.reflect` and `object.shear` check their params with. pub use object::{reflect_axis, scale_factors, shear_tangent}; -pub(crate) use paint::LIVE_PAINT_BUCKET; +pub(crate) use paint::{LIVE_PAINT_BUCKET, asks_defaults_only}; pub use plugin_call::{Location, ParamsPlace, key_location, location_in, location_keys}; pub use select::SIMILAR; pub(crate) use vectorcraft_doc::range::parse_range; diff --git a/crates/engine/src/cmd/gradient.rs b/crates/engine/src/cmd/gradient.rs index 8cf1091492..2b14fdba2d 100644 --- a/crates/engine/src/cmd/gradient.rs +++ b/crates/engine/src/cmd/gradient.rs @@ -24,7 +24,7 @@ pub fn specs() -> Vec { "Gradient", ["Window", "Gradient"], None, - "{stroke?: bool (default: the targeted item's kind, else the active proxy), kind?: linear|radial|conic|diamond|freeform (conic, also accepted as angle or conical, sweeps the stops once around the center, clockwise from the vector, with a seam where the last stop meets the first; diamond runs the stops from the center out to a square with a corner at the end of the vector; freeform places points on each object, coloured along the stops), mode?: points|lines (freeform: how the Gradient tool adds points), method?: classic|perceptual|hue-clockwise|hue-counterclockwise (how the colours between the stops mix: in display RGB, perceptually (OKLab) so the steps look even, or around the hue wheel: hue, saturation and brightness each change evenly from one stop to the next, the hue angle falling with hue-clockwise (red, magenta, blue, cyan, green, yellow) and rising with hue-counterclockwise; two stops whose hues are less than half a color level apart keep that hue; a stop whose RGB numbers are less than half a color level apart is gray and takes the hue of the stop it mixes with, and black that stop's saturation too; these two methods are VectorCraft's own, and SVG and PDF exports draw their gradients as RGB images, CMYK and spot color stops included; SVG exports draw a Perceptual gradient as an image, and PDF exports do too unless it is linear, radial, conic or diamond, has spot color stops, every other stop is paper white or written in CMYK or gray (an export that converts colors to a CMYK destination profile writes RGB and Lab stops in CMYK, and so does a CMYK document unless the export converts colors to an RGB destination profile), it is not a dithered fill and its curve does not have too many stops: then PDF writes tints of one spot ink as a Separation shading in that ink, and spot inks mixed with other spot, CMYK or gray inks as a DeviceN shading; freeform gradients mix their own way), spread?: pad|repeat|reflect (linear, radial, conic and diamond: what the gradient paints past the ends of its stops: pad carries the end colors on; repeat and reflect run the stops `repeats` times along the vector (around the circle, for a conic) and on past both ends, reflect mirroring every other run; an error on a freeform gradient), repeats?: 1..100 (a whole number: how many times repeat and reflect run the stops along the vector; VectorCraft's own limit; pad keeps it unused), stops?: [{offset 0..1, color? (needed without swatch; #rrggbbaa and #rgba are refused), opacity? 0..1 (or 0..100), midpoint? 0.13..0.87, swatch?: colour swatch name (a global or spot colour or tint swatch links the stop, so swatch edits recolour it and a spot stop prints on its plate; a process colour just gives its colour), tint?: 0..100 (% of the linked swatch; default 100, or a tint swatch's own)}] (at least 2; a freeform gradient's points are recoloured along them), keepModel?: bool (as paint.setFill; a stop color the gradient already has keeps its model), angle?: deg counter-clockwise (0: the gradient runs left to right; radial, conic and diamond: the vector turns about the center), aspect?: % (radial, conic and diamond; a negative one mirrors a conic's sweep and is an error for the other kinds; an error when no object is edited, as with nothing selected, the Live Paint Bucket's gradient, or a fill edit of a Live Paint group without faces: the default gradient fits each new object and keeps no aspect), reverse?: bool (the same ramp the other way round: the stops in reverse order, and a hue method turned the other way unless `method` is given too), dither?: bool (fills only: a linear, radial, conic or diamond gradient fill is drawn with fine noise that hides banding, and as pixels in SVG and PDF exports), item?: fill/stroke item index|null (omitted: the Appearance panel's active item when it is of the edited kind), aligned?: bool (as paint.setFill; without stroke, the kind of the row edited), ids?|id?, strokeMode?: within|along|across (strokes only: the gradient lies on the page and shows through the stroke, runs from the start of each subpath to its end, or runs from the stroke's left edge to its right all along it; with nothing selected, for the next object drawn; type characters' own strokes always paint within), target?: \"object\"|\"contents\"} edit the gradient in place (keeps its placement); solid/none paints become the default gradient. Without `item`, a Live Paint group's faces take a fill edit and its edges take a stroke edit. On a path directly in a graph series, the graph also stores the gradient when it is on the topmost visible fill or stroke (docs/mcp.md); on a graph label's row, or on a graph's axis line, tick mark or radar ring, the graph stores that object's topmost visible fill and stroke rows for every label or line of its kind (a line's gradient without its placement), and on its characters their gradient without its placement, fitted to each label. While the Live Paint Bucket is the active tool and no ids, id or item are given (a null ids or id counts as none), only the default changes (the paint the bucket paints with)", + "{stroke?: bool (default: the targeted item's kind, else the active proxy), kind?: linear|radial|conic|diamond|freeform (conic, also accepted as angle or conical, sweeps the stops once around the center, clockwise from the vector, with a seam where the last stop meets the first; diamond runs the stops from the center out to a square with a corner at the end of the vector; freeform places points on each object, coloured along the stops), mode?: points|lines (freeform: how the Gradient tool adds points), method?: classic|perceptual|hue-clockwise|hue-counterclockwise (how the colours between the stops mix: in display RGB, perceptually (OKLab) so the steps look even, or around the hue wheel: hue, saturation and brightness each change evenly from one stop to the next, the hue angle falling with hue-clockwise (red, magenta, blue, cyan, green, yellow) and rising with hue-counterclockwise; two stops whose hues are less than half a color level apart keep that hue; a stop whose RGB numbers are less than half a color level apart is gray and takes the hue of the stop it mixes with, and black that stop's saturation too; these two methods are VectorCraft's own, and SVG and PDF exports draw their gradients as RGB images, CMYK and spot color stops included; SVG exports draw a Perceptual gradient as an image, and PDF exports do too unless it is linear, radial, conic or diamond, has spot color stops, every other stop is paper white or written in CMYK or gray (an export that converts colors to a CMYK destination profile writes RGB and Lab stops in CMYK, and so does a CMYK document unless the export converts colors to an RGB destination profile), it is not a dithered fill and its curve does not have too many stops: then PDF writes tints of one spot ink as a Separation shading in that ink, and spot inks mixed with other spot, CMYK or gray inks as a DeviceN shading; freeform gradients mix their own way), spread?: pad|repeat|reflect (linear, radial, conic and diamond: what the gradient paints past the ends of its stops: pad carries the end colors on; repeat and reflect run the stops `repeats` times along the vector (around the circle, for a conic) and on past both ends, reflect mirroring every other run; an error on a freeform gradient), repeats?: 1..100 (a whole number: how many times repeat and reflect run the stops along the vector; VectorCraft's own limit; pad keeps it unused), stops?: [{offset 0..1, color? (needed without swatch; #rrggbbaa and #rgba are refused), opacity? 0..1 (or 0..100), midpoint? 0.13..0.87, swatch?: colour swatch name (a global or spot colour or tint swatch links the stop, so swatch edits recolour it and a spot stop prints on its plate; a process colour just gives its colour), tint?: 0..100 (% of the linked swatch; default 100, or a tint swatch's own)}] (at least 2; a freeform gradient's points are recoloured along them), keepModel?: bool (as paint.setFill; a stop color the gradient already has keeps its model), angle?: deg counter-clockwise (0: the gradient runs left to right; radial, conic and diamond: the vector turns about the center), aspect?: % (radial, conic and diamond; a negative one mirrors a conic's sweep and is an error for the other kinds; an error when no object is edited, as with nothing selected, the Live Paint Bucket's gradient, or a fill edit of a Live Paint group without faces: the default gradient fits each new object and keeps no aspect), reverse?: bool (the same ramp the other way round: the stops in reverse order, and a hue method turned the other way unless `method` is given too), dither?: bool (fills only: a linear, radial, conic or diamond gradient fill is drawn with fine noise that hides banding, and as pixels in SVG and PDF exports), item?: fill/stroke item index|null (omitted: the Appearance panel's active item when it is of the edited kind), aligned?: bool (as paint.setFill; without stroke, the kind of the row edited), ids?|id?, defaultsOnly?: bool (as paint.setFill), strokeMode?: within|along|across (strokes only: the gradient lies on the page and shows through the stroke, runs from the start of each subpath to its end, or runs from the stroke's left edge to its right all along it; with nothing selected, for the next object drawn; type characters' own strokes always paint within), target?: \"object\"|\"contents\"} edit the gradient in place (keeps its placement); solid/none paints become the default gradient. Without `item`, a Live Paint group's faces take a fill edit and its edges take a stroke edit. On a path directly in a graph series, the graph also stores the gradient when it is on the topmost visible fill or stroke (docs/mcp.md); on a graph label's row, or on a graph's axis line, tick mark or radar ring, the graph stores that object's topmost visible fill and stroke rows for every label or line of its kind (a line's gradient without its placement), and on its characters their gradient without its placement, fitted to each label. While the Live Paint Bucket is the active tool and no ids, id or item are given (a null ids or id counts as none), or `defaultsOnly: true` is given, only the default changes (the paint the bucket paints with)", has_doc, edit_gradient ), diff --git a/crates/engine/src/cmd/gradpresets.rs b/crates/engine/src/cmd/gradpresets.rs index c8eaa07135..89deda43ad 100644 --- a/crates/engine/src/cmd/gradpresets.rs +++ b/crates/engine/src/cmd/gradpresets.rs @@ -33,7 +33,7 @@ pub fn specs() -> Vec { "Apply Gradient Preset", [], None, - "{name: a preset's name (gradient.presets.list), stroke?, item?, ids?|id?, target? (as paint.editGradient)} give the gradient behind the active proxy (or the targeted fill or stroke) the preset's type, stops, method, spread and repeats (a freeform preset's: the first three), and a fill its dither, keeping its placement; a solid or no paint becomes the gradient. One undo step, as paint.editGradient (while the Live Paint Bucket is the active tool and no ids, id or item are given (a null ids or id counts as none), only the default changes, by the active proxy) → {name, ids: the objects painted (none: only the default changed)}", + "{name: a preset's name (gradient.presets.list), stroke?, item?, ids?|id?, defaultsOnly?, target? (as paint.editGradient)} give the gradient behind the active proxy (or the targeted fill or stroke) the preset's type, stops, method, spread and repeats (a freeform preset's: the first three), and a fill its dither, keeping its placement; a solid or no paint becomes the gradient. One undo step, as paint.editGradient (while the Live Paint Bucket is the active tool and no ids, id or item are given (a null ids or id counts as none), or `defaultsOnly: true` is given, only the default changes, by the active proxy) → {name, ids: the objects painted (none: only the default changed)}", has_doc, apply ), diff --git a/crates/engine/src/cmd/library.rs b/crates/engine/src/cmd/library.rs index 4d562a76e7..3da204e3ad 100644 --- a/crates/engine/src/cmd/library.rs +++ b/crates/engine/src/cmd/library.rs @@ -713,7 +713,7 @@ pub fn specs() -> Vec { "Use Library Item", [], None, - "{library?, kind, item: name (graphic: id or name), center?: [x, y] (graphic; default: the first artboard's centre), to?: fill|stroke (colors, gradients, patterns; default: the kind's), recorded?: the item as it was when used (recorded in the journal so a replay matches)} graphic: place a copy centred on `center`, its resources pasted along, selected, one undo step; colors and gradients: paint the selection (and the defaults) as paint.setFill/paint.setStroke, a gradient fitting each object; a spot color links to the document's spot swatch of its ink's name, added when the document has none of that colour (a name taken by another colour gets a number), one undo step; patterns: add the pattern and its swatch to the document (a name the document gives another pattern gets a number; the same pattern is reused) and paint the selection (and the defaults) with it, one undo step; charStyle/paraStyle: add the style to the document (a name taken by different attributes gets a number; a character style's color linked to a swatch that isn't a global or spot swatch of the document keeps the color it shows, unlinked) and apply it to the selected text, one undo step → {kind, ids?, style?}", + "{library?, kind, item: name (graphic: id or name), center?: [x, y] (graphic; default: the first artboard's centre), to?: fill|stroke (colors, gradients, patterns; default: the kind's), defaultsOnly?: bool (colors, gradients, patterns: paint only the defaults, as with paint.setFill's; the journal records it for an item used while the Live Paint Bucket is the active tool), recorded?: the item as it was when used (recorded in the journal so a replay matches)} graphic: place a copy centred on `center`, its resources pasted along, selected, one undo step; colors and gradients: paint the selection (and the defaults) as paint.setFill/paint.setStroke, a gradient fitting each object; a spot color links to the document's spot swatch of its ink's name, added when the document has none of that colour (a name taken by another colour gets a number), one undo step; patterns: add the pattern and its swatch to the document (a name the document gives another pattern gets a number; the same pattern is reused) and paint the selection (and the defaults) with it, one undo step; charStyle/paraStyle: add the style to the document (a name taken by different attributes gets a number; a character style's color linked to a swatch that isn't a global or spot swatch of the document keeps the color it shows, unlinked) and apply it to the selected text, one undo step → {kind, ids?, style?}", has_doc, use_item ), @@ -1186,6 +1186,7 @@ fn item_param<'a>(s: &Session, p: &'a Value, cmd: &str) -> Result<(String, Kind, fn use_item(s: &mut Session, p: &Value) -> Result { const C: &str = "library.use"; + super::switch_or(p, "defaultsOnly", false, C)?; // A replay (the journal) carries what the item was, so it doesn't depend on the library. let recorded = p.get("recorded").cloned(); let (kind, data) = match recorded { @@ -1247,18 +1248,20 @@ fn use_item(s: &mut Session, p: &Value) -> Result { } Kind::FillColor | Kind::StrokeColor => { let stroke = to_stroke(p, kind)?; + let only = super::paint::defaults_only(s, p, C)?; let color = data.get("color").cloned().ok_or_else(|| bad(C, "no colour"))?; let set = if stroke { "paint.setStroke" } else { "paint.setFill" }; match str_param(&data, "spot").map(str::trim).filter(|n| !n.is_empty()) { - Some(ink) => use_spot(s, set, ink, &color, &data)?, + Some(ink) => use_spot(s, set, ink, &color, &data, only)?, None => { - s.execute(set, &json!({ "color": color }))?; + s.execute(set, &super::paint::with_defaults_only(json!({ "color": color }), only))?; } } Ok(json!({ "kind": if stroke { "strokeColor" } else { "fillColor" } })) } Kind::FillGradient | Kind::StrokeGradient => { let stroke = to_stroke(p, kind)?; + let only = super::paint::defaults_only(s, p, C)?; let damaged = || bad(C, "the library item is damaged"); let mut g: GradientPaint = data.get("gradient").cloned().and_then(|v| serde_json::from_value(v).ok()).ok_or_else(damaged)?; if !clean_gradient(&mut g) { @@ -1268,12 +1271,13 @@ fn use_item(s: &mut Session, p: &Value) -> Result { for st in &mut g.gradient.stops { st.color = super::paint::new_color(s, &json!({}), st.color); } - super::paint::apply_paint(s, &json!({}), Paint::Gradient(Box::new(g)), !stroke)?; + super::paint::apply_paint(s, &super::paint::with_defaults_only(json!({}), only), Paint::Gradient(Box::new(g)), !stroke)?; Ok(json!({ "kind": if stroke { "strokeGradient" } else { "fillGradient" } })) } Kind::FillPattern | Kind::StrokePattern => { let stroke = to_stroke(p, kind)?; - let pattern = use_pattern(s, &data, stroke)?; + let only = super::paint::defaults_only(s, p, C)?; + let pattern = use_pattern(s, &data, stroke, only)?; Ok(json!({ "kind": if stroke { "strokePattern" } else { "fillPattern" }, "pattern": pattern })) } Kind::CharStyle | Kind::ParaStyle => { @@ -1304,8 +1308,8 @@ fn use_item(s: &mut Session, p: &Value) -> Result { /// Paint with library spot colour `ink` (`color` its full-strength colour, `data`'s `tint` its /// tint) through `set` (paint.setFill or paint.setStroke), linked to the document's spot swatch of /// that name: the one it has when it is the same colour, else a new one (a name taken by another -/// colour gets a number), one undo step (#5812). -fn use_spot(s: &mut Session, set: &str, ink: &str, color: &Value, data: &Value) -> Result<()> { +/// colour gets a number), one undo step (#5812). With `only`, only the default takes it. +fn use_spot(s: &mut Session, set: &str, ink: &str, color: &Value, data: &Value, only: bool) -> Result<()> { const C: &str = "library.use"; let c = color_value(color).ok_or_else(|| bad(C, "the library item is damaged"))?; let tint = data.get("tint").and_then(Value::as_f64).filter(|t| t.is_finite()).map_or(1.0, |t| t.clamp(0.0, 1.0)); @@ -1322,7 +1326,7 @@ fn use_spot(s: &mut Session, set: &str, ink: &str, color: &Value, data: &Value) if tint < 1.0 { p["tint"] = json!(tint * 100.0); } - s.execute(set, &p)?; + s.execute(set, &super::paint::with_defaults_only(p, only))?; Ok(()) }) } @@ -1340,8 +1344,8 @@ fn to_stroke(p: &Value, kind: Kind) -> Result { /// Add library pattern `data` (`{pattern, data}`) to the document, with its swatch and the /// resources its art uses (the same pattern there already is reused; a name the document gives /// another one gets a number), and paint the selection's fill (`stroke`: stroke) and the default -/// with it, one undo step → the pattern's name in the document. -fn use_pattern(s: &mut Session, data: &Value, stroke: bool) -> Result { +/// with it (with `only`, only the default), one undo step → the pattern's name in the document. +fn use_pattern(s: &mut Session, data: &Value, stroke: bool, only: bool) -> Result { const C: &str = "library.use"; let damaged = || bad(C, "the library item is damaged"); let bytes = data.get("data").and_then(Value::as_str).and_then(vectorcraft_format::base64_decode).ok_or_else(damaged)?; @@ -1378,7 +1382,7 @@ fn use_pattern(s: &mut Session, data: &Value, stroke: bool) -> Result { } // The pattern itself, not a swatch of its name (a color swatch can share it); `swatch` keeps // the placement of a pattern the targets already have, as picking its swatch does. - super::paint::apply_paint(s, &json!({ "swatch": target }), paint.clone(), !stroke) + super::paint::apply_paint(s, &super::paint::with_defaults_only(json!({ "swatch": target }), only), paint.clone(), !stroke) })?; Ok(target) } diff --git a/crates/engine/src/cmd/newart.rs b/crates/engine/src/cmd/newart.rs index a42088e7e3..88e025ea41 100644 --- a/crates/engine/src/cmd/newart.rs +++ b/crates/engine/src/cmd/newart.rs @@ -19,6 +19,18 @@ use vectorcraft_color::{BlendMode, Paint}; use vectorcraft_doc::{Appearance, AppearanceItem, ColorMode, DEFAULT_GRAPHIC_STYLE, Document, FillLayer, GraphicStyle, Node, NodeKind, StrokeLayer}; use vectorcraft_tools::PaintDefaults; +/// The object new art takes its appearance from, with that appearance +/// ([`Session::new_art_source`]). +#[derive(Clone, Debug, PartialEq)] +pub(crate) struct NewArtSource { + doc: u64, + id: vectorcraft_doc::NodeId, + appearance: Appearance, + opacity: f32, + blend: BlendMode, + style: Option, +} + use super::gradient::unplaced; use super::{CommandSpec, Result, Session, always, cmd, switch_or}; @@ -207,16 +219,35 @@ impl Session { /// After each command: with New Art Has Basic Appearance off, new art takes the appearance of /// the first selected object (so the last selection's once nothing is selected). Not while the - /// Live Paint Bucket is the active tool: the fill and stroke are the colors it paints with. + /// Live Paint Bucket is the active tool: the fill and stroke are the colors it paints with. Nor + /// after a command that changed only them (`defaultsOnly`), unless a later step of a batch + /// changed what new art would take ([`Session::new_art_source`]). pub(crate) fn inherit_new_art(&mut self) { if self.prefs.new_art_basic || self.bucket_paints() { return; } - let Some(st) = self.active() else { return }; - let Some(n) = st.selection.subjects().first().and_then(|id| st.doc.node(*id)) else { return }; - let style = super::style::linked_style(&st.doc, n).map(|g| g.name.clone()); - let (ap, opacity, blend) = (super::style::captured(n), n.opacity, n.blend); - self.take_new_art(ap, opacity, blend, style, true); + let Some(source) = self.new_art_source() else { return }; + if matches!(&self.defaults_only_ran, Some(Some(ran)) if *ran == source) { + return; + } + let NewArtSource { appearance, opacity, blend, style, .. } = source; + self.take_new_art(appearance, opacity, blend, style, true); + } + + /// What [`Session::inherit_new_art`] gives new art: the appearance of the active document's + /// first selected object, if any. + pub(crate) fn new_art_source(&self) -> Option { + let st = self.active()?; + let id = *st.selection.subjects().first()?; + let n = st.doc.node(id)?; + Some(NewArtSource { + doc: st.uid, + id, + appearance: super::style::captured(n), + opacity: n.opacity, + blend: n.blend, + style: super::style::linked_style(&st.doc, n).map(|g| g.name.clone()), + }) } /// After a command changed the selection, with New Art Has Basic Appearance on: the fill and diff --git a/crates/engine/src/cmd/paint.rs b/crates/engine/src/cmd/paint.rs index b94a45e4f5..e96ae7ed05 100644 --- a/crates/engine/src/cmd/paint.rs +++ b/crates/engine/src/cmd/paint.rs @@ -27,7 +27,7 @@ pub fn specs() -> Vec { "Fill", [], None, - "{color?: \"#rrggbb\"|[r,g,b]|{c,m,y,k}|{gray}|{l,a,b} (CIE Lab; #rrggbbaa and #rgba are refused), none?: true, swatch?: name (a global or spot colour stays linked, so swatch edits recolour it; a tint swatch links to its base at its tint; a gradient swatch is recorded as the gradient's swatch and fits each object, keeping its aspect; the built-in \"[Registration]\" prints on every plate), tint?: 0..100 (% of a global or spot `swatch`; default 100, or a tint swatch's own), gradient?: {kind?: linear|radial|conic|diamond|freeform (conic, also accepted as angle or conical: the stops sweep once around the center `start`, clockwise from the vector; diamond: the stops run from the center `start` out to a square with a corner at `end`), method?: classic|perceptual|hue-clockwise|hue-counterclockwise (as paint.editGradient; default classic), spread?: pad|repeat|reflect (as paint.editGradient; default pad), repeats?: 1..100 (as paint.editGradient; default 1), stops?: [{offset 0..1, color, opacity? 0..1 (or 0..100), midpoint? 0.13..0.87, swatch?: global or spot colour (or tint) swatch the stop links to (its colour comes from the swatch), tint?: 0..100}] (at least 2; default white→black), angle?: deg counter-clockwise (0: the gradient runs left to right), start?: [x,y], end?: [x,y] (the vector in document coordinates, both or neither; type objects keep it in text space), aspect?: % (radial, conic and diamond; a negative one mirrors a conic's sweep, counterclockwise, and is an error for the other kinds; without start/end the gradient is placed on each object's bounds), focal?: [x,y] (radial, with start/end: the focal point, where the first stop sits; an error with a conic or diamond), dither?: bool (linear, radial, conic and diamond fills: drawn with fine noise that hides banding, and as pixels in SVG and PDF exports; strokes ignore it), swatch?: linked gradient swatch name}, item?: appearance item index|null (omitted: the Appearance panel's active item if it is a fill, else the top fill), aligned?: bool (index and item are rows of the first target's stack: each other target edits its equal one, as the Appearance panel does for a mixed selection; with the art of a graph design in a series given first, rows of the art's stack: docs/mcp.md), ids?|id?, focus?: true (false keeps the active proxy), keepModel?: false (in a CMYK document, RGB colours and gradient stops are stored as CMYK unless true; Gray stays Gray), target?: \"object\"|\"contents\", span?: \"object\" (default: each target fits a gradient to its own bounds)|\"selection\" (a linear, radial, conic or diamond `gradient` without start/end is placed once on the union of the targets' bounds, so it runs across them)} sets the selection's fill and the default (new art fits a gradient to itself); a solid color recolors only the gradient mesh points picked with the Mesh tool, Direct Selection or the Lasso (unless an `item` index is given or the Appearance panel's active item is a fill); while the Type tool has characters selected (and no ids or item are given), the paint goes to those characters only; without `item`, a Live Paint group among the targets (or inside one) takes the fill on its faces only; without `item`, a grayscale or 1-bit image takes a solid color as the color it is drawn in (white pixels transparent; `none` takes it off; an image with an alpha channel takes only a spot color, black or white; a colorized image whose link is missing takes a solid color as its new colorize color, and refuses a process color while its color is a spot color, black or white); with an object of a dynamic symbol instance selected by Direct Selection and no ids, id or item, that object's fill changes for this instance only (solid, none, gradient or pattern). On a path directly in a graph series, the graph also stores the paint of the topmost visible fill when the command wrote that row or changed it (exceptions: docs/mcp.md); on a graph label, the graph stores the paint for every label of its kind, as a character fill when the characters took it and with the label's rows when a row did; on a graph's axis line, tick mark or radar ring, its rows for every line of its kind. While the Live Paint Bucket is the active tool and no ids, id or item are given (a null ids or id counts as none), only the default changes (the color the bucket paints with) and the selection keeps its paint → {objects: how many objects took the paint (the objects inside a group, unless an appearance item of the group's own is targeted; 0 when only the default changed)}", + "{color?: \"#rrggbb\"|[r,g,b]|{c,m,y,k}|{gray}|{l,a,b} (CIE Lab; #rrggbbaa and #rgba are refused), none?: true, swatch?: name (a global or spot colour stays linked, so swatch edits recolour it; a tint swatch links to its base at its tint; a gradient swatch is recorded as the gradient's swatch and fits each object, keeping its aspect; the built-in \"[Registration]\" prints on every plate), tint?: 0..100 (% of a global or spot `swatch`; default 100, or a tint swatch's own), gradient?: {kind?: linear|radial|conic|diamond|freeform (conic, also accepted as angle or conical: the stops sweep once around the center `start`, clockwise from the vector; diamond: the stops run from the center `start` out to a square with a corner at `end`), method?: classic|perceptual|hue-clockwise|hue-counterclockwise (as paint.editGradient; default classic), spread?: pad|repeat|reflect (as paint.editGradient; default pad), repeats?: 1..100 (as paint.editGradient; default 1), stops?: [{offset 0..1, color, opacity? 0..1 (or 0..100), midpoint? 0.13..0.87, swatch?: global or spot colour (or tint) swatch the stop links to (its colour comes from the swatch), tint?: 0..100}] (at least 2; default white→black), angle?: deg counter-clockwise (0: the gradient runs left to right), start?: [x,y], end?: [x,y] (the vector in document coordinates, both or neither; type objects keep it in text space), aspect?: % (radial, conic and diamond; a negative one mirrors a conic's sweep, counterclockwise, and is an error for the other kinds; without start/end the gradient is placed on each object's bounds), focal?: [x,y] (radial, with start/end: the focal point, where the first stop sits; an error with a conic or diamond), dither?: bool (linear, radial, conic and diamond fills: drawn with fine noise that hides banding, and as pixels in SVG and PDF exports; strokes ignore it), swatch?: linked gradient swatch name}, item?: appearance item index|null (omitted: the Appearance panel's active item if it is a fill, else the top fill), aligned?: bool (index and item are rows of the first target's stack: each other target edits its equal one, as the Appearance panel does for a mixed selection; with the art of a graph design in a series given first, rows of the art's stack: docs/mcp.md), ids?|id?, defaultsOnly?: bool, focus?: true (false keeps the active proxy), keepModel?: false (in a CMYK document, RGB colours and gradient stops are stored as CMYK unless true; Gray stays Gray), target?: \"object\"|\"contents\", span?: \"object\" (default: each target fits a gradient to its own bounds)|\"selection\" (a linear, radial, conic or diamond `gradient` without start/end is placed once on the union of the targets' bounds, so it runs across them)} sets the selection's fill and the default (new art fits a gradient to itself); a solid color recolors only the gradient mesh points picked with the Mesh tool, Direct Selection or the Lasso (unless an `item` index is given or the Appearance panel's active item is a fill); while the Type tool has characters selected (and no ids or item are given), the paint goes to those characters only; without `item`, a Live Paint group among the targets (or inside one) takes the fill on its faces only; without `item`, a grayscale or 1-bit image takes a solid color as the color it is drawn in (white pixels transparent; `none` takes it off; an image with an alpha channel takes only a spot color, black or white; a colorized image whose link is missing takes a solid color as its new colorize color, and refuses a process color while its color is a spot color, black or white); with an object of a dynamic symbol instance selected by Direct Selection and no ids, id or item, that object's fill changes for this instance only (solid, none, gradient or pattern). On a path directly in a graph series, the graph also stores the paint of the topmost visible fill when the command wrote that row or changed it (exceptions: docs/mcp.md); on a graph label, the graph stores the paint for every label of its kind, as a character fill when the characters took it and with the label's rows when a row did; on a graph's axis line, tick mark or radar ring, its rows for every line of its kind. While the Live Paint Bucket is the active tool and no ids, id or item are given (a null ids or id counts as none), or `defaultsOnly: true` is given, only the default changes (the color the bucket paints with) and the selection keeps its paint; `defaultsOnly` with ids, id or item is refused, and the journal records a change the bucket made this way with `defaultsOnly: true`, so a replay with another tool active changes the default too → {objects: how many objects took the paint (the objects inside a group, unless an appearance item of the group's own is targeted; 0 when only the default changed)}", has_doc, |s, p| set_paint(s, p, true) ), @@ -45,7 +45,7 @@ pub fn specs() -> Vec { "Swap Fill and Stroke", [], Some("Shift+X"), - "{ids?|id?} swap the fill and stroke of the selection (type too) and of the defaults. A Live Paint group's faces take the stroke its edges share and its edges take the fill its faces share, a gradient fitted to each face or edge; a group whose faces' fills or edges' strokes differ (a freeform gradient counts as differing), or that has no face or no edge, keeps its paint. On a path directly in a graph series, the graph also stores the swapped paints and the stroke weight, and on a graph label the swapped paints of its characters for every label of its kind, and on a graph's axis line, tick mark or radar ring what the swap changes on its rows for every line of its kind (exceptions: docs/mcp.md). While the Live Paint Bucket is the active tool and no ids or id are given (a null one counts as none), only the defaults change", + "{ids?|id?, defaultsOnly?: bool} swap the fill and stroke of the selection (type too) and of the defaults. A Live Paint group's faces take the stroke its edges share and its edges take the fill its faces share, a gradient fitted to each face or edge; a group whose faces' fills or edges' strokes differ (a freeform gradient counts as differing), or that has no face or no edge, keeps its paint. On a path directly in a graph series, the graph also stores the swapped paints and the stroke weight, and on a graph label the swapped paints of its characters for every label of its kind, and on a graph's axis line, tick mark or radar ring what the swap changes on its rows for every line of its kind (exceptions: docs/mcp.md). While the Live Paint Bucket is the active tool and no ids or id are given (a null one counts as none), or `defaultsOnly: true` is given, only the defaults change", has_doc, swap ), @@ -54,7 +54,7 @@ pub fn specs() -> Vec { "Default Fill and Stroke", [], Some("D"), - "{ids?|id?} white fill and 1 pt black stroke for the selection and the defaults (in a document whose Default Graphic Style differs from the shipped one, as a New Document profile can redefine it: that style's fills, strokes and effects, without its opacity or a link to it); type gets black fill and no stroke. A Live Paint group's faces get no fill and its edges get a 0.5 pt black stroke, in place of their whole appearance and also when the Default Graphic Style is redefined, and with only Live Paint groups selected (or in ids) the defaults become no fill and a 0.5 pt black stroke (with New Art Has Basic Appearance off, new art then takes the selection's appearance, as after any command). 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 on a graph label the black fill and no stroke of its characters for every label of its kind, and on a graph's axis line, tick mark or radar ring its rows for every line of its kind (exceptions: docs/mcp.md). While the Live Paint Bucket is the active tool and no ids or id are given (a null one counts as none), only the defaults change", + "{ids?|id?, defaultsOnly?: bool} white fill and 1 pt black stroke for the selection and the defaults (in a document whose Default Graphic Style differs from the shipped one, as a New Document profile can redefine it: that style's fills, strokes and effects, without its opacity or a link to it); type gets black fill and no stroke. A Live Paint group's faces get no fill and its edges get a 0.5 pt black stroke, in place of their whole appearance and also when the Default Graphic Style is redefined, and with only Live Paint groups selected (or in ids) the defaults become no fill and a 0.5 pt black stroke (with New Art Has Basic Appearance off, new art then takes the selection's appearance, as after any command). 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 on a graph label the black fill and no stroke of its characters for every label of its kind, and on a graph's axis line, tick mark or radar ring its rows for every line of its kind (exceptions: docs/mcp.md). While the Live Paint Bucket is the active tool and no ids or id are given (a null one counts as none), or `defaultsOnly: true` is given, only the defaults change", has_doc, default_paint ), @@ -75,11 +75,12 @@ pub fn specs() -> Vec { "None", [], Some("/"), - "{} set the active proxy (fill or stroke) to None, as paint.setFill or paint.setStroke with none does (while the Live Paint Bucket is the active tool, only the default changes) → {objects}", + "{defaultsOnly?: bool} set the active proxy (fill or stroke) to None, as paint.setFill or paint.setStroke with none does (while the Live Paint Bucket is the active tool, or with `defaultsOnly: true`, only the default changes) → {objects}", has_doc, - |s, _| { + |s, p| { let f = s.fill_active; - set_paint(s, &json!({"none": true}), f) + let only = switch_or(p, "defaultsOnly", false, "paint.none")?; + set_paint(s, &with_defaults_only(json!({"none": true}), only), f) } ), cmd!( @@ -102,7 +103,7 @@ pub fn proxy_specs() -> Vec { "Invert", [], None, - "{stroke?: bool (default: the active proxy), ids?|id?, item?: appearance item index|null, aligned?: bool (as paint.setFill), target?: \"object\"|\"contents\"} invert the active proxy's colours of the selection (or ids; groups recolour their contents and, except with target \"contents\", their own fills and strokes; a compound path's member stands for its compound path; a Live Paint group recolors its faces' fills or its edges' strokes) keeping each colour's model, as edit.colors.invert does; the Appearance panel's active fill/stroke item (appearance.setActiveItem) is inverted instead when it is of that kind and no ids are given; with an object of a dynamic symbol instance selected by Direct Selection and no ids, id or item, that object's solid color changes for this instance only, and a gradient or pattern, or type whose characters differ in color, is refused; with nothing selected, or while the Live Paint Bucket is the active tool and no ids, id or item are given (a null ids or id counts as none), invert the default. On a path directly in a graph series, the graph also stores the new color of the topmost visible fill or stroke, and on a graph label the new color of its characters and rows for every label of its kind, and on a graph's axis line, tick mark or radar ring its rows for every line of its kind (docs/mcp.md); no undo step when no color changes → {changed}", + "{stroke?: bool (default: the active proxy), ids?|id?, defaultsOnly?: bool, item?: appearance item index|null, aligned?: bool (as paint.setFill), target?: \"object\"|\"contents\"} invert the active proxy's colours of the selection (or ids; groups recolour their contents and, except with target \"contents\", their own fills and strokes; a compound path's member stands for its compound path; a Live Paint group recolors its faces' fills or its edges' strokes) keeping each colour's model, as edit.colors.invert does; the Appearance panel's active fill/stroke item (appearance.setActiveItem) is inverted instead when it is of that kind and no ids are given; with an object of a dynamic symbol instance selected by Direct Selection and no ids, id or item, that object's solid color changes for this instance only, and a gradient or pattern, or type whose characters differ in color, is refused; with nothing selected, or while the Live Paint Bucket is the active tool and no ids, id or item are given (a null ids or id counts as none), or `defaultsOnly: true` is given, invert the default. On a path directly in a graph series, the graph also stores the new color of the topmost visible fill or stroke, and on a graph label the new color of its characters and rows for every label of its kind, and on a graph's axis line, tick mark or radar ring its rows for every line of its kind (docs/mcp.md); no undo step when no color changes → {changed}", has_doc, |s, p| proxy_recolor(s, p, "paint.invert", "Invert", &super::colorcmds::invert) ), @@ -111,7 +112,7 @@ pub fn proxy_specs() -> Vec { "Complement", [], None, - "{stroke?: bool (default: the active proxy), ids?|id?, item?: appearance item index|null, aligned?: bool (as paint.setFill), target?: \"object\"|\"contents\"} replace the active proxy's colours by their complements ((highest + lowest) − each component, over RGB or CMY; grey unchanged) keeping each colour's model; a Live Paint group recolors its faces' fills or its edges' strokes as with paint.invert; honours the Appearance panel's active item and a selected object of a dynamic symbol instance as paint.invert does; with nothing selected, or while the Live Paint Bucket is the active tool and no ids, id or item are given (a null ids or id counts as none), the default; no undo step when no color changes → {changed}", + "{stroke?: bool (default: the active proxy), ids?|id?, defaultsOnly?: bool, item?: appearance item index|null, aligned?: bool (as paint.setFill), target?: \"object\"|\"contents\"} replace the active proxy's colours by their complements ((highest + lowest) − each component, over RGB or CMY; grey unchanged) keeping each colour's model; a Live Paint group recolors its faces' fills or its edges' strokes as with paint.invert; honours the Appearance panel's active item and a selected object of a dynamic symbol instance as paint.invert does; with nothing selected, or while the Live Paint Bucket is the active tool and no ids, id or item are given (a null ids or id counts as none), or `defaultsOnly: true` is given, the default; no undo step when no color changes → {changed}", has_doc, |s, p| proxy_recolor(s, p, "paint.complement", "Complement", &|c: Color| c.complement_keep_model()) ), @@ -120,7 +121,7 @@ pub fn proxy_specs() -> Vec { "Apply Last Color", [], Some(","), - "{stroke?: bool (default: the active proxy), ids?|id?, item?: appearance item index|null, aligned?: bool (as paint.setFill), target?: \"object\"|\"contents\"} apply the last solid colour used (paint.recent lastColor) to the active proxy of the selection and the default (while the Live Paint Bucket is the active tool and no ids, id or item are given (a null ids or id counts as none), to the default only) → {objects} (as paint.setFill)", + "{stroke?: bool (default: the active proxy), ids?|id?, defaultsOnly?: bool, item?: appearance item index|null, aligned?: bool (as paint.setFill), target?: \"object\"|\"contents\"} apply the last solid colour used (paint.recent lastColor) to the active proxy of the selection and the default (while the Live Paint Bucket is the active tool and no ids, id or item are given (a null ids or id counts as none), or `defaultsOnly: true` is given, to the default only) → {objects} (as paint.setFill)", has_doc, |s, p| { let paint = Paint::solid(s.last_solid); @@ -132,7 +133,7 @@ pub fn proxy_specs() -> Vec { "Apply Last Gradient", [], Some("."), - "{stroke?: bool (default: the active proxy), ids?|id?, item?: appearance item index|null, aligned?: bool (as paint.setFill), target?: \"object\"|\"contents\"} apply the last gradient used (paint.recent lastGradient), fitted to each object, to the active proxy of the selection and the default (while the Live Paint Bucket is the active tool and no ids, id or item are given (a null ids or id counts as none), to the default only) → {objects} (as paint.setFill)", + "{stroke?: bool (default: the active proxy), ids?|id?, defaultsOnly?: bool, item?: appearance item index|null, aligned?: bool (as paint.setFill), target?: \"object\"|\"contents\"} apply the last gradient used (paint.recent lastGradient), fitted to each object, to the active proxy of the selection and the default (while the Live Paint Bucket is the active tool and no ids, id or item are given (a null ids or id counts as none), or `defaultsOnly: true` is given, to the default only) → {objects} (as paint.setFill)", has_doc, |s, p| { let paint = super::gradient::unplaced(&Paint::Gradient(Box::new(s.last_gradient.clone()))); @@ -750,28 +751,84 @@ pub(crate) fn apply_paint(s: &mut Session, p: &Value, paint: Paint, fill: bool) Ok(json!({"objects": ids.iter().collect::>().len()})) } -/// Is the Live Paint Bucket the active tool ([`Session::bucket_paints`]) while `p` names no `ids`, -/// `id` or `item`? A fill, -/// stroke or stroke weight chosen then is what the bucket paints with, so it goes to the defaults -/// and the selection keeps its paint. -pub(crate) fn for_bucket(s: &Session, p: &Value) -> bool { +/// Does `p` name no `ids`, `id` or `item`? +fn names_no_target(p: &Value) -> bool { // A null `ids` or `id` is no target, as `given_nodes` reads it; `item: null` names the top row. - s.bucket_paints() && ["ids", "id"].iter().all(|k| p.get(k).is_none_or(Value::is_null)) && p.get("item").is_none() + ["ids", "id"].iter().all(|k| p.get(k).is_none_or(Value::is_null)) && p.get("item").is_none() } -/// `p` with `ids: []` when [`for_bucket`]: the paint goes to the defaults only. None otherwise. -/// A bad `target` or `aligned` is refused first, as it is without the bucket. -pub(crate) fn bucket_color_params(s: &Session, p: &Value, cmd: &str) -> Result> { +/// Is the Live Paint Bucket the active tool ([`Session::bucket_paints`]), or does `p` give +/// `defaultsOnly: true`, while `p` names no `ids`, `id` or `item`? A fill, stroke or stroke weight +/// chosen then is what the bucket paints with, so it goes to the defaults and the selection keeps +/// its paint. +pub(crate) fn for_bucket(s: &Session, p: &Value) -> bool { + names_no_target(p) && (s.bucket_paints() || asks_defaults_only(p)) +} + +/// Does `p` give `defaultsOnly: true`? +pub(crate) fn asks_defaults_only(p: &Value) -> bool { + p.get("defaultsOnly") == Some(&Value::Bool(true)) +} + +/// `p` with `ids: []` (and without `defaultsOnly`) when [`for_bucket`]: the paint goes to the +/// defaults only. None otherwise. A bad `target` or `aligned` is refused first, as it is without +/// the bucket, and so is a `defaultsOnly` that is not a bool or comes with `ids`, `id` or `item`. +/// When the bucket routed the command, the journal entry notes `defaultsOnly: true`, so replaying +/// it with another tool active changes the defaults only as well. +pub(crate) fn bucket_color_params(s: &mut Session, p: &Value, cmd: &str) -> Result> { + let only = switch_or(p, "defaultsOnly", false, cmd)?; + if only && !names_no_target(p) { + return Err(bad(cmd, "`defaultsOnly` cannot be combined with `ids`, `id` or `item`")); + } if !for_bucket(s, p) { return Ok(None); } super::appearance::aligned(p, cmd)?; super::appearance::targets_contents(p)?; + if !only { + s.note_journal("defaultsOnly", json!(true)); + } + s.note_defaults_only(); let mut v = p.as_object().cloned().unwrap_or_default(); + v.remove("defaultsOnly"); v.insert("ids".into(), json!([])); Ok(Some(Value::Object(v))) } +/// Whether the paint commands that `cmd` runs with params of its own change only the defaults: +/// `p` gives `defaultsOnly: true`, or the Live Paint Bucket paints ([`Session::bucket_paints`]), +/// which the journal entry of `cmd` notes for a replay. +pub(crate) fn defaults_only(s: &mut Session, p: &Value, cmd: &str) -> Result { + if switch_or(p, "defaultsOnly", false, cmd)? { + s.note_defaults_only(); + return Ok(true); + } + let bucket = s.bucket_paints(); + if bucket { + s.note_journal("defaultsOnly", json!(true)); + s.note_defaults_only(); + } + Ok(bucket) +} + +impl Session { + /// Note that the running command changed only the paint defaults, with the appearance new art + /// takes from the selection now ([`Session::inherit_new_art`]). No appearance is captured + /// while inheritance does not run (New Art Has Basic Appearance on, or the bucket painting). + fn note_defaults_only(&mut self) { + let inherits = !self.prefs.new_art_basic && !self.bucket_paints(); + self.defaults_only_ran = Some(if inherits { self.new_art_source() } else { None }); + } +} + +/// `q` with `defaultsOnly: true` when `only` ([`defaults_only`]). +pub(crate) fn with_defaults_only(mut q: Value, only: bool) -> Value { + if only && let Some(o) = q.as_object_mut() { + o.insert("defaultsOnly".into(), json!(true)); + } + q +} + /// The Live Paint groups in `roots` (or inside them), given or selected whole, with the ids of /// their faces and of their edges, found where [`leaf_targets`] finds the objects a paint command /// changes: a given or selected object other than a group or layer (a blend, say) and a compound diff --git a/crates/engine/src/cmd/stroke.rs b/crates/engine/src/cmd/stroke.rs index cb5d1fd374..16be04723a 100644 --- a/crates/engine/src/cmd/stroke.rs +++ b/crates/engine/src/cmd/stroke.rs @@ -23,7 +23,7 @@ pub fn specs() -> Vec { "Stroke Options", ["Window", "Stroke"], None, - "{weight?: pt, cap?: butt|round|square, join?: miter|round|bevel, miterLimit?, align?: center|inside|outside, dash?: [d,g,…]|null (a 0 dash with a round or projecting cap draws dots or squares; a new pattern keeps the current offset and alignment), dashOffset? (exact dashes only), alignDashes?: bool (true: dashes fitted to corners and path ends, every run between them holding whole periods with a dash centred on each corner and end; false, the default for a new pattern: exact lengths), startArrow?, endArrow?: Arrow|ArrowOpen|LineArrow|Barbed|Concave|DoubleArrow|HalfArrowLeft|HalfArrowRight|Chevron|Feather|Swallowtail|Triangle|TriangleOpen|TriangleReverse|TriangleBar|Kite|Leaf|Drop|Circle|CircleOpen|HalfCircle|Oval|Target|Square|SquareOpen|Tag|TagOpen|Diamond|DiamondOpen|Hexagon|HexagonOpen|Star|Cross|Plus|Bar|DoubleBar|DotOnBar|Slash|DoubleSlash|Bracket|Fork|null|{custom: name} (a custom arrowhead of the arrowheads file, stroke.arrowheads.list)|{Custom: {name, path, stop?}} (a custom head with its art, as document.inspect reports one; stop: where the stroke ends under the head, in head units back from the tip, 0..64 (otherwise, or without one, halfway along the head); refused when the path fills no area, parts thinner than a millionth of a head unit counting as none, or has more than 4096 anchors, more than 4096 subpaths or a point more than 64 head units from the tip) (HalfArrowLeft/Right: one barb, left or right of the direction the head points), arrowAlign?: \"extend\" (tip past the end point, default)|\"tip\" (tip on the end point; the stroke is shortened), profile?: \"uniform\"|\"lens\"|\"taperStart\"|\"taperEnd\"|\"pinch\"|\"teardrop\"|\"wave\"|a saved profile's name (stroke.widthProfile.list), widthPoints?, gradientMode? (as document.inspect reports them in strokeOptions, so those read back unchanged; ignored here: a custom profile is set with the Width tool, gradientMode with paint.editGradient), item?: stroke item index|null (omitted: the Appearance panel's active item if it is a stroke, else the top stroke, created when missing), ids?|id?, target?: \"object\"|\"contents\", aligned?: bool (index and item are rows of the first target's stack: each other target edits its equal one, as the Appearance panel does for a mixed selection; with the art of a graph design in a series given first, rows of the art's stack: docs/mcp.md)} Without a stroke item, type takes weight, cap, join, miterLimit, align (around its glyph outlines; the type stays live) and the dash options as its characters' stroke (every run; text.setRangeStyle `strokeOptions` styles a range), and images and symbol instances (also in groups) are left alone; a Live Paint group takes them on its edges only. With nothing selected (and no ids) they set up the next object drawn (appearance.newArt; weight always does). On a path directly in a graph series, the graph also stores a weight it changes on the topmost visible stroke (docs/mcp.md); on a graph label's stroke row, the graph stores the label's topmost visible fill and stroke rows for every label of its kind, and on its characters the stroke options they take; on a graph's axis line, tick mark or radar ring, the graph stores the paint, weight, opacity and blend mode of its topmost visible fill and stroke rows that the edit changes, and the weight it writes to the topmost visible stroke, for every line of its kind, and not its caps, joins, dashes, alignment or arrowheads. While the Live Paint Bucket is the active tool and no ids, id or item are given (a null ids or id counts as none), only the stroke for new art changes (the bucket paints edges with its color and weight) → {objects: how many objects took the stroke options}", + "{weight?: pt, cap?: butt|round|square, join?: miter|round|bevel, miterLimit?, align?: center|inside|outside, dash?: [d,g,…]|null (a 0 dash with a round or projecting cap draws dots or squares; a new pattern keeps the current offset and alignment), dashOffset? (exact dashes only), alignDashes?: bool (true: dashes fitted to corners and path ends, every run between them holding whole periods with a dash centred on each corner and end; false, the default for a new pattern: exact lengths), startArrow?, endArrow?: Arrow|ArrowOpen|LineArrow|Barbed|Concave|DoubleArrow|HalfArrowLeft|HalfArrowRight|Chevron|Feather|Swallowtail|Triangle|TriangleOpen|TriangleReverse|TriangleBar|Kite|Leaf|Drop|Circle|CircleOpen|HalfCircle|Oval|Target|Square|SquareOpen|Tag|TagOpen|Diamond|DiamondOpen|Hexagon|HexagonOpen|Star|Cross|Plus|Bar|DoubleBar|DotOnBar|Slash|DoubleSlash|Bracket|Fork|null|{custom: name} (a custom arrowhead of the arrowheads file, stroke.arrowheads.list)|{Custom: {name, path, stop?}} (a custom head with its art, as document.inspect reports one; stop: where the stroke ends under the head, in head units back from the tip, 0..64 (otherwise, or without one, halfway along the head); refused when the path fills no area, parts thinner than a millionth of a head unit counting as none, or has more than 4096 anchors, more than 4096 subpaths or a point more than 64 head units from the tip) (HalfArrowLeft/Right: one barb, left or right of the direction the head points), arrowAlign?: \"extend\" (tip past the end point, default)|\"tip\" (tip on the end point; the stroke is shortened), profile?: \"uniform\"|\"lens\"|\"taperStart\"|\"taperEnd\"|\"pinch\"|\"teardrop\"|\"wave\"|a saved profile's name (stroke.widthProfile.list), widthPoints?, gradientMode? (as document.inspect reports them in strokeOptions, so those read back unchanged; ignored here: a custom profile is set with the Width tool, gradientMode with paint.editGradient), item?: stroke item index|null (omitted: the Appearance panel's active item if it is a stroke, else the top stroke, created when missing), ids?|id?, defaultsOnly?: bool, target?: \"object\"|\"contents\", aligned?: bool (index and item are rows of the first target's stack: each other target edits its equal one, as the Appearance panel does for a mixed selection; with the art of a graph design in a series given first, rows of the art's stack: docs/mcp.md)} Without a stroke item, type takes weight, cap, join, miterLimit, align (around its glyph outlines; the type stays live) and the dash options as its characters' stroke (every run; text.setRangeStyle `strokeOptions` styles a range), and images and symbol instances (also in groups) are left alone; a Live Paint group takes them on its edges only. With nothing selected (and no ids) they set up the next object drawn (appearance.newArt; weight always does). On a path directly in a graph series, the graph also stores a weight it changes on the topmost visible stroke (docs/mcp.md); on a graph label's stroke row, the graph stores the label's topmost visible fill and stroke rows for every label of its kind, and on its characters the stroke options they take; on a graph's axis line, tick mark or radar ring, the graph stores the paint, weight, opacity and blend mode of its topmost visible fill and stroke rows that the edit changes, and the weight it writes to the topmost visible stroke, for every line of its kind, and not its caps, joins, dashes, alignment or arrowheads. While the Live Paint Bucket is the active tool and no ids, id or item are given (a null ids or id counts as none), or `defaultsOnly: true` is given (refused with ids, id or item), only the stroke for new art changes (the bucket paints edges with its color and weight) → {objects: how many objects took the stroke options}", has_doc, stroke_set ), @@ -32,7 +32,7 @@ pub fn specs() -> Vec { "Stroke Weight Up", [], Some("Cmd+Alt+."), - "{ids?|id?} raise each selected stroke's weight by one step of Units › Stroke (a quarter unit below one unit, then whole units; up to 1000 pt), each from its own weight: the selected objects' active or top stroke, type's stroked characters; objects without a stroke, and a Live Paint group's faces, are left alone. With nothing selected (and no ids), the weight of the next object drawn, and so while the Live Paint Bucket is the active tool and no ids or id are given (a null one counts as none). On a path directly in a graph series, the graph also stores the new weight of the topmost visible stroke, and on a graph label the new weight of its characters' stroke or its stroke row for every label of its kind, and on a graph's axis line, tick mark or radar ring its rows for every line of its kind (docs/mcp.md) → {objects}", + "{ids?|id?, defaultsOnly?: bool (as stroke.set)} raise each selected stroke's weight by one step of Units › Stroke (a quarter unit below one unit, then whole units; up to 1000 pt), each from its own weight: the selected objects' active or top stroke, type's stroked characters; objects without a stroke, and a Live Paint group's faces, are left alone. With nothing selected (and no ids), the weight of the next object drawn, and so while the Live Paint Bucket is the active tool and no ids or id are given (a null one counts as none), or `defaultsOnly: true` is given. On a path directly in a graph series, the graph also stores the new weight of the topmost visible stroke, and on a graph label the new weight of its characters' stroke or its stroke row for every label of its kind, and on a graph's axis line, tick mark or radar ring its rows for every line of its kind (docs/mcp.md) → {objects}", has_doc, |s, p| stroke_step(s, p, true) ), @@ -41,7 +41,7 @@ pub fn specs() -> Vec { "Stroke Weight Down", [], Some("Cmd+Alt+,"), - "{ids?|id?} lower each selected stroke's weight by one step, as stroke.weightUp raises it, down to a quarter unit (a thinner weight is kept) → {objects}", + "{ids?|id?, defaultsOnly?: bool (as stroke.set)} lower each selected stroke's weight by one step, as stroke.weightUp raises it, down to a quarter unit (a thinner weight is kept) → {objects}", has_doc, |s, p| stroke_step(s, p, false) ), @@ -50,7 +50,7 @@ pub fn specs() -> Vec { "Stroke Options", [], None, - "{arrowScale?: [start %, end %], swapArrows?: bool, flipProfile?: \"along\"|\"across\", brush?: name|null, item?: stroke item index|null, aligned?: bool (as stroke.set), ids?|id?, target?: \"object\"|\"contents\"} Stroke panel extras (with nothing selected, all but brush set up the next object drawn, and so while the Live Paint Bucket is the active tool and no ids, id, item or brush are given, a null ids or id counting as none; without item, a Live Paint group's edges take them and its faces are left alone)", + "{arrowScale?: [start %, end %], swapArrows?: bool, flipProfile?: \"along\"|\"across\", brush?: name|null, item?: stroke item index|null, aligned?: bool (as stroke.set), ids?|id?, defaultsOnly?: bool (as stroke.set; refused with brush), target?: \"object\"|\"contents\"} Stroke panel extras (with nothing selected, all but brush set up the next object drawn, and so while the Live Paint Bucket is the active tool, or with `defaultsOnly: true`, and no ids, id, item or brush are given, a null ids or id counting as none; without item, a Live Paint group's edges take them and its faces are left alone)", has_doc, stroke_advanced ), @@ -618,7 +618,10 @@ fn stroke_advanced(s: &mut Session, p: &Value) -> Result { return Err(bad(C, "nothing to change")); } // As stroke.set: the stroke the Live Paint Bucket paints with changes; the selection keeps its own. - // A brush still goes to the selection. + // A brush still goes to the selection, and new art has no brush for `defaultsOnly` to set. + if brush.is_some() && super::switch_or(p, "defaultsOnly", false, C)? { + return Err(bad(C, "`defaultsOnly` cannot be combined with `brush`")); + } let bucket_p = if brush.is_none() { super::paint::bucket_color_params(s, p, C)? } else { None }; let bucket = bucket_p.is_some(); let p = bucket_p.as_ref().unwrap_or(p); diff --git a/crates/engine/src/cmd/swatchlib.rs b/crates/engine/src/cmd/swatchlib.rs index e4d89b9c13..c36fb6413b 100644 --- a/crates/engine/src/cmd/swatchlib.rs +++ b/crates/engine/src/cmd/swatchlib.rs @@ -49,7 +49,7 @@ pub fn specs() -> Vec { "Add to Swatches", ["Window", "Swatch Libraries"], None, - "{library: id or name, names?: [swatch or colour group names in the library] (default: all of it; a group comes as a colour group, a single swatch ungrouped), apply?: \"fill\"|\"stroke\" (also apply the first one to the selection and the defaults, as paint.setFill / paint.setStroke), focus?: true (with apply: false keeps the active proxy)} copy library swatches into the document as one undo step. A swatch the document already has (same name and paint) isn't added again; a name taken by another swatch gets a number (\"Clay 1 2\"). A pattern swatch brings its pattern, as pasting art painted with it does: the same pattern the document has is used, and a name another pattern or swatch has gets a number; a global or spot color its art links to whose name the document gives another color comes in numbered, and the pattern links to it → {library, added: [names in the document], existing: [names already there], applied?: name}", + "{library: id or name, names?: [swatch or colour group names in the library] (default: all of it; a group comes as a colour group, a single swatch ungrouped), apply?: \"fill\"|\"stroke\" (also apply the first one to the selection and the defaults, as paint.setFill / paint.setStroke), focus?: true (with apply: false keeps the active proxy), defaultsOnly?: bool (with apply: apply it to the defaults only, as paint.setFill does; the journal records it for swatches applied while the Live Paint Bucket is the active tool)} copy library swatches into the document as one undo step. A swatch the document already has (same name and paint) isn't added again; a name taken by another swatch gets a number (\"Clay 1 2\"). A pattern swatch brings its pattern, as pasting art painted with it does: the same pattern the document has is used, and a name another pattern or swatch has gets a number; a global or spot color its art links to whose name the document gives another color comes in numbered, and the pattern links to it → {library, added: [names in the document], existing: [names already there], applied?: name}", has_doc, add ), @@ -1021,6 +1021,7 @@ fn add(s: &mut Session, p: &Value) -> Result { Some(other) => return Err(bad(C, format!("apply is \"fill\" or \"stroke\", not `{other}`"))), }; let focus = switch_or(p, "focus", true, C)?; + switch_or(p, "defaultsOnly", false, C)?; let picked = picked(&lib, &names_param(p, C)?, C)?; // Swatches the document already has (same name and paint; for a pattern swatch, a swatch of the // same pattern) are reused, not added again. The patterns are in a built-in pattern library's @@ -1144,7 +1145,8 @@ fn add(s: &mut Session, p: &Value) -> Result { let mut out = json!({"library": shown_library_id(s, &info.id), "added": names(&added), "existing": names(&existing)}); if let (Some(cmd), Some((_, first))) = (apply, picked.first()) { let name = added.iter().chain(&existing).find(|(l, _)| *l == first.name).map_or(first.name.clone(), |(_, n)| n.clone()); - s.execute(cmd, &json!({"swatch": name, "focus": focus}))?; + let only = super::paint::defaults_only(s, p, C)?; + s.execute(cmd, &super::paint::with_defaults_only(json!({"swatch": name, "focus": focus}), only))?; // Adding and applying undo together. squash(s, undo_before, "Add to Swatches"); out["applied"] = json!(name); diff --git a/crates/engine/src/cmd/xform.rs b/crates/engine/src/cmd/xform.rs index ba8f7e94ab..2ef9edbeb5 100644 --- a/crates/engine/src/cmd/xform.rs +++ b/crates/engine/src/cmd/xform.rs @@ -30,7 +30,7 @@ pub fn specs() -> Vec { "Sample Color", [], None, - "{color (#rrggbbaa and #rgba are refused), stroke?: bool (default: whichever proxy is active), ids?, stop?: index, clearStroke?: bool} sample a color into the active fill/stroke (and the selection; `ids: []` changes only the paint default, and so does a sample without ids while the Live Paint Bucket is the active tool, `stop` included); `clearStroke: true` requires `stroke: false`, `ids: []` and no `stop`, and clears the default stroke after sampling an image into the fill; with `stop`, recolor that stop of the gradient behind the proxy instead (paint.editGradient); in a CMYK document an RGB color is stored as CMYK through the color settings, as paint.setFill stores it", + "{color (#rrggbbaa and #rgba are refused), stroke?: bool (default: whichever proxy is active), ids?, defaultsOnly?: bool, stop?: index, clearStroke?: bool} sample a color into the active fill/stroke (and the selection; `ids: []` changes only the paint default, and so does a sample without ids while the Live Paint Bucket is the active tool or with `defaultsOnly: true` (refused with ids), `stop` included); `clearStroke: true` requires `stroke: false`, `ids: []` and no `stop`, and clears the default stroke after sampling an image into the fill; with `stop`, recolor that stop of the gradient behind the proxy instead (paint.editGradient); in a CMYK document an RGB color is stored as CMYK through the color settings, as paint.setFill stores it", has_doc, sample_color ), @@ -523,13 +523,19 @@ fn sample_color(s: &mut Session, p: &Value) -> Result { if clear_stroke && (stroke || p.get("stroke") != Some(&Value::Bool(false)) || p.get("ids") != Some(&json!([])) || p.get("stop").is_some()) { return Err(bad(C, "`clearStroke` requires `stroke: false`, `ids: []` and no `stop`")); } + let only = super::switch_or(p, "defaultsOnly", false, C)?; + if only && p.get("ids").is_some_and(|v| !v.is_null()) { + return Err(bad(C, "`defaultsOnly` cannot be combined with `ids`, `id` or `item`")); + } let c = p.get("color").ok_or_else(|| bad(C, "missing color"))?; let (id, mut q) = match p.get("stop") { None | Some(Value::Null) => (if stroke { "paint.setStroke" } else { "paint.setFill" }, json!({ "color": c })), Some(v) => { let i = v.as_u64().map(index).ok_or_else(|| bad(C, "`stop` must be a stop index"))?; let color = super::paint::new_color(s, p, color_value(c).ok_or_else(|| bad(C, format!("bad color {c}")))?); - let (fill, stroke_paint) = s.proxy_paints(); + // The default's gradient with `defaultsOnly`, as the proxies show it while the Live + // Paint Bucket paints. + let (fill, stroke_paint) = if only { (s.paint.fill.clone(), s.paint.stroke.clone()) } else { s.proxy_paints() }; let Paint::Gradient(g) = (if stroke { stroke_paint } else { fill }) else { return Err(bad(C, "the paint behind the proxy is not a gradient")); }; @@ -542,6 +548,7 @@ fn sample_color(s: &mut Session, p: &Value) -> Result { if let Some(ids) = p.get("ids") { q["ids"] = ids.clone(); } + let q = super::paint::with_defaults_only(q, only); let spec = find_command(id).ok_or_else(|| EngineError::UnknownCommand(id.into()))?; let result = super::run_checked(s, spec, &q)?; if clear_stroke { diff --git a/crates/engine/src/lib.rs b/crates/engine/src/lib.rs index e2e6430f1e..0283829552 100644 --- a/crates/engine/src/lib.rs +++ b/crates/engine/src/lib.rs @@ -234,6 +234,11 @@ pub struct Session { /// The running top-level query command changed the selection and is journaled like any other /// command ([`Session::journal_query`]). journal_query: bool, + /// The running top-level command changed only the paint defaults, as the Live Paint Bucket + /// or `defaultsOnly: true` has a paint command do, when new art would have taken this + /// appearance (none: nothing selected): unless a later batch step changes it, the selection's + /// appearance does not replace the defaults afterwards ([`Session::inherit_new_art`]). + pub(crate) defaults_only_ran: Option>, /// From `edit.undoGroup.begin` to `edit.undoGroup.end`: the name of the undo step (`None`: after /// its first edit). Each document opened or created meanwhile opens an undo group of its own /// ([`Session::add_document`]). `None` otherwise. diff --git a/crates/engine/src/session/documents.rs b/crates/engine/src/session/documents.rs index 61dbdb4491..7627635797 100644 --- a/crates/engine/src/session/documents.rs +++ b/crates/engine/src/session/documents.rs @@ -114,6 +114,7 @@ impl Session { journal_note: Default::default(), note_depth: 1, journal_query: false, + defaults_only_ran: None, explicit_undo_group: None, batch_stash: None, batch_steps: None, diff --git a/crates/engine/src/session/edit.rs b/crates/engine/src/session/edit.rs index bbd20fa5bb..a6af80f6a7 100644 --- a/crates/engine/src/session/edit.rs +++ b/crates/engine/src/session/edit.rs @@ -322,7 +322,8 @@ impl Session { return Err(EngineError::Busy); } // While the Live Paint Bucket is active, paint previews change only the bucket's colors, so - // each preview starts from the colors the interaction began with. + // each preview starts from the colors the interaction began with; so does a preview with + // `defaultsOnly: true`, and one after it. let bucket = self.bucket_paints(); let (paint, restore_paint) = { let menu = self.menu.clone(); @@ -339,7 +340,8 @@ impl Session { // the paints the interaction began with. let restore_paint = bucket || cmd == "command.batch" - || it.preview.as_ref().is_some_and(|(id, _)| id == "command.batch") + || cmd::asks_defaults_only(params) + || it.preview.as_ref().is_some_and(|(id, p)| id == "command.batch" || cmd::asks_defaults_only(p)) || it.color_mode_paints.is_some(); let paint = it.paint.clone(); it.preview_paint = None; @@ -484,12 +486,16 @@ impl Session { self.decoded_images.empty(); self.pending_paint = None; // While the Live Paint Bucket is active, a previewed color is the bucket's color, which the - // cancel puts back as well. + // cancel puts back as well, as it does a color previewed with `defaultsOnly: true`. let bucket = self.bucket_paints(); if let Some(paint) = self .active() .and_then(|st| st.interaction.as_ref()) - .filter(|it| bucket || it.preview.as_ref().is_some_and(|(id, _)| id == "command.batch") || it.color_mode_paints.is_some()) + .filter(|it| { + bucket + || it.preview.as_ref().is_some_and(|(id, p)| id == "command.batch" || cmd::asks_defaults_only(p)) + || it.color_mode_paints.is_some() + }) .map(|it| it.paint.clone()) { self.paint = paint; diff --git a/crates/engine/src/session/execute.rs b/crates/engine/src/session/execute.rs index 046c480079..f2c9c62f42 100644 --- a/crates/engine/src/session/execute.rs +++ b/crates/engine/src/session/execute.rs @@ -161,6 +161,7 @@ impl Session { self.journal_note.clear(); self.note_depth = 1; self.journal_query = false; + self.defaults_only_ran = None; self.batch_stash = None; self.batch_steps = None; } @@ -263,8 +264,9 @@ impl Session { } /// Record `key: value` in the running top-level command's journal entry (or its interaction's - /// preview, or its step in a batch) unless its params give `key` (a null gives nothing): a value - /// it resolved from the preferences or the clock. + /// preview, or its step in a batch) unless its params give `key` (a null gives nothing, and a + /// noted `defaultsOnly` replaces the params' own): a value it resolved from the preferences or + /// the clock. pub fn note_journal(&mut self, key: &str, value: Value) { if self.depth == self.note_depth { self.journal_note.insert(key.to_string(), value); @@ -359,10 +361,11 @@ impl Session { let mut note = std::mem::take(&mut self.journal_note); match params { // The params' own values win, except a null: it reads as a key left out, so the - // noted value is the one the command resolved. + // noted value is the one the command resolved. A noted `defaultsOnly` wins too: the + // Live Paint Bucket kept the command to the defaults although the params gave `false`. Value::Object(m) if !note.is_empty() => { for (k, v) in m { - if !v.is_null() || !note.contains_key(k) { + if (!v.is_null() && k != "defaultsOnly") || !note.contains_key(k) { note.insert(k.clone(), v.clone()); } } diff --git a/crates/engine/src/tests/build.rs b/crates/engine/src/tests/build.rs index 316e9b8ffc..dfe61cdd9e 100644 --- a/crates/engine/src/tests/build.rs +++ b/crates/engine/src/tests/build.rs @@ -3331,6 +3331,151 @@ fn live_paint_bucket_paint_and_stroke_commands_leave_the_selection_unpainted() { assert!(failed.is_empty(), "{failed:#?}"); } +/// A paint or stroke command that the Live Paint Bucket kept to its own colors is journaled with +/// `defaultsOnly: true`, also when its params gave `false`. Replaying the entry with the Selection +/// tool active changes the same defaults and leaves the selection's paint as it was, also with New +/// Art Has Basic Appearance off. Every command that fails is listed. +#[test] +fn live_paint_bucket_commands_replay_from_the_journal_with_another_tool() { + let blue = Color::from_hex("#0000ff").unwrap(); + // A Live Paint group and a rectangle, both selected, a library with a fill color, a radial + // gradient as the default fill and a 2 pt default weight. + let setup = |s: &mut Session, basic: bool| { + s.execute("appearance.setNewArtBasic", &json!({"on": basic})).unwrap(); + let g = live(s); + let art = rect(s, 300.0, 300.0, 40.0, 40.0); + s.execute("paint.setFill", &json!({"color": "#00ff00", "ids": [art.0]})).unwrap(); + let lib = s.execute("library.create", &json!({})).unwrap()["id"].as_str().unwrap().to_string(); + s.execute("select.set", &json!({"ids": [art.0]})).unwrap(); + let item = s.execute("library.add", &json!({"library": lib, "kind": "fillColor"})).unwrap()["name"].as_str().unwrap().to_string(); + s.execute("select.set", &json!({"ids": [g.0, art.0]})).unwrap(); + s.execute("paint.setFill", &json!({"gradient": {"kind": "radial"}, "defaultsOnly": true})).unwrap(); + s.paint.stroke_width = 2.0; + s.last_solid = blue; + (g, art, lib, item) + }; + let cases: Vec<(&str, Value)> = vec![ + ("paint.setFill", json!({"color": "#00ffff"})), + ("paint.setFill", json!({"color": "#00ffff", "defaultsOnly": false})), + ("paint.setStroke", json!({"color": "#00ffff"})), + ("paint.none", json!({})), + ("paint.swap", json!({})), + ("paint.default", json!({})), + ("paint.lastColor", json!({"stroke": false})), + ("paint.lastGradient", json!({"stroke": true})), + ("paint.invert", json!({"stroke": false})), + ("paint.complement", json!({"stroke": false})), + ("paint.sampleColor", json!({"color": "#00ffff", "stroke": true})), + ("paint.sampleColor", json!({"color": "#00ffff", "stroke": false, "stop": 0})), + ("paint.editGradient", json!({"stroke": false, "angle": 45})), + ("gradient.presets.apply", json!({"name": "vignette"})), + ("stroke.set", json!({"weight": 5})), + ("stroke.weightUp", json!({})), + ("stroke.weightDown", json!({})), + ("stroke.setAdvanced", json!({"arrowScale": [150, 200]})), + ("swatch.library.add", json!({"library": "web-safe-216", "names": ["#FF6600"], "apply": "fill"})), + ("library.use", json!({"kind": "fillColor"})), + ]; + let mut failed = vec![]; + for basic in [true, false] { + for (cmd, params) in &cases { + let mut params = params.clone(); + let mut a = session(); + let (_, _, lib, item) = setup(&mut a, basic); + if *cmd == "library.use" { + params["library"] = json!(lib); + params["item"] = json!(item); + } + a.select_tool("livePaintBucket", ViewInfo::default()).unwrap(); + let start = a.journal.len(); + if let Err(e) = a.execute(cmd, ¶ms) { + failed.push(format!("{cmd} {params} (basic {basic}): {e}")); + continue; + } + let Some((id, recorded)) = a.journal.since(start).last().cloned() else { + failed.push(format!("{cmd} {params} (basic {basic}): not journaled")); + continue; + }; + if recorded.get("defaultsOnly") != Some(&json!(true)) { + failed.push(format!("{cmd} {params} (basic {basic}): the journal entry {recorded} does not keep the change to the defaults")); + } + let mut b = session(); + let (g, art, _, _) = setup(&mut b, basic); + let (group, painted) = (node(&b, g), node(&b, art)); + if let Err(e) = b.replay(&id, &recorded) { + failed.push(format!("{cmd} {params} (basic {basic}): the replay failed: {e}")); + continue; + } + if node(&b, g) != group || node(&b, art) != painted { + failed.push(format!("{cmd} {params} (basic {basic}): the replay painted the selection")); + } + if (&b.paint.fill, &b.paint.stroke, b.paint.stroke_width, b.new_art_stroke()) + != (&a.paint.fill, &a.paint.stroke, a.paint.stroke_width, a.new_art_stroke()) + { + failed.push(format!("{cmd} {params} (basic {basic}): the replay left other defaults")); + } + } + } + assert!(failed.is_empty(), "{failed:#?}"); + // In a batch with New Art Has Basic Appearance off, a selection change after a `defaultsOnly` + // step still gives new art the new selection's appearance; without one, the defaults stay. + let cyan = Paint::solid(Color::from_hex("#00ffff").unwrap()); + let set_cyan = json!({"command": "paint.setFill", "params": {"color": "#00ffff", "defaultsOnly": true}}); + let mut s = session(); + let (_, art, ..) = setup(&mut s, false); + s.execute("command.batch", &json!({"commands": [set_cyan.clone()]})).unwrap(); + assert_eq!(s.paint.fill, cyan, "the defaults keep the batch's fill"); + s.execute("paint.setFill", &json!({"color": "#ff0000", "defaultsOnly": true})).unwrap(); + s.execute("command.batch", &json!({"commands": [set_cyan.clone(), {"command": "select.key", "params": {"id": art.0}}]})).unwrap(); + assert_eq!(s.paint.fill, cyan, "a new key object leaves the objects new art takes its appearance from"); + s.execute("command.batch", &json!({"commands": [set_cyan.clone(), {"command": "select.set", "params": {"ids": [art.0]}}]})).unwrap(); + assert_eq!(s.paint.fill, Paint::solid(Color::from_hex("#00ff00").unwrap()), "new art takes the newly selected fill"); + // A later step that changes the selected object's appearance gives new art that appearance. + s.execute("command.batch", &json!({"commands": [set_cyan, {"command": "transparency.set", "params": {"opacity": 40, "ids": [art.0]}}]})).unwrap(); + let green = Paint::solid(Color::from_hex("#00ff00").unwrap()); + assert_eq!((&s.paint.fill, s.paint.opacity), (&green, 0.4), "new art takes the selection's new opacity, and its fill"); + // `defaultsOnly: true` with the Selection tool: a canceled preview puts the defaults back, and + // each preview starts from the defaults the interaction began with. + let mut s = session(); + let (g, art, ..) = setup(&mut s, true); + let (group, painted, fill) = (node(&s, g), node(&s, art), s.paint.fill.clone()); + s.begin_interaction("Fill Color").unwrap(); + s.preview("paint.setFill", &json!({"color": "#123456", "defaultsOnly": true})).unwrap(); + assert_eq!(s.paint.fill, Paint::solid(Color::from_hex("#123456").unwrap())); + s.cancel_interaction().unwrap(); + assert_eq!(s.paint.fill, fill, "the canceled color is not kept"); + s.begin_interaction("Stroke Weight").unwrap(); + for _ in 0..3 { + s.preview("stroke.weightUp", &json!({"defaultsOnly": true})).unwrap(); + } + assert_eq!(s.paint.stroke_width, 3.0, "each preview starts from 2 pt"); + s.cancel_interaction().unwrap(); + assert_eq!(s.paint.stroke_width, 2.0); + // A preview with `defaultsOnly: true` after one that set the defaults with the selection + // starts from the defaults the interaction began with too. + s.begin_interaction("Stroke Weight").unwrap(); + s.preview("stroke.set", &json!({"weight": 7})).unwrap(); + assert_eq!(s.paint.stroke_width, 7.0); + s.preview("paint.setFill", &json!({"color": "#123456", "defaultsOnly": true})).unwrap(); + assert_eq!(s.paint.stroke_width, 2.0, "the discarded preview's weight is not kept"); + s.cancel_interaction().unwrap(); + assert_eq!((s.paint.fill.clone(), s.paint.stroke_width), (fill.clone(), 2.0)); + assert_eq!((node(&s, g), node(&s, art)), (group, painted), "the selection keeps its paint"); + // `defaultsOnly` is a bool, and names no objects or brush. + let (g, ..) = setup(&mut s, true); + for (cmd, params) in [ + ("paint.setFill", json!({"color": "#00ffff", "defaultsOnly": "yes"})), + ("paint.setFill", json!({"color": "#00ffff", "defaultsOnly": true, "ids": [g.0]})), + ("stroke.set", json!({"weight": 3, "defaultsOnly": true, "item": 0})), + ("paint.sampleColor", json!({"color": "#00ffff", "defaultsOnly": true, "ids": [g.0]})), + ("paint.none", json!({"defaultsOnly": 1})), + ("stroke.setAdvanced", json!({"brush": null, "defaultsOnly": true})), + ("stroke.setAdvanced", json!({"brush": "3 pt. Round", "defaultsOnly": true})), + ] { + assert!(s.execute(cmd, ¶ms).is_err(), "{cmd} {params}"); + } +} + /// `paint.editGradient` with an `aspect` and no object to edit (the Live Paint Bucket's gradient, /// nothing selected, or a fill edit of a Live Paint group without faces) is an error that leaves the default gradient as it was, since a gradient /// fitted to each object has no aspect of its own. Named objects still take the aspect. diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsv index 9ef6f066e6..2a2cd7273e 100644 --- a/crates/ui-egui/src/i18n/cs.tsv +++ b/crates/ui-egui/src/i18n/cs.tsv @@ -9022,6 +9022,8 @@ breakText Glyphs Glyfy @msg `dataBase64` is larger than the module limit `dataBase64` je větší než limit modulu @msg `dataBase64` is not valid base64 `dataBase64` není platný base64 @msg `defaultsOnly` cannot be combined with `ids`, `reverse` or `append` `defaultsOnly` nelze kombinovat s `ids`, `reverse` ani `append` +@msg `defaultsOnly` cannot be combined with `ids`, `id` or `item` `defaultsOnly` nelze kombinovat s `ids`, `id` ani `item` +@msg `defaultsOnly` cannot be combined with `brush` `defaultsOnly` nelze kombinovat s `brush` @msg `depth` and `childLimit` slice the summary: pass `summary: true` `depth` a `childLimit` omezují souhrn: předejte `summary: true` @msg `design` is a design name, or null for plain columns `design` je název návrhu, nebo null pro obyčejné sloupce @msg `design` is a design name, or null for the default marker `design` je název návrhu, nebo null pro výchozí značku diff --git a/crates/ui-egui/src/i18n/da.tsv b/crates/ui-egui/src/i18n/da.tsv index 0d8b14dba4..39ffd4b602 100644 --- a/crates/ui-egui/src/i18n/da.tsv +++ b/crates/ui-egui/src/i18n/da.tsv @@ -1136,6 +1136,8 @@ liquify-list-end {0}, {1} {0} og {1} @msg `dataBase64` is larger than the module limit `dataBase64` er større end modulgrænsen @msg `dataBase64` is not valid base64 `dataBase64` er ikke gyldig base64 @msg `defaultsOnly` cannot be combined with `ids`, `reverse` or `append` `defaultsOnly` kan ikke kombineres med `ids`, `reverse` eller `append` +@msg `defaultsOnly` cannot be combined with `ids`, `id` or `item` `defaultsOnly` kan ikke kombineres med `ids`, `id` eller `item` +@msg `defaultsOnly` cannot be combined with `brush` `defaultsOnly` kan ikke kombineres med `brush` @msg `depth` and `childLimit` slice the summary: pass `summary: true` `depth` og `childLimit` opdeler oversigten: angiv `summary: true` @msg `design` is a design name, or null for plain columns `design` er et designnavn eller null for almindelige søjler @msg `design` is a design name, or null for the default marker `design` er et designnavn eller null for standardmarkøren diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsv index bd04b8cc19..59b4ec7966 100644 --- a/crates/ui-egui/src/i18n/de.tsv +++ b/crates/ui-egui/src/i18n/de.tsv @@ -8868,6 +8868,8 @@ breakText Glyphs Glyphen @msg `dataBase64` is larger than the module limit `dataBase64` ist größer als die Modulgrenze @msg `dataBase64` is not valid base64 `dataBase64` ist kein gültiges Base64 @msg `defaultsOnly` cannot be combined with `ids`, `reverse` or `append` `defaultsOnly` kann nicht mit `ids`, `reverse` oder `append` kombiniert werden +@msg `defaultsOnly` cannot be combined with `ids`, `id` or `item` `defaultsOnly` kann nicht mit `ids`, `id` oder `item` kombiniert werden +@msg `defaultsOnly` cannot be combined with `brush` `defaultsOnly` kann nicht mit `brush` kombiniert werden @msg `depth` and `childLimit` slice the summary: pass `summary: true` `depth` und `childLimit` begrenzen die Zusammenfassung: Übergeben Sie `summary: true` @msg `design` is a design name, or null for plain columns `design` ist ein Designname oder null für einfache Säulen @msg `design` is a design name, or null for the default marker `design` ist ein Designname oder null für die Standardmarkierung diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv index 016f297b3b..d6f3c2226d 100644 --- a/crates/ui-egui/src/i18n/es.tsv +++ b/crates/ui-egui/src/i18n/es.tsv @@ -9311,6 +9311,8 @@ breakText Glyphs Glifos @msg `dataBase64` is larger than the module limit `dataBase64` supera el límite de módulos @msg `dataBase64` is not valid base64 `dataBase64` no es base64 válido @msg `defaultsOnly` cannot be combined with `ids`, `reverse` or `append` `defaultsOnly` no se puede combinar con `ids`, `reverse` ni `append` +@msg `defaultsOnly` cannot be combined with `ids`, `id` or `item` `defaultsOnly` no se puede combinar con `ids`, `id` ni `item` +@msg `defaultsOnly` cannot be combined with `brush` `defaultsOnly` no se puede combinar con `brush` @msg `depth` and `childLimit` slice the summary: pass `summary: true` `depth` y `childLimit` recortan el resumen: pasa `summary: true` @msg `design` is a design name, or null for plain columns `design` es el nombre de un diseño, o null para columnas simples @msg `design` is a design name, or null for the default marker `design` es el nombre de un diseño, o null para el marcador predeterminado diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv index 4ce31cfc06..48b1e5b5c4 100644 --- a/crates/ui-egui/src/i18n/fr.tsv +++ b/crates/ui-egui/src/i18n/fr.tsv @@ -8888,6 +8888,8 @@ breakText Glyphs Glyphes @msg `dataBase64` is larger than the module limit `dataBase64` dépasse la limite des modules @msg `dataBase64` is not valid base64 `dataBase64` n’est pas du base64 valide @msg `defaultsOnly` cannot be combined with `ids`, `reverse` or `append` `defaultsOnly` ne peut pas être combiné avec `ids`, `reverse` ou `append` +@msg `defaultsOnly` cannot be combined with `ids`, `id` or `item` `defaultsOnly` ne peut pas être combiné avec `ids`, `id` ou `item` +@msg `defaultsOnly` cannot be combined with `brush` `defaultsOnly` ne peut pas être combiné avec `brush` @msg `depth` and `childLimit` slice the summary: pass `summary: true` `depth` et `childLimit` découpent le résumé : passez `summary: true` @msg `design` is a design name, or null for plain columns `design` est un nom de motif, ou null pour des colonnes simples @msg `design` is a design name, or null for the default marker `design` est un nom de motif, ou null pour le repère par défaut diff --git a/crates/ui-egui/src/i18n/hi.tsv b/crates/ui-egui/src/i18n/hi.tsv index c8852f1ddd..bbd26b9ca4 100644 --- a/crates/ui-egui/src/i18n/hi.tsv +++ b/crates/ui-egui/src/i18n/hi.tsv @@ -7008,6 +7008,8 @@ arrowhead Feather पंख @msg `dataBase64` is not valid base64 `dataBase64` मान्य नहीं है base64 @msg `datasetFileNaming` must be `fileNumber`, `fileDataSetName` or `dataSetName` `datasetFileNaming` होना चाहिए `fileNumber`, `fileDataSetName` या `dataSetName` @msg `defaultsOnly` cannot be combined with `ids`, `reverse` or `append` `defaultsOnly` को `ids`, `reverse` या `append` के साथ उपयोग नहीं कर सकते +@msg `defaultsOnly` cannot be combined with `ids`, `id` or `item` `defaultsOnly` को `ids`, `id` या `item` के साथ उपयोग नहीं कर सकते +@msg `defaultsOnly` cannot be combined with `brush` `defaultsOnly` को `brush` के साथ उपयोग नहीं कर सकते @msg `depth` and `childLimit` slice the summary: pass `summary: true` `depth` और `childLimit` सारांश के हिस्से चुनते हैं: `summary: true` दें @msg `design` is a design name, or null for plain columns `design` एक डिजाइन नाम है, या सादे स्तंभों के लिए null है @msg `design` is a design name, or null for the default marker `design` एक डिजाइन नाम है, या डिफ़ॉल्ट मार्कर के लिए null है diff --git a/crates/ui-egui/src/i18n/hu.tsv b/crates/ui-egui/src/i18n/hu.tsv index 54ff192eed..e3dae2312f 100644 --- a/crates/ui-egui/src/i18n/hu.tsv +++ b/crates/ui-egui/src/i18n/hu.tsv @@ -8893,6 +8893,8 @@ breakText Glyphs Glifák @msg `dataBase64` is larger than the module limit `dataBase64`: nagyobb a modulok méretkorlátjánál @msg `dataBase64` is not valid base64 `dataBase64`: nem érvényes base64 @msg `defaultsOnly` cannot be combined with `ids`, `reverse` or `append` `defaultsOnly`: nem használható együtt ezekkel: `ids`, `reverse`, `append` +@msg `defaultsOnly` cannot be combined with `ids`, `id` or `item` `defaultsOnly`: nem használható együtt ezekkel: `ids`, `id`, `item` +@msg `defaultsOnly` cannot be combined with `brush` `defaultsOnly`: nem használható együtt ezzel: `brush` @msg `depth` and `childLimit` slice the summary: pass `summary: true` `depth` és `childLimit`: az összegzést szűkítik; add meg ezt: `summary: true` @msg `design` is a design name, or null for plain columns `design`: diagramminta neve, vagy null az egyszerű oszlopokhoz @msg `design` is a design name, or null for the default marker `design`: diagramminta neve, vagy null az alapértelmezett jelölőhöz diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsv index 190b136a06..c26a6120b8 100644 --- a/crates/ui-egui/src/i18n/it.tsv +++ b/crates/ui-egui/src/i18n/it.tsv @@ -8921,6 +8921,8 @@ breakText Glyphs Glifi @msg `dataBase64` is larger than the module limit `dataBase64` supera il limite del modulo @msg `dataBase64` is not valid base64 `dataBase64` non è un base64 valido @msg `defaultsOnly` cannot be combined with `ids`, `reverse` or `append` `defaultsOnly` non può essere combinato con `ids`, `reverse` o `append` +@msg `defaultsOnly` cannot be combined with `ids`, `id` or `item` `defaultsOnly` non può essere combinato con `ids`, `id` o `item` +@msg `defaultsOnly` cannot be combined with `brush` `defaultsOnly` non può essere combinato con `brush` @msg `depth` and `childLimit` slice the summary: pass `summary: true` `depth` e `childLimit` riducono il riepilogo: passa `summary: true` @msg `design` is a design name, or null for plain columns `design` è il nome di un design, o null per colonne semplici @msg `design` is a design name, or null for the default marker `design` è il nome di un design, o null per il marcatore predefinito diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv index 665e74c319..7a8823f851 100644 --- a/crates/ui-egui/src/i18n/ja.tsv +++ b/crates/ui-egui/src/i18n/ja.tsv @@ -7738,6 +7738,8 @@ axis Y Axis Y 軸 @msg `dataBase64` is larger than the module limit `dataBase64` がモジュールの上限を超えています @msg `dataBase64` is not valid base64 `dataBase64` が有効な base64 ではありません @msg `defaultsOnly` cannot be combined with `ids`, `reverse` or `append` `defaultsOnly` は `ids`、`reverse`、`append` と同時に使用できません +@msg `defaultsOnly` cannot be combined with `ids`, `id` or `item` `defaultsOnly` は `ids`、`id`、`item` と同時に使用できません +@msg `defaultsOnly` cannot be combined with `brush` `defaultsOnly` は `brush` と同時に使用できません @msg `depth` and `childLimit` slice the summary: pass `summary: true` `depth` と `childLimit` はサマリーを絞り込みます: `summary: true` を指定してください @msg `design` is a design name, or null for plain columns `design` にはデザイン名を指定します。通常の棒にするには null を指定します @msg `design` is a design name, or null for the default marker `design` にはデザイン名を指定します。初期設定のマーカーにするには null を指定します diff --git a/crates/ui-egui/src/i18n/ka.tsv b/crates/ui-egui/src/i18n/ka.tsv index d3ea2160c1..38eea76371 100644 --- a/crates/ui-egui/src/i18n/ka.tsv +++ b/crates/ui-egui/src/i18n/ka.tsv @@ -217,6 +217,8 @@ @msg `dataBase64` is larger than the module limit `dataBase64` მოდულის ლიმიტზე დიდია @msg `dataBase64` is not valid base64 `dataBase64` სწორი base64 არ არის @msg `defaultsOnly` cannot be combined with `ids`, `reverse` or `append` `defaultsOnly` ვერ გამოიყენება `ids`-თან, `reverse`-თან ან `append`-თან ერთად +@msg `defaultsOnly` cannot be combined with `ids`, `id` or `item` `defaultsOnly` ვერ გამოიყენება `ids`-თან, `id`-თან ან `item`-თან ერთად +@msg `defaultsOnly` cannot be combined with `brush` `defaultsOnly` ვერ გამოიყენება `brush`-თან ერთად @msg `depth` and `childLimit` slice the summary: pass `summary: true` `depth` და `childLimit` შეჯამებას ზღუდავს: გადაეცით `summary: true` @msg `design` is a design name, or null for plain columns `design` არის დიზაინის სახელი, ან null — ჩვეულებრივი სვეტებისთვის @msg `design` is a design name, or null for the default marker `design` არის დიზაინის სახელი, ან null — ნაგულისხმევი მარკერისთვის diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsv index 0c2642f758..15597a0192 100644 --- a/crates/ui-egui/src/i18n/ko.tsv +++ b/crates/ui-egui/src/i18n/ko.tsv @@ -8661,6 +8661,8 @@ breakText Glyphs 글리프 @msg `dataBase64` is larger than the module limit `dataBase64`이(가) 모듈 한도보다 큽니다 @msg `dataBase64` is not valid base64 `dataBase64`이(가) 올바른 base64가 아닙니다 @msg `defaultsOnly` cannot be combined with `ids`, `reverse` or `append` `defaultsOnly`은(는) `ids`, `reverse` 또는 `append`와 함께 쓸 수 없습니다 +@msg `defaultsOnly` cannot be combined with `ids`, `id` or `item` `defaultsOnly`은(는) `ids`, `id` 또는 `item`과 함께 쓸 수 없습니다 +@msg `defaultsOnly` cannot be combined with `brush` `defaultsOnly`은(는) `brush`와 함께 쓸 수 없습니다 @msg `depth` and `childLimit` slice the summary: pass `summary: true` `depth`와 `childLimit`은 요약을 잘라 냅니다: `summary: true`를 전달하세요 @msg `design` is a design name, or null for plain columns `design`은(는) 디자인 이름이며, 일반 막대에는 null입니다 @msg `design` is a design name, or null for the default marker `design`은(는) 디자인 이름이며, 기본 마커에는 null입니다 diff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsv index c1f7e36426..2492a94d48 100644 --- a/crates/ui-egui/src/i18n/nl.tsv +++ b/crates/ui-egui/src/i18n/nl.tsv @@ -6531,6 +6531,8 @@ imageTrace Outline Contour @msg `dataBase64` is larger than the module limit `dataBase64` is groter dan de modulelimiet @msg `dataBase64` is not valid base64 `dataBase64` is geen geldige base64 @msg `defaultsOnly` cannot be combined with `ids`, `reverse` or `append` `defaultsOnly` kan niet worden gecombineerd met `ids`, `reverse` of `append` +@msg `defaultsOnly` cannot be combined with `ids`, `id` or `item` `defaultsOnly` kan niet worden gecombineerd met `ids`, `id` of `item` +@msg `defaultsOnly` cannot be combined with `brush` `defaultsOnly` kan niet worden gecombineerd met `brush` @msg `depth` and `childLimit` slice the summary: pass `summary: true` `depth` en `childLimit` beperken de samenvatting: geef `summary: true` op @msg `design` is a design name, or null for plain columns `design` is de naam van een ontwerp, of null voor gewone kolommen @msg `design` is a design name, or null for the default marker `design` is de naam van een ontwerp, of null voor de standaardmarkering diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsv index 5808ddb8c2..2258f53359 100644 --- a/crates/ui-egui/src/i18n/pl.tsv +++ b/crates/ui-egui/src/i18n/pl.tsv @@ -9129,6 +9129,8 @@ breakText Glyphs Glify @msg `dataBase64` is larger than the module limit `dataBase64` przekracza limit rozmiaru modułu @msg `dataBase64` is not valid base64 `dataBase64` nie jest prawidłowym kodem base64 @msg `defaultsOnly` cannot be combined with `ids`, `reverse` or `append` `defaultsOnly` nie można łączyć z `ids`, `reverse` ani `append` +@msg `defaultsOnly` cannot be combined with `ids`, `id` or `item` `defaultsOnly` nie można łączyć z `ids`, `id` ani `item` +@msg `defaultsOnly` cannot be combined with `brush` `defaultsOnly` nie można łączyć z `brush` @msg `depth` and `childLimit` slice the summary: pass `summary: true` `depth` i `childLimit` ograniczają podsumowanie: przekaż `summary: true` @msg `design` is a design name, or null for plain columns `design` to nazwa wzoru albo null dla zwykłych kolumn @msg `design` is a design name, or null for the default marker `design` to nazwa wzoru albo null dla domyślnego znacznika diff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsv index 2204a2bdc1..2a9c0b1d75 100644 --- a/crates/ui-egui/src/i18n/pt-br.tsv +++ b/crates/ui-egui/src/i18n/pt-br.tsv @@ -9084,6 +9084,8 @@ swatch Yellow Green Verde-amarelado @msg `dataBase64` is larger than the module limit `dataBase64` excede o limite do módulo @msg `dataBase64` is not valid base64 `dataBase64` não é base64 válido @msg `defaultsOnly` cannot be combined with `ids`, `reverse` or `append` `defaultsOnly` não pode ser combinado com `ids`, `reverse` ou `append` +@msg `defaultsOnly` cannot be combined with `ids`, `id` or `item` `defaultsOnly` não pode ser combinado com `ids`, `id` ou `item` +@msg `defaultsOnly` cannot be combined with `brush` `defaultsOnly` não pode ser combinado com `brush` @msg `depth` and `childLimit` slice the summary: pass `summary: true` `depth` e `childLimit` recortam o resumo: passe `summary: true` @msg `design` is a design name, or null for plain columns `design` é o nome de um projeto, ou null para colunas simples @msg `design` is a design name, or null for the default marker `design` é o nome de um projeto, ou null para o marcador padrão diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsv index b3ca5d5d93..dbd54f0746 100644 --- a/crates/ui-egui/src/i18n/ru.tsv +++ b/crates/ui-egui/src/i18n/ru.tsv @@ -9007,6 +9007,8 @@ shape Open Открытый @msg `dataBase64` is larger than the module limit `dataBase64` больше ограничения для модуля @msg `dataBase64` is not valid base64 `dataBase64` не является допустимым base64 @msg `defaultsOnly` cannot be combined with `ids`, `reverse` or `append` `defaultsOnly` нельзя сочетать с `ids`, `reverse` или `append` +@msg `defaultsOnly` cannot be combined with `ids`, `id` or `item` `defaultsOnly` нельзя сочетать с `ids`, `id` или `item` +@msg `defaultsOnly` cannot be combined with `brush` `defaultsOnly` нельзя сочетать с `brush` @msg `depth` and `childLimit` slice the summary: pass `summary: true` `depth` и `childLimit` ограничивают сводку: передайте `summary: true` @msg `design` is a design name, or null for plain columns `design` — имя дизайна или null для обычных столбцов @msg `design` is a design name, or null for the default marker `design` — имя дизайна или null для маркера по умолчанию diff --git a/crates/ui-egui/src/i18n/sv.tsv b/crates/ui-egui/src/i18n/sv.tsv index 94a83ef975..bdab8aa5fe 100644 --- a/crates/ui-egui/src/i18n/sv.tsv +++ b/crates/ui-egui/src/i18n/sv.tsv @@ -8864,6 +8864,8 @@ digits Hindi Hindi @msg `dataBase64` is larger than the module limit `dataBase64` är större än modulgränsen @msg `dataBase64` is not valid base64 `dataBase64` är inte giltig base64 @msg `defaultsOnly` cannot be combined with `ids`, `reverse` or `append` `defaultsOnly` kan inte kombineras med `ids`, `reverse` eller `append` +@msg `defaultsOnly` cannot be combined with `ids`, `id` or `item` `defaultsOnly` kan inte kombineras med `ids`, `id` eller `item` +@msg `defaultsOnly` cannot be combined with `brush` `defaultsOnly` kan inte kombineras med `brush` @msg `depth` and `childLimit` slice the summary: pass `summary: true` `depth` och `childLimit` begränsar sammanfattningen: ange `summary: true` @msg `design` is a design name, or null for plain columns `design` är ett designnamn, eller null för vanliga kolumner @msg `design` is a design name, or null for the default marker `design` är ett designnamn, eller null för standardmarkören diff --git a/crates/ui-egui/src/i18n/tr.tsv b/crates/ui-egui/src/i18n/tr.tsv index 2fcd6d3b54..25f69773e3 100644 --- a/crates/ui-egui/src/i18n/tr.tsv +++ b/crates/ui-egui/src/i18n/tr.tsv @@ -8119,6 +8119,8 @@ axis Y Axis Y ekseni @msg `dataBase64` is larger than the module limit `dataBase64` modül sınırından büyük @msg `dataBase64` is not valid base64 `dataBase64` geçerli bir base64 değil @msg `defaultsOnly` cannot be combined with `ids`, `reverse` or `append` `defaultsOnly`; `ids`, `reverse` veya `append` ile birleştirilemez +@msg `defaultsOnly` cannot be combined with `ids`, `id` or `item` `defaultsOnly`; `ids`, `id` veya `item` ile birleştirilemez +@msg `defaultsOnly` cannot be combined with `brush` `defaultsOnly`; `brush` ile birleştirilemez @msg `depth` and `childLimit` slice the summary: pass `summary: true` `depth` ve `childLimit` özeti dilimler: `summary: true` verin @msg `design` is a design name, or null for plain columns `design` bir tasarım adıdır veya düz sütunlar için null olur @msg `design` is a design name, or null for the default marker `design` bir tasarım adıdır veya varsayılan işaretçi için null olur diff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsv index 49f8383268..464b9773f1 100644 --- a/crates/ui-egui/src/i18n/uk.tsv +++ b/crates/ui-egui/src/i18n/uk.tsv @@ -8670,6 +8670,8 @@ breakText Glyphs Гліфи @msg `dataBase64` is larger than the module limit `dataBase64` перевищує обмеження модуля @msg `dataBase64` is not valid base64 `dataBase64` не є припустимим base64 @msg `defaultsOnly` cannot be combined with `ids`, `reverse` or `append` `defaultsOnly` не можна поєднувати з `ids`, `reverse` або `append` +@msg `defaultsOnly` cannot be combined with `ids`, `id` or `item` `defaultsOnly` не можна поєднувати з `ids`, `id` або `item` +@msg `defaultsOnly` cannot be combined with `brush` `defaultsOnly` не можна поєднувати з `brush` @msg `depth` and `childLimit` slice the summary: pass `summary: true` `depth` і `childLimit` обмежують зведення: передайте `summary: true` @msg `design` is a design name, or null for plain columns `design` — це назва дизайну або null для звичайних стовпців @msg `design` is a design name, or null for the default marker `design` — це назва дизайну або null для стандартного маркера diff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsv index f51baaa7e7..1979424953 100644 --- a/crates/ui-egui/src/i18n/zh-hans.tsv +++ b/crates/ui-egui/src/i18n/zh-hans.tsv @@ -9140,6 +9140,8 @@ breakText Glyphs 字形 @msg `dataBase64` is larger than the module limit `dataBase64` 超过了模块大小上限 @msg `dataBase64` is not valid base64 `dataBase64` 不是有效的 base64 @msg `defaultsOnly` cannot be combined with `ids`, `reverse` or `append` `defaultsOnly` 不能与 `ids`、`reverse` 或 `append` 同时使用 +@msg `defaultsOnly` cannot be combined with `ids`, `id` or `item` `defaultsOnly` 不能与 `ids`、`id` 或 `item` 同时使用 +@msg `defaultsOnly` cannot be combined with `brush` `defaultsOnly` 不能与 `brush` 同时使用 @msg `depth` and `childLimit` slice the summary: pass `summary: true` `depth` 和 `childLimit` 用于截取摘要:请传入 `summary: true` @msg `design` is a design name, or null for plain columns `design` 是设计名称,或用 null 表示普通柱形 @msg `design` is a design name, or null for the default marker `design` 是设计名称,或用 null 表示默认标记 diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsv index d794ea15d9..8be1458d9b 100644 --- a/crates/ui-egui/src/i18n/zh-hant.tsv +++ b/crates/ui-egui/src/i18n/zh-hant.tsv @@ -9076,6 +9076,8 @@ breakText Glyphs 字符 @msg `dataBase64` is larger than the module limit `dataBase64` 大於模組上限 @msg `dataBase64` is not valid base64 `dataBase64` 不是有效的 base64 @msg `defaultsOnly` cannot be combined with `ids`, `reverse` or `append` `defaultsOnly` 不能與 `ids`、`reverse` 或 `append` 一起使用 +@msg `defaultsOnly` cannot be combined with `ids`, `id` or `item` `defaultsOnly` 不能與 `ids`、`id` 或 `item` 一起使用 +@msg `defaultsOnly` cannot be combined with `brush` `defaultsOnly` 不能與 `brush` 一起使用 @msg `depth` and `childLimit` slice the summary: pass `summary: true` `depth` 和 `childLimit` 用於裁切摘要:請傳入 `summary: true` @msg `design` is a design name, or null for plain columns `design` 是設計名稱,或以 null 表示一般直條 @msg `design` is a design name, or null for the default marker `design` 是設計名稱,或以 null 表示預設標記 diff --git a/docs/mcp.md b/docs/mcp.md index ae119cc4b1..afea44461b 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -4839,7 +4839,13 @@ already walks Image Trace. Short agent entry points: `paint.invert`, `paint.complement`, `paint.sampleColor`, `gradient.presets.apply`, a swatch or the Color Picker), and `paint.swap` or `paint.default` without `ids` or `id`, becomes the color the bucket paints with, and a stroke weight (`stroke.set`, `stroke.weightUp`, `stroke.weightDown`) becomes the weight it paints with. The selection keeps its - paint, and no undo step is recorded. A null `ids` or `id` counts as left out. The Stroke panel's other options + paint, and no undo step is recorded. A null `ids` or `id` counts as left out. The journal records each of these + commands with `defaultsOnly: true`, and it records `library.use` with a color, gradient or pattern and + `swatch.library.add` with `apply` the same way. A replay of the entry, or the same params sent with any tool active, changes + only the defaults. `defaultsOnly` is a bool, and it is refused together with `ids`, `id` or `item`, and in + `stroke.setAdvanced` together with `brush`. While the bucket is active, `defaultsOnly: false` without a target is + journaled as `true`. A preview with `defaultsOnly: true` starts from the defaults the interaction began with, and + canceling the interaction puts them back. The Stroke panel's other options (`stroke.set`, `stroke.setAdvanced` without `brush`) change the stroke for new art and leave the selection as it is; the bucket takes only the color and weight of that stroke. A stop selected on the bucket's gradient (`gradient.selectStop`) is deselected when another tool is chosen, when the first selected object changes, when an