Merge main into #8383

# Conflicts:
#	crates/engine/src/cmd/brushlib.rs
#	crates/engine/src/tests/brushlib.rs
#	crates/ui-egui/src/i18n/bg.tsv
#	crates/ui-egui/src/i18n/bs.tsv
#	crates/ui-egui/src/i18n/ca.tsv
#	crates/ui-egui/src/i18n/cs.tsv
#	crates/ui-egui/src/i18n/da.tsv
#	crates/ui-egui/src/i18n/de.tsv
#	crates/ui-egui/src/i18n/el.tsv
#	crates/ui-egui/src/i18n/es.tsv
#	crates/ui-egui/src/i18n/fi.tsv
#	crates/ui-egui/src/i18n/fr.tsv
#	crates/ui-egui/src/i18n/gu.tsv
#	crates/ui-egui/src/i18n/hi.tsv
#	crates/ui-egui/src/i18n/hu.tsv
#	crates/ui-egui/src/i18n/id.tsv
#	crates/ui-egui/src/i18n/it.tsv
#	crates/ui-egui/src/i18n/ja.tsv
#	crates/ui-egui/src/i18n/ka.tsv
#	crates/ui-egui/src/i18n/ko.tsv
#	crates/ui-egui/src/i18n/nl.tsv
#	crates/ui-egui/src/i18n/pl.tsv
#	crates/ui-egui/src/i18n/pt-br.tsv
#	crates/ui-egui/src/i18n/ru.tsv
#	crates/ui-egui/src/i18n/sv.tsv
#	crates/ui-egui/src/i18n/tr.tsv
#	crates/ui-egui/src/i18n/uk.tsv
#	crates/ui-egui/src/i18n/vi.tsv
#	crates/ui-egui/src/i18n/zh-hans.tsv
#	crates/ui-egui/src/i18n/zh-hant.tsv
#	crates/ui-egui/src/panels/tests_brush_libraries.rs
This commit is contained in:
bflatastic
2026-11-20 03:20:37 +07:00
61 changed files with 1481 additions and 125 deletions
+42
View File
@@ -177,6 +177,7 @@ pub const BUILTIN: &[BuiltinBrushLibrary] = &[
BuiltinBrushLibrary { id: "bristle-brushes", name: "Bristle Brushes", make: bristle_brushes },
BuiltinBrushLibrary { id: "paint", name: "Paint", make: paint },
BuiltinBrushLibrary { id: "pattern-borders", name: "Pattern Borders", make: pattern_borders },
BuiltinBrushLibrary { id: "decorative", name: "Decorative", make: decorative },
BuiltinBrushLibrary { id: "ornamental", name: "Ornamental", make: ornamental },
BuiltinBrushLibrary { id: "scatter-shapes", name: "Scatter Shapes", make: scatter_shapes },
BuiltinBrushLibrary { id: "stipple", name: "Stipple", make: stipple },
@@ -691,6 +692,47 @@ fn pattern_borders() -> BrushLibrary {
built("Pattern Borders", Document::new(100.0, 100.0), brushes)
}
/// Decorative: repeating plant, flower and hanging ornaments drawn as original vector tiles.
/// Every tile joins the next at x = 0 and 48 so open and closed paths stay continuous.
fn decorative() -> BrushLibrary {
let stem = || black(shapes::rectangle(Rect::new(0.0, -0.65, 48.0, 0.65)));
let vine = group(vec![
stem(),
black(polygon(&[(8.0, -0.2), (12.0, -5.0), (24.0, -8.0), (20.0, -1.0)])),
black(polygon(&[(28.0, 0.2), (32.0, 5.0), (44.0, 8.0), (40.0, 1.0)])),
]);
let mut blossoms = vec![stem()];
for x in [12.0, 36.0] {
for (dx, dy) in [(0.0, -4.0), (4.0, 0.0), (0.0, 4.0), (-4.0, 0.0)] {
blossoms.push(black(shapes::ellipse(Rect::new(x + dx - 2.5, dy - 2.5, x + dx + 2.5, dy + 2.5))));
}
blossoms.push(black(shapes::ellipse(Rect::new(x - 1.3, -1.3, x + 1.3, 1.3))));
}
let flowers = group(blossoms);
let pennants = group(vec![
black(shapes::rectangle(Rect::new(0.0, -5.2, 48.0, -4.2))),
black(polygon(&[(4.0, -4.2), (20.0, -4.2), (12.0, 10.0)])),
black(polygon(&[(28.0, -4.2), (44.0, -4.2), (36.0, 10.0)])),
]);
let lanterns = group(vec![
black(shapes::rectangle(Rect::new(0.0, -5.0, 48.0, -4.0))),
black(shapes::rectangle(Rect::new(11.4, -4.0, 12.6, -1.0))),
black(shapes::ellipse(Rect::new(7.0, -1.0, 17.0, 9.0))),
black(shapes::rectangle(Rect::new(35.4, -4.0, 36.6, -1.0))),
black(shapes::ellipse(Rect::new(31.0, -1.0, 41.0, 9.0))),
]);
built(
"Decorative",
Document::new(100.0, 100.0),
vec![
border("Leaf Vine", vine, None, PatternFit::Stretch),
border("Blossom Chain", flowers, None, PatternFit::Stretch),
border("Pennant Garland", pennants, None, PatternFit::Stretch),
border("Lantern String", lanterns, None, PatternFit::Stretch),
],
)
}
/// Ornamental: one-pass flourishes and arrow accents that stretch with the path rather than
/// repeating a pattern tile. Every shape is original filled vector art.
fn ornamental() -> BrushLibrary {
+2 -2
View File
@@ -63,7 +63,7 @@ fn select_stop(s: &mut Session, p: &Value) -> Result<Value> {
// No document is needed for the default paint's gradient, so this does not use `refuse_symbol_part`.
// While the Live Paint Bucket is active the proxies show the default paint, whose stops can be
// selected with a part picked.
if s.tool_id() != super::paint::LIVE_PAINT_BUCKET && s.active().is_some_and(|st| st.selection.symbol_part.is_some()) {
if !s.bucket_paints() && s.active().is_some_and(|st| st.selection.symbol_part.is_some()) {
return Err(super::brushsym::part_only());
}
let index = match p.get("index") {
@@ -111,7 +111,7 @@ impl StopOwner {
part: st.is_some_and(|d| d.selection.symbol_part.is_some()),
fill: s.fill_active,
item: s.appearance_item(),
bucket: s.tool_id() == super::paint::LIVE_PAINT_BUCKET,
bucket: s.bucket_paints(),
}
}
}
+1 -1
View File
@@ -209,7 +209,7 @@ impl Session {
/// 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.
pub(crate) fn inherit_new_art(&mut self) {
if self.prefs.new_art_basic || self.tool_id() == super::paint::LIVE_PAINT_BUCKET {
if self.prefs.new_art_basic || self.bucket_paints() {
return;
}
let Some(st) = self.active() else { return };
+25 -6
View File
@@ -203,10 +203,11 @@ impl Session {
/// The object whose fill (or stroke) the proxy shows, with the Appearance panel's active item
/// when it stands for it (see [`Session::proxy_paints`]); None: the defaults for new art. With
/// an object of a dynamic symbol instance selected ([`DocState::selected_symbol_part`]), that
/// object as the instance draws it. None while the Live Paint Bucket is the active tool: the
/// proxies show the colors it paints with.
/// object as the instance draws it. None while the Live Paint Bucket is the active tool (or
/// another tool works for it, [`Session::bucket_paints`]): the proxies show the colors it
/// paints with.
pub(crate) fn proxy_source(&self, stroke: bool) -> Option<(Cow<'_, Node>, Option<usize>)> {
if self.tool_id() == LIVE_PAINT_BUCKET {
if self.bucket_paints() {
return None;
}
let st = self.active()?;
@@ -378,11 +379,28 @@ impl DocState {
}
impl Session {
/// Do the fill and stroke proxies, and the paint commands that name no objects, stand for the
/// colors the Live Paint Bucket paints with? They do while the bucket is the active tool, while
/// a Cmd+click with the bucket uses the Selection tool, and while the Eyedropper samples into a
/// stop of the bucket's gradient for the Gradient panel's eyedropper, up to and including the
/// sample its click takes before it switches back to the bucket.
pub fn bucket_paints(&self) -> bool {
let for_bucket = |t: &dyn vectorcraft_tools::Tool| t.id() == LIVE_PAINT_BUCKET || t.returns_to() == Some(LIVE_PAINT_BUCKET);
// A Cmd+click lends the Selection tool to the bucket, or to the Eyedropper armed for it.
self.back_to_bucket || for_bucket(self.tool.as_ref()) || self.lender.as_deref().is_some_and(for_bucket)
}
/// The tool the active tool's armed one-shot pick switches back to after its click
/// ([`vectorcraft_tools::Tool::returns_to`]).
pub fn tool_returns_to(&self) -> Option<String> {
self.tool.returns_to().map(str::to_string)
}
/// [`DocState::proxy_mixed`] of the active document for the Appearance panel's active item.
/// A gradient mesh with points picked ([`Session::fill_mesh_points`]) counts with their colors.
/// Neither is mixed while the Live Paint Bucket is the active tool ([`Session::proxy_source`]).
pub fn proxy_mixed(&self) -> (bool, bool) {
if self.tool_id() == LIVE_PAINT_BUCKET {
if self.bucket_paints() {
return (false, false);
}
self.active().map_or((false, false), |st| st.proxy_mixed_with(self.appearance_item(), &self.fill_mesh_points()))
@@ -737,12 +755,13 @@ pub(crate) fn apply_paint(s: &mut Session, p: &Value, paint: Paint, fill: bool)
Ok(json!({"objects": ids.iter().collect::<std::collections::BTreeSet<_>>().len()}))
}
/// Is the Live Paint Bucket the active tool while `p` names no `ids`, `id` or `item`? A fill,
/// 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 {
// A null `ids` or `id` is no target, as `given_nodes` reads it; `item: null` names the top row.
s.tool_id() == LIVE_PAINT_BUCKET && ["ids", "id"].iter().all(|k| p.get(k).is_none_or(Value::is_null)) && p.get("item").is_none()
s.bucket_paints() && ["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.
+1 -1
View File
@@ -445,7 +445,7 @@ impl Session {
/// selection's stroke.
pub fn shown_stroke(&self) -> Option<StrokeLayer> {
let st = self.active()?;
if self.tool_id() == super::paint::LIVE_PAINT_BUCKET {
if self.bucket_paints() {
return Some(self.new_art_stroke());
}
if let Some(part) = st.selected_symbol_part() {
+4
View File
@@ -74,6 +74,10 @@ pub struct Session {
/// While Cmd lends `tool` (a selection tool) for a drag: the tool it was lent to, which comes
/// back as it was at the release ([`Session::pointer`]).
pub(crate) lender: Option<Box<dyn Tool>>,
/// Set while tool actions that end by switching back to the Live Paint Bucket are applied (the
/// Eyedropper's sample into a stop of the bucket's gradient): their paint commands change the
/// colors the bucket paints with ([`Session::bucket_paints`]).
pub(crate) back_to_bucket: bool,
/// Pointer and key input that came while the tool computed an edit on another thread, each with
/// its number and view, made in order once the edit is applied.
held_input: std::collections::VecDeque<(u64, tooling::HeldInput, ViewInfo)>,
+1
View File
@@ -55,6 +55,7 @@ impl Session {
histories_seen: None,
tool: vectorcraft_tools::create("selection"),
lender: None,
back_to_bucket: false,
held_input: Default::default(),
input_count: 0,
edit_started_by: None,
+2 -2
View File
@@ -323,7 +323,7 @@ impl Session {
}
// 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.
let bucket = self.tool_id() == cmd::LIVE_PAINT_BUCKET;
let bucket = self.bucket_paints();
let (paint, restore_paint) = {
let menu = self.menu.clone();
let st = self.doc_mut()?;
@@ -485,7 +485,7 @@ impl Session {
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.
let bucket = self.tool_id() == cmd::LIVE_PAINT_BUCKET;
let bucket = self.bucket_paints();
if let Some(paint) = self
.active()
.and_then(|st| st.interaction.as_ref())
+62 -7
View File
@@ -114,6 +114,7 @@ fn the_builtin_libraries_are_original_brushes_generated_in_code() {
"bristle-brushes",
"paint",
"pattern-borders",
"decorative",
"ornamental",
"scatter-shapes",
"stipple",
@@ -128,6 +129,20 @@ fn the_builtin_libraries_are_original_brushes_generated_in_code() {
]
);
assert!(libs.iter().all(|l| l["category"] == "builtIn"));
// None of them is a default brush.
let defaults: Vec<&str> = vectorcraft_brush::defaults().iter().map(|b| b.name.as_str()).collect();
for id in ids {
let (_, lib) = cmd::brushlib::library(&s, id).unwrap();
assert!(lib.brushes.iter().all(|b| !defaults.contains(&b.name.as_str())), "{id}");
}
assert!(s.execute("brush.library", &json!({"library": "nope"})).is_err());
}
#[test]
fn the_builtin_libraries_list_their_brush_names_and_counts() {
let mut s = Session::new();
let list = run(&mut s, "brush.libraries", json!({}));
let libs = list["libraries"].as_array().unwrap();
// Looked up by id, so a library added to the list does not shift these checks.
let entry = |id: &str| libs.iter().find(|l| l["id"] == id).unwrap();
let lib = run(&mut s, "brush.library", json!({"library": "art ribbons"}));
@@ -136,6 +151,7 @@ fn the_builtin_libraries_are_original_brushes_generated_in_code() {
["Notched Ribbon", "Double Line", "Wave", "Teardrop", "Striped Ribbon"]
);
assert_eq!(entry("art-ribbons")["count"].as_u64(), Some(5));
assert_eq!((entry("decorative")["name"].as_str(), entry("decorative")["count"].as_u64()), (Some("Decorative"), Some(4)));
let trails = run(&mut s, "brush.library", json!({"library": "game-trails"}));
assert_eq!(
trails["brushes"].as_array().unwrap().iter().map(|b| b["name"].as_str().unwrap()).collect::<Vec<_>>(),
@@ -165,6 +181,11 @@ fn the_builtin_libraries_are_original_brushes_generated_in_code() {
let id = run(&mut s, "shape.rectangle", json!({"x": 10, "y": 20, "width": 40, "height": 8}))["id"].as_u64().unwrap();
let added = run(&mut s, "brush.addFromLibrary", json!({"library": "energy-beams", "name": "Laser Bolt", "apply": true, "ids": [id]}));
assert_eq!(strs(&added["added"]), ["Laser Bolt"]);
}
#[test]
fn every_builtin_library_brush_has_its_kind_and_draws() {
let s = Session::new();
// One kind of brush per library (Ink and Wash: art brushes and a calligraphic one), every
// brush drawing something.
for (id, kind) in [
@@ -175,6 +196,7 @@ fn the_builtin_libraries_are_original_brushes_generated_in_code() {
("bristle-brushes", "bristle"),
("paint", "art"),
("pattern-borders", "pattern"),
("decorative", "pattern"),
("ornamental", "art"),
("scatter-shapes", "scatter"),
("stipple", "scatter"),
@@ -197,6 +219,11 @@ fn the_builtin_libraries_are_original_brushes_generated_in_code() {
assert!(!vectorcraft_brush::stroke_pieces(&lib.doc, b, &line, &stroke).is_empty(), "{} draws nothing", b.name);
}
}
}
#[test]
fn builtin_library_brushes_bring_the_resources_their_art_uses() {
let s = Session::new();
// The resources their art uses come with them: Striped Ribbon's pattern, Sparkles' symbol.
let (_, ribbons) = cmd::brushlib::library(&s, "art-ribbons").unwrap();
assert_eq!(art_patterns(ribbons.brush("Striped Ribbon").unwrap()), ["Pinstripes"]);
@@ -205,13 +232,6 @@ fn the_builtin_libraries_are_original_brushes_generated_in_code() {
let BrushKind::Scatter(sparkles) = &shapes.brush("Sparkles").unwrap().kind else { panic!("not a scatter brush") };
assert!(matches!(&sparkles.art.kind, NodeKind::SymbolInstance { symbol, .. } if symbol == "Sparkle"));
assert!(shapes.doc.symbols.iter().any(|x| x.name == "Sparkle"));
// None of them is a default brush.
let defaults: Vec<&str> = vectorcraft_brush::defaults().iter().map(|b| b.name.as_str()).collect();
for id in ids {
let (_, lib) = cmd::brushlib::library(&s, id).unwrap();
assert!(lib.brushes.iter().all(|b| !defaults.contains(&b.name.as_str())), "{id}");
}
assert!(s.execute("brush.library", &json!({"library": "nope"})).is_err());
}
#[test]
@@ -564,6 +584,41 @@ fn the_tech_circuit_library_constructs_adds_and_applies_each_brush() {
assert_eq!(vectorcraft_brush::library(&reopened), lib.brushes);
}
#[test]
fn decorative_brushes_repeat_distinct_art_and_survive_a_saved_library() {
let mut s = session();
let (_, lib) = cmd::brushlib::library(&s, "Decorative").unwrap();
let names = ["Leaf Vine", "Blossom Chain", "Pennant Garland", "Lantern String"];
assert_eq!(lib.brushes.iter().map(|b| b.name.as_str()).collect::<Vec<_>>(), names);
let path = run(&mut s, "shape.line", json!({"x1": 10, "y1": 40, "x2": 190, "y2": 40}))["id"].as_u64().unwrap();
let mut signatures = std::collections::HashSet::new();
for b in &lib.brushes {
let BrushKind::Pattern(pattern) = &b.kind else { panic!("{} is not a pattern brush", b.name) };
assert_eq!(pattern.colorization, vectorcraft_brush::Colorization::Tints);
let points = |len: f64| anchors(&vectorcraft_brush::stroke_pieces(&lib.doc, b, &line_to(len), &black_stroke()).iter().collect::<Vec<_>>());
let (one, four) = (points(48.0), points(192.0));
assert!(!one.is_empty() && four.iter().all(|p| p.x.is_finite() && p.y.is_finite()), "{}", b.name);
// A path four tiles long places the motif four times, each copy one tile further along.
assert_eq!(four.len(), 4 * one.len(), "{} repeats its motif", b.name);
for (i, p) in four.iter().enumerate() {
let q = one[i % one.len()];
let shift = 48.0 * (i / one.len()) as f64;
assert!((p.x - q.x - shift).abs() < 1e-3 && (p.y - q.y).abs() < 1e-3, "{} copy {} at {p:?}, not {q:?}", b.name, i / one.len());
}
signatures.insert(one.iter().map(|p| ((p.x * 100.0).round() as i64, (p.y * 100.0).round() as i64)).collect::<Vec<_>>());
let before = undo_len(&s);
let applied = run(&mut s, "brush.addFromLibrary", json!({"library": "decorative", "name": b.name, "apply": true, "ids": [path]}));
assert_eq!((strs(&applied["added"]), &applied["applied"]), (vec![b.name.as_str()], &json!([path])));
assert_eq!(undo_len(&s), before + 1);
assert_eq!(doc(&s).node(NodeId(path)).unwrap().appearance.stroke().unwrap().brush.as_deref(), Some(b.name.as_str()));
}
assert_eq!(signatures.len(), names.len(), "each design produces a different repeating shape");
let saved = run(&mut s, "brush.saveLibrary", json!({"names": names}));
let bytes = vectorcraft_format::base64_decode(saved["dataBase64"].as_str().unwrap()).unwrap();
let reopened = vectorcraft_format::load(&bytes).unwrap();
assert_eq!(vectorcraft_brush::library(&reopened), lib.brushes);
}
#[test]
fn ornamental_brushes_draw_flourishes_and_survive_a_saved_library() {
let mut s = session();
+59
View File
@@ -3434,6 +3434,65 @@ fn live_paint_bucket_gradient_preset_and_sampled_stop_follow_the_active_proxy()
assert_eq!(node(&s, rect), art, "the selection keeps its paint");
}
/// The Gradient panel's eyedropper, used on a stop of the Live Paint Bucket's gradient, samples the
/// color clicked into that stop of the bucket's fill, and the selection keeps its paint. A Cmd-click
/// with the bucket, or with the Eyedropper armed for it, which the selection tool takes, leaves the
/// bucket's colors as they were.
#[test]
fn live_paint_bucket_keeps_its_colors_through_the_stop_eyedropper_and_a_cmd_click() {
let v = ViewInfo::default();
let click = |s: &mut Session, mods: Mods| {
for kind in [PointerKind::Down, PointerKind::Up] {
s.pointer(&PointerEvent::new(kind, 320.0, 320.0).with_mods(mods), v).unwrap();
}
};
let mut s = session();
live(&mut s);
let rect = rect(&mut s, 300.0, 300.0, 40.0, 40.0);
s.execute("paint.setFill", &json!({"color": "#00ff00", "ids": [rect.0]})).unwrap();
s.execute("appearance.setNewArtBasic", &json!({"on": false})).unwrap();
s.execute("select.set", &json!({"ids": [rect.0]})).unwrap();
s.select_tool("livePaintBucket", v).unwrap();
s.execute("paint.editGradient", &json!({"stroke": false, "kind": "linear"})).unwrap();
s.execute("gradient.selectStop", &json!({"index": 1})).unwrap();
let art = node(&s, rect);
// The panel's eyedropper (`stop_eyedropper`): the Eyedropper, set to switch back to the bucket.
s.select_tool("eyedropper", v).unwrap();
s.set_tool_option("stop", &json!("livePaintBucket"));
assert_eq!(s.selected_stop(), Some(1), "the bucket's stop stays selected for the pick");
// A Cmd-click while the pick is armed selects the rectangle and leaves the bucket's gradient.
let fill = s.paint.fill.clone();
s.execute("select.set", &json!({"ids": []})).unwrap();
click(&mut s, Mods { cmd: true, ..Mods::default() });
assert_eq!(s.doc().unwrap().selection.objects, vec![rect], "the selection tool took the click");
assert_eq!((s.paint.fill.clone(), s.selected_stop()), (fill, Some(1)), "the bucket's fill and stop stay");
click(&mut s, Mods::default());
let Paint::Gradient(g) = &s.paint.fill else { panic!("the bucket's fill is not a gradient") };
assert_eq!(g.gradient.stops[1].color, Color::from_hex("#00ff00").unwrap(), "the sampled stop");
assert_eq!(node(&s, rect), art, "the selection keeps its paint");
// A Cmd-click selects the rectangle; the bucket keeps its gradient.
s.select_tool("livePaintBucket", v).unwrap();
let fill = s.paint.fill.clone();
s.execute("select.set", &json!({"ids": []})).unwrap();
click(&mut s, Mods { cmd: true, ..Mods::default() });
assert_eq!(s.doc().unwrap().selection.objects, vec![rect], "the selection tool took the click");
assert_eq!(s.paint.fill, fill, "the bucket's fill stays");
// Armed again, a Cmd-click on another object deselects the stop; the next click (a Shift-click,
// which would sample a color) ends the pick and leaves the bucket's gradient.
let other = self::rect(&mut s, 400.0, 400.0, 40.0, 40.0);
s.execute("select.set", &json!({"ids": [rect.0]})).unwrap();
s.execute("gradient.selectStop", &json!({"index": 1})).unwrap();
s.select_tool("eyedropper", v).unwrap();
s.set_tool_option("stop", &json!("livePaintBucket"));
for mods in [Mods { cmd: true, ..Mods::default() }, Mods { shift: true, ..Mods::default() }] {
for kind in [PointerKind::Down, PointerKind::Up] {
s.pointer(&PointerEvent::new(kind, 420.0, 420.0).with_mods(mods), v).unwrap();
}
}
assert_eq!(s.doc().unwrap().selection.objects, vec![other], "the Cmd-click selected the other object");
assert_eq!((s.paint.fill.clone(), s.tool_returns_to()), (fill, None), "the pick ended without a sample");
}
/// A gradient stop selected on the selection's gradient is not selected once the Live Paint
/// Bucket is active (its proxies show the default paint), and one selected on the bucket's
/// gradient is not selected once another tool is chosen.
+5
View File
@@ -1578,6 +1578,10 @@ impl Session {
/// Apply tool actions. Errors from previews are reported but keep the interaction alive.
pub fn apply_actions(&mut self, acts: Vec<Action>) -> Result<Vec<UiRequest>> {
let outer = std::mem::replace(&mut self.in_tool_actions, true);
let outer_bucket = self.back_to_bucket;
// The Eyedropper's sample into a stop of the Live Paint Bucket's gradient, which switches back to the bucket.
self.back_to_bucket |=
self.tool.id() == "eyedropper" && acts.iter().any(|a| matches!(a, Action::SwitchTool(t) if t == crate::cmd::LIVE_PAINT_BUCKET));
// A preview that settling applied (typing kept as its own step before a drag begins) shows
// its warning in the status bar, as the tool's own commit shows its preview's.
let r = if !outer && self.depth == 0 {
@@ -1587,6 +1591,7 @@ impl Session {
self.apply_tool_actions(acts)
};
self.in_tool_actions = outer;
self.back_to_bucket = outer_bucket;
if !outer && self.depth == 0 {
self.trim_histories();
}
+5
View File
@@ -230,6 +230,11 @@ pub trait Tool: Send {
fn wants_text(&self) -> bool {
false
}
/// The tool a gradient stop's one-shot pick switches back to after its click (the Eyedropper
/// armed by the Gradient panel's eyedropper); None when no such pick is armed.
fn returns_to(&self) -> Option<&str> {
None
}
fn text_input(&mut self, _cx: &ToolContext, _s: &str) -> Vec<Action> {
vec![]
}
+36 -1
View File
@@ -16,7 +16,8 @@
//!
//! The Gradient panel's eyedropper sets the `stop` option (the tool to return to): the next click
//! samples the colour under the cursor into the selected gradient stop (`paint.sampleColor
//! {stop}`) and switches back to that tool.
//! {stop}`) and switches back to that tool. Armed for the Live Paint Bucket, a click once its stop
//! is no longer selected ends the pick without sampling and switches back to the bucket.
//!
//! Gradient mesh points picked with the Mesh tool, Direct Selection or the Lasso before switching
//! to the Eyedropper stay picked (its `meshPoints` option), and go back to one of those tools
@@ -536,6 +537,15 @@ impl Tool for EyedropperTool {
self.stop = None;
return vec![Action::Dialog("brushKeyColor".into(), json!({ "color": color_json(&c) })), Action::SwitchTool(back)];
}
// A pick for a stop of the Live Paint Bucket's gradient (the default paint's) ends without
// sampling once that stop is no longer selected (a Cmd-click selected another object) or no
// longer there (another paint was chosen): the click switches back.
let bucket_paint = if cx.fill_active { &cx.paint.fill } else { &cx.paint.stroke };
let bucket_stop = cx.gradient_stop.filter(|i| matches!(bucket_paint, Paint::Gradient(g) if *i < g.gradient.stops.len()));
if self.stop.as_deref() == Some("livePaintBucket") && bucket_stop.is_none() {
self.stop = None;
return vec![Action::SwitchTool("livePaintBucket".into())];
}
let stop = self.stop.as_ref().zip(cx.gradient_stop);
// A plain click on a selected gradient mesh gives the fill color to the point there, else
// to the four points of the patch there.
@@ -660,6 +670,10 @@ impl Tool for EyedropperTool {
vec![]
}
fn returns_to(&self) -> Option<&str> {
self.stop.as_deref().filter(|_| !self.brush_key_color && self.image_trace_ignore_color.is_none())
}
/// Escape is the tool's while a pick is armed, so it switches back and ends nothing else.
fn claims_key(&self, _cx: &ToolContext, key: ToolKey) -> bool {
key == ToolKey::Escape && self.picking()
@@ -838,6 +852,27 @@ mod tests {
]
);
assert_eq!(t.options(), json!({"stop": null, "brushKeyColor": false}), "one sample only");
// Armed for the Live Paint Bucket with its stop no longer selected, a click ends the pick.
cx.gradient_stop = None;
t.set_option("stop", &json!("livePaintBucket"));
let a = t.pointer(&cx, &PointerEvent::new(PointerKind::Down, 100.0, 150.0));
assert_eq!(a, vec![Action::SwitchTool("livePaintBucket".into())]);
assert_eq!(t.returns_to(), None);
// So does a click once the default paint has no such stop (here, a solid fill).
cx.gradient_stop = Some(1);
assert!(!matches!(cx.paint.fill, Paint::Gradient(_)));
t.set_option("stop", &json!("livePaintBucket"));
assert_eq!(t.returns_to(), Some("livePaintBucket"));
let a = t.pointer(&cx, &PointerEvent::new(PointerKind::Down, 100.0, 150.0));
assert_eq!(a, vec![Action::SwitchTool("livePaintBucket".into())]);
// Neither a Key Color pick nor an Image Trace ignored-color pick is a gradient stop's.
t.set_option("brushKeyColor", &json!(true));
t.set_option("stop", &json!("livePaintBucket"));
assert_eq!(t.returns_to(), None);
let mut t = EyedropperTool::default();
t.set_option("imageTraceIgnoreColor", &json!({"dialog": "imageTrace"}));
t.set_option("stop", &json!("livePaintBucket"));
assert_eq!(t.returns_to(), None);
}
/// #8024: Escape ends a gradient stop's pick and a Key Color pick without sampling and
+4
View File
@@ -7909,6 +7909,10 @@ breakText Glyphs Глифи
Filigree Arrow Филигранна стрела
Petal Sweep Венчелистен замах
Twin Curl Двоен завитък
Leaf Vine Листна лоза
Blossom Chain Цветна верига
Pennant Garland Гирлянд от знаменца
Lantern String Низ от фенери
Orbit Lines Орбитални линии
Petal Garland Гирлянд от венчелистчета
Lattice Braid Решетъчна плетка
Can't render this file because it is too large.
+4
View File
@@ -7964,6 +7964,10 @@ shape Open Otvoren
Filigree Arrow Filigranska strelica
Petal Sweep Potez latica
Twin Curl Dvostruki zavoj
Leaf Vine Lisnata loza
Blossom Chain Cvjetni lanac
Pennant Garland Girlanda zastavica
Lantern String Niz lampiona
Orbit Lines Orbitalne linije
Petal Garland Vijenac od latica
Lattice Braid Rešetkasti preplet
Can't render this file because it contains an unexpected character in line 2 and column 73.
+4
View File
@@ -8949,6 +8949,10 @@ breakText Glyphs Glifs
Filigree Arrow Fletxa de filigrana
Petal Sweep Traç de pètals
Twin Curl Voluta doble
Leaf Vine Enfiladissa de fulles
Blossom Chain Cadena de flors
Pennant Garland Garlanda de banderins
Lantern String Filera de fanalets
Orbit Lines Línies orbitals
Petal Garland Garlanda de pètals
Lattice Braid Trena reticular
Can't render this file because it is too large.
+4
View File
@@ -10773,6 +10773,10 @@ breakText Glyphs Glyfy
Filigree Arrow Filigránový šíp
Petal Sweep Tah okvětních lístků
Twin Curl Dvojitá rozvilina
Leaf Vine Listová liána
Blossom Chain Květinový řetěz
Pennant Garland Girlanda praporků
Lantern String Řetěz luceren
Orbit Lines Orbitální čáry
Petal Garland Okvětní girlanda
Lattice Braid Mřížkový cop
Can't render this file because it is too large.
+4
View File
@@ -10835,6 +10835,10 @@ breakText Glyphs Glyffer
Filigree Arrow Filigranpil
Petal Sweep Kronbladssvirp
Twin Curl Dobbelt slyng
Leaf Vine Bladranke
Blossom Chain Blomsterkæde
Pennant Garland Vimpelguirlande
Lantern String Lygtekæde
Orbit Lines Banekurver
Petal Garland Kronbladsguirlande
Lattice Braid Gitterfletning
Can't render this file because it is too large.
+4
View File
@@ -10414,6 +10414,10 @@ breakText Glyphs Glyphen
Filigree Arrow Filigranpfeil
Petal Sweep Blütenblattschwung
Twin Curl Doppelschnörkel
Leaf Vine Blätterranke
Blossom Chain Blütenkette
Pennant Garland Wimpelgirlande
Lantern String Laternenkette
Orbit Lines Orbitlinien
Petal Garland Blütengirlande
Lattice Braid Gittergeflecht
Can't render this file because it is too large.
+4
View File
@@ -8922,6 +8922,10 @@ breakText Glyphs Γλύφοι
Filigree Arrow Φιλιγκράν βέλος
Petal Sweep Καμπύλη πετάλων
Twin Curl Διπλή σπείρα
Leaf Vine Κληματίδα φύλλων
Blossom Chain Αλυσίδα λουλουδιών
Pennant Garland Γιρλάντα σημαιών
Lantern String Σειρά φαναριών
Orbit Lines Τροχιακές γραμμές
Petal Garland Γιρλάντα πετάλων
Lattice Braid Πλεξούδα πλέγματος
Can't render this file because it is too large.
+4
View File
@@ -10666,6 +10666,10 @@ breakText Glyphs Glifos
Filigree Arrow Flecha de filigrana
Petal Sweep Trazo de pétalos
Twin Curl Voluta doble
Leaf Vine Enredadera de hojas
Blossom Chain Cadena de flores
Pennant Garland Guirnalda de banderines
Lantern String Cadena de faroles
Orbit Lines Líneas orbitales
Petal Garland Guirnalda de pétalos
Lattice Braid Trenza reticular
Can't render this file because it is too large.
+4
View File
@@ -9005,6 +9005,10 @@ breakText Glyphs Merkit
Filigree Arrow Filigraanin nuoli
Petal Sweep Terälehtipyyhkäisy
Twin Curl Kaksoiskiemura
Leaf Vine Lehtiköynnös
Blossom Chain Kukkaketju
Pennant Garland Viiririvistö
Lantern String Lyhtyketju
Orbit Lines Kiertoradan viivat
Petal Garland Terälehtiköynnös
Lattice Braid Ristikkopunos
Can't render this file because it is too large.
+4
View File
@@ -10736,6 +10736,10 @@ breakText Glyphs Glyphes
Filigree Arrow Flèche filigrane
Petal Sweep Courbe de pétales
Twin Curl Double volute
Leaf Vine Liane feuillue
Blossom Chain Chaîne de fleurs
Pennant Garland Guirlande de fanions
Lantern String Guirlande de lanternes
Orbit Lines Lignes orbitales
Petal Garland Guirlande de pétales
Lattice Braid Tresse en treillis
Can't render this file because it is too large.
+4
View File
@@ -5656,6 +5656,10 @@ swatch [Registration] [રજિસ્ટ્રેશન]
Filigree Arrow નાજુક કોતરણીવાળું તીર
Petal Sweep પાંખડીઓનો વળાંક
Twin Curl બેવડો વળાંક
Leaf Vine પાંદડાની વેલ
Blossom Chain ફૂલોની સાંકળ
Pennant Garland ધ્વજપટ્ટીની માળા
Lantern String ફાનસની હાર
Orbit Lines ભ્રમણકક્ષાની રેખાઓ
Petal Garland પાંખડીઓની માળા
Lattice Braid જાળી વેણી
Can't render this file because it contains an unexpected character in line 72 and column 5.
+4
View File
@@ -10379,6 +10379,10 @@ theme Appearance अपीयरेंस
Filigree Arrow जालीदार तीर
Petal Sweep पंखुड़ियों का घुमाव
Twin Curl दोहरा घुमाव
Leaf Vine पत्तों की बेल
Blossom Chain फूलों की शृंखला
Pennant Garland झंडियों की माला
Lantern String लालटेन की शृंखला
Orbit Lines कक्षीय रेखाएँ
Petal Garland पंखुड़ी माला
Lattice Braid जाली चोटी
Can't render this file because it is too large.
+4
View File
@@ -10762,6 +10762,10 @@ breakText Glyphs Glifák
Filigree Arrow Filigrán nyíl
Petal Sweep Sziromív
Twin Curl Kettős kacskaringó
Leaf Vine Leveles inda
Blossom Chain Virágfüzér
Pennant Garland Zászlófüzér
Lantern String Lámpásfüzér
Orbit Lines Pályavonalak
Petal Garland Sziromfüzér
Lattice Braid Rácsfonat
Can't render this file because it is too large.
+4
View File
@@ -8607,6 +8607,10 @@ breakText Glyphs Glif
Filigree Arrow Panah Filigran
Petal Sweep Sapuan Kelopak
Twin Curl Sulur Ganda
Leaf Vine Sulur Daun
Blossom Chain Rangkaian Bunga
Pennant Garland Untaian Panji
Lantern String Rangkaian Lentera
Orbit Lines Garis Orbit
Petal Garland Rangkaian Kelopak
Lattice Braid Anyaman Kisi
Can't render this file because it is too large.
+4
View File
@@ -10448,6 +10448,10 @@ breakText Glyphs Glifi
Filigree Arrow Freccia filigranata
Petal Sweep Tratto a petali
Twin Curl Doppia voluta
Leaf Vine Tralcio di foglie
Blossom Chain Catena di fiori
Pennant Garland Ghirlanda di bandierine
Lantern String Fila di lanterne
Orbit Lines Linee orbitali
Petal Garland Ghirlanda di petali
Lattice Braid Intreccio a reticolo
Can't render this file because it is too large.
+4
View File
@@ -10511,6 +10511,10 @@ breakText Glyphs 字形
Filigree Arrow フィリグリーの矢
Petal Sweep 花びらの流線
Twin Curl 二重カール
Leaf Vine 葉のつる
Blossom Chain 花の連なり
Pennant Garland 三角旗のガーランド
Lantern String ランタンの連なり
Orbit Lines 軌道線
Petal Garland 花びらのガーランド
Lattice Braid 格子編み
Can't render this file because it is too large.
+4
View File
@@ -11059,6 +11059,10 @@ font-script Japanese იაპონური
Filigree Arrow ფილიგრანული ისარი
Petal Sweep ფურცლების რკალი
Twin Curl ორმაგი ხვეული
Leaf Vine ფოთლების ვაზი
Blossom Chain ყვავილების ჯაჭვი
Pennant Garland ალმების გირლანდა
Lantern String ფარნების ჯაჭვი
Orbit Lines ორბიტული ხაზები
Petal Garland ფურცლების გირლანდა
Lattice Braid ბადის ნაწნავი
Can't render this file because it is too large.
+4
View File
@@ -10411,6 +10411,10 @@ breakText Glyphs 글리프
Filigree Arrow 세공 화살표
Petal Sweep 꽃잎 곡선
Twin Curl 이중 소용돌이
Leaf Vine 잎 덩굴
Blossom Chain 꽃사슬
Pennant Garland 깃발 장식
Lantern String 등불 줄
Orbit Lines 궤도 선
Petal Garland 꽃잎 화환
Lattice Braid 격자 땋기
Can't render this file because it is too large.
+4
View File
@@ -10812,6 +10812,10 @@ breakText Glyphs Glyphs
Filigree Arrow Filigraanpijl
Petal Sweep Bloemblaadjeszwaai
Twin Curl Dubbele krul
Leaf Vine Bladrank
Blossom Chain Bloemenketting
Pennant Garland Vlaggetjesslinger
Lantern String Lantaarnslinger
Orbit Lines Baanlijnen
Petal Garland Bloemblaadjesslinger
Lattice Braid Rastervlecht
Can't render this file because it is too large.
+4
View File
@@ -10637,6 +10637,10 @@ breakText Glyphs Glify
Filigree Arrow Filigranowa strzałka
Petal Sweep Smuga płatków
Twin Curl Podwójny zawijas
Leaf Vine Liściasta winorośl
Blossom Chain Łańcuch kwiatów
Pennant Garland Girlanda proporczyków
Lantern String Łańcuch lampionów
Orbit Lines Linie orbitalne
Petal Garland Girlanda płatków
Lattice Braid Plecionka kratowa
Can't render this file because it is too large.
+4
View File
@@ -10845,6 +10845,10 @@ swatch Yellow Green Verde-amarelado
Filigree Arrow Seta filigranada
Petal Sweep Traço de pétalas
Twin Curl Voluta dupla
Leaf Vine Trepadeira de folhas
Blossom Chain Corrente de flores
Pennant Garland Guirlanda de bandeirolas
Lantern String Cordão de lanternas
Orbit Lines Linhas orbitais
Petal Garland Guirlanda de pétalas
Lattice Braid Trança em grade
Can't render this file because it is too large.
+4
View File
@@ -10829,6 +10829,10 @@ shape Open Открытый
Filigree Arrow Филигранная стрела
Petal Sweep Лепестковый росчерк
Twin Curl Двойной завиток
Leaf Vine Лиственная лоза
Blossom Chain Цветочная цепочка
Pennant Garland Гирлянда флажков
Lantern String Цепочка фонариков
Orbit Lines Орбитальные линии
Petal Garland Гирлянда лепестков
Lattice Braid Решётчатое плетение
Can't render this file because it is too large.
+4
View File
@@ -10866,6 +10866,10 @@ digits Hindi Hindi
Filigree Arrow Filigranpil
Petal Sweep Kronbladssvep
Twin Curl Dubbel snirkel
Leaf Vine Bladranka
Blossom Chain Blomkedja
Pennant Garland Vimpelgirlang
Lantern String Lyktgirlang
Orbit Lines Banlinjer
Petal Garland Kronbladsgirlang
Lattice Braid Gallerfläta
Can't render this file because it is too large.
+4
View File
@@ -10731,6 +10731,10 @@ breakText Glyphs Glifler
Filigree Arrow Telkari ok
Petal Sweep Yaprakçık kıvrımı
Twin Curl Çift kıvrım
Leaf Vine Yapraklı sarmaşık
Blossom Chain Çiçek zinciri
Pennant Garland Bayrak süsü
Lantern String Fener dizisi
Orbit Lines Yörünge Çizgileri
Petal Garland Taç Yaprağı Çelengi
Lattice Braid Kafes Örgü
Can't render this file because it is too large.
+4
View File
@@ -10424,6 +10424,10 @@ breakText Glyphs Гліфи
Filigree Arrow Філігранна стріла
Petal Sweep Пелюстковий розчерк
Twin Curl Подвійний завиток
Leaf Vine Листяна лоза
Blossom Chain Квітковий ланцюжок
Pennant Garland Гірлянда прапорців
Lantern String Ланцюжок ліхтариків
Orbit Lines Орбітальні лінії
Petal Garland Гірлянда пелюсток
Lattice Braid Ґратчасте плетіння
Can't render this file because it is too large.
+4
View File
@@ -8621,6 +8621,10 @@ breakText Glyphs Glyph
Filigree Arrow Mũi tên hoa văn
Petal Sweep Nét cánh hoa
Twin Curl Nét cuộn đôi
Leaf Vine Dây leo lá
Blossom Chain Chuỗi hoa
Pennant Garland Dây cờ tam giác
Lantern String Dây đèn lồng
Orbit Lines Đường quỹ đạo
Petal Garland Vòng hoa cánh
Lattice Braid Bện lưới
Can't render this file because it is too large.
+4
View File
@@ -10616,6 +10616,10 @@ breakText Glyphs 字形
Filigree Arrow 花丝箭头
Petal Sweep 花瓣曲线
Twin Curl 双重卷饰
Leaf Vine 叶藤
Blossom Chain 花链
Pennant Garland 旗帜花环
Lantern String 灯笼串
Orbit Lines 轨道线
Petal Garland 花瓣花环
Lattice Braid 格纹编织
Can't render this file because it is too large.
+4
View File
@@ -10431,6 +10431,10 @@ breakText Glyphs 字符
Filigree Arrow 花絲箭頭
Petal Sweep 花瓣曲線
Twin Curl 雙重卷飾
Leaf Vine 葉藤
Blossom Chain 花鏈
Pennant Garland 旗幟花環
Lantern String 燈籠串
Orbit Lines 軌道線
Petal Garland 花瓣花環
Lattice Braid 格紋編織
Can't render this file because it is too large.
+374 -17
View File
@@ -319,8 +319,8 @@ pub(crate) struct Entry {
names_item: bool,
}
/// The last query, the recent picks it was ranked with, and its ranked results.
type Ranked = (String, Vec<u32>, Arc<[u32]>);
/// The last query, the recent picks and the pick counts it was ranked with, and its ranked results.
type Ranked = (String, Vec<u32>, CommandUses, Arc<[u32]>);
/// The palette's entries, the index a query is looked up in, and the last query's ranked results.
pub(crate) struct Catalog {
@@ -522,19 +522,24 @@ pub(crate) enum Picked {
Refused,
}
/// The entries the query `q` matches, best first ([`search::rank`]), with the picks that Recent
/// Commands lists for the ids `recent_ids` ([`recent`]) first among the entries that match as well.
/// The ranking of the last query is kept, so a frame that draws the same query with the same recent
/// picks does not rank again. [`show`] lists the first [`MAX_RESULTS`] and counts the rest.
fn matching<'a>(catalog: &'a Catalog, q: &str, recent_ids: &[String]) -> Vec<&'a Entry> {
/// The entries the query `q` matches, best first ([`search::rank`]), with the commands picked most
/// often (`uses`) first among the entries that match as well, and then the picks that Recent
/// Commands lists for the ids `recent_ids` ([`recent`]). The ranking of the last query is kept, so
/// a frame that draws the same query with the same counts and recent picks does not rank again.
/// [`show`] lists the first [`MAX_RESULTS`] and counts the rest.
fn matching<'a>(catalog: &'a Catalog, q: &str, recent_ids: &[String], uses: &CommandUses) -> Vec<&'a Entry> {
let q = search::normalize(q);
let picks: Vec<u32> = recent_places(&catalog.list, recent_ids).into_iter().filter_map(|i| u32::try_from(i).ok()).collect();
let kept = catalog.ranked.lock().ok().and_then(|last| last.as_ref().filter(|(k, p, _)| *k == q && *p == picks).map(|(_, _, r)| r.clone()));
let kept = catalog
.ranked
.lock()
.ok()
.and_then(|last| last.as_ref().filter(|(k, p, c, _)| *k == q && *p == picks && c == uses).map(|(_, _, _, r)| r.clone()));
let ranked = kept.unwrap_or_else(|| {
let ranked: Arc<[u32]> = search::rank(&catalog.list, &catalog.index, &q, &picks).into();
let ranked: Arc<[u32]> = search::rank(&catalog.list, &catalog.index, &q, &picks, &uses.grades(&catalog.list)).into();
// A poisoned lock only loses the kept ranking: the next frame ranks again.
if let Ok(mut last) = catalog.ranked.lock() {
*last = Some((q, picks, ranked.clone()));
*last = Some((q, picks, uses.clone(), ranked.clone()));
}
ranked
});
@@ -1065,6 +1070,127 @@ fn recent_places(entries: &[Entry], ids: &[String]) -> Vec<usize> {
.collect()
}
/// How many command ids [`CommandUses`] counts at most.
const MAX_COUNTED_COMMANDS: usize = 200;
/// The count at which [`CommandUses::count`] halves every count.
const HALVING_COUNT: u32 = 1_000;
/// How many times each command was picked in the palette: commands picked often rank first among
/// the results that match a query as well ([`matching`]). It counts at most
/// [`MAX_COUNTED_COMMANDS`] ids. When a count reaches [`HALVING_COUNT`], every count is halved, so
/// a count is at most 999.
#[derive(Clone, Debug, Default, PartialEq, Eq, serde::Serialize)]
pub struct CommandUses {
/// The number of the last pick; each pick takes the next one.
pick: u32,
/// For each command id, its count and the number of its last pick.
uses: std::collections::BTreeMap<String, (u32, u32)>,
}
impl CommandUses {
/// Counts a pick of `id`. A new id when [`MAX_COUNTED_COMMANDS`] are counted first removes
/// one id from the half of the ids picked longest ago: the one with the lowest count, of those
/// the one picked longest ago. It then counts once. When the pick number is at its limit, the
/// counted ids' pick numbers are first renumbered from 1 in their order ([`renumbered`]), so
/// the pick still takes a number above all of them.
pub(crate) fn count(&mut self, id: &str) {
if self.pick == u32::MAX {
let lasts: Vec<u64> = self.uses.values().map(|&(_, last)| u64::from(last)).collect();
for ((_, last), number) in self.uses.values_mut().zip(renumbered(&lasts)) {
*last = number;
}
self.pick = self.uses.values().map(|&(_, last)| last).max().unwrap_or(0);
}
self.pick = self.pick.saturating_add(1);
let pick = self.pick;
if let Some((n, last)) = self.uses.get_mut(id) {
*n = n.saturating_add(1);
*last = pick;
} else {
if self.uses.len() >= MAX_COUNTED_COMMANDS {
let mut by_age: Vec<(u32, u32, &String)> = self.uses.iter().map(|(k, &(n, last))| (last, n, k)).collect();
by_age.sort_unstable();
let older = by_age.len().div_ceil(2);
if let Some(least) = by_age.iter().take(older).min_by_key(|&&(last, n, _)| (n, last)).map(|&(_, _, k)| k.clone()) {
self.uses.remove(&least);
}
}
self.uses.insert(id.to_string(), (1, pick));
}
if self.uses.get(id).is_some_and(|&(n, _)| n >= HALVING_COUNT) {
for (n, _) in self.uses.values_mut() {
*n /= 2;
}
self.uses.retain(|_, (n, _)| *n > 0);
}
}
/// The count of `id`'s picks as a grade from 0 (never picked) to 9: the base-2 logarithm of
/// the count plus one, so 1 pick gives 1, 3 give 2, 7 give 3, and so on.
fn grade(&self, id: &str) -> u8 {
self.uses.get(id).map_or(0, |&(n, _)| u8::try_from(n.min(HALVING_COUNT - 1).saturating_add(1).ilog2()).unwrap_or(u8::MAX))
}
/// The grade ([`CommandUses::grade`]) of each of `entries`, in their order, or none when no
/// command was picked.
fn grades(&self, entries: &[Entry]) -> Vec<u8> {
if self.uses.is_empty() {
return vec![];
}
entries.iter().map(|e| self.grade(&e.id)).collect()
}
}
/// The pick numbers `lasts` renumbered from 1 in their order, in the order of `lasts`: equal
/// numbers stay equal, and the lowest becomes 1.
fn renumbered(lasts: &[u64]) -> Vec<u32> {
let mut distinct = lasts.to_vec();
distinct.sort_unstable();
distinct.dedup();
lasts.iter().map(|last| u32::try_from(distinct.partition_point(|d| d < last) + 1).unwrap_or(u32::MAX)).collect()
}
/// Serde reader for the saved pick counts ([`crate::UiState::command_uses`]): an entry that is not
/// a pair of counts is dropped, a count above 999 reads as 999, and of more than
/// [`MAX_COUNTED_COMMANDS`] ids the ones picked most recently are kept. When a kept pick number or
/// the last pick number is above the largest the counts hold, the kept pick numbers are
/// renumbered from 1 in their order ([`renumbered`]). Anything else reads as no picks, so an
/// unknown value doesn't lose the rest of the preferences.
pub fn deserialize_command_uses<'de, D: serde::Deserializer<'de>>(d: D) -> Result<CommandUses, D::Error> {
use std::cmp::Reverse;
let v = <serde_json::Value as serde::Deserialize>::deserialize(d)?;
let number = |v: Option<&serde_json::Value>| v.and_then(serde_json::Value::as_u64);
// The heap holds at most MAX_COUNTED_COMMANDS + 1 entries, the least recent pick on top (of
// equal picks, the id that sorts last), so a long saved list is not collected whole. Pick
// numbers are compared as saved, before any is renumbered.
let mut kept: std::collections::BinaryHeap<Reverse<(u64, Reverse<&String>, u32)>> = std::collections::BinaryHeap::new();
for (id, u) in v.get("uses").and_then(serde_json::Value::as_object).into_iter().flatten() {
let (Some(n), Some(last)) = (number(u.get(0)), number(u.get(1))) else { continue };
if n == 0 || !u.as_array().is_some_and(|a| a.len() == 2) {
continue;
}
let n = u32::try_from(n.min(u64::from(HALVING_COUNT - 1))).unwrap_or(HALVING_COUNT - 1);
kept.push(Reverse((last, Reverse(id), n)));
if kept.len() > MAX_COUNTED_COMMANDS {
kept.pop();
}
}
let kept: Vec<(&String, u32, u64)> = kept.into_iter().map(|Reverse((last, Reverse(id), n))| (id, n, last)).collect();
// The pick number stays above every saved last pick, so the next pick is the most recent.
let newest = kept.iter().map(|&(_, _, last)| last).max().unwrap_or(0);
let pick = number(v.get("pick")).unwrap_or(0).max(newest);
if let Ok(pick) = u32::try_from(pick) {
let uses = kept.into_iter().map(|(id, n, last)| (id.clone(), (n, u32::try_from(last).unwrap_or(pick)))).collect();
return Ok(CommandUses { pick, uses });
}
let lasts: Vec<u64> = kept.iter().map(|&(_, _, last)| last).collect();
let uses: std::collections::BTreeMap<String, (u32, u32)> =
kept.into_iter().zip(renumbered(&lasts)).map(|((id, n, _), last)| (id.clone(), (n, last))).collect();
let pick = uses.values().map(|&(_, last)| last).max().unwrap_or(0);
Ok(CommandUses { pick, uses })
}
/// The id of the Recent Commands list's popup.
fn recent_list_id() -> egui::Id {
egui::Id::unique("palette-recent-commands")
@@ -1129,7 +1255,7 @@ pub fn show(app: &mut VectorcraftApp, ctx: &egui::Context) {
let recent = recent(&entries.list, &app.ui.recent_commands);
// An empty search lists the recent picks, most recent first, so Enter runs the last pick again.
let empty = app.ui.palette_query.trim().is_empty();
let mut matches = if empty { recent.clone() } else { matching(&entries, &q, &app.ui.recent_commands) };
let mut matches = if empty { recent.clone() } else { matching(&entries, &q, &app.ui.recent_commands, &app.ui.command_uses) };
let total = matches.len();
// The highlighted result (#1757): Up and Down move it (wrapping), Page Up and Page Down move it
// by a page, the pointer over a result takes it, and a new query starts again from the first.
@@ -1461,15 +1587,18 @@ pub fn show(app: &mut VectorcraftApp, ctx: &egui::Context) {
app.ui.palette_open = false;
// A pick goes first in Recent Commands before it runs, and stays there when it ran or
// opened a dialog, even when the dialog is then canceled. A refused pick puts the list
// back as it was.
// back as it was. Only a pick that stays in the list is counted.
let before = (id != PALETTE_TOGGLE).then(|| app.ui.recent_commands.clone());
if before.is_some() {
remember(&mut app.ui.recent_commands, &id, |c| entries.list.iter().any(|e| e.id == c));
}
if run_pick(app, &id) == Picked::Refused
&& let Some(before) = before
{
app.ui.recent_commands = before;
let picked = run_pick(app, &id);
if let Some(before) = before {
if picked == Picked::Refused {
app.ui.recent_commands = before;
} else {
app.ui.command_uses.count(&id);
}
}
} else if outside {
app.ui.palette_open = false;
@@ -1486,6 +1615,11 @@ mod tests {
use super::*;
use crate::i18n::Lang;
/// The entries `q` matches, best first, with the recent picks `recent_ids` and no pick counts.
fn matching<'a>(catalog: &'a Catalog, q: &str, recent_ids: &[String]) -> Vec<&'a Entry> {
super::matching(catalog, q, recent_ids, &CommandUses::default())
}
#[test]
fn entries_are_built_once_per_language_and_match_english_shown_text_and_ids() {
let ctx = egui::Context::default();
@@ -2104,6 +2238,229 @@ mod tests {
assert_eq!(ids(&["plugin:test.UI.palette_removed".to_string(), effect.clone()]).first(), Some(&effect));
}
/// Pick counts for the ids `counts`, picked in that order.
fn counted(counts: &[(&str, u32)]) -> CommandUses {
let uses = counts.iter().zip(1..).map(|(&(id, n), last)| (id.to_string(), (n, last))).collect();
CommandUses { pick: u32::try_from(counts.len()).unwrap(), uses }
}
/// A command picked often ranks first among the results that match the query as well as it
/// does, also when it is no longer a recent pick, and the count is saved with the other
/// interface settings.
#[test]
fn a_command_picked_often_ranks_first_among_results_that_match_as_well() {
let (tool, effect) = ("tool:rectangle", "effect:convertToShape.rectangle");
let mut open = Open::new("rect", egui::vec2(1200.0, 900.0));
// The fixture has art selected, so the effect is not dimmed and its pick is counted.
open.app = VectorcraftApp::new(vectorcraft_testkit::fixtures::Fixture::Multi.session(), crate::Services::default());
open.app.ui.palette_open = true;
open.app.ui.palette_query = "rect".into();
open.frame(vec![]);
let before = open.listed();
assert_eq!(before.first().map(String::as_str), Some(tool));
let at = before.iter().position(|id| id == effect).unwrap();
open.press(egui::Key::ArrowDown, at);
open.press(egui::Key::Enter, 1);
assert_eq!(open.app.ui.command_uses.grade(effect), 1);
assert_eq!(open.app.ui.command_uses.grade(tool), 0);
open.app.ui.recent_commands.clear();
open.app.ui.dialog = None;
open.app.ui.palette_open = true;
open.app.ui.palette_query = "rect".into();
open.frame(vec![]);
let after = open.listed();
assert_eq!(after.first().map(String::as_str), Some(effect));
assert_eq!(after.get(1).map(String::as_str), Some(tool), "only the pick moves");
let restored: crate::state::UiState = serde_json::from_str(&serde_json::to_string(&open.app.ui).unwrap()).unwrap();
assert_eq!(restored.command_uses, open.app.ui.command_uses);
}
/// The kept ranking of a query is ranked again when a pick count changes.
#[test]
fn the_kept_ranking_follows_the_pick_counts() {
let ctx = egui::Context::default();
let entries = entries(&ctx, Lang::EN);
let first = |uses: &CommandUses| super::matching(&entries, "rect", &[], uses).first().map(|e| e.id.clone());
let effect = "effect:convertToShape.rectangle";
assert_eq!(first(&CommandUses::default()).as_deref(), Some("tool:rectangle"));
let mut uses = counted(&[("tool:rectangle", 1)]);
assert_eq!(first(&uses).as_deref(), Some("tool:rectangle"));
uses.count(effect);
assert_eq!(first(&uses).as_deref(), Some("tool:rectangle"), "the same grade: the catalog order");
uses.count(effect);
uses.count(effect);
assert_eq!(first(&uses).as_deref(), Some(effect), "three picks reach grade 2");
assert_eq!(first(&CommandUses::default()).as_deref(), Some("tool:rectangle"));
}
/// A count does not lift a result above one that matches the query better: the exact id
/// `view.goto1` lists Saved View 1 before Saved View 10, however often that was picked.
#[test]
fn a_count_does_not_pass_a_better_match() {
let ctx = egui::Context::default();
let entries = entries(&ctx, Lang::EN);
let uses = counted(&[("view.goto10", 999)]);
let ids: Vec<&str> = super::matching(&entries, "view.goto1", &[], &uses).into_iter().map(|e| e.id.as_str()).collect();
assert_eq!(ids.first(), Some(&"view.goto1"), "{ids:?}");
assert!(ids.contains(&"view.goto10"), "{ids:?}");
}
/// Counts grow in grades that double: 1 pick gives grade 1, 3 give 2, 7 give 3, and 999 give 9.
#[test]
fn pick_counts_rank_in_grades_that_double() {
let mut uses = CommandUses::default();
let grades: Vec<u8> = (0..8)
.map(|_| {
let g = uses.grade("a");
uses.count("a");
g
})
.collect();
assert_eq!(grades, [0, 1, 1, 2, 2, 2, 2, 3]);
assert_eq!(counted(&[("a", 999)]).grade("a"), 9);
assert_eq!(counted(&[("a", u32::MAX)]).grade("a"), 9);
assert!(CommandUses::default().grades(&[]).is_empty(), "no grades without counts");
}
/// A new id when 200 are counted removes, of the 100 ids picked longest ago, the id with the
/// lowest count, of those the one picked longest ago, and keeps the new one.
#[test]
fn the_201st_command_removes_the_least_used_and_keeps_itself() {
let ids: Vec<String> = (0..MAX_COUNTED_COMMANDS).map(|i| format!("c{i}")).collect();
let counts: Vec<(&str, u32)> = ids.iter().enumerate().map(|(i, id)| (id.as_str(), if i == 5 || i == 9 { 1 } else { 2 })).collect();
let mut uses = counted(&counts);
uses.count("new");
assert_eq!(uses.uses.len(), MAX_COUNTED_COMMANDS);
assert!(!uses.uses.contains_key("c5") && uses.uses.contains_key("c9"));
assert_eq!(uses.uses.get("new"), Some(&(1, 201)));
uses.count("newer");
assert!(!uses.uses.contains_key("c9"), "c9 was picked before new");
assert!(uses.uses.contains_key("new") && uses.uses.contains_key("newer"));
assert_eq!(uses.uses.len(), MAX_COUNTED_COMMANDS);
}
/// When all 200 counted ids have 2 picks or more, new ids picked in turn keep their places and
/// their counts grow; the ids removed are the ones picked longest ago.
#[test]
fn new_commands_build_up_counts_when_every_counted_one_has_more_picks() {
let ids: Vec<String> = (0..MAX_COUNTED_COMMANDS).map(|i| format!("c{i}")).collect();
let counts: Vec<(&str, u32)> = ids.iter().map(|id| (id.as_str(), 2)).collect();
let mut uses = counted(&counts);
for _ in 0..3 {
for id in ["a", "b", "c"] {
uses.count(id);
}
}
assert_eq!(uses.uses.len(), MAX_COUNTED_COMMANDS);
for id in ["a", "b", "c"] {
assert_eq!(uses.uses.get(id).map(|&(n, _)| n), Some(3), "{id}");
}
assert!(!uses.uses.contains_key("c0") && !uses.uses.contains_key("c2") && uses.uses.contains_key("c3"));
assert!(uses.uses.contains_key("c199"));
}
/// When a count reaches 1,000, every count is halved and ids left at 0 are removed.
#[test]
fn counts_are_halved_at_one_thousand() {
let mut uses = counted(&[("a", 999), ("b", 1), ("c", 5)]);
uses.count("a");
assert_eq!(uses.uses.get("a"), Some(&(500, 4)));
assert_eq!(uses.uses.get("c"), Some(&(2, 3)));
assert!(!uses.uses.contains_key("b"));
}
/// At the pick number's limit, the counted ids' pick numbers are renumbered from 1 in their
/// order, so a pick still takes a number above all of them and a command picked again leaves
/// the half of the ids picked longest ago.
#[test]
fn picks_keep_their_order_at_the_pick_number_limit() {
let ids: Vec<String> = (0..MAX_COUNTED_COMMANDS).map(|i| format!("c{i:03}")).collect();
let mut uses = CommandUses { pick: u32::MAX, uses: ids.iter().map(|id| (id.clone(), (2, u32::MAX))).collect() };
uses.uses.insert("c000".into(), (1, u32::MAX));
uses.count("c000");
assert_eq!(uses.uses.get("c000"), Some(&(2, 2)));
assert_eq!(uses.uses.get("c001"), Some(&(2, 1)));
uses.count("new");
assert!(uses.uses.contains_key("c000"), "c000 was picked last: {:?}", uses.uses.get("c000"));
assert!(!uses.uses.contains_key("c001"));
assert_eq!(uses.uses.get("new"), Some(&(1, 3)));
// Equal pick numbers stay equal, and the order of the others is kept.
let mut uses =
CommandUses { pick: u32::MAX, uses: [("a", (1, 7)), ("b", (1, u32::MAX)), ("c", (1, 7))].map(|(k, v)| (k.to_string(), v)).into() };
uses.count("d");
assert_eq!(
uses,
CommandUses { pick: 3, uses: [("a", (1, 1)), ("b", (1, 2)), ("c", (1, 1)), ("d", (1, 3))].map(|(k, v)| (k.to_string(), v)).into() }
);
}
/// Saved counts load what is readable: a count above 999 reads as 999, entries that are not a
/// pair of counts are dropped, of more than 200 ids the most recent picks are kept, and a value
/// of the wrong kind, or none (an older settings file), reads as no picks.
#[test]
fn saved_pick_counts_load_what_is_readable() {
let load = |v: serde_json::Value| serde_json::from_value::<crate::state::UiState>(json!({ "command_uses": v })).unwrap().command_uses;
let uses = load(json!({
"pick": 3,
"uses": {"a": [5000, 2], "b": "x", "c": [1], "d": [0, 1], "e": [2, 3, 4], "f": [-1, 2], "g": [4, 1], "h": [1.5, 1], "i": [3, 9]}
}));
assert_eq!(uses, CommandUses { pick: 9, uses: [("a", (999, 2)), ("g", (4, 1)), ("i", (3, 9))].map(|(k, v)| (k.to_string(), v)).into() });
for wrong in [json!("x"), json!(null), json!([1, 2]), json!({"uses": [1]}), json!({"pick": "x", "uses": {}})] {
assert_eq!(load(wrong.clone()), CommandUses::default(), "{wrong}");
}
let older: crate::state::UiState = serde_json::from_value(json!({})).unwrap();
assert_eq!(older.command_uses, CommandUses::default());
let many: serde_json::Map<String, serde_json::Value> = (1..=250).map(|i| (format!("c{i}"), json!([1, i]))).collect();
let uses = load(json!({ "pick": 250, "uses": many }));
assert_eq!(uses.uses.len(), MAX_COUNTED_COMMANDS);
assert!(uses.uses.contains_key("c51") && !uses.uses.contains_key("c50"));
// The next pick is the most recent, also when the saved pick number is behind.
let mut uses = load(json!({ "pick": 1, "uses": {"a": [1, 9]} }));
uses.count("b");
assert_eq!(uses.uses.get("b"), Some(&(1, 10)));
// Saved pick numbers above the largest the counts hold are compared as saved, and the kept
// ones are renumbered from 1 in their order.
let big = u64::from(u32::MAX) + 1;
let mut many: serde_json::Map<String, serde_json::Value> = (0..MAX_COUNTED_COMMANDS).map(|i| (format!("c{i:03}"), json!([1, big]))).collect();
many.insert("z".into(), json!([1, big + 1]));
let uses = load(json!({ "pick": big + 1, "uses": many }));
assert_eq!(uses.uses.len(), MAX_COUNTED_COMMANDS);
assert_eq!(uses.uses.get("z"), Some(&(1, 2)), "the newest pick is kept");
assert_eq!(uses.uses.get("c000"), Some(&(1, 1)));
assert_eq!(uses.pick, 2);
let uses = load(json!({ "pick": big, "uses": {"a": [1, 5], "b": [1, 3]} }));
assert_eq!(uses, CommandUses { pick: 2, uses: [("a", (1, 2)), ("b", (1, 1))].map(|(k, v)| (k.to_string(), v)).into() });
}
/// A pick is counted only when Recent Commands records it: a refused pick and a pick of the
/// palette's own toggle are not counted, and a pick that opens a dialog is.
#[test]
fn only_a_pick_recorded_in_recent_commands_is_counted() {
for (query, id) in [("find and replace", "edit.findReplace"), ("search commands", PALETTE_TOGGLE)] {
let mut open = Open::new(query, WINDOW);
let k = open.listed().iter().position(|c| c == id).unwrap_or_else(|| panic!("{query:?} finds {id}"));
open.frame(vec![]);
open.press(egui::Key::ArrowDown, k);
assert_eq!(open.highlighted(), k, "{id}");
open.press(egui::Key::Enter, 1);
assert!(open.app.ui.recent_commands.is_empty(), "{id}");
assert_eq!(open.app.ui.command_uses, CommandUses::default(), "{id}");
}
let id = "object.path.cleanUp";
let mut open = Open::new("clean up", WINDOW);
open.app = VectorcraftApp::new(vectorcraft_testkit::fixtures::Fixture::Single.session(), crate::Services::default());
open.app.ui.palette_open = true;
open.app.ui.palette_query = "clean up".into();
let k = open.listed().iter().position(|c| c == id).expect("the search finds Clean Up…");
open.frame(vec![]);
open.press(egui::Key::ArrowDown, k);
open.press(egui::Key::Enter, 1);
assert!(open.app.ui.dialog.is_some());
assert_eq!(open.app.ui.recent_commands, [id]);
assert_eq!(open.app.ui.command_uses.grade(id), 1);
}
/// #6376: with nothing picked yet, Recent Commands shows a dimmed No recent commands row.
#[test]
fn recent_commands_without_picks_show_a_dimmed_row() {
@@ -2904,7 +3261,7 @@ mod tests {
let listed = if self.app.ui.palette_query.trim().is_empty() {
recent(&entries.list, &self.app.ui.recent_commands)
} else {
matching(&entries, &self.app.ui.palette_query.to_lowercase(), &self.app.ui.recent_commands)
super::matching(&entries, &self.app.ui.palette_query.to_lowercase(), &self.app.ui.recent_commands, &self.app.ui.command_uses)
};
listed.iter().take(MAX_RESULTS).map(|e| e.id.clone()).collect()
}
+62 -21
View File
@@ -682,9 +682,9 @@ fn phrase(e: &Entry, query: &str, initials: bool) -> u8 {
/// What results are ordered by, compared field by field: whether a word matched only through a
/// description, whether a word matched only through a typo, how the whole query matches, the worst
/// grade a word gets, the sum of the grades, how the whole query matches when read with the words
/// of the same meaning it matched through, the result's place among the recent picks, the kind of
/// result and the label's length.
type RankKey = (bool, bool, u8, u8, u32, u8, usize, u8, usize);
/// of the same meaning it matched through, how often the result was picked (higher first), the
/// result's place among the recent picks, the kind of result and the label's length.
type RankKey = (bool, bool, u8, u8, u32, u8, std::cmp::Reverse<u8>, usize, u8, usize);
/// The results of `entries` that the lowercased `query` matches, best first, as places in
/// `entries`. A result matches when every word of the query is text in one of its names or ids
@@ -705,12 +705,14 @@ type RankKey = (bool, bool, u8, u8, u32, u8, usize, u8, usize);
/// worst grade a word gets, the sum of the grades, how the whole query matches when read with each
/// word matched through a word of the same meaning replaced by that word ("colour" as "color"; of
/// several such words the result holds, the ones that match the whole query best),
/// then by the result's place in `recent`, the places in `entries` of the recent picks, most
/// recent first (a result not in it comes after every result in it), then the kind of result
/// ([`kind`]), the label's length and the catalog order. So a recent pick ranks above the results
/// that match the query as well as it does and below every result that matches it better. An
/// empty query lists every result in catalog order.
pub(crate) fn rank(entries: &[Entry], index: &Index, query: &str, recent: &[u32]) -> Vec<u32> {
/// then by the grade in `uses` of how often the result was picked, highest first (`uses` holds one
/// grade per entry of `entries`, in their order; a missing grade is 0), then by the result's place
/// in `recent`, the places in `entries` of the recent picks, most recent first (a result not in it
/// comes after every result in it), then the kind of result ([`kind`]), the label's length and the
/// catalog order. So a result picked often, or recently, ranks above the results that match the
/// query as well as it does and below every result that matches it better. An empty query lists
/// every result in catalog order.
pub(crate) fn rank(entries: &[Entry], index: &Index, query: &str, recent: &[u32], uses: &[u8]) -> Vec<u32> {
let query = normalize(query);
if query.is_empty() {
return (0..entries.len()).filter_map(|i| u32::try_from(i).ok()).collect();
@@ -858,7 +860,8 @@ pub(crate) fn rank(entries: &[Entry], index: &Index, query: &str, recent: &[u32]
let meant_tier = if synonym { best_reading(&query, &starts, &tokens, &meant, |read| phrase(e, read, false)) } else { tier };
let length = split_name(&e.shown).0.chars().count();
let picked = recent.iter().position(|&r| r == place).unwrap_or(recent.len());
ranked.push(((described, typo, tier, worst, sum, meant_tier, picked, e.kind, length), place));
let used = std::cmp::Reverse(uses.get(i).copied().unwrap_or(0));
ranked.push(((described, typo, tier, worst, sum, meant_tier, used, picked, e.kind, length), place));
}
ranked.sort_by_key(|&(key, place)| (key, place));
ranked.into_iter().map(|(_, place)| place).collect()
@@ -966,8 +969,15 @@ mod tests {
/// The ids of the results `query` lists, best first, with the results of ids `picked` as the
/// recent picks, most recent first.
fn recently(c: &Catalog, query: &str, picked: &[&str]) -> Vec<String> {
used(c, query, picked, &[])
}
/// The ids of the results `query` lists, best first, with the results of ids `picked` as the
/// recent picks, most recent first, and the results of ids `counted` given those use grades.
fn used(c: &Catalog, query: &str, picked: &[&str], counted: &[(&str, u8)]) -> Vec<String> {
let recent: Vec<u32> = picked.iter().filter_map(|id| c.list.iter().position(|e| e.id == *id)).filter_map(|i| u32::try_from(i).ok()).collect();
rank(&c.list, &c.index, query, &recent).iter().filter_map(|&i| c.list.get(i as usize)).map(|e| e.id.clone()).collect()
let uses: Vec<u8> = c.list.iter().map(|e| counted.iter().find(|(id, _)| e.id == *id).map_or(0, |&(_, g)| g)).collect();
rank(&c.list, &c.index, query, &recent, &uses).iter().filter_map(|&i| c.list.get(i as usize)).map(|e| e.id.clone()).collect()
}
/// A result named `name` (`›`-separated, its last part the label) with id `id`.
@@ -1095,13 +1105,11 @@ mod tests {
assert_eq!(ranked(&c, "same zz"), ranked(&c, "same zz"));
}
/// For each pair of adjacent grades and whole-query tiers, a recent pick ranks above a result
/// that matches the query as well as it does and comes earlier in the catalog, and below the
/// result that matches better; of two such recent picks, the more recent ranks first.
#[test]
fn a_recent_pick_ranks_first_within_its_grades() {
/// For each pair of adjacent grades and whole-query tiers: a query, a result that matches it
/// better, one that matches it as the next grade or tier, and the description of the latter.
fn adjacent_grades() -> [(&'static str, Entry, Entry, &'static str); 14] {
let description = "{} keeps the art central on the page";
for (query, better, worse, said) in [
[
("cut zz", entry("Zz Cut", "a.one"), entry("Zz Cutter", "b.two"), ""),
("scale zz", entry("Zz Scale", "a.one"), entry("Zz Scaling", "b.two"), ""),
("scale zz", entry("Zz Scaling", "a.one"), entry("Zz Scalers", "scale.two"), ""),
@@ -1120,7 +1128,15 @@ mod tests {
("remove", entry("Zz Remove", "a.one"), entry("Zz Delete", "b.two"), ""),
// Matches through a word of the same meaning: the whole label, then a word of it.
("colour", entry("Color", "a.one"), entry("Zz Color", "b.two"), ""),
] {
]
}
/// For each pair of adjacent grades and whole-query tiers, a recent pick ranks above a result
/// that matches the query as well as it does and comes earlier in the catalog, and below the
/// result that matches better; of two such recent picks, the more recent ranks first.
#[test]
fn a_recent_pick_ranks_first_within_its_grades() {
for (query, better, worse, said) in adjacent_grades() {
let (b, w) = (better.id.clone(), worse.id.clone());
// A second result that matches as the worse one does and comes before it.
let twin = entry(&worse.shown, &format!("{w}x"));
@@ -1137,6 +1153,31 @@ mod tests {
assert_eq!(recently(&c, "", &["b.two"]), ["a.one", "b.two"]);
}
/// For each pair of adjacent grades and whole-query tiers, a result picked often ranks above a
/// result that matches the query as well as it does and comes earlier in the catalog, and below
/// the result that matches better, which was never picked. Of two such results, the
/// one with the higher use grade ranks first, and a recent pick ranks first only among results
/// of the same use grade.
#[test]
fn a_command_picked_often_ranks_first_within_its_grades() {
for (query, better, worse, said) in adjacent_grades() {
let (b, w) = (better.id.clone(), worse.id.clone());
// A second result that matches as the worse one does and comes before it.
let twin = entry(&worse.shown, &format!("{w}x"));
let t = twin.id.clone();
let c = described(vec![twin, worse, better], &[said, said, ""]);
let (b, w, t) = (b.as_str(), w.as_str(), t.as_str());
assert_eq!(used(&c, query, &[], &[(w, 1)]), [b, w, t], "{query}: one pick ranks above none");
assert_eq!(used(&c, query, &[], &[(w, 9), (t, 3)]), [b, w, t], "{query}: the higher grade first");
assert_eq!(used(&c, query, &[], &[(w, 1), (t, 3)]), [b, t, w], "{query}: the higher grade first");
assert_eq!(used(&c, query, &[w], &[(t, 1)]), [b, t, w], "{query}: a recent pick within its use grade");
assert_eq!(used(&c, query, &[w], &[(w, 1), (t, 1)]), [b, w, t], "{query}: a recent pick within its use grade");
}
// An empty query lists every result in catalog order.
let c = synthetic(vec![entry("Zz One", "a.one"), entry("Zz Two", "b.two")]);
assert_eq!(used(&c, "", &[], &[("b.two", 9)]), ["a.one", "b.two"]);
}
/// A query that is a menu's title ranks a result whose label holds it as a word above the items
/// of that menu, which match only by their menu path. A query that names the menu with `›`
/// still starts the item's name.
@@ -1147,7 +1188,7 @@ mod tests {
assert_eq!(ranked(&c, "object › pa"), ["a.one"]);
let en = catalog(Lang::EN, false);
for q in ["object", "effect", "select", "view", "type", "edit"] {
let first = rank(&en.list, &en.index, q, &[]).first().and_then(|&i| en.list.get(i as usize)).map(|e| e.shown.to_lowercase());
let first = rank(&en.list, &en.index, q, &[], &[]).first().and_then(|&i| en.list.get(i as usize)).map(|e| e.shown.to_lowercase());
let label = first.as_deref().map(|n| split_name(n).0.to_string()).unwrap_or_default();
assert!(words(&label).any(|w| w.starts_with(q)), "{q}: {first:?}");
}
@@ -1362,7 +1403,7 @@ mod tests {
] {
assert!(substring_rule(&c, typo).is_empty(), "{typo} matched nothing before");
let top = |q: &str| ranked(&c, q).into_iter().take(4).collect::<Vec<_>>();
let spelled_right: Vec<String> = rank(&c.list, &plain, word, &[]).iter().take(4).map(id).collect();
let spelled_right: Vec<String> = rank(&c.list, &plain, word, &[], &[]).iter().take(4).map(id).collect();
assert_eq!(top(typo), spelled_right, "{typo}");
assert!(place(&c, typo, tool).is_some_and(|p| p < 4), "{typo}: {:?}", ranked(&c, typo));
}
@@ -1923,7 +1964,7 @@ mod tests {
let started = std::time::Instant::now();
let runs = 100;
for _ in 0..runs {
std::hint::black_box(rank(&c.list, &c.index, q, &[]));
std::hint::black_box(rank(&c.list, &c.index, q, &[], &[]));
}
println!("{:>12}: {:?} per query", q.get(..12).unwrap_or(q), started.elapsed() / runs);
}
+4 -4
View File
@@ -341,10 +341,10 @@ pub(crate) fn current_paints(app: &VectorcraftApp) -> (Paint, Paint) {
/// document revision, Appearance panel item and picked gradient mesh points (picking points
/// changes no revision).
pub(crate) fn mixed_paints(app: &VectorcraftApp, ctx: &egui::Context) -> (bool, bool) {
type Key = (u64, u64, Option<usize>, Vec<(NodeId, Vec<usize>)>, &'static str);
type Key = (u64, u64, Option<usize>, Vec<(NodeId, Vec<usize>)>, bool);
let Some(st) = app.session.active() else { return (false, false) };
// The tool too: while the Live Paint Bucket is active the proxies show its colors.
let key: Key = (st.uid, st.revision, app.session.appearance_item(), app.session.fill_mesh_points(), app.session.tool_id());
// Whether the proxies show the Live Paint Bucket's colors too.
let key: Key = (st.uid, st.revision, app.session.appearance_item(), app.session.fill_mesh_points(), app.session.bucket_paints());
match pstate::<Option<(Key, (bool, bool))>>(ctx, "proxy-mixed") {
Some((k, mixed)) if k == key => mixed,
_ => {
@@ -373,7 +373,7 @@ pub(crate) fn stroke_mixed(app: &VectorcraftApp, ctx: &egui::Context) -> StrokeM
if character::text_editing(app).is_some() {
return StrokeMixed { can_align: true, ..Default::default() };
}
if app.session.tool_id() == "livePaintBucket" {
if app.session.bucket_paints() {
return StrokeMixed { can_align: true, ..Default::default() };
}
let Some(st) = app.session.active() else { return StrokeMixed::default() };
+79 -3
View File
@@ -199,13 +199,21 @@ fn multi(app: &VectorcraftApp, ctx: &egui::Context, list: &[(String, String)], c
set_pstate(ctx, "br-selected", (None::<Vec<String>>, None::<ClickKey>));
return None;
}
let (names, _): (Option<Vec<String>>, Option<ClickKey>) = pstate(ctx, "br-selected");
let (names, key): (Option<Vec<String>>, Option<ClickKey>) = pstate(ctx, "br-selected");
let names = names?;
if names.is_empty() {
return Some(names);
}
let orig_len = names.len();
let kept: Vec<String> = names.into_iter().filter(|n| list.iter().any(|b| &b.0 == n)).collect();
(!kept.is_empty()).then_some(kept)
if kept.is_empty() {
set_pstate(ctx, "br-selected", (None::<Vec<String>>, key));
return None;
}
if kept.len() != orig_len {
set_pstate(ctx, "br-selected", (Some(kept.clone()), key));
}
Some(kept)
}
/// The brushes Delete Brush and Duplicate Brush act on: the multi-selection, else the selected
@@ -300,6 +308,53 @@ fn replace_drop(ui: &Ui, resp: &egui::Response, name: &str, ty: &str, replaced:
}
}
/// A brush item's right-click context menu.
fn item_context_menu(app: &mut VectorcraftApp, ui: &mut Ui, name: &str) {
let (current_list, current) = brushes(app);
let multi_names = multi(app, ui.ctx(), &current_list, current.as_deref());
let is_multi = multi_names.as_ref().is_some_and(|m| m.len() > 1 && m.iter().any(|b| b == name));
let targets = if is_multi { multi_names.unwrap_or_default() } else { vec![name.to_string()] };
let all_exist = app.session.active().is_some_and(|st| {
let lib = vectorcraft_brush::library(&st.doc);
targets.iter().all(|n| lib.iter().any(|b| &b.name == n))
});
let can_delete = all_exist && targets.len() < current_list.len() && current_list.len() > 1;
let can_duplicate = all_exist;
if is_multi {
if menu_item(ui, tl!("Duplicate Brushes"), can_duplicate, false) {
if let Err(e) = app.run("brush.duplicate", json!({ "names": targets })) {
app.status(e);
}
ui.close();
}
if menu_item(ui, tl!("Delete Brushes"), can_delete, false) {
delete(app, &targets, true);
ui.close();
}
} else {
let can_options = all_exist;
if menu_item(ui, tl!("Brush Options…"), can_options, false) {
if let Err(e) = app.run("ui.brushOptions", json!({ "name": name })) {
app.status(e);
}
ui.close();
}
if menu_item(ui, tl!("Duplicate Brush"), can_duplicate, false) {
if let Err(e) = app.run("brush.duplicate", json!({ "name": name })) {
app.status(e);
}
ui.close();
}
if menu_item(ui, tl!("Delete Brush"), can_delete, false) {
delete(app, &[name.to_string()], true);
ui.close();
}
}
}
pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
let t = Tokens::get(ui.ctx());
let (list, current) = brushes(app);
@@ -316,6 +371,7 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
let mut options: Option<String> = None;
let mut moved: Option<Value> = None;
let mut replaced: Option<(String, Vec<u64>)> = None;
let mut secondary_selected: Option<String> = None;
let list_rect = widgets::list_box(ui, |ui| {
ui.set_min_height(110.0);
ui.set_width(ui.available_width());
@@ -366,8 +422,25 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
resp.on_hover_text(name)
};
// A click applies or selects the brush; the second click of a double-click opens its
// options.
// options; a right-click selects if unselected and displays its item context menu.
let mut pick = |resp: egui::Response, name: &String| {
if resp.secondary_clicked() {
let is_selected = match &multi {
Some(m) => m.iter().any(|b| b == name),
None => sel_brush.as_deref() == Some(name) || (sel_brush.is_none() && current.as_deref() == Some(name)),
};
if !is_selected {
set_pstate(&resp.ctx, "br-anchor", name.clone());
if let Err(e) = app.run("brush.setCurrent", json!({ "name": name })) {
app.status(e);
}
let now = brushes(app).1;
let key = click_key(app, now.as_deref());
set_pstate(&resp.ctx, "br-selected", (Some(vec![name.clone()]), key));
secondary_selected = Some(name.clone());
}
}
resp.context_menu(|ui| item_context_menu(app, ui, name));
if resp.double_clicked() {
options = Some(name.clone());
} else if resp.clicked() {
@@ -417,6 +490,9 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
{
app.status(e);
}
if let Some(name) = secondary_selected {
multi = Some(vec![name]);
}
let highlighted = sel_brush.clone().or(current.clone());
match clicked {
// Shift and Cmd/Ctrl only select, as in the Swatches panel: they start from the
+132
View File
@@ -888,3 +888,135 @@ fn rows_of_two_brushes_with_one_name_show_the_first() {
assert_eq!(shown.ty, "art");
assert_eq!(shown.def, got, "the first of two rows of one name is the one shown");
}
/// Right-clicking a brush in the Brushes panel selects it (if unselected), displays
/// the context menu ("Brush Options…", "Duplicate Brush", "Delete Brush"), and clicking
/// an item dispatches the corresponding command. Multi-selection right-click preserves
/// selection and offers "Duplicate Brushes" / "Delete Brushes". "Delete Brush" is disabled
/// when it is the last brush in the library.
#[test]
fn right_click_context_menu_in_brushes_panel() {
use egui_kittest::kittest::{NodeT, Queryable};
let mut app = VectorcraftApp::new(Session::new(), Default::default());
app.run("file.new", json!({"width": 400, "height": 300})).unwrap();
app.run("shape.rectangle", json!({"x": 10, "y": 10, "width": 50, "height": 40})).unwrap();
app.run("brush.apply", json!({"name": "Tapered Stroke"})).unwrap();
let mut h = egui_kittest::Harness::builder().with_size(vec2(260.0, 500.0)).with_accessibility_check(false).build_ui_state(
|ui, app: &mut VectorcraftApp| {
show(app, ui);
},
app,
);
h.run_steps(2);
let right_click = |h: &mut egui_kittest::Harness<'static, VectorcraftApp>, label: &str| {
let node = h.get_by_label(label);
let pos = node.rect().center();
h.event(egui::Event::PointerMoved(pos));
h.event(egui::Event::PointerButton { pos, button: egui::PointerButton::Secondary, pressed: true, modifiers: Default::default() });
h.event(egui::Event::PointerButton { pos, button: egui::PointerButton::Secondary, pressed: false, modifiers: Default::default() });
h.run_steps(2);
};
// 1. Initial state: artwork uses Tapered Stroke; Charcoal is not current
assert_eq!(selected_brush(h.state()).as_deref(), Some("Tapered Stroke"));
assert_ne!(brushes(h.state_mut()).1.as_deref(), Some("Charcoal"));
// Right-click unselected "Charcoal"
right_click(&mut h, "Charcoal");
// Right-clicking selects Charcoal in panel without applying it to the selected artwork
assert_eq!(brushes(h.state_mut()).1.as_deref(), Some("Charcoal"));
assert_eq!(selected_brush(h.state()).as_deref(), Some("Tapered Stroke"), "right-click must not apply brush to artwork");
let (multi_sel, _): (Option<Vec<String>>, Option<ClickKey>) = pstate(&h.ctx, "br-selected");
assert_eq!(multi_sel, Some(vec!["Charcoal".to_string()]), "right-clicked brush is recorded as panel selection");
let (b_list, b_cur) = brushes(h.state_mut());
assert_eq!(targets(h.state(), &h.ctx, &b_list, b_cur.as_deref()), vec!["Charcoal".to_string()]);
// Context menu displays Brush Options…, Duplicate Brush, Delete Brush
let opt = h.get_by_label(" Brush Options…");
let dup = h.get_by_label(" Duplicate Brush");
let del = h.get_by_label(" Delete Brush");
assert!(!opt.accesskit_node().is_disabled());
assert!(!dup.accesskit_node().is_disabled());
assert!(!del.accesskit_node().is_disabled());
// 2. Click "Duplicate Brush" dispatches brush.duplicate and adds a copy
dup.click();
h.run_steps(2);
let all_names = names(h.state_mut());
assert!(all_names.contains(&"Charcoal copy".to_string()));
// 3. Right-click "Charcoal copy" and click "Delete Brush"
right_click(&mut h, "Charcoal copy");
let undo_before = undo_count(h.state());
h.get_by_label(" Delete Brush").click();
h.run_steps(2);
assert!(!names(h.state_mut()).contains(&"Charcoal copy".to_string()));
assert_eq!(undo_count(h.state()), undo_before + 1);
// Undo restores the deleted copy
h.state_mut().run("edit.undo", json!({})).unwrap();
assert!(names(h.state_mut()).contains(&"Charcoal copy".to_string()));
// 4. Click "Brush Options…" opens the Brush Options dialog
right_click(&mut h, "Charcoal");
h.get_by_label(" Brush Options…").click();
h.run_steps(2);
assert_eq!(h.state().ui.dialog.as_ref().map(|d| d.kind.as_str()), Some(crate::dialogs::brush_options::KIND));
assert_eq!(h.state().ui.dialog.as_ref().unwrap().str("name"), "Charcoal");
crate::dialogs::cancel(h.state_mut());
assert!(h.state().ui.dialog.is_none());
// 5. Multi-selection: right-clicking within multi-selection preserves it and offers
// "Duplicate Brushes" and "Delete Brushes"
let cur = brushes(h.state_mut()).1;
let key = click_key(h.state(), cur.as_deref());
set_pstate(&h.ctx, "br-selected", (Some(vec!["Charcoal".to_string(), "Tapered Stroke".to_string()]), key));
h.run_steps(1);
right_click(&mut h, "Tapered Stroke");
let (multi_sel, _): (Option<Vec<String>>, Option<ClickKey>) = pstate(&h.ctx, "br-selected");
assert_eq!(multi_sel, Some(vec!["Charcoal".to_string(), "Tapered Stroke".to_string()]));
let dup_multi = h.get_by_label(" Duplicate Brushes");
let del_multi = h.get_by_label(" Delete Brushes");
assert!(!dup_multi.accesskit_node().is_disabled());
assert!(!del_multi.accesskit_node().is_disabled());
// Click Duplicate Brushes
dup_multi.click();
h.run_steps(2);
let all_names = names(h.state_mut());
assert!(all_names.contains(&"Charcoal copy 2".to_string()));
assert!(all_names.contains(&"Tapered Stroke copy".to_string()));
// 6. Delete a brush in use by artwork prompts with the brushDelete confirmation dialog
h.state_mut().run("brush.apply", json!({ "name": "Tapered Stroke" })).unwrap();
assert_eq!(selected_brush(h.state()).as_deref(), Some("Tapered Stroke"));
right_click(&mut h, "Tapered Stroke");
h.get_by_label(" Delete Brush").click();
h.run_steps(2);
assert_eq!(h.state().ui.dialog.as_ref().map(|d| d.kind.as_str()), Some(crate::dialogs::brush_delete::KIND));
crate::dialogs::cancel(h.state_mut());
assert!(names(h.state_mut()).contains(&"Tapered Stroke".to_string()));
// 7. Delete Brush is disabled when it is the last brush in the library
let current_brushes = names(h.state_mut());
let to_delete: Vec<String> = current_brushes.into_iter().filter(|n| n != "Charcoal").collect();
h.state_mut().run("brush.delete", json!({ "names": to_delete })).unwrap();
assert_eq!(names(h.state_mut()), vec!["Charcoal".to_string()]);
h.run_steps(2);
right_click(&mut h, "Charcoal");
let del_last = h.get_by_label(" Delete Brush");
assert!(del_last.accesskit_node().is_disabled(), "last remaining brush cannot be deleted");
}
+6
View File
@@ -999,6 +999,12 @@ fn a_mixed_selection_has_no_colour_to_edit() {
frame(&mut app, &ctx, vec![], egui::Modifiers::NONE);
assert_eq!(crate::panels::mixed_paints(&app, &ctx), (true, false));
let _ = ctx.run_ui(Default::default(), |ui| assert_eq!(target(&app, ui).color(), None));
// The Eyedropper armed for a stop of the Live Paint Bucket's gradient shows the bucket's color.
app.select_tool("eyedropper");
assert_eq!(crate::panels::mixed_paints(&app, &ctx), (true, false));
app.session.set_tool_option("stop", &json!("livePaintBucket"));
assert_eq!(crate::panels::mixed_paints(&app, &ctx), (false, false), "arming the pick recomputes it");
app.session.set_tool_option("stop", &serde_json::Value::Null);
app.run("paint.setFill", json!({"color": "#0000ff"})).unwrap();
assert_eq!(crate::panels::mixed_paints(&app, &ctx), (false, false), "a new revision recomputes it");
}
+4 -2
View File
@@ -708,9 +708,11 @@ fn ramp_row(app: &mut VectorcraftApp, ui: &mut Ui, g: &Gradient, is_grad: bool)
}
/// The stop's eyedropper: the Eyedropper tool samples the next colour clicked on the art into the
/// selected stop, then hands back to the current tool.
/// selected stop, then hands back to the current tool (or, while a pick is already armed, to the
/// tool that armed it).
pub(crate) fn stop_eyedropper(app: &mut VectorcraftApp) {
let back = app.session.tool_id();
let tool = app.session.tool_id();
let back = (tool == "eyedropper").then(|| app.session.tool_returns_to()).flatten().unwrap_or_else(|| tool.to_string());
app.select_tool("eyedropper");
app.session.set_tool_option("stop", &json!(back));
}
@@ -740,6 +740,9 @@ fn the_stop_eyedropper_arms_the_eyedropper_for_the_stop() {
assert!(texts.iter().any(|(t, _)| t == "#FFFFFF"), "the stop's colour row: {texts:?}");
stop_eyedropper(&mut app);
assert_eq!((app.session.tool_id(), app.session.tool_options()), ("eyedropper", json!({"stop": "gradient", "brushKeyColor": false})));
// A second click on the eyedropper while the pick is armed still hands back to the Gradient tool.
stop_eyedropper(&mut app);
assert_eq!(app.session.tool_options()["stop"], "gradient");
}
/// #8024: Escape ends the stop eyedropper's pick and returns to the Gradient tool. The stop keeps
+262 -8
View File
@@ -26,7 +26,10 @@ use serde_json::{Value, json};
use vectorcraft_color::{BlendMode, Color, Paint};
use vectorcraft_doc::style_libs::STYLE_LIBRARIES;
use vectorcraft_doc::text::{CharStyle, TextObject};
use vectorcraft_doc::{Appearance, AppearanceItem, Document, FillLayer, GraphicStyle, Node, NodeId, NodeKind, PatternDef, StrokeLayer, StyleLibrary};
use vectorcraft_doc::{
Appearance, AppearanceItem, DEFAULT_GRAPHIC_STYLE, Document, FillLayer, GraphicStyle, Node, NodeId, NodeKind, PatternDef, StrokeLayer,
StyleLibrary,
};
use vectorcraft_engine::cmd::stylelib;
use vectorcraft_engine::cmd::swatchlib::LibraryInfo;
use vectorcraft_geom::{Affine, Point, shapes};
@@ -486,21 +489,84 @@ fn zone_input(ui: &Ui, zone: &Response, d: &Document, ev: &mut Events) {
}
}
/// An item's right-click context menu in the Graphic Styles panel.
fn item_context_menu(app: &mut VectorcraftApp, ui: &mut Ui, name: &str, sel: &[String]) {
let is_default = name == DEFAULT_GRAPHIC_STYLE;
let is_multi = sel.len() > 1 && sel.contains(&name.to_string());
let targets: Vec<String> = if is_multi {
let doc = app.session.active().map(|st| st.doc.clone());
if let Some(d) = &doc { d.graphic_styles.iter().filter(|g| sel.contains(&g.name)).map(|g| g.name.clone()).collect() } else { sel.to_vec() }
} else {
vec![name.to_string()]
};
let doomed: Vec<String> = targets.iter().filter(|s| *s != DEFAULT_GRAPHIC_STYLE).cloned().collect();
let can_options = !is_default && !is_multi;
if menu_item(ui, tl!("Graphic Style Options…"), can_options, false) {
if let Err(e) = app.run("ui.graphicStyleOptions", json!({ "name": name })) {
app.status(e);
}
ui.close();
}
let duplicate_label = if is_multi { tl!("Duplicate Graphic Styles") } else { tl!("Duplicate Graphic Style") };
if menu_item(ui, duplicate_label, true, false) {
duplicate(app, ui.ctx(), &targets);
ui.close();
}
let delete_label = if is_multi { tl!("Delete Graphic Styles") } else { tl!("Delete Graphic Style") };
let can_delete = !is_default && !doomed.is_empty();
if menu_item(ui, delete_label, can_delete, false) {
let res = if doomed.len() == 1 {
app.run("graphicStyle.delete", json!({ "name": doomed[0] }))
} else {
app.run("graphicStyle.delete", json!({ "names": doomed }))
};
if res.is_ok() {
set_pstate(ui.ctx(), "gs-sel", Vec::<String>::new());
}
ui.close();
}
ui.separator();
let has_art_sel = selection_len(app) > 0;
if menu_item(ui, tl!("Redefine Graphic Style"), has_art_sel, false) {
if let Err(e) = app.run("graphicStyle.redefine", json!({ "name": name })) {
app.status(e);
}
ui.close();
}
let is_linked = app.session.selection_graphic_style().is_some_and(|(g, linked)| linked && g.name == name);
if menu_item(ui, tl!("Break Link to Graphic Style"), is_linked, false) {
if let Err(e) = app.run("graphicStyle.breakLink", json!({})) {
app.status(e);
}
ui.close();
}
}
/// The thumbnail grid (Thumbnail View and the Control bar's picker), `sel` outlined.
fn tiles(app: &VectorcraftApp, ui: &mut Ui, s: &Shown, sel: &[String], ev: &mut Events) {
fn tiles(app: &mut VectorcraftApp, ui: &mut Ui, s: &Shown, sel: &mut Vec<String>, ev: &mut Events, in_panel: bool) {
ui.horizontal_wrapped(|ui| {
ui.spacing_mut().item_spacing = vec2(3.0, 3.0);
for (i, g) in s.d.graphic_styles.iter().enumerate() {
let (r, resp) = ui.allocate_exact_size(vec2(TILE, TILE), Sense::click_and_drag());
s.paint(app, ui, r, i);
outline(ui, r, sel.contains(&g.name), resp.hovered());
cell_input(ui, &resp.on_hover_text(&g.name), s.d, i, false, ev);
let resp = resp.on_hover_text(&g.name);
cell_input(ui, &resp, s.d, i, false, ev);
if in_panel {
if resp.secondary_clicked() && !sel.contains(&g.name) {
*sel = vec![g.name.clone()];
set_pstate(ui.ctx(), "gs-anchor", g.name.clone());
set_pstate(ui.ctx(), "gs-sel", sel.clone());
}
resp.context_menu(|ui| item_context_menu(app, ui, &g.name, sel));
}
}
});
}
/// The list views' rows (`row`: height and thumbnail side), `sel` highlighted.
fn rows(app: &VectorcraftApp, ui: &mut Ui, s: &Shown, sel: &[String], row: (f32, f32), ev: &mut Events) {
fn rows(app: &mut VectorcraftApp, ui: &mut Ui, s: &Shown, sel: &mut Vec<String>, row: (f32, f32), ev: &mut Events) {
let t = Tokens::get(ui.ctx());
let (h, side) = row;
for (i, g) in s.d.graphic_styles.iter().enumerate() {
@@ -514,7 +580,14 @@ fn rows(app: &VectorcraftApp, ui: &mut Ui, s: &Shown, sel: &[String], row: (f32,
s.paint(app, ui, th, i);
ui.painter().rect_stroke(th, 0.0, Stroke::new(1.0, t.border), StrokeKind::Outside);
ui.painter().text(pos2(th.right() + 8.0, r.center().y), egui::Align2::LEFT_CENTER, &g.name, egui::FontId::proportional(12.0), t.text);
let resp = resp.on_hover_text(&g.name);
cell_input(ui, &resp, s.d, i, true, ev);
if resp.secondary_clicked() && !sel.contains(&g.name) {
*sel = vec![g.name.clone()];
set_pstate(ui.ctx(), "gs-anchor", g.name.clone());
set_pstate(ui.ctx(), "gs-sel", sel.clone());
}
resp.context_menu(|ui| item_context_menu(app, ui, &g.name, sel));
}
}
@@ -588,7 +661,7 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
};
let looks = look_hashes(ui.ctx(), app);
let shown = Shown { d: &doc, looks: &looks, preview: pstate(ui.ctx(), "gs-preview") };
let sel = selected(ui.ctx(), &doc);
let mut sel = selected(ui.ctx(), &doc);
let view = app.ui.graphic_styles_view;
let mut ev = Events::default();
// In a sized panel the list fills the space above the footer (#2992), as the Artboards list
@@ -609,8 +682,8 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) {
return;
}
match view.row() {
Some(row) => rows(app, ui, &shown, &sel, row, &mut ev),
None => tiles(app, ui, &shown, &sel, &mut ev),
Some(row) => rows(app, ui, &shown, &mut sel, row, &mut ev),
None => tiles(app, ui, &shown, &mut sel, &mut ev, true),
}
});
// The drop zone is the part of the list on screen: when the list shrinks to its rows,
@@ -674,8 +747,9 @@ pub(crate) fn picker(app: &mut VectorcraftApp, ui: &mut Ui) {
let looks = look_hashes(ui.ctx(), app);
let shown = Shown { d: &doc, looks: &looks, preview: pstate(ui.ctx(), "gs-preview") };
let mut ev = Events::default();
let mut sel = Vec::new();
ui.set_max_width(6.0 * (TILE + 3.0));
tiles(app, ui, &shown, &[], &mut ev);
tiles(app, ui, &shown, &mut sel, &mut ev, false);
act(app, ui, &shown, ev, true);
}
@@ -1755,4 +1829,184 @@ mod tests {
frame_with(&ctx, click(false), |ui| picker(&mut app, ui));
assert_eq!(app.session.selection_graphic_style().map(|(g, linked)| (g.name.clone(), linked)), Some((name, true)));
}
#[test]
fn right_click_context_menu_in_graphic_styles_panel() {
use egui_kittest::kittest::{NodeT, Queryable};
let mut app = app();
app.run("graphicStyle.new", json!({"name": "Style A"})).unwrap();
app.run("graphicStyle.new", json!({"name": "Style B"})).unwrap();
let mut h = egui_kittest::Harness::builder().with_size(vec2(260.0, 400.0)).with_accessibility_check(false).build_ui_state(
|ui, app: &mut VectorcraftApp| {
show(app, ui);
},
app,
);
h.run_steps(2);
// Initially "Style B" was added last; "Style A" is unselected.
let pos_a = h.get_by_label("Style A").rect().center();
// 1. Right-click unselected "Style A"
h.event(egui::Event::PointerMoved(pos_a));
h.event(egui::Event::PointerButton { pos: pos_a, button: egui::PointerButton::Secondary, pressed: true, modifiers: Default::default() });
h.event(egui::Event::PointerButton { pos: pos_a, button: egui::PointerButton::Secondary, pressed: false, modifiers: Default::default() });
h.run_steps(2);
// Right-clicking unselected "Style A" selects it.
let doc = h.state().session.active().unwrap().doc.clone();
assert_eq!(selected(&h.ctx, &doc), vec!["Style A"]);
// Context menu items are displayed
let options = h.get_by_label(" Graphic Style Options…");
let duplicate = h.get_by_label(" Duplicate Graphic Style");
let delete = h.get_by_label(" Delete Graphic Style");
let redefine = h.get_by_label(" Redefine Graphic Style");
let break_link = h.get_by_label(" Break Link to Graphic Style");
assert!(!options.accesskit_node().is_disabled());
assert!(!duplicate.accesskit_node().is_disabled());
assert!(!delete.accesskit_node().is_disabled());
assert!(!redefine.accesskit_node().is_disabled()); // Art is selected
assert!(break_link.accesskit_node().is_disabled()); // Art not linked to Style A
// 2. Click "Duplicate Graphic Style"
duplicate.click();
h.run_steps(3);
let doc = h.state().session.active().unwrap().doc.clone();
assert!(doc.graphic_style("Style A copy").is_some());
assert_eq!(selected(&h.ctx, &doc), vec!["Style A copy"]);
// 3. Apply Style A to the active art and verify Break Link
h.state_mut().run("graphicStyle.apply", json!({"name": "Style A"})).unwrap();
// Modify appearance so style is out of sync (not linked)
h.state_mut().run("paint.setFill", json!({"color": "#ff0000"})).unwrap();
h.run_steps(2);
let pos_a = h.get_by_label("Style A").rect().center();
h.event(egui::Event::PointerMoved(pos_a));
h.event(egui::Event::PointerButton { pos: pos_a, button: egui::PointerButton::Secondary, pressed: true, modifiers: Default::default() });
h.event(egui::Event::PointerButton { pos: pos_a, button: egui::PointerButton::Secondary, pressed: false, modifiers: Default::default() });
h.run_steps(2);
let break_link = h.get_by_label(" Break Link to Graphic Style");
assert!(break_link.accesskit_node().is_disabled(), "Break link is disabled when style is out of sync");
// Close menu
h.event(egui::Event::Key { key: egui::Key::Escape, physical_key: None, pressed: true, repeat: false, modifiers: Default::default() });
h.run_steps(2);
// Reapply Style A so it is in sync
h.state_mut().run("graphicStyle.apply", json!({"name": "Style A"})).unwrap();
h.run_steps(2);
let pos_a = h.get_by_label("Style A").rect().center();
h.event(egui::Event::PointerMoved(pos_a));
h.event(egui::Event::PointerButton { pos: pos_a, button: egui::PointerButton::Secondary, pressed: true, modifiers: Default::default() });
h.event(egui::Event::PointerButton { pos: pos_a, button: egui::PointerButton::Secondary, pressed: false, modifiers: Default::default() });
h.run_steps(2);
let break_link = h.get_by_label(" Break Link to Graphic Style");
assert!(!break_link.accesskit_node().is_disabled(), "Break link is enabled when style is in sync");
break_link.click();
h.run_steps(3);
assert!(h.state().session.selection_graphic_style().is_none());
// 4. Right-click Style A and click "Delete Graphic Style"
let pos_a = h.get_by_label("Style A").rect().center();
h.event(egui::Event::PointerMoved(pos_a));
h.event(egui::Event::PointerButton { pos: pos_a, button: egui::PointerButton::Secondary, pressed: true, modifiers: Default::default() });
h.event(egui::Event::PointerButton { pos: pos_a, button: egui::PointerButton::Secondary, pressed: false, modifiers: Default::default() });
h.run_steps(2);
let delete = h.get_by_label(" Delete Graphic Style");
assert!(!delete.accesskit_node().is_disabled());
delete.click();
h.run_steps(3);
let doc = h.state().session.active().unwrap().doc.clone();
assert!(doc.graphic_style("Style A").is_none());
// Verify one undo step restores it
h.state_mut().run("edit.undo", json!({})).unwrap();
let doc = h.state().session.active().unwrap().doc.clone();
assert!(doc.graphic_style("Style A").is_some());
}
#[test]
fn right_click_context_menu_default_style_disables_options_and_delete() {
use egui_kittest::kittest::{NodeT, Queryable};
let app = app();
let mut h = egui_kittest::Harness::builder().with_size(vec2(260.0, 400.0)).with_accessibility_check(false).build_ui_state(
|ui, app: &mut VectorcraftApp| {
show(app, ui);
},
app,
);
h.run_steps(2);
let pos_def = h.get_by_label(DEFAULT_GRAPHIC_STYLE).rect().center();
h.event(egui::Event::PointerMoved(pos_def));
h.event(egui::Event::PointerButton { pos: pos_def, button: egui::PointerButton::Secondary, pressed: true, modifiers: Default::default() });
h.event(egui::Event::PointerButton { pos: pos_def, button: egui::PointerButton::Secondary, pressed: false, modifiers: Default::default() });
h.run_steps(2);
let options = h.get_by_label(" Graphic Style Options…");
let duplicate = h.get_by_label(" Duplicate Graphic Style");
let delete = h.get_by_label(" Delete Graphic Style");
assert!(options.accesskit_node().is_disabled(), "Options disabled on Default Graphic Style");
assert!(!duplicate.accesskit_node().is_disabled(), "Duplicate enabled on Default Graphic Style");
assert!(delete.accesskit_node().is_disabled(), "Delete disabled on Default Graphic Style");
}
#[test]
fn right_click_context_menu_preserves_multiselection_and_works_in_list_view() {
use egui_kittest::kittest::{NodeT, Queryable};
let mut app = app();
app.ui.graphic_styles_view = View::SmallList;
app.run("graphicStyle.new", json!({"name": "Style 1"})).unwrap();
app.run("graphicStyle.new", json!({"name": "Style 2"})).unwrap();
let mut h = egui_kittest::Harness::builder().with_size(vec2(260.0, 400.0)).with_accessibility_check(false).build_ui_state(
|ui, app: &mut VectorcraftApp| {
show(app, ui);
},
app,
);
h.run_steps(2);
set_pstate(&h.ctx, "gs-sel", vec!["Style 1".to_string(), "Style 2".to_string()]);
h.run_steps(1);
let pos_2 = h.get_by_label("Style 2").rect().center();
h.event(egui::Event::PointerMoved(pos_2));
h.event(egui::Event::PointerButton { pos: pos_2, button: egui::PointerButton::Secondary, pressed: true, modifiers: Default::default() });
h.event(egui::Event::PointerButton { pos: pos_2, button: egui::PointerButton::Secondary, pressed: false, modifiers: Default::default() });
h.run_steps(2);
let doc = h.state().session.active().unwrap().doc.clone();
assert_eq!(selected(&h.ctx, &doc), vec!["Style 1", "Style 2"]);
let options = h.get_by_label(" Graphic Style Options…");
let duplicate = h.get_by_label(" Duplicate Graphic Styles");
let delete = h.get_by_label(" Delete Graphic Styles");
assert!(options.accesskit_node().is_disabled(), "Options disabled on multi-selection");
assert!(!duplicate.accesskit_node().is_disabled());
assert!(!delete.accesskit_node().is_disabled());
duplicate.click();
h.run_steps(3);
let doc = h.state().session.active().unwrap().doc.clone();
assert!(doc.graphic_style("Style 1 copy").is_some());
assert!(doc.graphic_style("Style 2 copy").is_some());
}
}
+1 -1
View File
@@ -514,7 +514,7 @@ pub(crate) const PROFILE_DROPDOWN_WIDTH: f32 = 100.0;
/// member's.
pub(crate) fn brush_keeps_size(app: &VectorcraftApp, ctx: &egui::Context, shown: Option<&StrokeLayer>) -> Option<bool> {
let st = app.session.active()?;
let bucket = app.session.tool_id() == "livePaintBucket";
let bucket = app.session.bucket_paints();
if bucket || (st.selection.objects.is_empty() && st.selection.subjects().is_empty()) {
let s = shown?;
let name = s.brush.as_deref()?;
@@ -63,17 +63,6 @@ fn undo_len(app: &VectorcraftApp) -> usize {
app.session.doc().unwrap().history.undo.len()
}
/// Opens `library` (id `id`, with `count` brushes) and clicks its brush `name` at `time`: that brush,
/// and not the library's `other` one, is added to the document in one step.
fn pick(app: &mut VectorcraftApp, ctx: &egui::Context, (library, id, count): (&str, &str, u64), (name, other): (&str, &str), time: f64) {
let r = app.run("window.brushLibrary", json!({"library": library})).unwrap();
assert_eq!((r["open"].as_str(), r["count"].as_u64()), (Some(id), Some(count)));
let undo = undo_len(app);
click(app, ctx, name, Modifiers::NONE, time);
assert!(has(app, name) && !has(app, other), "{name}");
assert_eq!(undo_len(app), undo + 1);
}
fn has(app: &VectorcraftApp, name: &str) -> bool {
vectorcraft_brush::find(&app.session.doc().unwrap().doc, name).is_some()
}
@@ -210,6 +199,7 @@ fn the_window_menu_and_the_brushes_panel_open_brush_libraries() {
json!("bristle-brushes"),
json!("paint"),
json!("pattern-borders"),
json!("decorative"),
json!("ornamental"),
json!("scatter-shapes"),
json!("stipple"),
@@ -239,8 +229,18 @@ fn the_window_menu_and_the_brushes_panel_open_brush_libraries() {
assert!(texts.iter().any(|x| x.ends_with(t)), "{t}: {texts:?}");
}
// Dry Media opens in a library panel, and a click on Chalk Grain adds it in one step.
pick(&mut app, &ctx, ("Dry Media", "dry-media", 4), ("Chalk Grain", "Wax Crayon"), 1.0);
pick(&mut app, &ctx, ("Tech Circuit", "tech-circuit", 3), ("Circuit Trace", "Bus Lines"), 2.0);
let r = app.run("window.brushLibrary", json!({"library": "Dry Media"})).unwrap();
assert_eq!((r["open"].as_str(), r["count"].as_u64()), (Some("dry-media"), Some(4)));
let undo = undo_len(&app);
click(&mut app, &ctx, "Chalk Grain", Modifiers::NONE, 1.0);
assert!(has(&app, "Chalk Grain") && !has(&app, "Wax Crayon"));
assert_eq!(undo_len(&app), undo + 1);
let r = app.run("window.brushLibrary", json!({"library": "Tech Circuit"})).unwrap();
assert_eq!((r["open"].as_str(), r["count"].as_u64()), (Some("tech-circuit"), Some(3)));
let undo = undo_len(&app);
click(&mut app, &ctx, "Circuit Trace", Modifiers::NONE, 2.0);
assert!(has(&app, "Circuit Trace") && !has(&app, "Bus Lines"));
assert_eq!(undo_len(&app), undo + 1);
let r = app.run("window.brushLibrary", json!({"library": "Artistic Brushes"})).unwrap();
assert_eq!((r["open"].as_str(), r["count"].as_u64()), (Some("artistic"), Some(4)));
let previous = crate::i18n::current();
@@ -262,17 +262,39 @@ fn the_window_menu_and_the_brushes_panel_open_brush_libraries() {
app.session.doc().unwrap().doc.node(vectorcraft_doc::NodeId(path)).unwrap().appearance.stroke().unwrap().brush.as_deref(),
Some("Scrollwork")
);
// Without brushes there is nothing to save.
let all: Vec<String> = vectorcraft_brush::library(&app.session.doc().unwrap().doc).into_iter().map(|b| b.name).collect();
app.run("brush.delete", json!({ "names": all })).unwrap();
let entries = crate::menus::menu_entries(&app);
assert!(entries.iter().any(|e| under(e) && e.command.as_deref() == Some("ui.saveBrushLibrary") && !e.enabled));
}
#[test]
fn pressure_decorative_paint_and_image_libraries_add_a_brush_in_one_step() {
let mut app = app();
let ctx = context();
let r = app.run("window.brushLibrary", json!({"library": "Pressure Sensitive"})).unwrap();
assert_eq!((r["open"].as_str(), r["count"].as_u64()), (Some("pressure-sensitive"), Some(4)));
let path = app.run("shape.line", json!({"x1": 10, "y1": 100, "x2": 180, "y2": 100})).unwrap()["id"].as_u64().unwrap();
let undo = undo_len(&app);
click(&mut app, &ctx, "Flex Ribbon", Modifiers::NONE, 5.0);
click(&mut app, &ctx, "Flex Ribbon", Modifiers::NONE, 4.0);
assert!(has(&app, "Flex Ribbon") && !has(&app, "Pulse Stroke"));
assert_eq!(undo_len(&app), undo + 1);
assert_eq!(
app.session.doc().unwrap().doc.node(vectorcraft_doc::NodeId(path)).unwrap().appearance.stroke().unwrap().brush.as_deref(),
Some("Flex Ribbon")
);
let r = app.run("window.brushLibrary", json!({"library": "Decorative"})).unwrap();
assert_eq!((r["open"].as_str(), r["count"].as_u64()), (Some("decorative"), Some(4)));
let path = app.run("shape.line", json!({"x1": 10, "y1": 100, "x2": 180, "y2": 100})).unwrap()["id"].as_u64().unwrap();
let undo = undo_len(&app);
click(&mut app, &ctx, "Leaf Vine", Modifiers::NONE, 5.0);
assert!(has(&app, "Leaf Vine") && !has(&app, "Lantern String"));
assert_eq!(undo_len(&app), undo + 1);
assert_eq!(
app.session.doc().unwrap().doc.node(vectorcraft_doc::NodeId(path)).unwrap().appearance.stroke().unwrap().brush.as_deref(),
Some("Leaf Vine")
);
let r = app.run("window.brushLibrary", json!({"library": "Paint"})).unwrap();
assert_eq!((r["open"].as_str(), r["count"].as_u64()), (Some("paint"), Some(4)));
let path = app.run("shape.line", json!({"x1": 10, "y1": 140, "x2": 180, "y2": 140})).unwrap()["id"].as_u64().unwrap();
@@ -284,12 +306,12 @@ fn the_window_menu_and_the_brushes_panel_open_brush_libraries() {
app.session.doc().unwrap().doc.node(vectorcraft_doc::NodeId(path)).unwrap().appearance.stroke().unwrap().brush.as_deref(),
Some("Flat Sweep")
);
pick(&mut app, &ctx, ("Image Brush", "image-brush", 4), ("Soft Bloom", "Color Flecks"), 7.0);
// Without brushes there is nothing to save.
let all: Vec<String> = vectorcraft_brush::library(&app.session.doc().unwrap().doc).into_iter().map(|b| b.name).collect();
app.run("brush.delete", json!({ "names": all })).unwrap();
let entries = crate::menus::menu_entries(&app);
assert!(entries.iter().any(|e| under(e) && e.command.as_deref() == Some("ui.saveBrushLibrary") && !e.enabled));
let r = app.run("window.brushLibrary", json!({"library": "Image Brush"})).unwrap();
assert_eq!((r["open"].as_str(), r["count"].as_u64()), (Some("image-brush"), Some(4)));
let undo = undo_len(&app);
click(&mut app, &ctx, "Soft Bloom", Modifiers::NONE, 8.0);
assert!(has(&app, "Soft Bloom") && !has(&app, "Color Flecks"));
assert_eq!(undo_len(&app), undo + 1);
}
#[test]
+66 -4
View File
@@ -2432,6 +2432,38 @@ fn keyboard_focus_on_a_slices_row_shows_its_description() {
assert!(described.iter().any(|d| d == numbers), "the focused control carries the sentence: {described:?}");
}
/// Whether `sentence` is one of `texts` and is drawn on the description line of the frame that
/// painted them.
fn painted_on_line(ctx: &egui::Context, texts: &[(String, egui::Rect)], sentence: &str) -> bool {
let line = description_line_rects(ctx).line;
texts.iter().any(|(t, r)| t == sentence && r.intersects(line))
}
/// Tab from the search field, which must have the keyboard, until each of `sentences` has shown on
/// the description line. Other controls may come between them, but a sentence that shows before the
/// ones ahead of it in `sentences` fails the test. → For each sentence, the description of the focused
/// accessibility node and the focused widget when it first showed.
fn tab_to_each(a: &mut VectorcraftApp, ctx: &egui::Context, sentences: &[&str]) -> Vec<(Option<String>, Option<egui::Id>)> {
assert!(ctx.memory(|m| m.has_focus(search_edit_id())), "the search field has the keyboard before the first Tab");
let mut first = vec![];
for _ in 0..40 {
if first.len() == sentences.len() {
break;
}
let (texts, described) = description_frame(a, ctx, key_press(egui::Key::Tab, egui::Modifiers::NONE));
if let Some(i) = sentences.iter().position(|s| painted_on_line(ctx, &texts, s)) {
assert!(i <= first.len(), "Tab reaches {:?} before {:?}", sentences[i], sentences[first.len()]);
if i == first.len() {
first.push((described, ctx.memory(|m| m.focused())));
}
}
}
if let Some(missing) = sentences.get(first.len()) {
panic!("Tab does not reach the row of {missing:?}");
}
first
}
/// The pointer over Hyphenation's Default Language row and over its Exceptions row shows each
/// row's sentence.
#[test]
@@ -2449,10 +2481,10 @@ fn hovering_a_hyphenation_row_shows_its_description() {
let exceptions = descriptions::description("hyphenationExceptions").expect("Exceptions has a sentence");
description_frame(&mut a, &ctx, vec![egui::Event::PointerMoved(row(&texts, "Default Language:"))]);
let (after, _) = description_frame(&mut a, &ctx, vec![]);
assert!(painted(&after, language) && !painted(&after, exceptions), "the Default Language row's sentence shows: {after:?}");
assert!(painted_on_line(&ctx, &after, language) && !painted(&after, exceptions), "the Default Language row's sentence shows: {after:?}");
description_frame(&mut a, &ctx, vec![egui::Event::PointerMoved(row(&texts, "Exceptions"))]);
let (after, _) = description_frame(&mut a, &ctx, vec![]);
assert!(painted(&after, exceptions) && !painted(&after, language), "the Exceptions row's sentence shows: {after:?}");
assert!(painted_on_line(&ctx, &after, exceptions) && !painted(&after, language), "the Exceptions row's sentence shows: {after:?}");
}
/// Tab from the search field reaches Hyphenation's Default Language menu and then its Exceptions
@@ -2494,7 +2526,37 @@ fn hovering_a_plugins_and_scratch_disks_row_shows_its_description() {
description_frame(&mut a, &ctx, vec![egui::Event::PointerMoved(row(&texts, label))]);
let (after, _) = description_frame(&mut a, &ctx, vec![]);
for (j, sentence) in sentences.iter().enumerate() {
assert_eq!(painted(&after, sentence), i == j, "pointer over `{label}`, sentence {j}: {after:?}");
let shown = if i == j { painted_on_line(&ctx, &after, sentence) } else { painted(&after, sentence) };
assert_eq!(shown, i == j, "pointer over `{label}`, sentence {j}: {after:?}");
}
}
}
/// Tab from the search field reaches the Additional Plug-ins Folder field, then Primary, then
/// Secondary: the line shows each one's sentence in turn, and a screen reader gets it as the focused
/// field's description. With a folder picker, Choose… shares the folder's row, and the folder's
/// text field still has the keyboard when its sentence first shows.
#[test]
fn keyboard_focus_on_a_plugins_and_scratch_disks_row_shows_its_description() {
let keys = ["pluginsFolder", "scratchPrimary", "scratchSecondary"];
let sentences: Vec<_> = keys.iter().map(|key| descriptions::description(key).unwrap_or_else(|| panic!("`{key}` has a sentence"))).collect();
for picker in [false, true] {
let mut a = app();
if picker {
a.services.pick_folder = Some(Box::new(|| None));
}
open(&mut a, Some("Plug-ins & Scratch Disks"));
let ctx = egui::Context::default();
ctx.enable_accesskit();
crate::theme::install_fonts(&ctx);
description_frame(&mut a, &ctx, vec![]);
let (texts, _) = description_frame(&mut a, &ctx, vec![]);
assert_eq!(texts.iter().any(|(t, _)| t == "Choose…"), picker, "Choose… shows only with a folder picker: {texts:?}");
let visits = tab_to_each(&mut a, &ctx, &sentences);
for ((described, focused), (key, sentence)) in visits.iter().zip(keys.iter().zip(&sentences)) {
let field = focused.is_some_and(|id| egui::text_edit::TextEditState::load(&ctx, id).is_some());
assert!(field, "the `{key}` text field has the keyboard (picker {picker})");
assert!(described.iter().any(|d| d == sentence), "the focused `{key}` field carries the sentence (picker {picker}): {described:?}");
}
}
}
@@ -2503,7 +2565,7 @@ fn hovering_a_plugins_and_scratch_disks_row_shows_its_description() {
/// Budget menu, then Primary, then Secondary: the line shows each one's sentence in turn, and a
/// screen reader gets it as the focused control's description.
#[test]
fn keyboard_focus_on_a_plugins_and_scratch_disks_row_shows_its_description() {
fn keyboard_focus_on_the_plugin_instruction_budget_menu_shows_its_description() {
let mut a = app();
open(&mut a, Some("Plug-ins & Scratch Disks"));
let ctx = egui::Context::default();
+3 -2
View File
@@ -992,9 +992,10 @@ fn listed_on_its_own(c: &vectorcraft_engine::CommandSpec) -> bool {
/// Is UI command `id` (default key `sc`, params doc `params`) listed in Edit › Keyboard Shortcuts
/// whether or not an item of the menu bar runs it? It is when it has a default key or a params doc
/// of `{}` or `{path…}`. Rename has no default key, and a key press names the selection: it needs
/// no `id`.
/// no `id`. Color Picker… has no default key either, and a key press opens it for the proxy in
/// front.
fn ui_listed_on_its_own(id: &str, sc: &str, params: &str) -> bool {
!sc.is_empty() || params.starts_with("{}") || params.starts_with("{path") || id == "ui.rename"
!sc.is_empty() || params.starts_with("{}") || params.starts_with("{path") || id == "ui.rename" || id == "ui.colorPicker"
}
/// Does a menu bar item run the command with no params, so that it does what its label says and opens
+39
View File
@@ -1638,6 +1638,45 @@ fn polygonal_lasso_takes_backspace_delete_enter_and_escape_while_a_loop_is_open(
assert_eq!(sel.anchors.get(&id).map(|a| a.len()), Some(1), "only the corner inside the loop");
}
/// Color Picker… (`ui.colorPicker`) has no default key. Keyboard Shortcuts lists it, and a key
/// assigned there opens the picker for the proxy in front: with no document open, with nothing
/// selected and with an object selected, and for the stroke while the Stroke proxy is in front,
/// with or without a document open.
#[test]
fn a_key_assigned_to_the_color_picker_opens_it_for_the_proxy_in_front() {
let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default());
crate::shortcut_editor::sync(&app.ui);
assert_eq!(crate::shortcut_editor::default_command_shortcut("ui.colorPicker"), None);
let listed = app.run("shortcuts.list", json!({"query": "ui.colorPicker"})).unwrap();
let rows: Vec<_> = listed.as_array().expect("rows").iter().map(|r| r["label"].clone()).collect();
assert_eq!(rows, [json!("Color Picker…")], "Keyboard Shortcuts lists it");
app.run("shortcuts.set", json!({"id": "ui.colorPicker", "shortcut": "Cmd+Alt+Shift+F12"})).unwrap();
crate::shortcut_editor::sync(&app.ui);
let key = || press(Key::F12, Modifiers::COMMAND | Modifiers::ALT | Modifiers::SHIFT);
let opened = |app: &mut VectorcraftApp| {
let stroke = app.ui.dialog.as_ref().filter(|d| d.kind == "colorPicker").map(|d| d.bool("stroke"));
app.ui.dialog = None;
stroke
};
frame(&mut app, key());
assert_eq!(opened(&mut app), Some(false), "no document: the fill");
app.run("paint.toggleActive", json!({"fill": false})).unwrap();
frame(&mut app, key());
assert_eq!(opened(&mut app), Some(true), "no document, the Stroke proxy in front: the stroke");
app.run("paint.toggleActive", json!({"fill": true})).unwrap();
app.run("file.new", json!({"width": 200, "height": 200})).unwrap();
frame(&mut app, key());
assert_eq!(opened(&mut app), Some(false), "nothing selected: the fill");
let id = app.run("shape.rectangle", json!({"x": 10, "y": 10, "width": 50, "height": 50})).unwrap()["id"].clone();
app.run("select.set", json!({"ids": [id]})).unwrap();
frame(&mut app, key());
assert_eq!(opened(&mut app), Some(false), "an object selected: the fill");
app.run("paint.toggleActive", json!({})).unwrap();
frame(&mut app, key());
assert_eq!(opened(&mut app), Some(true), "the Stroke proxy in front: the stroke");
crate::shortcut_editor::sync(&crate::state::UiState::default());
}
/// Binds Show Grid to `chord`, or with `None` leaves every command its default shortcut.
fn bind_grid(app: &mut VectorcraftApp, chord: Option<&str>) {
app.ui.shortcut_overrides.clear();
+5
View File
@@ -762,6 +762,10 @@ pub struct UiState {
/// Help › Search Commands' Recent Commands list: the ids of the last picks, most recent first.
#[serde(default)]
pub recent_commands: Vec<String>,
/// How many times each command was picked in Help › Search Commands, which ranks the commands
/// picked most often first among results that match as well.
#[serde(default, deserialize_with = "crate::palette::deserialize_command_uses")]
pub command_uses: crate::palette::CommandUses,
/// Families starred in the font menus (the ★ filter shows only these).
#[serde(default)]
pub favorite_fonts: Vec<String>,
@@ -1348,6 +1352,7 @@ impl Default for UiState {
recent_files: vec![],
recent_fonts: vec![],
recent_commands: vec![],
command_uses: Default::default(),
favorite_fonts: vec![],
engine_prefs: Value::Null,
original_editor: Default::default(),
+7 -3
View File
File diff suppressed because one or more lines are too long
+16 -9
View File
@@ -675,12 +675,13 @@ objects' fills or strokes differ (`fillMixed` / `strokeMixed`, drawn as a "?" pr
In the app's Color panel and Color Picker, RGB, HSB, hex and Web Safe RGB values describe the active working RGB
space. RGB edits preserve the other native channels; HSB uses those same working RGB components. Colors outside
display sRGB retain their native numeric values. `ui.colorPanel` selects the panel mode and `ui.colorPicker`
opens the picker through `run_command` with the remote backend. `ui.colorPanel {"recentColors": false}` unchecks
the panel menu's Show Recent Colors, which hides the Color panel's Recent Colors row, and `true` shows it again;
applied colors still join the list while it is hidden. `ui.colorPanel {"rgbPercent": true}` shows the Color panel's
RGB fields in percent, as a double-click right of an RGB field does, and `false` shows them from 0 to 255 again.
`ui.colorRgbPercent` (Toggle RGB Percent in the command palette and Keyboard Shortcuts) switches between the two
and answers true when the fields show in percent.
opens the picker through `run_command` with the remote backend. Edit › Keyboard Shortcuts lists `ui.colorPicker` as
Color Picker… with no default key; a key assigned there opens the picker for the proxy in front, as `{}` does.
`ui.colorPanel {"recentColors": false}` unchecks the panel menu's Show Recent Colors, which hides the Color panel's
Recent Colors row, and `true` shows it again; applied colors still join the list while it is hidden.
`ui.colorPanel {"rgbPercent": true}` shows the Color panel's RGB fields in percent, as a double-click right of an RGB
field does, and `false` shows them from 0 to 255 again. `ui.colorRgbPercent` (Toggle RGB Percent in the command
palette and Keyboard Shortcuts) switches between the two and answers true when the fields show in percent.
`ui.colorWheel {"view": "box", "channel": "red"}` shows the Color Wheel panel's box (a color field with the channel's
strip at its right) in place of the wheel, as the panel menu's Box View and Box Channel do, and `"view": "wheel"`
shows the wheel again. `{"harmony": true, "harmonyRule": "triad"}` puts a marker on the wheel's ring for each other
@@ -4811,7 +4812,13 @@ already walks Image Trace. Short agent entry points:
Appearance panel's active row changes. The Fill and Stroke proxies (`paint.proxies`) show those colors, never mixed, the Stroke panel shows
that stroke as it does with nothing selected, and with New Art Has Basic Appearance off the selection's appearance
does not replace them after a command. They are also the fill and stroke for new art, so another tool chosen
afterwards keeps them until a command or a new selection changes them.
afterwards keeps them until a command or a new selection changes them. All of this also holds while a Cmd/Ctrl-click
with the bucket uses the Selection tool, and while the Eyedropper samples into a stop of the bucket's gradient for
the Gradient panel's eyedropper (`tool.select {tool: "eyedropper"}`, then
`tool.setOption {tool: "eyedropper", values: {stop: "livePaintBucket"}}`): the stop
stays selected, and the click's `paint.sampleColor {color, stop}` recolors that stop of the bucket's gradient and
leaves the selection's paint as it is. Once that stop is no longer selected (a Cmd/Ctrl-click selected another
object), the next click ends the pick without sampling and switches back to the bucket.
With the Live Paint Bucket selected and no drag in progress, Left and Right without Shift, Alt or Cmd/Ctrl (which
keep their shortcuts) run `paint.setFill {swatch, ids: []}` (or
`paint.setStroke` when the Stroke proxy is in front) with the color swatch before or after the active paint in the
@@ -5791,8 +5798,8 @@ error.
## Brush libraries
Brush libraries are read-only sets of brushes: fourteen generated in code (Art Ribbons, Ink and Wash, Calligraphic Nibs, Pressure Sensitive with Flex Ribbon, Pulse Stroke, Round Flow and Chisel Flow, Bristle
Brushes with one bristle brush for each tip shape, Pattern Borders, Scatter Shapes, Stipple with Fine, Dense, Soft and Bold dot textures, Game Trails, Energy Beams, and Dry Media with the Chalk Grain, Graphite Pencil, Wax Crayon and
Brush libraries are read-only sets of brushes: fifteen generated in code (Art Ribbons, Ink and Wash, Calligraphic Nibs, Pressure Sensitive with Flex Ribbon, Pulse Stroke, Round Flow and Chisel Flow, Bristle
Brushes with one bristle brush for each tip shape, Pattern Borders, Decorative with Leaf Vine, Blossom Chain, Pennant Garland and Lantern String, Scatter Shapes, Stipple with Fine, Dense, Soft and Bold dot textures, Game Trails, Energy Beams, and Dry Media with the Chalk Grain, Graphite Pencil, Wax Crayon and
Charcoal Dust art brushes, id `dry-media`, Tech Circuit with Circuit Trace (art), Bus Lines and Terminal Nodes (pattern), id `tech-circuit`, Engraving with Fine Hatching, Dense Hatching, Tapered Hatching and Broken Hatching art brushes, id `engraving`, and Arrows with Solid, Open, Double, Chevron and Dashed Arrow art brushes, id `arrows`), the `.vectorcraft` files in the user library folder of the desktop app (User
Defined) and the brushes of any document loaded with `brush.loadLibrary` (a document without brushes of its own has
the default ones). `brush.libraries` lists them (`id`, `name`, `category`: `builtIn`, `user` or `loaded`, `count`) and
+3 -2
View File
@@ -71,6 +71,7 @@ M7 type: Touch Type moves a right-to-left character along its line and up from i
| Date | Change | Summary |
|---|---|---|
| 2026-11-19 | minor | M14/G12: Graphic Styles panel item context menus in thumbnail and list views (Options…, Duplicate, Delete, Redefine, Break Link); regression tests in crates/ui-egui/src/panels/graphic_styles.rs; scores and estimates unchanged. |
| 2026-11-18 | minor | M10/G5: Media Controls joins Basic Shapes, UI Frames, Map Markers, Inventory Icons, Skill Icons and Weather Icons as a seventh built-in symbol library (Play, Pause, Stop, Skip Next, Shuffle, Repeat; original procedural vector symbols generated in code, no default 9-slice); G5 estimate decremented to 2–12 h, milestone estimates unchanged |
| 2026-11-18 | minor | M14: PDF export writes the document language (Document Setup) as the catalog's `/Lang` (#3644). Scores and estimates unchanged. |
| 2026-11-13 | minor | Layers: selected guide rows stay highlighted after the pointer leaves (#7344); scores and estimates unchanged. |
@@ -186,11 +187,11 @@ Gujarati interface follow-up (2026-11-14): the catalog and zero/one plural rule
| M7 | Type (point/area/path, editing, styles, OpenType, threading, glyphs) | Spell check engine: `text.spelling.check` and `text.spelling.suggest` on craft-proof, the custom dictionary and Ignore All commands, Auto Spell Check with its right-click suggestions, Ignore All and Add to Dictionary, Spelling › Auto Spell Check in the context menu of type, the Edit Custom Dictionary dialog, and the modal Check Spelling dialog (Edit › Spelling › Check Spelling…, `Cmd+I`, `ui.checkSpelling`, #4936); Right-aligned area type sets the text after a line's last tab against the right edge, the text before it at its stops (#6147); A line a soft return ends is justified as a wrapped line is (#6137); Indian-language pattern hyphenation preserves syllables in both composers (#4947); 🟡 Hanging punctuation keeps its published amounts under Glyph Scaling, and Standard burasagari counts a hung line start as room; Fullwidth `!` / `?` keep an upright fallback in vertical type; Hyphenation… and Justification… per paragraph (#2310, #2755), Auto Leading also driving the Character panel's Leading, the Alt+↑/↓ leading nudge and Fill with Placeholder Text; Document-point character controls after object/group scaling (#1034; optional font-size preservation remains separate), Character/Paragraph Styles (explicit Auto-leading resets and local leading overrides), per-paragraph paragraph attributes, mixed paragraph alignment indication (headless regressions, full integration CI and visual review pass), Area Type Options (with Width/Height, Auto Size and Shrink Text to Fit; overflow reported to agents and vertical Align), type areas resized by their handles and reshaped with Direct Selection, threaded text, Fit Headline, Glyphs (feature-valued alternates and unencoded glyphs applied in one Undo step while keeping Arabic joining, #5514), OpenType panel (including font-defined Stylistic Sets), Find Font (Document, Recent and System replacement sources, #5217), installed system fonts in every font menu (fonts registered with Windows outside its font folders, the XDG and Flatpak host font folders on Linux, and fonts installed while the app runs, listed when it comes back to the front; searchable; the Character and Properties menus show each family's sample of the selected text, preview it live under the pointer or ↑/↓, show recently applied families first (#3515), filter by script and kind, list a family's styles, and star favourites; the Glyphs panel and Find Font's Replace With use the same menu without the live preview) and found by name on open/import (full-name aliases and Missing Fonts searches verified, #1258; Windows font-service QA pending), variable fonts' named instances as styles, CJK names in the UI, input methods (marked text in place, candidate window at the caret; Japanese IME), Text Wrap (offset, invert, both sides of an object; follows edits), Type on a Path effects and Options with draggable start/centre/end brackets (slide, flip), tab stops + Tabs panel (Above Text floats it over the selected text, its ruler at the canvas zoom so stops line up with the columns, #729), inline symbols in text (beyond parity), Hebrew/Arabic bidirectional text, Paragraph Direction, Every-line/Single-line Composer per object (ragged text too) done; paint-only Arabic harakat keep joining with GDEF-mark ownership and Insert Kashidas tatweels on the base letter's paint (`tests::harakat`); tab leaders, vertical type pending | 45–60 |
| M8 | Transform & distort (Puppet Warp, Liquify tools, Envelopes, Blends, Perspective Grid) | ✅ done (M8.1–M8.20 on 2026-10-06, fidelity pass): Liquify Tool Options with one shared brush, pen pressure, hold-to-apply, a safe scope and incremental strokes; tool options that last; Puppet Warp rotation, multi-select, Control bar and a rest-shape session that follows Undo; Width tool on compound paths; Envelope dialogs with preview, Reset with Warp/Mesh, full Envelope Options, type/images/symbols/appearance/gradients/patterns distorted on canvas and in every export, warps that keep their frame, Edit Contents, mesh handles and Control bar; Blend Options, anchor-targeted Blend tool, editable spine, keys picked on the canvas, faithful interpolation and knockout; Anchor Point spine conversion/handle editing and selection priority (#2544), with #2425 Shift reshape preserved; Perspective Grid with Define Grid, presets, lock/snap/rulers, widgets, the 1–4 plane switch, movable planes, Perspective Selection scale/copy/perpendicular/Transform Again, and type and symbols truly projected with Edit Text. Left: Anti-Alias and Preserve Shape output, warp-envelope point editing, brush interpolation in blends, Free Transform/Scale/Reflect along a rotated box; #5179 curved-spine redraw bounds include rotated keys and steps (two focused CPU regressions) | 2–4 |
| M9 | Live effects (+ 3D & Materials) | 🟡 2D effects done incl. Effect → Pathfinder, Color Adjustments and Document Raster Effects Settings; PDF export warns when the pixel cap lowers raster-effect resolution; Artistic › Colored Pencil, Cutout, Dry Brush, Film Grain, Fresco, Neon Glow, Paint Daubs, Palette Knife, Poster Edges, Rough Pastels, Smudge Stick, Sponge, Underpainting and Watercolor and Sketch › Halftone Pattern, Bas Relief, Charcoal, Conté Crayon, Photocopy, Stamp, Torn Edges and Water Paper done (57/57 Photoshop filters); Revolve with automatic smooth vector shading, default-on circular caps and continuous rims, Extrude & Bevel, Inflate and Rotate with one to ten colored directional lights and four original lighting presets; SVG Filters, remaining raster effects and 3D materials and shadows pending | 81–130 |
| M10 | Brushes, symbols, patterns, Repeat | 🟡 pattern swatches (5 tile types, Pattern Options, editing mode, SVG `<pattern>`/PDF export) and live Repeat (radial/grid/mirror) done; interactive selected mirror axis implemented (focused and native checks passed; full CI blocked by an unrelated text test); symbol libraries done (Window › Symbol Libraries, six generated libraries (Basic Shapes, UI Frames, Map Markers, Inventory Icons, Skill Icons, Weather Icons), User Defined, Other Library…, Save Symbols); brush libraries done (Window › Brush Libraries, fourteen generated libraries including Tech Circuit, Engraving, Arrows, Stipple, Pressure Sensitive, Ink and Wash, Bristle Brushes and Dry Media, User Defined, Other Library…, Save Brushes); symbol editing shows draggable 9-slice guides (#5280), with guides outside the artwork still unsupported; brushes/symbols in progress | 23–37 |
| M10 | Brushes, symbols, patterns, Repeat | 🟡 pattern swatches (5 tile types, Pattern Options, editing mode, SVG `<pattern>`/PDF export) and live Repeat (radial/grid/mirror) done; interactive selected mirror axis implemented (focused and native checks passed; full CI blocked by an unrelated text test); symbol libraries done (Window › Symbol Libraries, six generated libraries (Basic Shapes, UI Frames, Map Markers, Inventory Icons, Skill Icons, Weather Icons), User Defined, Other Library…, Save Symbols); brush libraries done (Window › Brush Libraries, fifteen generated libraries including Tech Circuit, Decorative, Engraving, Arrows, Stipple, Pressure Sensitive, Ink and Wash, Bristle Brushes and Dry Media, User Defined, Other Library…, Save Brushes); symbol editing shows draggable 9-slice guides (#5280), with guides outside the artwork still unsupported; brushes/symbols in progress | 23–37 |
| M11 | Artboards & views (selected-set deletion shared by Artboards menu, trash and Properties, retaining artboard 1 when all are selected; Artboard deletion keys keep the first of an all-selected set and protect artwork; history prunes invalid indices while preserving valid multiselection (history tests and full workspace CI pass); click-to-fit objects with the Artboard tool (#1227), artboard escape routing and document setup modal handoff done; artboard panel/tool with Move Artwork for X/Y fields and Artboard Options, Trim View, middle-button pan, print tiling and the status bar's artboard navigator with synchronized Artboard tool selection done; Window › Arrange › Tile and Consolidate All Windows done; multiple windows, presentation polish) (cached canvas reprojection preserves scale during resize, rotation and DPI changes; regression-tested and contributor-confirmed 2026-10-19; estimates unchanged) (cached canvas dimensions match the renderer limit before cache-key creation, view construction and worker submission; regression-tested; estimates unchanged); status-bar pointer coordinates follow the active ruler origin and General units | 🟡; Artboard Options shares existing presets and orientation controls and can fit artwork without moving it; artwork fitting includes all drawn document art across artboards and off-board; artwork bounds are cached by active document and revision, and selection uses the shared bounds cache across artboards | 15–25 |
| M12 | Advanced color & art (CMYK/ICC, separations, Gradient Mesh, Live Paint, Image Trace, Graphs) | 🟡 Gradient Mesh, Live Paint, Image Trace (junction-returning pieces retain their positioned boundaries; a simpler contour walk with identical output; an edge's sub-pixel shift is the same from either side; notches read only their own piece; collapsed loops keep few segments; large images trace with a warning; Auto Color keeps rare distinct colours; quick presets trace at once and the Image Trace button opens the adjustment controls; Properties reopens them; tiny fitted contours retain islands and holes; Create Strokes: exact crop EDT, Guo–Hall thinning and maximal-disc graph simplification; 15 presets, the 14 documented ones each with an enhanced version; Ignore Color (manual picker and canvas eyedropper from original pixels, no canvas View change, missed pixels keep the pick armed, Preview/Undo retained; #8068), Shapes, Auto Grouping and Gradients options; measured in `image-trace-quality.md`; closed outlines retain their interior after straightening; the Flat Logo mode places edges to a fraction of a pixel, restores sharp corners, snaps lines and circles, and refuses gradients; live trace result bounds and selection highlights exclude the retained bitmap except in source-image views), Recolor Artwork, colour management (ICC, soft proofing, separations preview), Graphs (all 9 tools, Graph Data/Type, group-selected series colours persist through regenerate/save/open) done; Graph Design and Marker designs, Transpose and Switch x/y, `\|` label line breaks, the pie options, drop shadows, the legend across the top, overlapping widths, First Row/Column in Front, filled lines, kept label formatting and the Graph Data worksheet done; graph Column designs pending; Vector Halftone Preview keeps the selection box without drawing dot selection marks (#6369); Live Paint Bucket fills faces crossed in one drag (#6373) | 6–10 |
| M13 | Automation (Actions ✅ record/playback, persisted; variables, scripting, batch) | 🟡 MCP `add_text` exposes existing vertical point, area and path type; `script.run` and File › Scripts › Other Script… run JavaScript files, and Window › Script Console shows their output; the script document model and batch work remain | 18–27 |
| M14 | 1.0 polish (preferences, shortcut editor, workspaces, accessibility, packaging for all OSes) (status messages and readouts use stable responsive allocations sized for localized labels and ordinary coordinates; sample widths cached by language/unit/DPI; regression-tested and contributor-confirmed 2026-10-19; estimates unchanged) | 🟡 Icon-strip flyouts resize on their free edges and retain sizes (#5713); interim macOS cursor delivery (#2292) uses existing artwork and host-owned AppKit cursors; headless coverage only, native menu/focus/handback and display validation pending. Dock groups collapse to their tabs by a double-click on a tab (UI.8); Preferences › General › Constrain Angle acts for the arrow keys, Shift drags and new objects (#394, 2026-10-21); numeric-field pointer selection and focus regression-tested (#1326; a release more than 1 pt from the press keeps the caret, a tap within 1 pt selects all, #6659); RPM runtime capabilities and glibc floor checked (#1275; real-distro install/start-up pending), Eyedropper cursor with precise-setting checks (#1269), Preferences, shortcut editor (chords with Shift and a punctuation key fire as typed; other apps' text shortcut sets imported), workspaces (each keeps its layout changes until Reset <name>, UI.7), Window › Help Bar shown or hidden apart from the status bar and kept in saved workspaces, panels docked by dragging into any dock group (as tabs or a top/bottom split) or into the icon column, and closed from a dock tab's context menu (UI.6), a custom title bar on Windows/Linux with a Home button, content-sized dialogs, menus that scroll when longer than the window and macOS native menu dismissal done (M14.8), and native macOS save sheets with a Format menu (#866); titled PDF exports set `DisplayDocTitle` for viewers and accessibility checkers (#3646) and give the document language as the catalog's `/Lang` (#3644); accessibility and broader Windows/Linux packaging/QA pending; floating tab groups collapse into the side icon rail and opened rail panels fold back into it (#5925, in part), with pointer and native-window regression coverage; estimates unchanged; numeric spinner arrows keep repeating while held with the mouse (#6307); Swatches item context menus tested in all five views and rendered layouts inspected; Linux full CI passed, Windows engine baseline limitations documented (G12); Window > Toolbars > Compact Tools offers optional denser main Tools spacing in one or two columns, with the existing layout still the default (#7234) | 18–28 |
| M14 | 1.0 polish (preferences, shortcut editor, workspaces, accessibility, packaging for all OSes) (status messages and readouts use stable responsive allocations sized for localized labels and ordinary coordinates; sample widths cached by language/unit/DPI; regression-tested and contributor-confirmed 2026-10-19; estimates unchanged) | 🟡 Icon-strip flyouts resize on their free edges and retain sizes (#5713); interim macOS cursor delivery (#2292) uses existing artwork and host-owned AppKit cursors; headless coverage only, native menu/focus/handback and display validation pending. Dock groups collapse to their tabs by a double-click on a tab (UI.8); Preferences › General › Constrain Angle acts for the arrow keys, Shift drags and new objects (#394, 2026-10-21); numeric-field pointer selection and focus regression-tested (#1326; a release more than 1 pt from the press keeps the caret, a tap within 1 pt selects all, #6659); RPM runtime capabilities and glibc floor checked (#1275; real-distro install/start-up pending), Eyedropper cursor with precise-setting checks (#1269), Preferences, shortcut editor (chords with Shift and a punctuation key fire as typed; other apps' text shortcut sets imported), workspaces (each keeps its layout changes until Reset <name>, UI.7), Window › Help Bar shown or hidden apart from the status bar and kept in saved workspaces, panels docked by dragging into any dock group (as tabs or a top/bottom split) or into the icon column, and closed from a dock tab's context menu (UI.6), a custom title bar on Windows/Linux with a Home button, content-sized dialogs, menus that scroll when longer than the window and macOS native menu dismissal done (M14.8), and native macOS save sheets with a Format menu (#866); titled PDF exports set `DisplayDocTitle` for viewers and accessibility checkers (#3646) and give the document language as the catalog's `/Lang` (#3644); accessibility and broader Windows/Linux packaging/QA pending; floating tab groups collapse into the side icon rail and opened rail panels fold back into it (#5925, in part), with pointer and native-window regression coverage; estimates unchanged; numeric spinner arrows keep repeating while held with the mouse (#6307); Swatches item context menus tested in all five views and rendered layouts inspected; Linux full CI passed, Windows engine baseline limitations documented (G12); Graphic Styles item context menus in thumbnail and list views with Options, Duplicate, Delete, Redefine, Break Link (#8755); Window > Toolbars > Compact Tools offers optional denser main Tools spacing in one or two columns, with the existing layout still the default (#7234) | 18–28 |
| — | Interaction fidelity pass (every tool's modifiers, Properties panel per context, isolation, nuance; width-point creation and adjoining adjustment regression-tested; dialog layout reviewed) | ⬜ (new ruler-guide Alt orientation implemented; existing-guide Escape cancellation regression-tested; broader pass remains) | 60–90 |
| — | Hardening at scale (big-file corpus, fuzzing, cross-platform + browser QA) | 🟡 PngSuite integrity and bounded fetching verified (#1729); real-world corpus/manual QA remain | 50–80 |
| M14 follow-up | Color Picker layout (#2008) | ✅ Compact controls, centered header, stacked actions, aligned fields and screen sampling; narrow windows scroll vertically | Included above |
File diff suppressed because one or more lines are too long
+5 -3
View File
File diff suppressed because one or more lines are too long