diff --git a/crates/ui-egui/src/place.rs b/crates/ui-egui/src/place.rs index 6458cc8d5d..0a1bf2d436 100644 --- a/crates/ui-egui/src/place.rs +++ b/crates/ui-egui/src/place.rs @@ -833,16 +833,15 @@ impl VectorcraftApp { } } -/// Files held over, or dropped on, a canvas that would be placed there. +/// A file drop that includes artwork for this canvas. pub struct CanvasDrop { files: Vec, at: Point, } -/// The canvas as a target of files dragged from the OS: it takes those [`VectorcraftApp::drop_target`] -/// places, and outlines the canvas while they hover. On the web the browser gives a hovered file's -/// type but not its name, so any file is taken then, including libraries, presets, plug-ins and -/// shortcut sets, which open when dropped. +/// The canvas accepts a file drop when [`VectorcraftApp::drop_target`] would place any member and +/// outlines the canvas while it hovers. The drop router places or opens each member of the batch. +/// A file hovering without a name is also eligible until its name arrives. pub struct CanvasFiles<'a> { app: &'a VectorcraftApp, rect: egui::Rect, @@ -862,13 +861,11 @@ impl FilesTarget for CanvasFiles<'_> { fn accept(&self, payload: &OsFiles, at: egui::Pos2, _op: DropOperation) -> Option { let doc = self.view.to_doc(at); let at = Point::new(doc.x, doc.y); - let files: Vec = payload + let accepts = payload .files .iter() - .filter(|f| f.name.is_empty() || matches!(self.app.drop_target(&f.name, DropSpot::Canvas(at), false), DropTarget::Place(_))) - .cloned() - .collect(); - (!files.is_empty()).then_some(CanvasDrop { files, at }) + .any(|file| file.name.is_empty() || matches!(self.app.drop_target(&file.name, DropSpot::Canvas(at), false), DropTarget::Place(_))); + accepts.then(|| CanvasDrop { files: payload.files.clone(), at }) } fn mark(&self, _: &CanvasDrop) -> DropMark { @@ -881,7 +878,7 @@ impl FilesTarget for CanvasFiles<'_> { } } -/// Files dropped on the canvas ([`CanvasFiles`]), placed where they landed; Shift embeds them. +/// Route the whole canvas drop. Shift embeds its placed artwork. // PLAN: `DropOperation` has no Shift, so the held modifiers of the drop's frame are read here. pub fn canvas_drop(app: &mut VectorcraftApp, ctx: &egui::Context, dropped: CanvasDrop) { let shift = ctx.input(|i| i.modifiers.shift); diff --git a/crates/ui-egui/src/tests/place.rs b/crates/ui-egui/src/tests/place.rs index 6ae8dcd25c..8b9af4a449 100644 --- a/crates/ui-egui/src/tests/place.rs +++ b/crates/ui-egui/src/tests/place.rs @@ -340,6 +340,30 @@ fn a_dropped_png_is_placed_where_it_was_dropped() { assert!(matches!(&selected_image(&app).kind, NodeKind::Image(im) if im.link.is_none())); } +#[test] +fn a_mixed_canvas_drop_places_the_artwork_and_opens_the_palette() { + let mut app = app(); + let ctx = window(&app); + let rect = laid_out(&mut app, &ctx); + let dir = Folder::new("ui-place-image-and-palette"); + let palette = dir.file("mixed.gpl", b"GIMP Palette\nName: Mixed Drop\n#\n255 0 0\tRed\n"); + let png = dir.file("artwork.png", &png(20, 10, 72.0)); + let pos = rect.center() + vec2(60.0, -40.0); + let want = app.canvas_view().unwrap().to_doc(pos); + + frame(&mut app, &ctx, vec![egui::Event::PointerMoved(pos)], &[&palette, &png], false); + + let placed = selected_image(&app); + let center = placed.geometric_bounds().unwrap().center(); + assert!((center.x - want.x).abs() < 1e-6 && (center.y - want.y).abs() < 1e-6, "{center:?} vs {want:?}"); + assert_eq!((app.session.documents().len(), images(&app, 0)), (1, 1)); + assert!( + crate::panels::library_panel::last_open(&app.ui).is_some_and(|library| library.id == format!("loaded/{palette}")), + "the same canvas drop must open the palette: {}", + app.ui.status + ); +} + /// A document dropped where the platform gives no position opens as a new tab, not into the open /// document; the pictures dropped with it are placed in the document that was open, before it /// opens. diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index c0e3246958..8d6b694226 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1312,7 +1312,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - An EPS or PostScript file that stops on a PostScript error gives the error's name as PostScript spells it (`typecheck`, `rangecheck` and the other names the reader raises, except `undefined`, whose message names the unknown name) followed by what it means, in the warning after opening and in the error when the file can't be opened. The status bar and the open-error dialog show the meaning in the interface language: each meaning has a row in every catalog (`postscript_error_meanings_are_translated`). - The macOS menu bar is built from the in-window menus (one model, `native_menu`) and laid out as a Mac app's: the VectorCraft menu holds About, Settings ▸ (each Preferences page, General… ⌘K), Language ▸, Appearance ▸ (UI brightness), Services, Hide VectorCraft ⌃⌘H (⌘H stays Hide Edges), Hide Others, Show All and Quit; Window gains Minimize ⌃⌘M, Zoom and Bring All to Front, and Help the system's search field. Its key equivalents go back to egui as key presses, so user shortcuts, focused text fields and the Type tool's input method behave as in the window, and nothing fires twice; enabled, check marks and labels update in place. `--in-window-menus` or `VECTORCRAFT_IN_WINDOW_MENUS=1` keeps the menus in the window; `ui.inspect` reports `nativeMenuBar`. - macOS: Finder opens every format File › Open reads with VectorCraft (double-click, Open With, a drop on the Dock icon, `open -a`), at launch or while it runs; the release and `cargo xtask bundle` apps share one `Info.plist` that declares those document types, owning only VectorCraft's own formats. The DMG opens on a designed Finder window, VectorCraft.app beside the `Applications` link over a background with the app icon (#493). - - Swatch and graphic style libraries, Libraries panel files, presets and plug-ins open wherever they are dropped on the window, as File › Open opens them. + - Swatch and graphic style libraries, Libraries panel files, presets and plug-ins open wherever they are dropped on the window, as File › Open opens them. A mixed canvas drop places its artwork and opens its library files. Evidence includes `a_mixed_canvas_drop_places_the_artwork_and_opens_the_palette`. - File › Open has a filter for each kind of file it opens other than a document, Graphic Style Libraries (`.vcstyles`, after Swatch libraries) and Perspective grid presets (`.vcperspective`, after Print presets) among them, and Other Library… lists its library filter once. Graph designs are stored in the document, with no file type or filter of their own. Tests: `open_exts_cover_every_readable_format`, `library_open_filters_list_library_formats_first`. - **Symbol libraries** ([public source](https://helpx.adobe.com/illustrator/desktop/manage-objects/traces-mockups-symbols/create-or-import-symbol-libraries.html)): Window › Symbol Libraries and the Symbols panel's Symbol Libraries Menu open each library in a library panel of its own, as swatch and graphic style libraries do. The built-in libraries, Basic Shapes, UI Frames (Panel, Button and Bar with default 9-slice guides), Map Markers (Pin, Flag, Crosshair and Checkpoint, no default 9-slice), Inventory Icons (Sword, Shield, Potion, Key and Gem, no default 9-slice), Skill Icons (Attack, Defend, Heal, Buff and Ult, no default 9-slice), Weather Icons (Sun, Moon, Cloud, Rain, Thunder and Snow, no default 9-slice), Nature Icons (Leaf, Flower, Tree, Mountain and Wave, no default 9-slice) and Media Controls (Play, Pause, Stop, Skip Next, Shuffle and Repeat, no default 9-slice), are original art generated in code (`crates/engine/src/cmd/symbollib.rs`). A click on a symbol adds it to the document's Symbols as one undo step, with its Symbol Options (size, registration, export type, 9-slice guides) and every resource it uses (the symbols it nests, patterns, swatches, brushes, graphic styles, images), and makes it the current symbol; a symbol the document already has is not added again and another symbol of the same name keeps its name, the library's comes in numbered. Thumbnails, in the library panels and the Symbols panel, draw a symbol with the symbols it nests and the patterns and images it uses. Dragging a library symbol onto the canvas also places an instance there, in the same step ([placing from a library](https://helpx.adobe.com/illustrator/desktop/manage-objects/traces-mockups-symbols/create-and-place-symbols.html)). Save Symbols (the library menu) and Save Symbol Library… (the Symbols panel menu) write the document's symbols as a `.vectorcraft` document holding only them, into the user library folder (listed under User Defined) or a file; Other Library… reads the symbols of any document VectorCraft opens; a file it can't read is an error and opens no panel. Tests: `crates/engine/src/tests/symbollib.rs`, `crates/ui-egui/src/panels/tests_symbol_libraries.rs`, `panels::symbols::tests::thumbnails_show_the_symbols_a_symbol_nests`, `canvas::tests::a_library_symbol_dropped_on_the_canvas_is_added_and_placed_there_in_one_step`. - **Nature Icons library:** Leaf, Flower, Tree, Mountain and Wave are five original procedural vector symbols. Each has a finite natural size, can be added and placed through the symbol library controls, and survives saving to a library file; no 9-slice guides are assigned by default.