From 47058f9041cfe57350ace00740656260c4cedb01 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Fri, 27 Nov 2026 15:07:53 -0800 Subject: [PATCH 1/3] Tests: wait for the Scripts and Proof Setups reads with no deadline The test helpers scripts_menu::finish and proof_setup::wait called JobQueue::finish with a 10 s deadline and ignored its result. On a busy runner a read still running on a lane past that deadline left the test reading a partial listing. Both helpers now call finish(Duration::MAX), which waits on the queue's end-of-job signal with no deadline, and assert that it finished. The test that a finished read asks for a frame waited up to 10 s for the repaint. It now installs a host whose jobs wait until the test runs them (ManualJobs), runs the lane on another thread, joins it, and then checks that the frame was asked for. --- crates/ui-egui/src/dialogs/proof_setup.rs | 4 ++-- crates/ui-egui/src/scripts_menu.rs | 4 ++-- crates/ui-egui/src/tests/scripts_menu.rs | 19 +++++++++++++------ 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/crates/ui-egui/src/dialogs/proof_setup.rs b/crates/ui-egui/src/dialogs/proof_setup.rs index cb0e6981d2..20b5b52289 100644 --- a/crates/ui-egui/src/dialogs/proof_setup.rs +++ b/crates/ui-egui/src/dialogs/proof_setup.rs @@ -469,11 +469,11 @@ fn take() { } } -/// Wait for the listing under way and take it in. +/// Wait for the listing under way, however long it takes, and take it in. #[cfg(test)] pub(crate) fn wait() { if let Some(queue) = &saved().queue { - queue.finish(std::time::Duration::from_secs(10)); + assert!(queue.finish(std::time::Duration::MAX), "the listing of the Proof Setups folder could not finish"); } take(); } diff --git a/crates/ui-egui/src/scripts_menu.rs b/crates/ui-egui/src/scripts_menu.rs index c27df08742..794fc3d0a8 100644 --- a/crates/ui-egui/src/scripts_menu.rs +++ b/crates/ui-egui/src/scripts_menu.rs @@ -200,13 +200,13 @@ fn take() { } } -/// Wait for the reads under way and take them in. +/// Wait for the reads under way, however long they take, and take them in. #[cfg(test)] pub(crate) fn finish() { { let state = state(); if let Some(queue) = &state.queue { - queue.finish(Duration::from_secs(10)); + assert!(queue.finish(Duration::MAX), "the reads of the Scripts folder could not finish"); } } take(); diff --git a/crates/ui-egui/src/tests/scripts_menu.rs b/crates/ui-egui/src/tests/scripts_menu.rs index 300e0dbb32..49e78d12d0 100644 --- a/crates/ui-egui/src/tests/scripts_menu.rs +++ b/crates/ui-egui/src/tests/scripts_menu.rs @@ -3,9 +3,8 @@ //! is gone, the notes and the reads of the folder. use std::sync::Arc; -use std::time::Duration; -use craft::host::{AppInfo, Host, ThreadJobs}; +use craft::host::{AppInfo, Host, ManualJobs, ThreadJobs}; use craft::menu::Node; use serde_json::{Value, json}; use vectorcraft_engine::Session; @@ -259,13 +258,19 @@ fn a_script_that_left_the_folder_is_not_run_and_the_folder_is_read_again() { fn the_read_after_a_script_that_left_the_folder_asks_for_a_frame() { let dir = folder("gone-frame"); let mut app = app(&dir); + // The reads' lanes wait until the test runs them, so the test knows when the read has ended. + let jobs = Arc::new(ManualJobs::new()); + let held = crate::testing::ui_context(); + Host::builder(AppInfo { id: "vectorcraft", name: "VectorCraft", version: "0" }).jobs(jobs.clone()).install(&held); + app.ui_ctx = Some(held.clone()); let gone = write(&dir, "gone.js", DRAW); - read(&app); + scripts_menu::refresh(&app, &held); + scripts_menu::finish(); std::fs::remove_file(&gone).unwrap(); let (tx, frames) = std::sync::mpsc::channel(); let test = std::thread::current().id(); // The observer sees every request; the repaint callback drops one no sooner than the first read's, still pending. - ctx().set_repaint_observer(move |_| { + held.set_repaint_observer(move |_| { // The read's lane asks from a thread of its own. if std::thread::current().id() != test { let _ = tx.send(()); @@ -274,8 +279,10 @@ fn the_read_after_a_script_that_left_the_folder_asks_for_a_frame() { assert!(menus::run_ui_command(&mut app, scripts_menu::COMMAND, &json!({ "path": gone })).unwrap().is_err()); // With the app's copy of the context dropped, only the queue's wake can still ask for a frame. app.ui_ctx = None; - let asked = frames.recv_timeout(Duration::from_secs(10)); - ctx().set_repaint_observer(|_| {}); + let lanes = Arc::clone(&jobs); + assert!(std::thread::spawn(move || lanes.run_all()).join().unwrap() > 0, "the read ran on a lane"); + let asked = frames.try_recv(); + held.set_repaint_observer(|_| {}); assert_eq!(asked, Ok(()), "the finished read asks for a frame so an idle window takes it in"); scripts_menu::finish(); let _ = std::fs::remove_dir_all(dir); From 8aa8c22633cf83bf633528ec51b4e542e9139118 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Fri, 27 Nov 2026 16:04:16 -0800 Subject: [PATCH 2/3] macOS: clippy -D warnings passes on the desktop app again `cargo clippy -p vectorcraft --all-targets -- -D warnings` failed on macOS with three dead-code errors: - `launch_profile::child_args` and `child_args_for` have one caller, `single_instance`, which is not built on macOS. They and their two tests are now `cfg(not(target_os = "macos"))`, the same as that module. - `app.rs`'s `discard_marked_text` lost its caller in #8800, where the craft UI framework took over IME routing. The framework's window layer discards the input method's marked text on macOS itself, so the app's copy is removed, along with the `NSTextInputContext` feature of `objc2-app-kit` that only it used. --- apps/vectorcraft/Cargo.toml | 2 +- apps/vectorcraft/src/app.rs | 11 ----------- apps/vectorcraft/src/launch_profile.rs | 5 +++++ 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/apps/vectorcraft/Cargo.toml b/apps/vectorcraft/Cargo.toml index bc9945e513..1c3e7f39e7 100644 --- a/apps/vectorcraft/Cargo.toml +++ b/apps/vectorcraft/Cargo.toml @@ -69,7 +69,7 @@ vectorcraft-render = { workspace = true } [target.'cfg(target_os = "macos")'.dependencies] objc2 = "0.6" -objc2-app-kit = { version = "0.3", default-features = false, features = ["std", "block2", "objc2-core-foundation", "objc2-quartz-core", "NSApplication", "NSCursor", "NSImage", "NSImageRep", "NSBitmapImageRep", "NSButton", "NSColor", "NSColorSpace", "NSControl", "NSEvent", "NSPasteboard", "NSPopUpButton", "NSResponder", "NSSavePanel", "NSScreen", "NSTextField", "NSTextInputContext", "NSView", "NSWindow"] } +objc2-app-kit = { version = "0.3", default-features = false, features = ["std", "block2", "objc2-core-foundation", "objc2-quartz-core", "NSApplication", "NSCursor", "NSImage", "NSImageRep", "NSBitmapImageRep", "NSButton", "NSColor", "NSColorSpace", "NSControl", "NSEvent", "NSPasteboard", "NSPopUpButton", "NSResponder", "NSSavePanel", "NSScreen", "NSTextField", "NSView", "NSWindow"] } # Files opened from Finder and the Dock (src/open_documents.rs) and pasted bitmaps (src/clipboard.rs); both already come with winit. objc2-foundation = { version = "0.3", default-features = false, features = ["std", "block2", "NSArray", "NSData", "NSGeometry", "NSNotification", "NSOperation", "NSProcessInfo", "NSString", "NSURL"] } block2 = "0.6" diff --git a/apps/vectorcraft/src/app.rs b/apps/vectorcraft/src/app.rs index 83d488a243..b91282e7da 100644 --- a/apps/vectorcraft/src/app.rs +++ b/apps/vectorcraft/src/app.rs @@ -243,14 +243,3 @@ pub(crate) fn open_files(app: &mut VectorcraftApp, files: Vec) { } } } - -/// Tell the macOS input method to drop its composition (the Type tool kept the marked text as -/// typed). winit's IME toggle only clears its own copy, so the IME would type it again. -#[cfg(target_os = "macos")] -fn discard_marked_text() { - if let Some(mtm) = objc2::MainThreadMarker::new() - && let Some(ic) = objc2_app_kit::NSTextInputContext::currentInputContext(mtm) - { - ic.discardMarkedText(); - } -} diff --git a/apps/vectorcraft/src/launch_profile.rs b/apps/vectorcraft/src/launch_profile.rs index 2cc32f39dd..12615dd81d 100644 --- a/apps/vectorcraft/src/launch_profile.rs +++ b/apps/vectorcraft/src/launch_profile.rs @@ -124,10 +124,13 @@ pub fn validate_root(root: &Path, env: impl Fn(&str) -> Option, exe: O /// The arguments a child of this process starts with: a nightly launch hands its profile on, so the /// child opens the same private profile instead of being refused ("Open VectorCraft Nightly…"), and /// `--` keeps a file whose name starts with '-' a file. Stable's child arguments are unchanged. +/// Only `single_instance` starts a child, and macOS does not build it. +#[cfg(not(target_os = "macos"))] pub fn child_args(files: &[String]) -> Vec { child_args_for(current(), files) } +#[cfg(not(target_os = "macos"))] fn child_args_for(profile: &Profile, files: &[String]) -> Vec { let mut args: Vec = match profile { Profile::Stable => Vec::new(), @@ -245,12 +248,14 @@ mod tests { } } + #[cfg(not(target_os = "macos"))] #[test] fn a_stable_child_gets_the_file_delimiter_only() { let child = child_args_for(&Profile::Stable, &["a file.svg".to_string(), "--looks-like-a-flag".to_string()]); assert_eq!(child, args(&["--", "a file.svg", "--looks-like-a-flag"])); } + #[cfg(not(target_os = "macos"))] #[test] fn a_nightly_child_inherits_the_selected_profile() { let root = PathBuf::from(absolute()); From ad9210bcca959467a465eddd35f2465840657a7d Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Fri, 27 Nov 2026 18:29:10 -0800 Subject: [PATCH 3/3] Restore canceled Composite Fonts sample zoom --- crates/ui-egui/src/dialogs/composite_fonts.rs | 3 +- .../src/dialogs/composite_fonts/sample.rs | 100 +++++++++++++++++- docs/mcp.md | 5 +- docs/ui-parity.md | 1 + 4 files changed, 104 insertions(+), 5 deletions(-) diff --git a/crates/ui-egui/src/dialogs/composite_fonts.rs b/crates/ui-egui/src/dialogs/composite_fonts.rs index 61bcee82b7..3ab762bfc5 100644 --- a/crates/ui-egui/src/dialogs/composite_fonts.rs +++ b/crates/ui-egui/src/dialogs/composite_fonts.rs @@ -149,7 +149,8 @@ pub struct CompositeFontsDialog { entry_mode: EntryMode, /// The index of the character picked in the set picked. picked_char: Option, - /// Show Sample's fields ([`sample::defaults`]). + /// Show Sample's fields ([`sample::defaults`]). Zoom previews menu choices and restores its opening + /// percentage on cancellation; a later automation edit takes precedence over that older gesture. sample: Map, /// The view settings of the Composite Font row's picker and of the Character Set row's. pickers: (PresetState, PresetState), diff --git a/crates/ui-egui/src/dialogs/composite_fonts/sample.rs b/crates/ui-egui/src/dialogs/composite_fonts/sample.rs index f266d1ca29..10e9ede502 100644 --- a/crates/ui-egui/src/dialogs/composite_fonts/sample.rs +++ b/crates/ui-egui/src/dialogs/composite_fonts/sample.rs @@ -283,7 +283,8 @@ thread_local! { } /// Show Sample's area under the table: the sample of `f` with the marks `fields` show, then a swatch -/// and a toggle for each mark and Zoom beside it. A change the user makes goes into `fields`. +/// and a toggle for each mark and Zoom beside it. Zoom writes live proposals into `fields`, restores +/// its opening percentage on cancellation and preserves a later automation edit. pub(super) fn show(ui: &mut Ui, fields: &mut Map, f: &CompositeFont) { let zoom_now = zoom(fields); let marks: Vec = Mark::ALL.into_iter().filter(|m| on(fields, m.field())).collect(); @@ -318,8 +319,10 @@ pub(super) fn show(ui: &mut Ui, fields: &mut Map, f: &CompositeFo } Row::new().id_salt("zoom").show(ui, |ui, _| { Text::new(tl!("Zoom")).show(ui); - if let Some(z) = Select::new(tl!("Zoom"), Bind::given(zoom_now), &entries).show(ui).value().copied() { - fields.insert("zoom".into(), json!(z)); + let mut chosen_zoom = zoom_now; + Select::new(tl!("Zoom"), Bind::bound(&mut chosen_zoom), &entries).show(ui); + if chosen_zoom != zoom_now { + fields.insert("zoom".into(), json!(chosen_zoom)); } }); }); @@ -384,3 +387,94 @@ pub(super) fn draw(f: &CompositeFont, size: f64, baseline: f64, px: (u16, u16), let empty = || vectorcraft_render::Rendered { width: u32::from(w), height: u32::from(h), pixels: vec![0; usize::from(w) * usize::from(h) * 4] }; RENDERER.with(|r| r.borrow_mut().render_node(&doc, &node, w, h, view)).unwrap_or_else(empty) } + +#[cfg(test)] +mod zoom_tests { + use craft::ui::contract::Role; + use craft::ui::dialog::dialog_id; + use egui::{Key, Modifiers, vec2}; + use vectorcraft_engine::Session; + + use super::super::{KIND, open, with_dialog}; + use super::*; + use crate::VectorcraftApp; + use crate::tests::panel_harness::Panel; + + fn opened(width: f32) -> Panel { + let mut app = crate::testing::windowed(VectorcraftApp::new(Session::new(), Default::default())); + app.run("file.new", json!({"width": 300, "height": 200})).unwrap(); + let mut panel = Panel::new(app, crate::tests::picks::dialogs); + panel.room(vec2(width, 1000.0)); + open(&mut panel.app()).unwrap(); + with_dialog(&panel.app(), |dialog| { + dialog.fonts = vec![CompositeFont::new("Sample draft", "Source Sans 3", "Regular")]; + dialog.select(0); + }) + .unwrap(); + panel.frame(); + panel.click("Show Sample"); + panel + } + + fn fields(panel: &Panel) -> Map { + with_dialog(&panel.app(), |dialog| dialog.sample.clone()).expect("the Composite Fonts dialog remains open") + } + + #[test] + fn composite_sample_zoom_escape_restores_the_opening_value() { + for width in [1024.0, 1280.0] { + let mut panel = opened(width); + let before = fields(&panel); + let (document, undo, revision) = { + let app = panel.app(); + let st = app.session.active().unwrap(); + (st.doc.clone(), st.history.undo.len(), st.revision) + }; + assert_eq!(panel.value_role("Zoom", Role::COMBO_BOX).as_deref(), Some("100%")); + panel.click_role("Zoom", Role::COMBO_BOX); + panel.key(Key::ArrowDown, Modifiers::NONE); + assert_ne!(fields(&panel)["zoom"], before["zoom"], "the open popup previews its proposed magnification"); + panel.key(Key::Escape, Modifiers::NONE); + assert_eq!(fields(&panel), before, "Escape restores the complete sample draft while keeping the parent dialog open"); + assert_eq!(panel.value_role("Zoom", Role::COMBO_BOX).as_deref(), Some("100%")); + let app = panel.app(); + let st = app.session.active().unwrap(); + assert_eq!(st.doc, document); + assert_eq!(st.history.undo.len(), undo); + assert_eq!(st.revision, revision); + } + } + + #[test] + fn composite_sample_zoom_accepts_pointer_and_keyboard_choices() { + let mut panel = opened(1280.0); + panel.click_role("Zoom", Role::COMBO_BOX); + panel.key(Key::ArrowDown, Modifiers::NONE); + panel.key(Key::Enter, Modifiers::NONE); + assert_eq!(fields(&panel)["zoom"], json!(200)); + panel.click_role("Zoom", Role::COMBO_BOX); + panel.key(Key::ArrowDown, Modifiers::NONE); + panel.key(Key::Escape, Modifiers::NONE); + assert_eq!(fields(&panel)["zoom"], json!(200), "a later cancellation restores the last accepted choice"); + panel.click_role("Zoom", Role::COMBO_BOX); + panel.click("400%"); + assert_eq!(fields(&panel)["zoom"], json!(400)); + assert_eq!(panel.value_role("Zoom", Role::COMBO_BOX).as_deref(), Some("400%")); + } + + #[test] + fn composite_sample_zoom_preserves_an_automation_edit_during_a_popup() { + let mut panel = opened(1280.0); + panel.click_role("Zoom", Role::COMBO_BOX); + panel.key(Key::ArrowDown, Modifiers::NONE); + assert_eq!(fields(&panel)["zoom"], json!(200)); + { + let app = panel.app(); + let ctx = app.ui_ctx.clone().unwrap(); + app.dialogs().unwrap().with(|host| host.set_json_field(&ctx, dialog_id(KIND), "zoom", json!(400))).unwrap(); + } + panel.key(Key::Escape, Modifiers::NONE); + assert_eq!(fields(&panel)["zoom"], json!(400), "canceling an older popup must not undo the later automation edit"); + assert_eq!(panel.value_role("Zoom", Role::COMBO_BOX).as_deref(), Some("400%")); + } +} diff --git a/docs/mcp.md b/docs/mcp.md index 1bbe49574d..c79f58104e 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -13165,7 +13165,10 @@ The em box and ICF box are those of the font of the part that sets the sample's custom set that holds that character), the cap height and x-height those of the face the Roman letters are drawn in (a fallback face when the part's font lacks the character), Max Ascent/Descent the highest ascent and lowest descent of the faces the sample uses, and Max Ascender the top of its tallest glyph; each takes its part's size, baseline and vertical scale. Zoom draws it at 25% to 800% of 36 pt. The -sample text, the zoom steps and the size are VectorCraft's own. OK runs `type.compositeFonts.set` with every font as one +sample text, the zoom steps and the size are VectorCraft's own. Highlighting a Zoom choice previews it in the sample; +Enter or a click accepts it, and Escape restores the percentage from when the menu opened. A later `ui.dialog.set` +edit of `zoom` is preserved when the older popup is canceled. These Zoom interactions change only the sample preview, +without editing the document or its Undo history. OK runs `type.compositeFonts.set` with every font as one undo step; a refused font keeps the dialog open. `ui.dialog.set` takes `custom`, `entry` and `char` (the index of the character picked in the set) as soon as the dialog opens, and `sample` (true or false), `zoom` (25, 50, 75, 100, 200, 400 or 800) and `lineIcfBox`, `lineEmBox`, `lineBaseline`, `lineCapHeight`, `lineAscentDescent`, `lineAscender` and diff --git a/docs/ui-parity.md b/docs/ui-parity.md index 1c491b9714..31d5f25940 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -507,6 +507,7 @@ next unit in the order a right-click on a ruler lists them, from Feet back to Po | Control bar: numeric Corner Radius for eligible selected ordinary and live corners (part of #7238, request 3 only) | done | Anchor Points visibility group; common/mixed values, general document units and multi-object edits through `object.setLiveShape`, one Undo. A partial selection containing no eligible corners contributes no target. Corner kind and relative mode are retained; existing corner-widget selection, widget visibility and maximum-radius behavior are unchanged. Requests 1/2 remain open. | | Stroke panel: custom arrowheads after the built-in ones in both arrowhead menus, from the arrowheads file that the panel menu's Edit Arrowheads… opens; saving the file reloads the menus, and a stroke keeps a copy of its custom head's art | done | [Apply stroke on an object](https://helpx.adobe.com/illustrator/using/stroke-object.html) (Customize arrowheads); the file's layout (one symbol per head, pointing right, tip at the registration point, height drawn as wide as the built-in heads) is VectorCraft's own; `stroke.arrowheads.edit`, `stroke.arrowheads.list`, `stroke.arrowheads.reload`, `stroke.set` `{custom: name}`; engine `tests::arrowheads`, `stroke::tests_arrows::custom_heads_draw_their_own_art_at_the_tip` | | Control bar: Paragraph: link and Align left/center/right while type is selected (#5372) | done | After the Character controls, as the public documentation has the Control panel format paragraphs ([Paragraph panel overview](https://helpx.adobe.com/illustrator/using/formatting-paragraphs.html), [Align text](https://helpx.adobe.com/illustrator/using/align-text.html)); the link opens the Paragraph panel in a popover, as Character: does with the Character panel. The bar trims from its right end: X/Y/W/H, Distribute, Align, area type vertical alignment, then these buttons, then the link. The three-button set is our choice for room; all seven alignments are in the popover. `panels/paragraph/tests.rs` headless tests (`the_control_bar_shows_the_paragraph_alignment_of_the_selected_type`, `the_control_bar_trims_its_paragraph_section_after_the_controls_to_its_right`) | +| Composite Fonts sample Zoom restores canceled choices | done | Highlighting previews a percentage; Enter or a click accepts it, and Escape restores the previous choice without editing the document or Undo history. A later automation change is preserved. | | Pathfinder shape results keep their source names and SVG IDs | done | #1293; Minus Front keeps the back name, Minus Back the front name; Unite/Intersect/Exclude use the backmost named input; compound output carries it once; geometry and paint unchanged | | Attributes fill-rule controls with a compound member selected | done | Edits the compound's rule; direction still edits only the member; rendered-hole and Undo/Redo regression tests (#1197) | | Info panel follows the tool in use: W and H show the change in x and y, with the distance and the angle, while the selection moves, the Gradient tool draws a vector or a Pen drag pulls out an anchor's handle; the Scale tool's percentages; the center and angles of a Rotate, Reflect or Shear tool drag; the Zoom tool's magnification; the Paintbrush's brush. W and H follow Use Preview Bounds, several selected objects show only the paint and type they share, and Show Options names a tint or a gradient swatch | done | `info.readout`; `Tool::readout`; behavior from the Info panel overview in the [archived user guide](https://web.archive.org/web/20220911143322/https://helpx.adobe.com/pdf/cs6/illustrator_reference.pdf#page=76); number formats, the rows shown between drags and the Direct Selection and Group Selection readouts are VectorCraft's own |