From 59b4e54710d297ed76e59a4fe39baf48904ef143 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 09:08:57 -0800 Subject: [PATCH 01/12] Build: the workspace manifest prints no unused-dependency or unused-patch warnings Every cargo command printed seven manifest warnings, and clippy on all targets printed one more. Each entry below had no reader on main. - peniko (workspace dependency): no member crate has ever declared it. It has been in the list since the workspace skeleton (bfee80a22c). crates/render reaches peniko through vello_cpu::peniko. - rfd and webbrowser (workspace dependencies): #8800 moved the app onto the craft UI framework and removed their last declarations in apps/vectorcraft and crates/ui-egui. The folder picker and the browser links now come from craft-libs. The rfd name in xtask's layer check is a crate name to reject, so it does not read this entry. - workspace.package.repository: no member crate sets repository.workspace = true, and no packaging script, xtask command or workflow reads the field. - egui_demo_lib, egui_inspection and egui_system_font_provider ([patch.crates-io]): #8800 copied these from craft-libs' own patch list, and nothing in VectorCraft's graph depends on them. Cargo.lock listed them under [[patch.unused]]. A dependency's [patch] does not apply in this workspace, so removing them does not change how craft-libs builds. The egui crates that are in the graph keep their patches at 932a73b285. - apps/vectorcraft-web declared egui_extras for every target, but only the wasm32 module web.rs calls it. It now sits under the wasm32 target dependencies. Cargo.lock drops the three [[patch.unused]] entries. --- Cargo.lock | 15 --------------- Cargo.toml | 7 ------- apps/vectorcraft-web/Cargo.toml | 3 ++- 3 files changed, 2 insertions(+), 23 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 520647b95d..d12ce6efa6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10758,18 +10758,3 @@ dependencies = [ "syn 3.0.9", "winnow", ] - -[[patch.unused]] -name = "egui_demo_lib" -version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=932a73b28560acb1a695533307b2cd0d66a42081#932a73b28560acb1a695533307b2cd0d66a42081" - -[[patch.unused]] -name = "egui_inspection" -version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=932a73b28560acb1a695533307b2cd0d66a42081#932a73b28560acb1a695533307b2cd0d66a42081" - -[[patch.unused]] -name = "egui_system_font_provider" -version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=932a73b28560acb1a695533307b2cd0d66a42081#932a73b28560acb1a695533307b2cd0d66a42081" diff --git a/Cargo.toml b/Cargo.toml index a0fb986dcc..f8b43c538d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,6 @@ version = "0.24.1" edition = "2024" license = "MIT OR Apache-2.0" rust-version = "1.95" -repository = "https://github.com/storytold/vectorcraft" [workspace.dependencies] craft-cms = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853" } @@ -86,7 +85,6 @@ vectorcraft-apischema = { path = "crates/apischema" } # foundation kurbo = { version = "0.13", features = ["serde"] } -peniko = "0.6" thiserror = "2" serde = { version = "1", features = ["derive", "rc"] } serde_json = { version = "1", features = ["float_roundtrip"] } @@ -156,10 +154,8 @@ egui = "0.37" egui_extras = { version = "0.37", default-features = false, features = ["svg"] } eframe = { version = "0.37", default-features = false } egui_kittest = "0.37" -rfd = "0.17" arboard = { version = "3.6", default-features = false } clipboard-win = "5.4" -webbrowser = "1" [workspace.lints.rust] unsafe_code = "deny" @@ -210,8 +206,5 @@ egui-wgpu = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560 egui_glow = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" } egui_extras = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" } egui_kittest = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" } -egui_system_font_provider = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" } eframe = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" } -egui_demo_lib = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" } -egui_inspection = { git = "https://github.com/storytold/egui.git", rev = "932a73b28560acb1a695533307b2cd0d66a42081" } winit = { git = "https://github.com/storytold/winit.git", rev = "a517b3846ee8457d84ee4975110bfda6797c44dc" } diff --git a/apps/vectorcraft-web/Cargo.toml b/apps/vectorcraft-web/Cargo.toml index e8b56c29a9..d4293d8320 100644 --- a/apps/vectorcraft-web/Cargo.toml +++ b/apps/vectorcraft-web/Cargo.toml @@ -20,12 +20,13 @@ vectorcraft-format = { workspace = true } vectorcraft-text = { workspace = true } craft = { workspace = true, features = ["ui", "keymap", "automation", "platform"] } egui = { workspace = true } -egui_extras = { workspace = true } log = { workspace = true } [target.'cfg(target_arch = "wasm32")'.dependencies] # `wgpu` pulls egui-wgpu's defaults: WebGPU plus the WebGL2 fallback. eframe = { workspace = true, features = ["default_fonts", "wgpu", "accesskit"] } +# The image loaders `web.rs` installs. +egui_extras = { workspace = true } # The page command API (storytold/craft-libs#413): the request plumbing behind window.vectorcraft. craft-web-api = { git = "https://github.com/storytold/craft-libs", rev = "610c86792a02aa3d416926ee44e3ec3788dea853", version = "0.1.0" } From 740b04cde0bab8b78449c06d61bc5426fabd65ca Mon Sep 17 00:00:00 2001 From: Fredrik Hallin Date: Sun, 29 Nov 2026 18:54:50 +0100 Subject: [PATCH 02/12] CI: use the standard macOS runner for releases --- .github/workflows/release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 226830fc1b..538d09cc31 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -42,6 +42,7 @@ jobs: dry-run: ${{ github.event_name == 'schedule' }} app-name: vectorcraft app-title: VectorCraft + macos-runner: macos-15 craft-fonts-ref: b076417b5880bd4154bd22f00695b1d28c6bea83 web-craft-fonts: true version: ${{ inputs.version }} From a17883546e75e8e63f115b51d8a385597e932e08 Mon Sep 17 00:00:00 2001 From: Fredrik Hallin Date: Sun, 29 Nov 2026 18:58:59 +0100 Subject: [PATCH 03/12] Release: VectorCraft v0.25.0 Ship the drawing, text, import/export and editing fixes merged since 0.24.1. --- Cargo.lock | 120 ++++++++++++++++++++++++++--------------------------- Cargo.toml | 2 +- 2 files changed, 61 insertions(+), 61 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4da7886c88..b6394fde6b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8515,7 +8515,7 @@ dependencies = [ [[package]] name = "vectorcraft" -version = "0.24.1" +version = "0.25.0" dependencies = [ "arboard", "block2 0.6.2", @@ -8559,7 +8559,7 @@ dependencies = [ [[package]] name = "vectorcraft-affinity" -version = "0.24.1" +version = "0.25.0" dependencies = [ "craft-affinity", "craft-image-codecs", @@ -8570,26 +8570,26 @@ dependencies = [ [[package]] name = "vectorcraft-apischema" -version = "0.24.1" +version = "0.25.0" dependencies = [ "serde_json", ] [[package]] name = "vectorcraft-brush" -version = "0.24.1" +version = "0.25.0" dependencies = [ "kurbo 0.13.1", "serde", "serde_json", "vectorcraft-color", "vectorcraft-doc", - "vectorcraft-geom 0.24.1", + "vectorcraft-geom 0.25.0", ] [[package]] name = "vectorcraft-cad" -version = "0.24.1" +version = "0.25.0" dependencies = [ "craft-dxf", "craft-image-codecs", @@ -8601,14 +8601,14 @@ dependencies = [ "vectorcraft-color", "vectorcraft-doc", "vectorcraft-effects", - "vectorcraft-geom 0.24.1", - "vectorcraft-pathops 0.24.1", + "vectorcraft-geom 0.25.0", + "vectorcraft-pathops 0.25.0", "vectorcraft-text", ] [[package]] name = "vectorcraft-cli" -version = "0.24.1" +version = "0.25.0" dependencies = [ "log", "objc2-core-foundation", @@ -8619,7 +8619,7 @@ dependencies = [ "vectorcraft-doc", "vectorcraft-engine", "vectorcraft-format", - "vectorcraft-geom 0.24.1", + "vectorcraft-geom 0.25.0", "vectorcraft-mcp", "vectorcraft-render", "vectorcraft-svg", @@ -8631,7 +8631,7 @@ dependencies = [ [[package]] name = "vectorcraft-color" -version = "0.24.1" +version = "0.25.0" dependencies = [ "craft-cms", "craft-color-ui", @@ -8647,7 +8647,7 @@ dependencies = [ [[package]] name = "vectorcraft-doc" -version = "0.24.1" +version = "0.25.0" dependencies = [ "chrono", "craft-image-codecs", @@ -8663,13 +8663,13 @@ dependencies = [ "thiserror 2.0.21", "tiff", "vectorcraft-color", - "vectorcraft-geom 0.24.1", + "vectorcraft-geom 0.25.0", "zune-jpeg", ] [[package]] name = "vectorcraft-effects" -version = "0.24.1" +version = "0.25.0" dependencies = [ "craft-image-codecs", "craft-svg", @@ -8679,8 +8679,8 @@ dependencies = [ "svgtypes 0.16.1", "vectorcraft-color", "vectorcraft-doc", - "vectorcraft-geom 0.24.1", - "vectorcraft-pathops 0.24.1", + "vectorcraft-geom 0.25.0", + "vectorcraft-pathops 0.25.0", "vectorcraft-plugins", "vectorcraft-text", "vectorcraft-three-d", @@ -8690,7 +8690,7 @@ dependencies = [ [[package]] name = "vectorcraft-engine" -version = "0.24.1" +version = "0.25.0" dependencies = [ "apple-native-keyring-store", "cfb", @@ -8737,10 +8737,10 @@ dependencies = [ "vectorcraft-doc", "vectorcraft-eps", "vectorcraft-format", - "vectorcraft-geom 0.24.1", + "vectorcraft-geom 0.25.0", "vectorcraft-js", "vectorcraft-metafile", - "vectorcraft-pathops 0.24.1", + "vectorcraft-pathops 0.25.0", "vectorcraft-pdf", "vectorcraft-plugins", "vectorcraft-render", @@ -8760,7 +8760,7 @@ dependencies = [ [[package]] name = "vectorcraft-eps" -version = "0.24.1" +version = "0.25.0" dependencies = [ "craft-eps", "craft-image-codecs", @@ -8781,9 +8781,9 @@ dependencies = [ "vectorcraft-doc", "vectorcraft-effects", "vectorcraft-eps", - "vectorcraft-geom 0.24.1", + "vectorcraft-geom 0.25.0", "vectorcraft-metafile", - "vectorcraft-pathops 0.24.1", + "vectorcraft-pathops 0.25.0", "vectorcraft-pdf", "vectorcraft-render", "vectorcraft-testkit", @@ -8792,7 +8792,7 @@ dependencies = [ [[package]] name = "vectorcraft-format" -version = "0.24.1" +version = "0.25.0" dependencies = [ "craft-gzip", "craft-vectorcraft-format", @@ -8804,7 +8804,7 @@ dependencies = [ "thiserror 2.0.21", "vectorcraft-brush", "vectorcraft-doc", - "vectorcraft-geom 0.24.1", + "vectorcraft-geom 0.25.0", "vectorcraft-testkit", ] @@ -8820,7 +8820,7 @@ dependencies = [ [[package]] name = "vectorcraft-geom" -version = "0.24.1" +version = "0.25.0" dependencies = [ "kurbo 0.13.1", "proptest", @@ -8831,7 +8831,7 @@ dependencies = [ [[package]] name = "vectorcraft-js" -version = "0.24.1" +version = "0.25.0" dependencies = [ "chrono", "craft-xml", @@ -8842,7 +8842,7 @@ dependencies = [ [[package]] name = "vectorcraft-mcp" -version = "0.24.1" +version = "0.25.0" dependencies = [ "craft", "craft-image-codecs", @@ -8854,7 +8854,7 @@ dependencies = [ "vectorcraft-doc", "vectorcraft-engine", "vectorcraft-format", - "vectorcraft-geom 0.24.1", + "vectorcraft-geom 0.25.0", "vectorcraft-render", "vectorcraft-svg", "vectorcraft-testkit", @@ -8863,7 +8863,7 @@ dependencies = [ [[package]] name = "vectorcraft-metafile" -version = "0.24.1" +version = "0.25.0" dependencies = [ "craft-image-codecs", "craft-metafile", @@ -8873,7 +8873,7 @@ dependencies = [ "vectorcraft-color", "vectorcraft-doc", "vectorcraft-effects", - "vectorcraft-geom 0.24.1", + "vectorcraft-geom 0.25.0", "vectorcraft-text", ] @@ -8890,19 +8890,19 @@ dependencies = [ [[package]] name = "vectorcraft-pathops" -version = "0.24.1" +version = "0.25.0" dependencies = [ "kurbo 0.13.1", "linesweeper", "proptest", "thiserror 2.0.21", - "vectorcraft-geom 0.24.1", + "vectorcraft-geom 0.25.0", "vectorcraft-testkit", ] [[package]] name = "vectorcraft-pdf" -version = "0.24.1" +version = "0.25.0" dependencies = [ "aes 0.8.4", "chrono", @@ -8931,7 +8931,7 @@ dependencies = [ "vectorcraft-color", "vectorcraft-doc", "vectorcraft-effects", - "vectorcraft-geom 0.24.1", + "vectorcraft-geom 0.25.0", "vectorcraft-pdf", "vectorcraft-testkit", "vectorcraft-text", @@ -8939,7 +8939,7 @@ dependencies = [ [[package]] name = "vectorcraft-plugin-worker" -version = "0.24.1" +version = "0.25.0" dependencies = [ "js-sys", "vectorcraft-plugins", @@ -8949,7 +8949,7 @@ dependencies = [ [[package]] name = "vectorcraft-plugins" -version = "0.24.1" +version = "0.25.0" dependencies = [ "craft-image-codecs", "craft-vectorcraft-format", @@ -8961,7 +8961,7 @@ dependencies = [ "thiserror 2.0.21", "vectorcraft-color", "vectorcraft-doc", - "vectorcraft-geom 0.24.1", + "vectorcraft-geom 0.25.0", "vectorcraft-js", "vectorcraft-plugins", "wasmi", @@ -8972,7 +8972,7 @@ dependencies = [ [[package]] name = "vectorcraft-render" -version = "0.24.1" +version = "0.25.0" dependencies = [ "craft-gif", "craft-image-codecs", @@ -8990,7 +8990,7 @@ dependencies = [ "vectorcraft-color", "vectorcraft-doc", "vectorcraft-effects", - "vectorcraft-geom 0.24.1", + "vectorcraft-geom 0.25.0", "vectorcraft-plugins", "vectorcraft-testkit", "vectorcraft-text", @@ -9003,7 +9003,7 @@ dependencies = [ [[package]] name = "vectorcraft-scriptcheck" -version = "0.24.1" +version = "0.25.0" dependencies = [ "proptest", "unicode-properties", @@ -9011,7 +9011,7 @@ dependencies = [ [[package]] name = "vectorcraft-svg" -version = "0.24.1" +version = "0.25.0" dependencies = [ "craft-docpath", "craft-image-codecs", @@ -9035,15 +9035,15 @@ dependencies = [ "vectorcraft-color", "vectorcraft-doc", "vectorcraft-effects", - "vectorcraft-geom 0.24.1", - "vectorcraft-pathops 0.24.1", + "vectorcraft-geom 0.25.0", + "vectorcraft-pathops 0.25.0", "vectorcraft-testkit", "vectorcraft-text", ] [[package]] name = "vectorcraft-testkit" -version = "0.24.1" +version = "0.25.0" dependencies = [ "craft-image-codecs", "fax", @@ -9054,14 +9054,14 @@ dependencies = [ "vectorcraft-doc", "vectorcraft-engine", "vectorcraft-format", - "vectorcraft-geom 0.24.1", + "vectorcraft-geom 0.25.0", "vectorcraft-render", "vectorcraft-svg", ] [[package]] name = "vectorcraft-text" -version = "0.24.1" +version = "0.25.0" dependencies = [ "craft", "craft-fonts-build", @@ -9079,23 +9079,23 @@ dependencies = [ "unicode-script", "unicode-segmentation", "vectorcraft-doc", - "vectorcraft-geom 0.24.1", + "vectorcraft-geom 0.25.0", "vello_cpu", "write-fonts", ] [[package]] name = "vectorcraft-three-d" -version = "0.24.1" +version = "0.25.0" dependencies = [ "proptest", - "vectorcraft-geom 0.24.1", - "vectorcraft-pathops 0.24.1", + "vectorcraft-geom 0.25.0", + "vectorcraft-pathops 0.25.0", ] [[package]] name = "vectorcraft-thumbnail-handler" -version = "0.24.1" +version = "0.25.0" dependencies = [ "png 0.18.1", "windows", @@ -9104,7 +9104,7 @@ dependencies = [ [[package]] name = "vectorcraft-tools" -version = "0.24.1" +version = "0.25.0" dependencies = [ "craft-image-codecs", "kurbo 0.13.1", @@ -9114,15 +9114,15 @@ dependencies = [ "vectorcraft-color", "vectorcraft-doc", "vectorcraft-effects", - "vectorcraft-geom 0.24.1", - "vectorcraft-pathops 0.24.1", + "vectorcraft-geom 0.25.0", + "vectorcraft-pathops 0.25.0", "vectorcraft-text", "vectorcraft-tools", ] [[package]] name = "vectorcraft-trace" -version = "0.24.1" +version = "0.25.0" dependencies = [ "craft-image-codecs", "image", @@ -9130,12 +9130,12 @@ dependencies = [ "serde", "serde_json", "thiserror 2.0.21", - "vectorcraft-geom 0.24.1", + "vectorcraft-geom 0.25.0", ] [[package]] name = "vectorcraft-ui-egui" -version = "0.24.1" +version = "0.25.0" dependencies = [ "bytemuck", "chrono", @@ -9159,7 +9159,7 @@ dependencies = [ "vectorcraft-engine", "vectorcraft-eps", "vectorcraft-format", - "vectorcraft-geom 0.24.1", + "vectorcraft-geom 0.25.0", "vectorcraft-pdf", "vectorcraft-plugins", "vectorcraft-render", @@ -9174,7 +9174,7 @@ dependencies = [ [[package]] name = "vectorcraft-web" -version = "0.24.1" +version = "0.25.0" dependencies = [ "craft", "craft-web-api", @@ -10403,7 +10403,7 @@ checksum = "9440ea3e5aeabb0ac63af70daf835274065238cdd0cec83418f417eae38bacee" [[package]] name = "xtask" -version = "0.24.1" +version = "0.25.0" dependencies = [ "serde_json", ] diff --git a/Cargo.toml b/Cargo.toml index d3057fb0af..1a611b41e1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ members = ["crates/*", "apps/*", "xtask"] default-members = ["crates/*", "apps/vectorcraft", "apps/vectorcraft-cli", "xtask"] [workspace.package] -version = "0.24.1" +version = "0.25.0" edition = "2024" license = "MIT OR Apache-2.0" rust-version = "1.95" From c31cef119901acf0df8201107d1734f5109c9d55 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 10:12:18 -0800 Subject: [PATCH 04/12] Tools: the controls under the tools scroll with them in a short window In a window too short for every tool, the Tools panel kept its paint chips, drawing modes and the other controls under the tools pinned at the bottom, so fewer tools were in view. The controls now scroll with the tools (ToolRail::footer_scrolls): in a window 560 points tall the rail shows 14 tools instead of 10, and scrolling to the end brings the controls into view under the last tool. Toolbars made with New Toolbar and torn-off strips keep their footer in view. --- crates/ui-egui/src/toolbar.rs | 4 +++ crates/ui-egui/src/toolbar/tests.rs | 49 ++++++++++++++++++++++++++--- 2 files changed, 48 insertions(+), 5 deletions(-) diff --git a/crates/ui-egui/src/toolbar.rs b/crates/ui-egui/src/toolbar.rs index 6f2f72d06a..65c1aadc35 100644 --- a/crates/ui-egui/src/toolbar.rs +++ b/crates/ui-egui/src/toolbar.rs @@ -456,6 +456,10 @@ fn show_rail(app: &mut VectorcraftApp, ui: &mut Ui, owner: Owner, at: GroupAt, m if app.session.prefs.tool_group_labels { rail = rail.captions(); } + // The Tools panel's controls under the tools scroll with them, so a short window shows more tools. + if tools_panel { + rail = rail.footer_scrolls(); + } if own_bar { rail = rail.tear_off().edit_toolbar(tl!("Edit Toolbar")); } diff --git a/crates/ui-egui/src/toolbar/tests.rs b/crates/ui-egui/src/toolbar/tests.rs index 9ce6cca2e6..75dfeb327c 100644 --- a/crates/ui-egui/src/toolbar/tests.rs +++ b/crates/ui-egui/src/toolbar/tests.rs @@ -282,17 +282,18 @@ fn polygon_and_star_canvas_counts_persist_without_new_toolbar_dialogs() { /// The paint chips, drawing modes and the rest of the footer lie inside the rail at one and at two columns (one column /// shows the current drawing mode alone), and in two columns the three drawing modes sit side by side, each setting -/// its mode (#1129). +/// its mode (#1129). The window is tall enough for every tool and the controls under them, which scroll with the tools. #[test] fn the_paint_and_drawing_mode_buttons_fit_the_toolbar_width() { let mut app = app_with(200, 200); let ctx = reader(); + let height = 2000.0; let footer = ["Color (, or Shift+,)", "Gradient (. or Shift+.)", "None (/)", "Draw Normal (Shift+D)", "Draw Behind (Shift+D)", "Draw Inside (Shift+D)"]; let mut nodes = vec![]; for (k, double) in [false, true].into_iter().enumerate() { app.run("window.toolbarColumns", json!({ "double": double })).unwrap(); - nodes = settled(&mut app, &ctx, k as f64 * 10.0, 900.0); + nodes = settled(&mut app, &ctx, k as f64 * 10.0, height); // The rail itself, not its dock grip, which is named for the pane too. let rail = nodes.iter().find(|n| n.role() == Role::Toolbar && n.label() == Some("Tools")).and_then(bounds).expect("the rail is drawn"); for label in &footer[..if double { 6 } else { 4 }] { @@ -302,13 +303,12 @@ fn the_paint_and_drawing_mode_buttons_fit_the_toolbar_width() { } let modes = ["Draw Normal (Shift+D)", "Draw Behind (Shift+D)", "Draw Inside (Shift+D)"].map(|label| named_rect(&nodes, label)); assert!(modes.iter().all(|r| (r.top() - modes[0].top()).abs() < 0.5), "side by side: {modes:?}"); - click(&mut app, &ctx, 20.0, modes[1].center(), 900.0); + click(&mut app, &ctx, 20.0, modes[1].center(), height); assert_eq!(app.session.draw_mode, vectorcraft_engine::DrawMode::Behind); } /// In one column the Color, Gradient and None chips share one line, and a rule across the rail parts the controls under -/// the tools from the tools, which scroll above them in a short rail: it lies between the last tool and Fill and -/// Stroke. +/// the tools from the tools: it lies between the last tool and Fill and Stroke. #[test] fn the_controls_under_the_tools_share_a_line_under_a_rule() { let mut app = app_with(200, 200); @@ -604,3 +604,42 @@ fn a_short_tools_rail_shows_its_scroll_bar_at_rest() { assert!(bars(&mut app, 0.0, 400.0) > 0, "a short rail shows its scroll bar with the pointer away"); assert_eq!(bars(&mut app, 10.0, 2000.0), 0, "a rail with room for every tool shows no scroll bar"); } + +/// In a window too short for the Tools panel, the controls under the tools scroll with them: the tool buttons fill +/// the rail down to its bottom edge, Fill and Stroke starts out of view under them, and scrolling to the end brings +/// Fill and Stroke into view under the last tool. +#[test] +fn the_tools_panel_controls_scroll_with_the_tools_in_a_short_window() { + let mut app = app_with(200, 200); + let ctx = reader(); + app.run("window.toolbarColumns", json!({ "double": false })).unwrap(); + let height = 560.0; + let nodes = settled(&mut app, &ctx, 0.0, height); + let rail = nodes.iter().find(|n| n.role() == Role::Toolbar && n.label() == Some("Tools")).and_then(bounds).expect("the rail is drawn"); + let tools = cells(&app, &nodes); + let in_view: Vec<&egui::Rect> = tools.iter().filter(|r| r.bottom() <= rail.bottom() + 0.5).collect(); + assert!(in_view.len() < tools.len(), "the window is too short for every tool: {} of {}", in_view.len(), tools.len()); + let pitch = tools[1].top() - tools[0].top(); + let lowest = in_view.iter().map(|r| r.bottom()).fold(f32::MIN, f32::max); + let bottom = rail.bottom(); + assert!(bottom - lowest < pitch, "the tools fill the rail to its bottom: the last in view ends at {lowest}, the rail at {bottom}"); + let proxy = named_rect(&nodes, "Fill and Stroke"); + assert!(proxy.top() >= rail.bottom() - 0.5, "Fill and Stroke starts out of view: {proxy:?} under {rail:?}"); + + let wheel = Event::MouseWheel { + unit: egui::MouseWheelUnit::Point, + delta: egui::vec2(0.0, -400.0), + modifiers: Default::default(), + phase: egui::TouchPhase::Move, + source: egui::MouseWheelSource::Unknown, + }; + let over = tools[0].center(); + for k in 0..10 { + frame(&mut app, &ctx, 1.0 + f64::from(k) * 0.05, vec![Event::PointerMoved(over), wheel.clone()], height); + } + let nodes = settled(&mut app, &ctx, 2.0, height); + let proxy = named_rect(&nodes, "Fill and Stroke"); + let last = cells(&app, &nodes).into_iter().max_by(|a, b| a.bottom().total_cmp(&b.bottom())).expect("the rail shows tools"); + assert!(proxy.bottom() <= rail.bottom() + 0.5, "Fill and Stroke is in view after scrolling: {proxy:?} in {rail:?}"); + assert!(last.bottom() <= proxy.top(), "the last tool {last:?} stands above Fill and Stroke {proxy:?}"); +} From a978fd242a56161482bcc533e5aae8baa97fc426 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 10:16:00 -0800 Subject: [PATCH 05/12] Type: an edit runs each idle and typing frame once The Type tool's text part was shown in the canvas's flow, in a scope sized to the caret. While the tool edited text, every other frame ran its UI twice: the frame's layout check found the part changed and the frame was run again. The part is now shown at the caret's rect with no allocation, as the canvas's other overlays are, and each idle and typing frame runs once. --- crates/ui-egui/src/tests/lifecycle.rs | 19 +++++++++++++++++++ crates/ui-egui/src/type_editing.rs | 6 +++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/crates/ui-egui/src/tests/lifecycle.rs b/crates/ui-egui/src/tests/lifecycle.rs index 41ace0ff2d..4080427be8 100644 --- a/crates/ui-egui/src/tests/lifecycle.rs +++ b/crates/ui-egui/src/tests/lifecycle.rs @@ -245,3 +245,22 @@ fn ime_delete_surrounding_then_commit_edit_the_type_tool_once_in_order() { ime_frame(&mut app, &ctx, vec![Event::Ime(egui::ImeEvent::Commit("Q".into()))], |_| {}); assert_eq!(plain(&app, id), "abcQZ"); } + +/// While the Type tool edits text, each idle frame and each typing frame runs its UI once: the text part measures the +/// same in the measuring run and the real run, so no frame is discarded and run again. +#[test] +fn an_edit_runs_each_idle_and_typing_frame_once() { + let (mut app, id) = app_with_text("abc"); + let ctx = crate::testing::ui_context(); + ime_frame(&mut app, &ctx, vec![], |_| {}); + ime_frame(&mut app, &ctx, vec![], |_| {}); + begin_typing(&mut app, &ctx, id); + for _ in 0..3 { + ime_frame(&mut app, &ctx, vec![], |_| {}); + } + let idle: Vec = (0..6).map(|_| run_frame(&mut app, &ctx, vec![], |_| {}, false).0).collect(); + assert_eq!(idle, [1; 6], "each idle frame of the edit runs one pass"); + let typing: Vec = (0..6).map(|_| run_frame(&mut app, &ctx, vec![Event::Text("x".into())], |_| {}, false).0).collect(); + assert_eq!(typing, [1; 6], "each typing frame runs one pass"); + assert!(plain(&app, id).contains("xxxxxx"), "every frame's typing reached the text"); +} diff --git a/crates/ui-egui/src/type_editing.rs b/crates/ui-egui/src/type_editing.rs index 8ee26749a2..878d1d757e 100644 --- a/crates/ui-egui/src/type_editing.rs +++ b/crates/ui-egui/src/type_editing.rs @@ -486,7 +486,8 @@ impl Component for TypeEditor<'_> { } /// Shows the editor part over the Type tool's caret while the tool edits text, before the tool host; returns the part's -/// id. A new edit target is a new IME owner, so a reloaded document interrupts its composition. +/// id. A new edit target is a new IME owner, so a reloaded document interrupts its composition. The part is shown at +/// the caret's rect and takes no room in the canvas's flow, as the canvas's other overlays are. pub(crate) fn show(app: &mut VectorcraftApp, ui: &mut egui::Ui) -> Option { if !app.session.tool_wants_text() || app.viewport_hidden(ui.ctx()) { return None; @@ -496,8 +497,7 @@ pub(crate) fn show(app: &mut VectorcraftApp, ui: &mut egui::Ui) -> Option Date: Sun, 29 Nov 2026 10:54:58 -0800 Subject: [PATCH 06/12] Tests: Save options radios start in the control column The craft-libs pin on main includes craft-libs#4231, which starts a radio row's options past the form's label column. A new test checks that in the EPS and .ai save options dialogs the All and Range radios start where the artboard check box starts, and that Transparent and Opaque start where the Preview menu starts. With the craft-libs rev pinned before #4231 it fails: All starts at x 526 and the check box at x 619. --- .../ui-egui/src/dialogs/save_options/tests.rs | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/crates/ui-egui/src/dialogs/save_options/tests.rs b/crates/ui-egui/src/dialogs/save_options/tests.rs index 750e5b1130..666f094e60 100644 --- a/crates/ui-egui/src/dialogs/save_options/tests.rs +++ b/crates/ui-egui/src/dialogs/save_options/tests.rs @@ -568,6 +568,31 @@ fn save_options_radios_have_no_empty_caption_over_them() { } } +/// The All and Range radios start where the artboard check box above them starts, in the control column past the +/// captions, and EPS's Transparent and Opaque radios start where the Preview menu starts. +#[test] +fn save_options_radios_start_in_the_control_column() { + for (picked, check) in [("art.eps", "Use Artboards"), ("art.ai", "Save each artboard to a separate file")] { + let (mut app, _, _) = desktop(picked); + save_as(&mut app, "file.saveAs"); + let controls = labelled_controls(&mut app); + let (check, all, range) = (control(&controls, check), control(&controls, "All"), control(&controls, "Range:")); + assert!((all.left() - check.left()).abs() < 1.0, "{picked}: All at {all:?}, the check box at {check:?}"); + assert!((range.left() - check.left()).abs() < 1.0, "{picked}: Range at {range:?}, the check box at {check:?}"); + if picked == "art.eps" { + let (transparent, opaque) = (control(&controls, "Transparent"), control(&controls, "Opaque")); + let preview = controls + .iter() + .filter(|(l, r)| l.trim_end_matches(':') == "Preview" && r.bottom() <= transparent.top()) + .map(|(_, r)| *r) + .max_by(|a, b| a.bottom().total_cmp(&b.bottom())) + .expect("the Preview menu above Transparent"); + assert!((transparent.left() - preview.left()).abs() < 1.0, "Transparent at {transparent:?}, Preview at {preview:?}"); + assert!((opaque.left() - preview.left()).abs() < 1.0, "Opaque at {opaque:?}, Preview at {preview:?}"); + } + } +} + #[test] fn a_native_save_options_draft_cannot_redirect_its_path_to_another_drawing() { let (mut app, written, _) = desktop("original.vectorcraft"); From 9f7501a8f6bf523351ef7b6232994da64ea1a31a Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 11:24:48 -0800 Subject: [PATCH 07/12] Status bar: scrolling the view no longer lays out the zoom and artboard controls again The status bar's Zoom field, Zoom Presets menu, Rotation menu and artboard navigator were one memoized view keyed on the whole canvas view, so every frame of a wheel pan changed the key and ran all four again. The Zoom field reads only the view's zoom, and the status bar reads only the zoom of the view the field commits. - The Zoom field and Zoom Presets menu are their own memoized view, keyed on the zoom instead of the canvas view, so a pan replays them. - The Rotation menu and the artboard navigator are a second memoized view, so a zoom change runs only the zoom controls. The new test counts the runs of each view over ten pan frames and four zoom changes; before the change the pan ran the navigation controls ten times. --- crates/ui-egui/src/chrome/status_bar.rs | 130 +++++++++++++++--------- 1 file changed, 84 insertions(+), 46 deletions(-) diff --git a/crates/ui-egui/src/chrome/status_bar.rs b/crates/ui-egui/src/chrome/status_bar.rs index 1a3df7737b..b7446defb4 100644 --- a/crates/ui-egui/src/chrome/status_bar.rs +++ b/crates/ui-egui/src/chrome/status_bar.rs @@ -1,5 +1,5 @@ use super::{ROTATE_VIEW_ANGLES, Ui, VectorcraftApp, json}; -use craft::behavior::kurbo::Size; +use craft::behavior::kurbo::{Point, Size}; use craft::behavior::{CanvasView, IconId}; use craft::ui::bars::{Bar, BarKind, StatusMessage, StatusProgress}; use craft::ui::buttons::{Button, IconButton}; @@ -31,7 +31,7 @@ pub fn status_bar(app: &mut VectorcraftApp, ui: &mut Ui) { let view = app.view(); let rotation = view.map_or(0.0, |v| v.rotation); let lang = crate::i18n::current(); - let canvas_view = app.canvas_view(); + let canvas_zoom = app.canvas_view().map(|v| v.zoom); // PLAN: assumed Artboard::rect has `width()` and `height()`. let document = st.and_then(|d| d.doc.artboards.get(cur)).map_or(Size::new(1.0, 1.0), |a| Size::new(a.rect.width(), a.rect.height())); let scaling = app.ui_scaling(); @@ -92,21 +92,10 @@ pub fn status_bar(app: &mut VectorcraftApp, ui: &mut Ui) { }; // PLAN: assumed VectorcraftApp::canvas_view() -> Option (cv.S4) and the label msgid "Status Bar". Bar::new(tl!("Status Bar"), BarKind::Status).trailing(readouts).show(ui, |ui, _| { - let navigation = Navigation { - view: canvas_view, - document, - scaling, - print, - shown_zoom, - has_view: view.is_some(), - turned, - degrees, - cur, - revision, - artboards, - lang, - picked: Outbox::new(&mut picks), - }; + let zoom = + ZoomControls { zoom: canvas_zoom, document, scaling, print, shown_zoom, has_view: view.is_some(), lang, picked: Outbox::new(&mut picks) }; + let _ = MemoView::new("status-bar-zoom", zoom, show_zoom).show(ui); + let navigation = Navigation { has_view: view.is_some(), turned, degrees, cur, revision, artboards, lang, picked: Outbox::new(&mut picks) }; let _ = MemoView::new("status-bar-navigation", navigation, show_navigation).show(ui); Divider::vertical().show(ui); // An empty readout shows a dash. @@ -187,13 +176,12 @@ pub fn status_bar(app: &mut VectorcraftApp, ui: &mut Ui) { } } -/// What the status bar's navigation controls read: the Zoom field, the Rotation menu and the artboard navigator. The -/// bar replays them while these hold still and nothing reaches them (`MemoView`), as most frames only move the -/// readouts. +/// What the status bar's Zoom field and Zoom Presets menu read. The bar replays them while these hold still and +/// nothing reaches them (`MemoView`). The canvas view's center is not among them, so a pan replays them. #[derive(MemoProps)] -struct Navigation<'a> { - /// The canvas view the Zoom field shows and edits. - view: Option, +struct ZoomControls<'a> { + /// The canvas view's zoom (`CanvasView::zoom`), which the Zoom field shows and edits. + zoom: Option, /// The size of the artboard the navigator shows, which the Zoom field fits. document: Size, /// UI Scaling, which divides the canvas view's zoom. @@ -202,6 +190,45 @@ struct Navigation<'a> { print: Option, /// The view's zoom percentage, which the Zoom Presets menu checks. shown_zoom: Option, + /// Whether the active document has a view to zoom. + has_view: bool, + #[memo_props(hash = "an interface language: an index into the languages offered")] + lang: crate::i18n::Lang, + /// What the controls chose in the pass. + picked: Outbox<'a, NavigationPick>, +} + +/// The Zoom field and the Zoom Presets menu of the status bar, from [`ZoomControls`]. +fn show_zoom(p: &mut ZoomControls<'_>, ui: &mut Ui) { + #[cfg(test)] + tests::ZOOM_RUNS.with(|n| n.set(n.get() + 1)); + // The field reads only the view's zoom, and the bar reads only the zoom of the view it commits. + let view = p.zoom.map(|zoom| CanvasView::new(egui::Rect::ZERO, Point::ZERO, zoom)); + let document = p.document; + let zoom = Field::new(tl!("Zoom")) + .side(SideLabel::new().kind(LabelKind::Hidden)) + .show(ui, |ui, _| ZoomField::new(tl!("Zoom"), view, document).scrub(true).status_bar().show(ui)); + // The field edits the canvas view, whose zoom is divided by UI Scaling; `view.setZoom` takes the view's zoom. + if let Some(zoom) = zoom.inner { + if let Some(view) = zoom.view.committed() { + let percent = crate::state::zoom_display_percent(crate::state::View::zoom_of_canvas(view, p.scaling), p.print); + p.picked.send(NavigationPick::Zoom(percent)); + } + if let Some(invalid) = zoom.invalid_zoom { + p.picked.send(NavigationPick::InvalidZoom(invalid.message(&Env::of(ui)))); + } + } + let presets = zoom_presets(p.shown_zoom, p.print); + let open_presets = IconButton::new(IconId::new("chevron_down")).label(tl!("Zoom Presets")).enabled(p.has_view).show(ui); + if let Some(preset) = Menu::new(tl!("Zoom Presets")).values().opened_by(open_presets.response(), Trigger::Press).pick(ui, &presets).picked { + p.picked.send(NavigationPick::Preset(preset)); + } +} + +/// What the status bar's Rotation menu and artboard navigator read. The bar replays them while these hold still and +/// nothing reaches them (`MemoView`), as most frames only move the readouts, and a pan or a zoom leaves them alone. +#[derive(MemoProps)] +struct Navigation<'a> { /// Whether the active document has a view to turn. has_view: bool, /// The Rotate View preset the view is turned to, else `usize::MAX`. @@ -234,29 +261,10 @@ enum NavigationPick { Artboard(serde_json::Value), } -/// The Zoom field, the Rotation menu and the artboard navigator of the status bar, from [`Navigation`]. +/// The Rotation menu and the artboard navigator of the status bar, from [`Navigation`]. fn show_navigation(p: &mut Navigation<'_>, ui: &mut Ui) { #[cfg(test)] tests::NAVIGATION_RUNS.with(|n| n.set(n.get() + 1)); - let (view, document) = (p.view, p.document); - let zoom = Field::new(tl!("Zoom")) - .side(SideLabel::new().kind(LabelKind::Hidden)) - .show(ui, |ui, _| ZoomField::new(tl!("Zoom"), view, document).scrub(true).status_bar().show(ui)); - // The field edits the canvas view, whose zoom is divided by UI Scaling; `view.setZoom` takes the view's zoom. - if let Some(zoom) = zoom.inner { - if let Some(view) = zoom.view.committed() { - let percent = crate::state::zoom_display_percent(crate::state::View::zoom_of_canvas(view, p.scaling), p.print); - p.picked.send(NavigationPick::Zoom(percent)); - } - if let Some(invalid) = zoom.invalid_zoom { - p.picked.send(NavigationPick::InvalidZoom(invalid.message(&Env::of(ui)))); - } - } - let presets = zoom_presets(p.shown_zoom, p.print); - let open_presets = IconButton::new(IconId::new("chevron_down")).label(tl!("Zoom Presets")).enabled(p.has_view).show(ui); - if let Some(preset) = Menu::new(tl!("Zoom Presets")).values().opened_by(open_presets.response(), Trigger::Press).pick(ui, &presets).picked { - p.picked.send(NavigationPick::Preset(preset)); - } let angles: Vec> = ROTATE_VIEW_ANGLES.iter().enumerate().map(|(i, (label, _))| Entry::new(i, *label)).collect(); let (turned, angle, has_view) = (p.turned, format!("{}°", p.degrees), p.has_view); let mut rotate_to = None; @@ -388,13 +396,15 @@ mod tests { thread_local! { /// How many times this thread ran the status bar's navigation controls ([`show_navigation`]). pub(super) static NAVIGATION_RUNS: std::cell::Cell = const { std::cell::Cell::new(0) }; + /// How many times this thread ran the status bar's Zoom field and Zoom Presets menu ([`show_zoom`]). + pub(super) static ZOOM_RUNS: std::cell::Cell = const { std::cell::Cell::new(0) }; } - /// Frames that change nothing the navigation controls show replay them instead of laying them out again; a new - /// zoom or a new artboard runs them once, and they show it. + /// Frames that change nothing the zoom and navigation controls show replay them instead of laying them out again; + /// a new zoom or a new artboard runs them once, and they show it. #[test] fn idle_frames_replay_the_navigation_controls() { - let runs = || NAVIGATION_RUNS.with(std::cell::Cell::get); + let runs = || ZOOM_RUNS.with(std::cell::Cell::get) + NAVIGATION_RUNS.with(std::cell::Cell::get); let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default()); app.run("file.new", json!({"width": 300, "height": 200})).unwrap(); app.view_mut().unwrap().rect = egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(600.0, 400.0)); @@ -423,6 +433,34 @@ mod tests { assert!(panel.enabled("Next Artboard") || panel.enabled("Previous Artboard"), "the navigator counts the new artboard"); } + /// Scrolling the view moves its center and nothing the navigation controls show, so frames of a wheel pan replay + /// them; a new zoom runs only the Zoom field and its presets, not the Rotation menu and the artboard navigator. + #[test] + fn wheel_frames_run_only_the_controls_that_show_what_changed() { + let runs = || (ZOOM_RUNS.with(std::cell::Cell::get), NAVIGATION_RUNS.with(std::cell::Cell::get)); + let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default()); + app.run("file.new", json!({"width": 300, "height": 200})).unwrap(); + app.view_mut().unwrap().rect = egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(600.0, 400.0)); + let mut panel = Panel::new(app, status_bar); + panel.room(egui::vec2(1200.0, 300.0)); + panel.frame(); + panel.frame(); + let before = runs(); + for i in 0..10 { + panel.app().view_mut().unwrap().center.y += if i % 2 == 0 { 40.0 } else { -25.0 }; + panel.frame(); + } + assert_eq!(runs(), before, "a pan runs neither the zoom controls nor the navigation controls"); + for i in 0..4 { + panel.app().run("view.setZoom", json!({"zoom": 150 + 25 * i})).unwrap(); + panel.frame(); + } + let after = runs(); + assert!(after.0 > before.0, "a new zoom runs the zoom controls"); + assert_eq!(after.1, before.1, "a new zoom does not run the Rotation menu and the artboard navigator"); + assert_eq!(panel.value("Zoom").as_deref(), Some("225%"), "the field shows the last zoom"); + } + #[test] fn the_zoom_presets_menu_sets_a_stop_and_fits_the_view() { let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default()); From da9c3947e250e87b0ce3138b3c8971748e56dd10 Mon Sep 17 00:00:00 2001 From: ".CooCoo" Date: Sun, 29 Nov 2026 11:34:41 -0800 Subject: [PATCH 08/12] Dialogs: style options dialogs keep their tab through the framework (#10109) craft-libs 186a229c8d holds storytold/craft-libs#4261, so a properties dialog keeps its bound tab when a measuring frame ends before its body runs. The style_dialog! wrapper no longer saves and restores the tab around that frame for Character Style Options, Paragraph Style Options and New Character Style or New Paragraph Style. New tests open Character Style Options on Advanced Character Formats, New Character Style on Character Color, and Document Setup on Transparency, Type and Color, and check that each tab is still shown after the first frames. With craft-libs before that change they fail with the dialog back on General. --- .../ui-egui/src/dialogs/char_style_options.rs | 10 +----- .../src/dialogs/char_style_options/tests.rs | 32 +++++++++++++++++++ crates/ui-egui/src/dialogs/document_setup.rs | 28 ++++++++++++++++ 3 files changed, 61 insertions(+), 9 deletions(-) diff --git a/crates/ui-egui/src/dialogs/char_style_options.rs b/crates/ui-egui/src/dialogs/char_style_options.rs index 3e8a78a618..584964e0c4 100644 --- a/crates/ui-egui/src/dialogs/char_style_options.rs +++ b/crates/ui-egui/src/dialogs/char_style_options.rs @@ -1126,15 +1126,7 @@ macro_rules! style_dialog { } fn show(&mut self, ui: &mut egui::Ui, stack: &craft::ui::dialog::DialogStack) -> Option> { - // A measuring run can end without running the dialog's body and then sets the first tab as the - // shown one. The dialog keeps the tab that was shown before that run. - let measuring = craft::ui::runtime::measure::active(ui.ctx()); - let tab = self.inner.tab(); - let shown = craft::ui::dialog::StackDialog::show(&mut self.inner, ui, stack); - if measuring && self.inner.tab() != tab { - let _ = craft::ui::dialog::StackDialog::set_json_field(&mut self.inner, ui.ctx(), "tab", serde_json::json!(tab)); - } - shown + craft::ui::dialog::StackDialog::show(&mut self.inner, ui, stack) } fn key(&self) -> Option<&str> { diff --git a/crates/ui-egui/src/dialogs/char_style_options/tests.rs b/crates/ui-egui/src/dialogs/char_style_options/tests.rs index 258d925608..c779f4a9f6 100644 --- a/crates/ui-egui/src/dialogs/char_style_options/tests.rs +++ b/crates/ui-egui/src/dialogs/char_style_options/tests.rs @@ -1079,6 +1079,38 @@ fn new_character_style_refuses_size_and_leading_errors_at_ok() { } } +/// Character Style Options and New Character Style opened on a tab other than General still show that tab after +/// their first frames, which measure the dialog before its body runs. +#[test] +fn a_style_dialog_opened_on_a_later_tab_keeps_it_through_its_first_frames() { + use egui::{Pos2, RawInput, Rect, vec2}; + + let mut app = app(); + app.run("charStyle.new", json!({"name": "Body", "attrs": {}})).unwrap(); + let ctx = app.ui_ctx.clone().unwrap(); + let screen = Rect::from_min_size(Pos2::ZERO, vec2(800.0, 500.0)); + let mut time = 0.0; + let mut frame = |app: &mut VectorcraftApp| { + time += 0.25; + crate::testing::app_frame(app, &ctx, RawInput { time: Some(time), screen_rect: Some(screen), ..Default::default() }); + }; + frame(&mut app); + open(&mut app, "Body"); + set::(&app, "tab", json!("advanced")); + for _ in 0..5 { + frame(&mut app); + } + assert_eq!(fields::(&app)["tab"], json!("advanced"), "Character Style Options left Advanced Character Formats"); + cancel::(&mut app); + + app.run("ui.newCharStyle", json!({})).unwrap(); + set::(&app, "tab", json!("color")); + for _ in 0..5 { + frame(&mut app); + } + assert_eq!(fields::(&app)["tab"], json!("color"), "New Character Style left Character Color"); +} + #[test] fn invalid_number_keeps_last_valid_preview() { let mut app = app(); diff --git a/crates/ui-egui/src/dialogs/document_setup.rs b/crates/ui-egui/src/dialogs/document_setup.rs index 94ff0e8339..c82a6f76d5 100644 --- a/crates/ui-egui/src/dialogs/document_setup.rs +++ b/crates/ui-egui/src/dialogs/document_setup.rs @@ -907,6 +907,34 @@ mod tests { assert!(st.history.undo.is_empty()); } + /// Document Setup opened on a tab other than General still shows that tab after its first frames, which + /// measure the dialog before its body runs. + #[test] + fn a_later_tab_picked_before_the_first_frame_stays_shown() { + for tab in ["Transparency", "Type", "Color"] { + let mut app = crate::testing::windowed(VectorcraftApp::new(Session::new(), Default::default())); + app.run("file.new", json!({"width": 200, "height": 200})).unwrap(); + let ctx = app.ui_ctx.clone().unwrap(); + let screen = Rect::from_min_size(Pos2::ZERO, vec2(1200.0, 900.0)); + let mut time = 0.0; + let mut frame = |app: &mut VectorcraftApp| { + time += 0.25; + crate::testing::app_frame(app, &ctx, egui::RawInput { time: Some(time), screen_rect: Some(screen), ..Default::default() }); + }; + frame(&mut app); + app.run("file.documentSetup", json!({})).unwrap(); + set(&app, &ctx, "tab", json!(tab)); + for _ in 0..5 { + frame(&mut app); + } + let shown = app.dialogs().unwrap().with(|h| { + use craft::ui::dialog::StackDialog as _; + h.get_by_id::(id()).and_then(|d| d.json_fields()) + }); + assert_eq!(shown.map(|f| f["tab"].clone()), Some(json!(tab)), "Document Setup left {tab}"); + } + } + #[test] fn every_tab_draws_and_ok_is_one_undo_step() { let (mut app, ctx) = setup_open(); From 3617039ef5c2b953e2f6e028a1d4cc88c680fc22 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 11:36:48 -0800 Subject: [PATCH 09/12] Global Edit: the canvas shares the kept outlines instead of copying them each frame With one object selected and the Selection tool active, or while Global Edit is on, every frame copied each highlighted outline out of the kept list and made one overlay per object, which the canvas flattened and stroked again. With 10,000 matching objects that was most of a 27 ms frame. highlights and similar now return the kept outlines as a shared Highlights, grouped by layer color with a revision that changes only when the outlines are found again. The session sends one Overlay::Outlines per color, and the canvas shows it as a SelectionOutline keyed by that revision, so the lines are stroked again only when the outlines or the view change. --- crates/engine/src/cmd/globaledit.rs | 65 ++++++++++++++++++++++----- crates/engine/src/tests/globaledit.rs | 42 +++++++++++++++-- crates/engine/src/tooling.rs | 9 ++-- crates/tools/src/lib.rs | 5 +++ crates/ui-egui/src/canvas/overlays.rs | 10 ++++- crates/ui-egui/src/canvas/tests.rs | 24 ++++++++++ 6 files changed, 136 insertions(+), 19 deletions(-) diff --git a/crates/engine/src/cmd/globaledit.rs b/crates/engine/src/cmd/globaledit.rs index 4f498e972a..cecf216b24 100644 --- a/crates/engine/src/cmd/globaledit.rs +++ b/crates/engine/src/cmd/globaledit.rs @@ -194,6 +194,51 @@ impl Options { /// Outlines with their layer colours ([`highlights`]). pub type Outlines = Vec<(BezPath, [u8; 3])>; +/// The outlines [`highlights`] gives the canvas, grouped by layer color. The canvas asks every frame and gets the same +/// allocation back until the outlines are found again. +#[derive(Debug, Default, PartialEq)] +pub struct Highlights { + /// A number given to each set of outlines when it is found, and never to another set: the canvas keeps the lines + /// it stroked for these outlines while the number stays the same. + pub revision: u64, + /// The outlines in each layer color, the colors in the order of their first outline. + pub groups: Vec<([u8; 3], std::sync::Arc<[BezPath]>)>, +} + +/// The [`Highlights::revision`] the next set of outlines takes. +static NEXT_HIGHLIGHTS: std::sync::atomic::AtomicU64 = std::sync::atomic::AtomicU64::new(1); + +/// [`Highlights`] with no outline, shared so the frames that show none allocate nothing. +static NO_HIGHLIGHTS: std::sync::LazyLock> = std::sync::LazyLock::new(Default::default); + +impl Highlights { + /// `outlines` grouped by color, under a new revision. + fn new(outlines: Outlines) -> std::sync::Arc { + if outlines.is_empty() { + return NO_HIGHLIGHTS.clone(); + } + let mut groups: Vec<([u8; 3], Vec)> = vec![]; + for (path, color) in outlines { + match groups.iter_mut().find(|(c, _)| *c == color) { + Some((_, paths)) => paths.push(path), + None => groups.push((color, vec![path])), + } + } + let revision = NEXT_HIGHLIGHTS.fetch_add(1, std::sync::atomic::Ordering::Relaxed); + std::sync::Arc::new(Highlights { revision, groups: groups.into_iter().map(|(c, paths)| (c, paths.into())).collect() }) + } + + /// How many outlines there are, in every color. + pub fn len(&self) -> usize { + self.groups.iter().map(|(_, paths)| paths.len()).sum() + } + + /// Whether there is no outline. + pub fn is_empty(&self) -> bool { + self.groups.iter().all(|(_, paths)| paths.is_empty()) + } +} + /// A Global Edit in progress (per document; not saved, not an undo step). #[derive(Clone, Debug, PartialEq)] pub struct GlobalEdit { @@ -202,7 +247,7 @@ pub struct GlobalEdit { /// outline onto its own. pub members: Vec<(NodeId, Affine)>, /// [`highlights`] as of a document revision: the canvas asks every frame. - outlines: std::cell::RefCell>, + outlines: std::cell::RefCell)>>, } /// An outline reduced to its form: the anchors and handles placed in a unit box, with what tells @@ -1017,31 +1062,31 @@ fn keep_series_changes(before: &Document, d: &mut Document, edited: &[NodeId]) { /// highlights them while Global Edit is on. While it is off, with one supported object selected, /// they are the outlines of the objects Start Global Edit would take with the Global Edit Options /// ([`similar`]). -pub fn highlights(s: &Session) -> Outlines { - let Some(st) = s.active() else { return vec![] }; +pub fn highlights(s: &Session) -> std::sync::Arc { + let Some(st) = s.active() else { return NO_HIGHLIGHTS.clone() }; let Some(ge) = &st.global_edit else { return similar(s) }; if let Some((rev, out)) = &*ge.outlines.borrow() && *rev == st.revision { return out.clone(); } - let out = outlines(st, &ge.members); + let out = Highlights::new(outlines(st, &ge.members)); *ge.outlines.borrow_mut() = Some((st.revision, out.clone())); out } /// [`similar`]'s outlines as of a document revision and the options they were found with. -pub type SimilarCache = std::cell::RefCell>; +pub type SimilarCache = std::cell::RefCell)>>; /// Before Global Edit starts: with one supported object selected, the outlines of the other /// objects Start Global Edit would take now with the session's Global Edit Options, so the canvas /// shows them as soon as the object is selected. None while an interaction (a drag) is in /// progress, or when fewer than two objects would be taken. Kept per document revision and /// options, as finding them walks the whole document. -pub fn similar(s: &Session) -> Outlines { - let Some(st) = s.active() else { return vec![] }; +pub fn similar(s: &Session) -> std::sync::Arc { + let Some(st) = s.active() else { return NO_HIGHLIGHTS.clone() }; if st.global_edit.is_some() || st.interaction.is_some() || st.selection.objects.len() != 1 { - return vec![]; + return NO_HIGHLIGHTS.clone(); } let o = &s.global_edit_options; if let Some((rev, opts, out)) = &*st.similar_outlines.borrow() @@ -1050,10 +1095,10 @@ pub fn similar(s: &Session) -> Outlines { { return out.clone(); } - let out = match matches(s, o) { + let out = Highlights::new(match matches(s, o) { Ok(m) if m.len() >= 2 => outlines(st, &m), _ => vec![], - }; + }); *st.similar_outlines.borrow_mut() = Some((st.revision, o.clone(), out.clone())); out } diff --git a/crates/engine/src/tests/globaledit.rs b/crates/engine/src/tests/globaledit.rs index ae56fa7c5a..076816e994 100644 --- a/crates/engine/src/tests/globaledit.rs +++ b/crates/engine/src/tests/globaledit.rs @@ -150,7 +150,7 @@ fn after_an_edit_only_the_changed_objects_are_compared_again_from_scratch() { assert_eq!(since(before), (4, 2), "the selected object and the three edited copies, two of them still similar"); assert_eq!(shown.len(), 38, "the widened copy is another shape; the moved and the enlarged ones still match"); let moved = node(&s, copies[1]).stroke_path().unwrap(); - assert!(shown.iter().any(|(p, _)| *p == moved), "the moved copy is shown where it is now"); + assert!(shown.groups.iter().flat_map(|(_, paths)| paths.iter()).any(|p| *p == moved), "the moved copy is shown where it is now"); s.execute("select.globalEditOptions", &json!({"size": true})).unwrap(); assert_eq!(highlights(&s).len(), 37, "with Size, the enlarged copy is left out"); assert_eq!(crate::cmd::globaledit::match_count(&s), 38); @@ -162,9 +162,7 @@ fn the_canvas_highlights_similar_objects_before_the_start_with_the_selection_too let [a, b, ..] = squares(&mut s); let outline = node(&s, b).stroke_path().unwrap(); let shown = |s: &mut Session| { - s.overlays(ViewInfo::default()) - .iter() - .any(|o| matches!(o, vectorcraft_tools::Overlay::Path { path, width, .. } if *path == outline && *width == 1.0)) + s.overlays(ViewInfo::default()).iter().any(|o| matches!(o, vectorcraft_tools::Overlay::Outlines { paths, .. } if paths.contains(&outline))) }; sel(&mut s, &[a]); s.select_tool("selection", ViewInfo::default()).unwrap(); @@ -175,6 +173,42 @@ fn the_canvas_highlights_similar_objects_before_the_start_with_the_selection_too assert!(shown(&mut s), "while Global Edit is on, with any tool"); } +/// Each frame hands the canvas the kept outlines, one overlay per layer color sharing them, with no copy of a path; the +/// revision changes when the outlines are found again. +#[test] +fn every_frame_shares_the_kept_outlines_instead_of_copying_each_one() { + use std::sync::Arc; + use vectorcraft_tools::Overlay; + let outlines = |s: &mut Session| -> Vec<(Arc<[vectorcraft_geom::BezPath]>, u64)> { + s.overlays(ViewInfo::default()) + .into_iter() + .filter_map(|o| if let Overlay::Outlines { paths, revision, .. } = o { Some((paths, revision)) } else { None }) + .collect() + }; + let mut s = session(); + let key = rect(&mut s, 0.0, 0.0, 10.0, 10.0); + for i in 1..200 { + rect(&mut s, 20.0 * f64::from(i % 20), 100.0 + 20.0 * f64::from(i / 20), 10.0, 10.0); + } + sel(&mut s, &[key]); + s.select_tool("selection", ViewInfo::default()).unwrap(); + let first = outlines(&mut s); + let [(paths, revision)] = &first[..] else { panic!("one overlay for the one layer color, not one per object: {}", first.len()) }; + assert_eq!(paths.len(), 199); + let second = outlines(&mut s); + let [(again, same)] = &second[..] else { panic!("{}", second.len()) }; + assert!(Arc::ptr_eq(paths, again), "the next frame gets the same outlines, not a copy"); + assert_eq!(same, revision); + s.execute("select.globalEdit", &json!({})).unwrap(); + let on = outlines(&mut s); + let [(members, started)] = &on[..] else { panic!("{}", on.len()) }; + assert_eq!(members.len(), 199); + assert_ne!(started, revision, "outlines found again take a new revision"); + let next = outlines(&mut s); + let [(kept, still)] = &next[..] else { panic!("{}", next.len()) }; + assert!(Arc::ptr_eq(members, kept) && still == started, "and are kept from frame to frame while Global Edit is on"); +} + #[test] fn size_and_appearance_options_narrow_the_match() { let mut s = session(); diff --git a/crates/engine/src/tooling.rs b/crates/engine/src/tooling.rs index c5d2905963..422caab5ec 100644 --- a/crates/engine/src/tooling.rs +++ b/crates/engine/src/tooling.rs @@ -1478,9 +1478,12 @@ impl Session { // Global Edit: the objects edited with the selected one are highlighted; before it starts, // with the Selection tool, the objects it would take. let ge_on = self.active().is_some_and(|d| d.global_edit.is_some()); - let shown = if ge_on || self.tool.id() == "selection" { crate::cmd::globaledit::highlights(self) } else { vec![] }; - for (path, color) in shown { - v.push(Overlay::Path { path, color, width: 1.0, dashed: false }); + // One overlay per layer color, sharing the kept outlines. + if ge_on || self.tool.id() == "selection" { + let shown = crate::cmd::globaledit::highlights(self); + for (color, paths) in &shown.groups { + v.push(Overlay::Outlines { paths: paths.clone(), color: *color, revision: shown.revision }); + } } if let Some((cmd, p)) = deferred_preview { v.extend(self.deferred_preview_overlays_from_command(&cmd, &p)); diff --git a/crates/tools/src/lib.rs b/crates/tools/src/lib.rs index cfcce40bf9..7d0c17f068 100644 --- a/crates/tools/src/lib.rs +++ b/crates/tools/src/lib.rs @@ -88,6 +88,11 @@ pub enum Overlay { /// the dash pattern: the pieces of one line, each starting where the one before it ends, dash /// as the whole line does. SharedPath { path: std::sync::Arc, color: [u8; 3], width: f32, dash: Option }, + /// Thin solid outlines of many objects in one color (the objects Global Edit takes). Later calls + /// return the same `paths` with the same `revision` for as long as the outlines do not change, and + /// a new `revision` when they do. The host strokes them again only when `revision` or the view + /// changes. + Outlines { paths: std::sync::Arc<[BezPath]>, color: [u8; 3], revision: u64 }, /// A line segment (smart guide, handle line). Line { a: Point, b: Point, color: [u8; 3], dashed: bool }, /// An anchor square: filled = selected. diff --git a/crates/ui-egui/src/canvas/overlays.rs b/crates/ui-egui/src/canvas/overlays.rs index 8f9bd6f663..d1f8c469a8 100644 --- a/crates/ui-egui/src/canvas/overlays.rs +++ b/crates/ui-egui/src/canvas/overlays.rs @@ -48,7 +48,7 @@ pub(super) fn show(app: &VectorcraftApp, ui: &mut egui::Ui, space: &CanvasSpace, }); } -/// The framework control `o` stands for, if it is one: a marquee, a settled outline or a distance. +/// The framework control `o` stands for, if it is one: a marquee, a settled outline, a set of outlines or a distance. fn show_control(ui: &mut egui::Ui, rect: ScreenRect, o: &Overlay) { match o { Overlay::Marquee(r) => { @@ -65,6 +65,11 @@ fn show_control(ui: &mut egui::Ui, rect: ScreenRect, o: &Overlay) { let outline = if dash.is_some() { SelectionOutline::dashed(Label::Empty, paths) } else { SelectionOutline::solid(Label::Empty, paths) }; outline.color(data(*color)).revision(revision).show_at(ui, rect); } + Overlay::Outlines { paths, color, revision } => { + // The overlay's revision changes whenever its paths do, so the lines are stroked again only then or when + // the view changes. + SelectionOutline::solid(Label::Empty, paths).color(data(*color)).revision(*revision).show_at(ui, rect); + } Overlay::Distance { .. } => { if let Some((measure, color)) = distance_measure(o) { SmartGuides::new(&[], std::slice::from_ref(&measure)).color(color).show_at(ui, rect); @@ -180,7 +185,7 @@ impl Component for ToolMarks<'_> { } } -/// Paints the marks of `overlays` through `draw` in `view`; the marquees, shared paths and distances are controls +/// Paints the marks of `overlays` through `draw` in `view`; the marquees, shared paths, outlines and distances are controls /// of their own and paint nothing here. // PLAN: contract cv.S14 gives `paint(draw, view, overlays, options)`; the pill, ink and ring colours come from the theme, so the style goes too. fn paint(draw: &Draw<'_>, view: &CanvasView, overlays: &[Overlay], options: &PathOptionsSettings, style: &ToolMarksStyle) { @@ -244,6 +249,7 @@ fn paint(draw: &Draw<'_>, view: &CanvasView, overlays: &[Overlay], options: &Pat Overlay::Marquee(_) | Overlay::SelectionMarquee { .. } | Overlay::SharedPath { .. } + | Overlay::Outlines { .. } | Overlay::Distance { .. } | Overlay::HoverText { .. } => {} } diff --git a/crates/ui-egui/src/canvas/tests.rs b/crates/ui-egui/src/canvas/tests.rs index ae6956a288..a5fa556b8c 100644 --- a/crates/ui-egui/src/canvas/tests.rs +++ b/crates/ui-egui/src/canvas/tests.rs @@ -333,6 +333,30 @@ fn a_selection_drag_draws_its_marks_in_the_frame_the_pointer_moves() { assert!(moved >= 4, "the drag moves the object: {moved} frames"); } +/// With one rectangle selected, the canvas outlines its copies, which Start Global Edit would take, at their corners. +#[test] +fn the_canvas_outlines_the_objects_global_edit_would_take() { + let mut app = drag_app(); + let rect = |app: &mut VectorcraftApp, x: f64| { + app.session.execute("shape.rectangle", &json!({"x": x, "y": 100, "width": 40, "height": 30})).unwrap()["id"].as_u64().unwrap() + }; + let key = rect(&mut app, 20.0); + let copies = [rect(&mut app, 120.0), rect(&mut app, 220.0)]; + app.select_tool("selection"); + app.session.execute("select.set", &json!({"ids": [key]})).unwrap(); + let ctx = crate::testing::ui_context(); + frame(&mut app, &ctx, vec![]); + let xf = app.canvas_view().unwrap(); + let points = painted_points(&mut app, &ctx, vec![]); + for id in copies { + let b = app.session.active().unwrap().doc.bounds_of(&[vectorcraft_doc::NodeId(id)], false).unwrap(); + for corner in [Point::new(b.x0, b.y0), Point::new(b.x1, b.y1)] { + let at = xf.to_screen(corner); + assert!(points.iter().any(|p| p.distance(at) < 1.0), "copy {id} is outlined at {at:?}"); + } + } +} + /// A Pen drag draws the handle it pulls out in the frame the pointer moves: its end at that frame's pointer, and /// none at the pointer of the frame before. #[test] From 214c88d98536c143061b8560dff02f092afa1804 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 11:45:44 -0800 Subject: [PATCH 10/12] Tools: the controls under the tools scroll with them, as bottom_controls says The doc comment on bottom_controls still said the tools scroll above the controls in a short rail. The Tools panel's rail now uses footer_scrolls, so the controls scroll with the tools and the rail draws the rule above them. --- crates/ui-egui/src/toolbar.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/toolbar.rs b/crates/ui-egui/src/toolbar.rs index 4d58c972d7..618bace39b 100644 --- a/crates/ui-egui/src/toolbar.rs +++ b/crates/ui-egui/src/toolbar.rs @@ -772,8 +772,8 @@ fn quad_bounds(quad: &[Point; 4]) -> vectorcraft_geom::Rect { /// The Fill/Stroke proxy, Color/Gradient/None, the drawing modes and screen mode under the rail's /// tools: in two columns the three drawing modes show, in one only the current one, which cycles /// them. A row the rail is too narrow for goes on in the next line. The All Tools drawer's Show -/// section hides any of them. The rail's footer region draws the rule that parts them from the tools, which scroll -/// above it in a short rail. +/// section hides any of them. The rail draws the rule that parts them from the tools, and they scroll with the tools +/// in a short rail. fn bottom_controls(app: &mut VectorcraftApp, ui: &mut Ui, footer: RailFooter) { let two = footer.columns > 1; let show = app.ui.toolbar_show; From c3c8a0a17a78966a8417c711b25aa596308c9eb7 Mon Sep 17 00:00:00 2001 From: Codex Date: Sun, 29 Nov 2026 21:28:17 +0100 Subject: [PATCH 11/12] Pin Binaryen 133 for the web release optimizer --- apps/vectorcraft-web/Trunk.toml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/apps/vectorcraft-web/Trunk.toml b/apps/vectorcraft-web/Trunk.toml index aad9a1638f..1bb9ef3f24 100644 --- a/apps/vectorcraft-web/Trunk.toml +++ b/apps/vectorcraft-web/Trunk.toml @@ -5,6 +5,10 @@ dist = "../../dist/web" public_url = "./" filehash = true +[tools] +# Binaryen 123 crashes while optimizing the release bundle; keep the optimizer explicit. +wasm_opt = "version_133" + [serve] addresses = ["127.0.0.1"] port = 8766 From a3b93d585b3458c9296776a32fe6924c748ec3f7 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Sun, 29 Nov 2026 15:57:37 -0500 Subject: [PATCH 12/12] ci(sonarcloud): give each main commit its own concurrency group (#10126) --- .github/workflows/sonarcloud.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 4cd4eb6387..dde1f6f5a8 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -11,7 +11,7 @@ permissions: contents: read concurrency: - group: sonarcloud-${{ github.ref }} + group: ${{ github.ref == 'refs/heads/main' && format('sonarcloud-main-{0}', github.sha) || format('sonarcloud-{0}', github.ref) }} # A push to main is the run that publishes coverage; superseded runs there would never finish. cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}