From 1bccc76d77d76876058b3ce2d283a155c51e5bda Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 3 Dec 2026 20:23:55 -0800 Subject: [PATCH 1/3] Tests: dock panel tests wait for the font scan before counting idle frames dock::tests::idle_frames_replay_the_color_panel failed now and then with "idle frames replay the Color panel" (left: 1, right: 0). The app starts the scan of the installed fonts on a background thread, and frames do not wait for it. When the scan ends, the fonts' generation changes, and a panel body's inputs hold that generation through layout_inputs. On a loaded machine the scan can end after the helper's two settle frames, so the first idle frame runs the body once. The panel() helper now calls FontDb::global().family_list() after making the app, which waits for that scan (or runs it), as the font menu, properties and native menu tests already do. Every test in the module goes through panel(), so all of them get the fix. --- crates/ui-egui/src/dock.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crates/ui-egui/src/dock.rs b/crates/ui-egui/src/dock.rs index ea6dcb4c69..f07c0e9a4f 100644 --- a/crates/ui-egui/src/dock.rs +++ b/crates/ui-egui/src/dock.rs @@ -202,6 +202,9 @@ mod tests { fn panel(id: &'static str) -> Panel { SHOWN.with(|s| *s.borrow_mut() = id); let mut app = VectorcraftApp::new(Session::new(), Default::default()); + // The scan of the installed fonts, which the app starts, changes the fonts' generation when it ends, and the + // bodies' inputs hold that generation: wait for it, or an idle frame that it ends in runs the body. + vectorcraft_text::FontDb::global().family_list(); app.run("file.new", json!({"width": 200, "height": 200})).unwrap(); app.run("shape.rectangle", json!({"x": 10, "y": 10, "width": 50, "height": 50})).unwrap(); let mut panel = Panel::new(app, draw); From b2f59ace0714e2848159cb4745029492d6b1c921 Mon Sep 17 00:00:00 2001 From: yoriswind <164435053+yoriswind@users.noreply.github.com> Date: Thu, 3 Dec 2026 22:36:50 -0800 Subject: [PATCH 2/3] Docs: add a script for editable numbered grids (#10417) * Docs: add a script for editable numbered grids * Docs: bound the numbered-grid example and validate label numbers --------- Co-authored-by: FredApps <153173854+FredApps@users.noreply.github.com> --- docs/mcp.md | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/docs/mcp.md b/docs/mcp.md index 0937b3ba51..e99e34fe86 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -4245,6 +4245,49 @@ change anything outside the documents: `script.*` except `script.check`, `plugin an error. With Data Recovery off for complex documents, a run in the web build does not start while a complex document has unsaved changes. +#### Create a numbered grid + +Open the drawing, save the code below as `Number Grid.jsx`, then run it with **File › Scripts › Other Script…**. +Change the first number, count, columns and spacing before running it. Positions and spacing are in document +points. `left` and `top` set the baseline origin of the first label, and numbers advance across each row. +Every label stays editable with the Type tool. One Undo removes the entire grid. + +```javascript +var firstNumber = 1; +var count = 31; +var columns = 7; +var left = 36; +var top = 54; +var columnSpacing = 42; +var rowSpacing = 32; +var size = 16; + +if (count < 1 || count > 1000 || count !== Math.floor(count)) { + throw new Error("Count must be a whole number from 1 to 1000."); +} +if (!isFinite(columns) || columns < 1 || columns !== Math.floor(columns)) { + throw new Error("Columns must be a positive whole number."); +} +var maxInteger = 9007199254740991; +var lastNumber = firstNumber + (count - 1); +if (firstNumber !== Math.floor(firstNumber) || + Math.abs(firstNumber) > maxInteger || Math.abs(lastNumber) > maxInteger) { + throw new Error("The first and last label number must be safe integers."); +} + +for (var i = 0; i < count; i++) { + vc.run("text.create", { + x: left + (i % columns) * columnSpacing, + y: top + Math.floor(i / columns) * rowSpacing, + text: String(firstNumber + i), + size: size + }); +} +``` + +This example creates up to 1,000 labels in one run. Make more room between larger labels by increasing +`columnSpacing`. + ### Script engines A named engine (`#targetengine`) keeps its globals and functions between the runs that name it, until it is dropped From 4070779f8838c87ba7b8abff95356f9b2ccaf201 Mon Sep 17 00:00:00 2001 From: yoriswind <164435053+yoriswind@users.noreply.github.com> Date: Thu, 3 Dec 2026 22:52:39 -0800 Subject: [PATCH 3/3] View: keep Cmd+0 on Fit Artboard in Window (#10396) Co-authored-by: FredApps <153173854+FredApps@users.noreply.github.com> --- crates/ui-egui/src/menus/model.rs | 5 ++++- crates/ui-egui/src/shortcuts/tests.rs | 27 +++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/menus/model.rs b/crates/ui-egui/src/menus/model.rs index 3e4cecdc1d..84125b1a43 100644 --- a/crates/ui-egui/src/menus/model.rs +++ b/crates/ui-egui/src/menus/model.rs @@ -477,7 +477,10 @@ fn build_catalog(app: &VectorcraftApp, listed: &Listed, plays: &[(String, craft: Ok(catalog) => { // While a text field has the keys no shortcut runs, as in production; the text-editing chords still edit it, // and the Type tool's commands run while it types. - let catalog = catalog.typing_rule(TypingRule::AllWait); + // The document canvas also defaults to Cmd+0, but its Fit on Screen stops at actual size. + // Leave that chord to VectorCraft's Fit Artboard in Window. + let fit_on_screen = CommandRef::from(craft::ui::canvas::ViewCommands::FitOnScreen); + let catalog = catalog.typing_rule(TypingRule::AllWait).replace_defaults(fit_on_screen.id, Vec::new()); let catalog = linked_keys.into_iter().fold(catalog, |catalog, (id, keys)| catalog.replace_defaults(id, keys)); let catalog = UNROUTED.iter().fold(catalog, |catalog, id| catalog.replace_defaults(id.as_str(), Vec::new())); Some(type_keys.into_iter().fold(catalog, |catalog, (id, keys)| catalog.replace_defaults(id, keys))) diff --git a/crates/ui-egui/src/shortcuts/tests.rs b/crates/ui-egui/src/shortcuts/tests.rs index 6673ef5da6..5ed8517c01 100644 --- a/crates/ui-egui/src/shortcuts/tests.rs +++ b/crates/ui-egui/src/shortcuts/tests.rs @@ -80,6 +80,33 @@ fn idle(app: &mut VectorcraftApp, ctx: &egui::Context, n: usize) { } } +/// A focused document canvas must use the app's artboard fit, whose zoom may exceed 100%. +#[test] +fn command_zero_fits_the_active_artboard_when_the_canvas_has_focus() { + let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default()); + app.session.execute("file.new", &json!({"width": 120, "height": 80, "artboards": 2})).unwrap(); + app.session.execute("prefs.set", &json!({"key": "displayPrintSize", "value": false})).unwrap(); + let ctx = ready(&mut app); + app.view_mut().unwrap().artboard = 1; + + app.run("view.fitArtboard", json!({})).unwrap(); + idle(&mut app, &ctx, 12); + let fitted = app.view().unwrap(); + let (zoom, center) = (fitted.zoom, fitted.center); + assert!(zoom > 1.0, "this artboard has room to grow past actual size: {zoom}"); + + app.run("view.setZoom", json!({"zoom": 50})).unwrap(); + idle(&mut app, &ctx, 12); + focus_canvas(&mut app, &ctx); + assert!(app.view().unwrap().zoom < 1.0); + key_frame(&mut app, &ctx, tap(Key::Num0, cmd())); + idle(&mut app, &ctx, 12); + + let fitted = app.view().unwrap(); + assert!((fitted.zoom - zoom).abs() < 1e-6, "shortcut zoom {} should match the menu fit {zoom}", fitted.zoom); + assert_eq!(fitted.center, center, "fit the active artboard, not the whole document"); +} + /// An app with a 200 × 200 document whose window has drawn its first frame, which builds the keymap the shortcut /// commands edit. fn new_app() -> VectorcraftApp {