From 2089ca34f79a39307c342a4b43130619b58ef4ed Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 22 Nov 2026 17:45:17 -0800 Subject: [PATCH 1/2] Gradient panel: a preset from the Presets menu goes to the proxy in front The Presets menu sent gradient.presets.apply without `stroke`, so the command chose the fill or stroke by the Appearance panel's active row. With a fill row active and the Stroke proxy in front, the preset went to the fill the panel was not showing. The menu now passes the proxy in front, as the panel's other controls do; an active row of that kind still takes the preset. --- crates/ui-egui/src/panels/gradient.rs | 7 +- crates/ui-egui/src/panels/gradient/tests.rs | 85 +++++++++++++++++++++ docs/target-app-parity.md | 1 + 3 files changed, 90 insertions(+), 3 deletions(-) diff --git a/crates/ui-egui/src/panels/gradient.rs b/crates/ui-egui/src/panels/gradient.rs index 945c18ea0d..4664838728 100644 --- a/crates/ui-egui/src/panels/gradient.rs +++ b/crates/ui-egui/src/panels/gradient.rs @@ -449,8 +449,9 @@ const REPEAT_PRESETS: [f64; 6] = [1.0, 2.0, 3.0, 4.0, 5.0, 10.0]; /// The Presets row: a menu of the preset gradients by library (theme), then the /// saved ones; a choice applies to the gradient behind the active proxy, keeping its placement -/// (`gradient.presets.apply`; a solid or no paint becomes the gradient). The menu shows the preset -/// the gradient is, if any. +/// (`gradient.presets.apply`; a solid or no paint becomes the gradient), as the panel's other +/// controls do: an active Appearance row stands for it only when it is a row of the proxy's kind. +/// The menu shows the preset the gradient is, if any. fn presets_row(app: &mut VectorcraftApp, ui: &mut Ui, g: Option<&GradientPaint>) { let shown = g.and_then(|g| app.session.gradient_preset_name(&g.gradient)).unwrap_or_default(); let enabled = crate::menus::enabled(app, "gradient.presets.apply"); @@ -458,7 +459,7 @@ fn presets_row(app: &mut VectorcraftApp, ui: &mut Ui, g: Option<&GradientPaint>) widgets::dim_label(ui, tl!("Presets:")); let chosen = ui.add_enabled_ui(enabled, |ui| widgets::combo(ui, "grad-presets", &shown, 150.0, |ui| preset_list(app, ui, &shown))).inner; if let Some(name) = chosen { - app.run("gradient.presets.apply", json!({ "name": name })).ok(); + app.run("gradient.presets.apply", json!({ "name": name, "stroke": !app.session.fill_active })).ok(); } }); } diff --git a/crates/ui-egui/src/panels/gradient/tests.rs b/crates/ui-egui/src/panels/gradient/tests.rs index 1a607b8f24..9bb7903362 100644 --- a/crates/ui-egui/src/panels/gradient/tests.rs +++ b/crates/ui-egui/src/panels/gradient/tests.rs @@ -863,6 +863,91 @@ fn the_presets_menu_applies_a_preset_and_shows_it() { assert_eq!(fill(&app).gradient.stops, preset.stops); } +/// The paints of the selected object's appearance rows, in stack order. +fn row_paints(app: &VectorcraftApp) -> Vec { + let st = app.session.active().unwrap(); + let node = st.doc.node(st.selection.subjects()[0]).unwrap(); + node.appearance.items.iter().map(|i| i.paint().clone()).collect() +} + +/// The indices of the selected object's fill (`fill`) or stroke rows. +fn rows_of_kind(app: &VectorcraftApp, fill: bool) -> Vec { + let st = app.session.active().unwrap(); + let node = st.doc.node(st.selection.subjects()[0]).unwrap(); + node.appearance.items.iter().enumerate().filter(|(_, i)| i.is_fill() == fill).map(|(n, _)| n).collect() +} + +/// A selected rectangle with a gradient fill and a gradient stroke. +fn gradient_fill_and_stroke() -> VectorcraftApp { + let mut app = app(json!({"gradient": {}})); + app.run("paint.setStroke", json!({"gradient": {}, "focus": false})).unwrap(); + app +} + +/// With appearance row `active` active and the Fill (`front_fill`) or Stroke proxy in front, +/// chooses Soft Spectrum from the Presets menu and checks that row `target` takes the preset while +/// every other row keeps its paint. +fn assert_preset_goes_to(mut app: VectorcraftApp, active: usize, front_fill: bool, target: usize) { + let soft = app.session.gradient_preset("Soft Spectrum").unwrap().gradient.stops; + app.run("appearance.setActiveItem", json!({ "index": active })).unwrap(); + let before = row_paints(&app); + let mut p = Panel::new(); + p.frame(&mut app, vec![], Modifiers::NONE); + let proxy = + if front_fill { p.widget("fill-proxy").left_top() + vec2(2.0, 2.0) } else { p.widget("stroke-proxy").right_bottom() - vec2(2.0, 2.0) }; + p.click(&mut app, proxy); + assert_eq!(app.session.fill_active, front_fill); + assert_eq!(app.session.appearance_item(), Some(active), "the row stays active"); + let texts = p.frame(&mut app, vec![], Modifiers::NONE); + let combo = p.widget_after(text_at(&texts, "Presets:").expect("the Presets row")); + let texts = p.click(&mut app, combo.center()); + p.click(&mut app, text_at(&texts, "Soft Spectrum").expect("the preset")); + let after = row_paints(&app); + assert_eq!(after.len(), before.len()); + for (n, (was, now)) in before.iter().zip(&after).enumerate() { + if n == target { + assert!(matches!(now, Paint::Gradient(g) if g.gradient.stops == soft), "row {n} takes the preset: {now:?}"); + } else { + assert_eq!(now, was, "row {n} keeps its paint"); + } + } +} + +/// With a fill row active and the Stroke proxy in front, the Presets menu applies the preset to +/// the stroke. +#[test] +fn the_presets_menu_applies_to_the_stroke_in_front_over_an_active_fill_row() { + let app = gradient_fill_and_stroke(); + let (fill_row, stroke_row) = (rows_of_kind(&app, true)[0], rows_of_kind(&app, false)[0]); + assert_preset_goes_to(app, fill_row, false, stroke_row); +} + +/// With a stroke row active and the Fill proxy in front, the Presets menu applies the preset to +/// the fill. +#[test] +fn the_presets_menu_applies_to_the_fill_in_front_over_an_active_stroke_row() { + let app = gradient_fill_and_stroke(); + let (fill_row, stroke_row) = (rows_of_kind(&app, true)[0], rows_of_kind(&app, false)[0]); + assert_preset_goes_to(app, stroke_row, true, fill_row); +} + +/// With the proxy of the active row's kind in front, the Presets menu applies the preset to the +/// active row, not to the topmost row of that kind. +#[test] +fn the_presets_menu_applies_to_the_active_row_of_the_kind_in_front() { + for fill in [true, false] { + let mut app = gradient_fill_and_stroke(); + app.run(if fill { "appearance.addFill" } else { "appearance.addStroke" }, json!({})).unwrap(); + // Without an active row a solid goes to the topmost row of the kind; the other stays a gradient. + app.run(if fill { "paint.setFill" } else { "paint.setStroke" }, json!({"color": "#ff0000", "focus": false})).unwrap(); + let paints = row_paints(&app); + let rows = rows_of_kind(&app, fill); + assert_eq!(rows.len(), 2); + let lower = rows.into_iter().find(|&n| matches!(paints[n], Paint::Gradient(_))).expect("a gradient row under the solid one"); + assert_preset_goes_to(app, lower, fill, lower); + } +} + /// The panel menu saves the gradient as a preset (named in a dialog), which the Presets menu then /// lists under Saved; Delete Gradient Preset removes it, and Hide Presets leaves the row out. #[test] diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index e84ce63592..83c1cc0f83 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -2066,6 +2066,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur Escape ends that eyedropper's pick, and Brush Options' Key Color pick, without sampling and returns to the tool that started it; the stop keeps its color, and Brush Options stays open with its Key Color until a new Escape cancels it (#8024, [Modify gradients, archived user guide](https://web.archive.org/web/20210601162814/https://helpx.adobe.com/pdf/illustrator_reference.pdf#page=264)). Cmd/Ctrl-click on the Gradient panel's Gradient Fill box or on the Tools panel's Gradient button resets the gradient of the active Fill or Stroke to the linear White, Black gradient, as one undo step ([Default keyboard shortcuts](https://web.archive.org/web/20260726060015/https://helpx.adobe.com/illustrator/using/default-keyboard-shortcuts.html)). With a gradient stop or a freeform gradient point selected, Alt-clicking a color swatch in the Swatches panel recolors it instead of the inactive Fill or Stroke. + The Gradient panel's Presets menu applies the chosen preset to the fill or stroke behind the proxy in front, as the panel's other controls do. The panel's Fill or Stroke toggle chooses whether the panel edits the fill or the stroke ([Gradient panel options](https://web.archive.org/web/20251006210616/https://helpx.adobe.com/illustrator/desktop/paint-and-fill/create-and-edit-gradients/gradient-tool-and-panel.html)). As VectorCraft's own rule, an active Appearance panel row takes the preset only when it is a fill row and the Fill proxy is in front, or a stroke row and the Stroke proxy is in front (`panels::gradient` tests `the_presets_menu_applies_to_the_stroke_in_front_over_an_active_fill_row`, `the_presets_menu_applies_to_the_fill_in_front_over_an_active_stroke_row` and `the_presets_menu_applies_to_the_active_row_of_the_kind_in_front`). In the Gradient tool's freeform Lines mode, moving the pointer out of the object and back ends the line being drawn, and the next click on the object starts a new line from the point it adds. The help page describes this way of starting another line segment in the same object ([Create freeform gradient in lines mode](https://web.archive.org/web/20210601162814/https://helpx.adobe.com/pdf/illustrator_reference.pdf#page=262)). As VectorCraft's own rules, the line ends as soon as the pointer, with no button held, moves off the object's own art, its fill, stroke or glyphs (other art lying over the object still counts as inside), and Escape and a click off the art still end it as before (`xform::freeform::tests::leaving_the_object_ends_the_line`). - **Freeform gradient colors in their own model:** Object ▸ Expand and Object ▸ Create Gradient Mesh (`object.mesh.create`) mix a freeform gradient's points in the color model they share: points of C50 M20 Y0 K10 give mesh points of C50 M20 Y0 K10, and RGB points keep their values in a working RGB space other than sRGB. The canvas, the gradient chips and the SVG, PDF, EPS and EMF writers mix the points in that model too. PDF and EPS write a gradient whose points are all CMYK, or all Gray in a CMYK file, as a CMYK image, which PDF's Output settings convert as they convert any CMYK image. Points in different models mix in display RGB (on the canvas in a CMYK document that shows transparency, as the inks of each point), and a CMYK document stores the result of Expand as CMYK through the color settings. Points colored along CMYK stops (`paint.editGradient {stops}`, or a CMYK gradient switched to freeform) are CMYK, and so are a point `paint.freeform.splitLine` adds between CMYK points and a point `paint.freeform.addPoint` adds without `color` to CMYK points. Public reference: [Gradients](https://web.archive.org/web/20250714042311/https://helpx.adobe.com/illustrator/using/gradients.html) and [Meshes](https://web.archive.org/web/20250812201019/https://helpx.adobe.com/illustrator/using/meshes.html), which do not state how colors in different models mix; the rule is VectorCraft's own. - **Strokes:** one stroke-geometry module shared by the canvas, SVG, PDF and Outline Stroke; dotted lines (zero-length dashes draw dots or squares); arrowheads with hollow outlines, tip-on-end or extend-past-end alignment and one opacity for line and head. SVG and PDF export arrowheads, width profiles, brushes and aligned strokes exactly as the canvas draws them; Outline Stroke and the live Outline Stroke effect outline every stroke item as drawn (dashes, heads, profiles, alignment); dashes can be fitted to corners and path ends; width profiles carry through dashes, and their corners take the join. The Stroke panel edits type's character strokes, follows the stroke units (its weight presets are round values in that unit: `0.25 mm`, `0.0625 in`, `1 px`, #426; fields show four decimals in mm, cm and inches, three in points), shows mixed values blank and opens from the Control bar. A width profile library, thirty-one more arrowheads (among them Line Arrow: two arms of the head's weight (stroke weight × arrowhead scale, at least 0.25 pt: the line's weight at 100 % for lines of 0.25 pt or more) at right angles, cut square, #5421), and Width Point Edit with multi-select and discontinuous points. Visual bounds and clicks cover the whole painted stroke. Scale Strokes & Effects, Scale Corners and Use Preview Bounds work everywhere, and new art inherits stroke options, a graphic style or the whole last appearance. A width profile's sides run as a smooth C1 curve between the width points (a monotone cubic Hermite, Fritsch–Carlson, with the one-sided three-point PCHIP slope at the profile's ends and flat either side of a step), sampled adaptively along the path (two samples per profile segment, refined where the width bends, and leaning on dense path flattening) so straight runs draw it too; added samples offset along the source curve's exact tangent, not the flattened chord, so high zoom follows the true width; the sampled edges are fitted with G1 cubics within a tenth of the flattening tolerance (0.001 pt at the default 0.01 pt) rather than one cubic per flatten step, so exports stay close to a uniform stroke's path data; a point reshapes the curve as far as its neighbours' neighbours (their slopes depend on it), and coincident points still step. From a1995ad2b5e69fb231070cadb70496f5d652a9b8 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 22 Nov 2026 18:23:28 -0800 Subject: [PATCH 2/2] Gradient panel: name the row and proxy in the Presets menu's docs The doc comment on presets_row and the docs line now say that an active fill row takes the preset with the Fill proxy in front, and an active stroke row with the Stroke proxy in front. The docs line describes the help page's Fill or Stroke control as the page does. --- crates/ui-egui/src/panels/gradient.rs | 3 ++- docs/target-app-parity.md | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/panels/gradient.rs b/crates/ui-egui/src/panels/gradient.rs index 4664838728..2634f0f5c7 100644 --- a/crates/ui-egui/src/panels/gradient.rs +++ b/crates/ui-egui/src/panels/gradient.rs @@ -450,7 +450,8 @@ const REPEAT_PRESETS: [f64; 6] = [1.0, 2.0, 3.0, 4.0, 5.0, 10.0]; /// The Presets row: a menu of the preset gradients by library (theme), then the /// saved ones; a choice applies to the gradient behind the active proxy, keeping its placement /// (`gradient.presets.apply`; a solid or no paint becomes the gradient), as the panel's other -/// controls do: an active Appearance row stands for it only when it is a row of the proxy's kind. +/// controls do: an active Appearance row takes the preset only when that row is a fill row with the +/// Fill proxy in front, or a stroke row with the Stroke proxy in front. /// The menu shows the preset the gradient is, if any. fn presets_row(app: &mut VectorcraftApp, ui: &mut Ui, g: Option<&GradientPaint>) { let shown = g.and_then(|g| app.session.gradient_preset_name(&g.gradient)).unwrap_or_default(); diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 83c1cc0f83..3470ceeb96 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -2066,7 +2066,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur Escape ends that eyedropper's pick, and Brush Options' Key Color pick, without sampling and returns to the tool that started it; the stop keeps its color, and Brush Options stays open with its Key Color until a new Escape cancels it (#8024, [Modify gradients, archived user guide](https://web.archive.org/web/20210601162814/https://helpx.adobe.com/pdf/illustrator_reference.pdf#page=264)). Cmd/Ctrl-click on the Gradient panel's Gradient Fill box or on the Tools panel's Gradient button resets the gradient of the active Fill or Stroke to the linear White, Black gradient, as one undo step ([Default keyboard shortcuts](https://web.archive.org/web/20260726060015/https://helpx.adobe.com/illustrator/using/default-keyboard-shortcuts.html)). With a gradient stop or a freeform gradient point selected, Alt-clicking a color swatch in the Swatches panel recolors it instead of the inactive Fill or Stroke. - The Gradient panel's Presets menu applies the chosen preset to the fill or stroke behind the proxy in front, as the panel's other controls do. The panel's Fill or Stroke toggle chooses whether the panel edits the fill or the stroke ([Gradient panel options](https://web.archive.org/web/20251006210616/https://helpx.adobe.com/illustrator/desktop/paint-and-fill/create-and-edit-gradients/gradient-tool-and-panel.html)). As VectorCraft's own rule, an active Appearance panel row takes the preset only when it is a fill row and the Fill proxy is in front, or a stroke row and the Stroke proxy is in front (`panels::gradient` tests `the_presets_menu_applies_to_the_stroke_in_front_over_an_active_fill_row`, `the_presets_menu_applies_to_the_fill_in_front_over_an_active_stroke_row` and `the_presets_menu_applies_to_the_active_row_of_the_kind_in_front`). + The Gradient panel's Presets menu applies the chosen preset to the fill or stroke behind the proxy in front, as the panel's other controls do. The help page describes a Fill or Stroke control on the Gradient panel that toggles whether the fill or the stroke is being edited ([Gradient panel options](https://web.archive.org/web/20251006210616/https://helpx.adobe.com/illustrator/desktop/paint-and-fill/create-and-edit-gradients/gradient-tool-and-panel.html)). As VectorCraft's own rule, an active Appearance panel row takes the preset only when it is a fill row and the Fill proxy is in front, or a stroke row and the Stroke proxy is in front (`panels::gradient` tests `the_presets_menu_applies_to_the_stroke_in_front_over_an_active_fill_row`, `the_presets_menu_applies_to_the_fill_in_front_over_an_active_stroke_row` and `the_presets_menu_applies_to_the_active_row_of_the_kind_in_front`). In the Gradient tool's freeform Lines mode, moving the pointer out of the object and back ends the line being drawn, and the next click on the object starts a new line from the point it adds. The help page describes this way of starting another line segment in the same object ([Create freeform gradient in lines mode](https://web.archive.org/web/20210601162814/https://helpx.adobe.com/pdf/illustrator_reference.pdf#page=262)). As VectorCraft's own rules, the line ends as soon as the pointer, with no button held, moves off the object's own art, its fill, stroke or glyphs (other art lying over the object still counts as inside), and Escape and a click off the art still end it as before (`xform::freeform::tests::leaving_the_object_ends_the_line`). - **Freeform gradient colors in their own model:** Object ▸ Expand and Object ▸ Create Gradient Mesh (`object.mesh.create`) mix a freeform gradient's points in the color model they share: points of C50 M20 Y0 K10 give mesh points of C50 M20 Y0 K10, and RGB points keep their values in a working RGB space other than sRGB. The canvas, the gradient chips and the SVG, PDF, EPS and EMF writers mix the points in that model too. PDF and EPS write a gradient whose points are all CMYK, or all Gray in a CMYK file, as a CMYK image, which PDF's Output settings convert as they convert any CMYK image. Points in different models mix in display RGB (on the canvas in a CMYK document that shows transparency, as the inks of each point), and a CMYK document stores the result of Expand as CMYK through the color settings. Points colored along CMYK stops (`paint.editGradient {stops}`, or a CMYK gradient switched to freeform) are CMYK, and so are a point `paint.freeform.splitLine` adds between CMYK points and a point `paint.freeform.addPoint` adds without `color` to CMYK points. Public reference: [Gradients](https://web.archive.org/web/20250714042311/https://helpx.adobe.com/illustrator/using/gradients.html) and [Meshes](https://web.archive.org/web/20250812201019/https://helpx.adobe.com/illustrator/using/meshes.html), which do not state how colors in different models mix; the rule is VectorCraft's own. - **Strokes:** one stroke-geometry module shared by the canvas, SVG, PDF and Outline Stroke; dotted lines (zero-length dashes draw dots or squares); arrowheads with hollow outlines, tip-on-end or extend-past-end alignment and one opacity for line and head. SVG and PDF export arrowheads, width profiles, brushes and aligned strokes exactly as the canvas draws them; Outline Stroke and the live Outline Stroke effect outline every stroke item as drawn (dashes, heads, profiles, alignment); dashes can be fitted to corners and path ends; width profiles carry through dashes, and their corners take the join. The Stroke panel edits type's character strokes, follows the stroke units (its weight presets are round values in that unit: `0.25 mm`, `0.0625 in`, `1 px`, #426; fields show four decimals in mm, cm and inches, three in points), shows mixed values blank and opens from the Control bar. A width profile library, thirty-one more arrowheads (among them Line Arrow: two arms of the head's weight (stroke weight × arrowhead scale, at least 0.25 pt: the line's weight at 100 % for lines of 0.25 pt or more) at right angles, cut square, #5421), and Width Point Edit with multi-select and discontinuous points. Visual bounds and clicks cover the whole painted stroke. Scale Strokes & Effects, Scale Corners and Use Preview Bounds work everywhere, and new art inherits stroke options, a graphic style or the whole last appearance. A width profile's sides run as a smooth C1 curve between the width points (a monotone cubic Hermite, Fritsch–Carlson, with the one-sided three-point PCHIP slope at the profile's ends and flat either side of a step), sampled adaptively along the path (two samples per profile segment, refined where the width bends, and leaning on dense path flattening) so straight runs draw it too; added samples offset along the source curve's exact tangent, not the flattened chord, so high zoom follows the true width; the sampled edges are fitted with G1 cubics within a tenth of the flattening tolerance (0.001 pt at the default 0.01 pt) rather than one cubic per flatten step, so exports stay close to a uniform stroke's path data; a point reshapes the curve as far as its neighbours' neighbours (their slopes depend on it), and coincident points still step.