mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-10-24 09:46:59 -06:00
Merge pull request #3335 from dotCooCoo/feat/pattern-scale-slider
Brush Options: Pattern Scale and Art Width have sliders
This commit is contained in:
@@ -214,6 +214,13 @@ fn number(ui: &mut egui::Ui, d: &mut Dialog, key: &str, range: (f64, f64), suffi
|
||||
});
|
||||
}
|
||||
|
||||
/// A row labeled `label` with a slider and a whole-number field (%) bound to `d.fields[key]`, both
|
||||
/// kept within `range`; screen readers call the slider `label`.
|
||||
fn slider_row(ui: &mut egui::Ui, d: &mut Dialog, key: &str, label: &str, range: (f64, f64)) {
|
||||
let rail = Tokens::get(ui.ctx()).input_border;
|
||||
widgets::label_row(ui, label, LABEL_W, |ui| super::form::slider_field_named(ui, d, key, label, range.0..=range.1, "%", &|_| rail));
|
||||
}
|
||||
|
||||
/// A row of radio buttons bound to the string field `key`: (value, label).
|
||||
fn radios(ui: &mut egui::Ui, d: &mut Dialog, key: &str, options: &[(&str, &str)]) {
|
||||
let cur = d.str(key);
|
||||
@@ -260,7 +267,7 @@ fn scatter_body(ui: &mut egui::Ui, d: &mut Dialog) {
|
||||
}
|
||||
|
||||
fn art_body(ui: &mut egui::Ui, d: &mut Dialog) {
|
||||
widgets::label_row(ui, tl!("Width:"), LABEL_W, |ui| number(ui, d, "width", ArtBrush::WIDTH_RANGE, "%", true));
|
||||
slider_row(ui, d, "width", tl!("Width:"), ArtBrush::WIDTH_RANGE);
|
||||
ui.add_space(4.0);
|
||||
widgets::section_header(ui, tl!("Brush Scale Options"));
|
||||
let scales = [
|
||||
@@ -318,7 +325,7 @@ fn arrow_button(ui: &mut egui::Ui, dir: Direction, selected: bool, tip: &str) ->
|
||||
}
|
||||
|
||||
fn pattern_body(ui: &mut egui::Ui, d: &mut Dialog) {
|
||||
widgets::label_row(ui, tl!("Scale:"), LABEL_W, |ui| number(ui, d, "scale", PatternBrush::SCALE_RANGE, "%", true));
|
||||
slider_row(ui, d, "scale", tl!("Scale:"), PatternBrush::SCALE_RANGE);
|
||||
widgets::label_row(ui, tl!("Spacing:"), LABEL_W, |ui| number(ui, d, "spacing", PatternBrush::SPACING_RANGE, "%", true));
|
||||
ui.add_space(6.0);
|
||||
tiles(ui, d);
|
||||
|
||||
@@ -493,4 +493,21 @@ mod tests {
|
||||
);
|
||||
assert!((drawn_height(&app, id) / before - 2.0).abs() < 1e-6, "tiles twice the size");
|
||||
}
|
||||
|
||||
/// Art Brush Options' Width and Pattern Brush Options' Scale each have a slider beside their
|
||||
/// field, which screen readers name as the row, with the field's number and text over the
|
||||
/// value's whole range.
|
||||
#[test]
|
||||
fn art_width_and_pattern_scale_have_sliders() {
|
||||
use crate::widgets::accessibility_tests::{slider_value, tree};
|
||||
let mut app = app();
|
||||
app.run("ui.brushOptions", json!({"name": "Arrow"})).unwrap();
|
||||
set(&mut app, json!({"width": 250}));
|
||||
let shown = tree(|ui| super::super::show(&mut app, ui.ctx()));
|
||||
assert_eq!(slider_value(&shown, "Width:"), (Some(250.0), Some(1.0), Some(1000.0), Some("250%".into())));
|
||||
app.ui.dialog = None;
|
||||
app.run("ui.brushOptions", json!({"name": "Diamonds"})).unwrap();
|
||||
let shown = tree(|ui| super::super::show(&mut app, ui.ctx()));
|
||||
assert_eq!(slider_value(&shown, "Scale:"), (Some(100.0), Some(1.0), Some(10000.0), Some("100%".into())));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1317,6 +1317,24 @@ fn dialog_sliders_report_the_numbers_their_fields_show() {
|
||||
assert_eq!(slider_value(&shown, "Raster/Vector Balance:"), v(30.0, (0.0, 100.0), "30"));
|
||||
}
|
||||
|
||||
/// Dragging Pattern Brush Options' Scale slider past its right end sets Scale to 10000%, and
|
||||
/// dragging Art Brush Options' Width slider past its left end sets Width to 1%; OK gives each
|
||||
/// brush its new value.
|
||||
#[test]
|
||||
fn brush_options_sliders_set_pattern_scale_and_art_width() {
|
||||
use egui::accesskit::Role::Slider;
|
||||
let mut app = app();
|
||||
for (brush, label, key, by, want) in [("Diamonds", "Scale:", "scale", 400.0, 10000.0), ("Arrow", "Width:", "width", -400.0, 1.0)] {
|
||||
app.run("ui.brushOptions", json!({ "name": brush })).unwrap();
|
||||
let mut f = Frames::new();
|
||||
let at = f.control(&mut app, label, Slider);
|
||||
f.drag(&mut app, at, egui::vec2(by, 0.0));
|
||||
assert_eq!(app.ui.dialog.as_ref().expect("Brush Options is open").f64(key, 0.0), want, "{brush}");
|
||||
confirm(&mut app).unwrap();
|
||||
assert_eq!(app.run("brush.get", json!({ "name": brush })).unwrap()[key], json!(want), "{brush}");
|
||||
}
|
||||
}
|
||||
|
||||
/// Frames of the dialog layer on one context (so a drag and the keyboard focus last from frame to
|
||||
/// frame), with the screen-reader tree turned on.
|
||||
struct Frames {
|
||||
|
||||
@@ -693,6 +693,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
|
||||
- **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. Points in different models mix in display RGB, and a CMYK document stores the result 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 more arrowheads, 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.
|
||||
- **Brushes (part of #852):** double-clicking a brush in the Brushes panel (or the panel menu's Brush Options…) opens Calligraphic Brush Options (Name; Angle, Roundness and Size, each Fixed, Random or Pressure with its Variation; live previews of the nib and of a light–heavy–light stroke) or Bristle Brush Options (Shape and the bristle sliders); OK edits the brush and every stroke painted with it. The Paintbrush records the pen pressure along each stroke (kept with the path, saved, and joined when a stroke continues a path); a Calligraphic value on Pressure goes from value − variation at the lightest pressure to value + variation at the heaviest, on the canvas and in SVG, PDF and the other exports. Brushes saved before keep their look. Scatter Brush Options (Size, Spacing, Scatter and Rotation, each Fixed, Random between two values or Pressure from the first at the lightest pressure to the second at the heaviest; Rotation relative to Page or Path), Art Brush Options (Width, Scale Proportionately, Stretch to Fit Stroke Length or Stretch Between Guides with the guides' start and end, the four Directions, Flip Along and Across) and Pattern Brush Options (Scale, Spacing, the five tiles shown, Flip Along and Across, Stretch to fit, Add space to fit or Approximate path) each have Colorization (None, Tints, Tints and Shades, Hue Shift with its Key Color picked from the art's colours) and a live stroke preview; values from files and commands are clamped to their ranges. Still to come: the Art brush's Overlap, auto-generated Pattern brush corners, new tile art picked in Pattern Brush Options, Stylus Wheel, Tilt, Bearing and Rotation, and pen pressure on macOS.
|
||||
Art Brush Options' Width (1% to 1000%) and Pattern Brush Options' Scale (1% to 10000%) each have a slider beside the field, over the same range in whole percents; screen readers name the slider as its row and read the field's value.
|
||||
Hue Shift set by `brush.new` or `brush.options` without a key color takes the color the art's fills and strokes use most, as Brush Options already offers it, following the Brushes page: "By default, the key color is the most prominent color in the art" (<https://web.archive.org/web/20241230205225/https://helpx.adobe.com/illustrator/using/brushes.html>). The page does not state how prominence is measured. Counting the fills and strokes that use each solid color, with the first one found winning a tie and black for art with no solid color, is VectorCraft's own rule. A `brush.options` edit that gives only the method keeps the brush's key color, and one that gives only an art brush's start guide keeps its end guide. Evidence: `tests_brushsym::hue_shift_without_a_key_takes_the_most_used_art_color`, `tests_brushsym::art_brush_options_keep_the_scale_fields_an_edit_leaves_out`.
|
||||
In the Brushes panel, Shift-click selects a range of brushes and Ctrl/Cmd-click adds or removes one. Delete Brush and Duplicate Brush then act on all of them (`brush.delete {names}`, `brush.duplicate {names}`).
|
||||
Document Info has a Brushes category after Graphic Styles. It lists the Brushes panel's brushes, or with Selection Only it lists the brushes that the selected objects' strokes use. The Document Info report and Package's report list them too (`document.info {category: "brushes"}`, `brushNames`).
|
||||
|
||||
Reference in New Issue
Block a user