diff --git a/crates/ui-egui/src/panels/separations.rs b/crates/ui-egui/src/panels/separations.rs index 845552dd76..a62d126f24 100644 --- a/crates/ui-egui/src/panels/separations.rs +++ b/crates/ui-egui/src/panels/separations.rs @@ -20,7 +20,7 @@ use craft::ui::contract::{ use craft::ui::display::Text; use craft::ui::layout_components::{Row, Stack}; use craft::ui::list::{List, ListRow, ThumbSize, ToggleCell}; -use craft::ui::menu::PanelRow; +use craft::ui::menu::{Menu, MenuItem, PanelRow}; use craft::ui::notices::Notice; use craft::ui::pickers::Select; use craft::ui::runtime::commands::{CommandState, CommandStates}; @@ -132,7 +132,7 @@ fn plates_section(app: &mut VectorcraftApp, ui: &mut Ui) { if let Some(want) = check(ui, tl!("Overprint Preview (separations)"), on, app.session.active().is_some()) { act(app, "view.separationsPreview", json!({"on": want})); } - let Some(doc) = app.session.active().map(|d| d.doc.clone()) else { + let Some((document, doc)) = app.session.active().map(|d| (d.uid, d.doc.clone())) else { Notice::new(Tone::Neutral, tl!("No document open.")).show(ui); return; }; @@ -151,7 +151,7 @@ fn plates_section(app: &mut VectorcraftApp, ui: &mut Ui) { ]; // Disabled while the preview is off: the eyes then take no press and the rows read dim. let out = List::new(tl!("Plates")) - .id_salt("plates") + .id(ui.scope_id().with(("plates", document))) .select(SelectMode::None) .sizing(Sizing::Content) .natural_height(true) @@ -163,13 +163,23 @@ fn plates_section(app: &mut VectorcraftApp, ui: &mut Ui) { if *key == 0 { tl!("Show all plates") } else { tl!("Show/hide plate (Alt-click: only this plate; Alt-click again: all plates)") }; let mut list_row = ListRow::new(row.shown.clone()).toggle(ToggleCell::eye(EYE, row.visible).tooltip(tooltip)); if let Some(ink) = row.chip { - list_row = list_row.thumb(ThumbSize::Small, move |painter, rect| { + list_row = list_row.row_menu().thumb(ThumbSize::Small, move |painter, rect| { painter.painter.rect_filled(rect, 2.0, ink); }); } list_row.cells(item.cells()).state(item.row.clone()) }); + let target_id = out.response.id.with("ink-menu-target"); for event in out.events { + if let CollectionEvent::ContextMenu(request) = &event { + let ink = request.key.checked_sub(1).and_then(|i| plates.get(i)); + ui.ctx().data_mut(|data| { + data.remove::(target_id); + if let Some(ink) = ink { + data.insert_temp(target_id, ink.name.clone()); + } + }); + } // A flip lands once: a click's set, or a sweep's commit at the release. It carries the Alt held at the press. let CollectionEvent::Toggle(EditEvent::Set { after: edit, .. } | EditEvent::Commit { after: edit, .. }) = event else { continue }; let p = match edit.key.checked_sub(1).and_then(|n| plates.get(n)) { @@ -178,6 +188,26 @@ fn plates_section(app: &mut VectorcraftApp, ui: &mut Ui) { }; act(app, "view.separationsPreview", p); } + let name = ui.ctx().data(|data| data.get_temp::(target_id)); + if on && let Some(plate) = name.as_ref().and_then(|name| plates.iter().find(|p| &p.name == name)) { + let menu = Menu::context(tl!("Plates"), &out.response).show(ui, |ui, _| { + let toggle = if visible(&plate.name) { tl!("Hide Plate") } else { tl!("Show Plate") }; + if MenuItem::new(toggle).show(ui).ran { + act(app, "view.separationsPreview", eye_click(&plate.name, false)); + } + if MenuItem::new(tl!("Show Only This Plate")).show(ui).ran { + act(app, "view.separationsPreview", json!({"only": plate.name})); + } + if MenuItem::new(tl!("Show All Plates")).show(ui).ran { + act(app, SHOW_ALL_PLATES, json!({})); + } + }); + if menu.output.closed.is_some() { + ui.ctx().data_mut(|data| data.remove::(target_id)); + } + } else { + ui.ctx().data_mut(|data| data.remove::(target_id)); + } } /// The `view.separationsPreview` params for a click on plate `name`'s eye: with Alt, that plate @@ -464,6 +494,69 @@ mod tests { use crate::tests::panel_harness::Panel; use vectorcraft_engine::Session; + #[test] + fn plate_menu_keyboard_focus_and_actions() { + use egui::{Key, Modifiers}; + + if !crate::testing::in_own_process("panels::separations::tests::plate_menu_keyboard_focus_and_actions") { + return; + } + let mut app = VectorcraftApp::new(Session::new(), Default::default()); + app.run("file.new", json!({})).unwrap(); + app.run("view.separationsPreview", json!({"on": true})).unwrap(); + let mut panel = Panel::new(app, plates_section); + panel.focus("Black"); + assert!(panel.focused("Black")); + panel.key(Key::F10, Modifiers::SHIFT); + panel.frame(); + panel.frame(); + assert!(panel.focused("Hide Plate")); + for item in ["Hide Plate", "Show Only This Plate", "Show All Plates"] { + assert!(panel.menu_item_enabled(item)); + } + panel.key(Key::Escape, Modifiers::NONE); + panel.frame(); + panel.frame(); + assert!(!panel.shows("Hide Plate")); + assert!(panel.focused("Black")); + panel.key(Key::F10, Modifiers::SHIFT); + panel.frame(); + panel.frame(); + panel.key(Key::ArrowDown, Modifiers::NONE); + assert!(panel.focused("Show Only This Plate")); + panel.key(Key::Enter, Modifiers::NONE); + assert_eq!(proof::view().separations.unwrap(), ["Black"]); + } + + #[test] + fn plate_menu_targets_the_clicked_process_or_spot_ink() { + // Plate visibility belongs to the process-wide proof view. + if !crate::testing::in_own_process("panels::separations::tests::plate_menu_targets_the_clicked_process_or_spot_ink") { + return; + } + let mut app = VectorcraftApp::new(Session::new(), Default::default()); + app.run("file.new", json!({})).unwrap(); + app.run("swatch.new", json!({"name": "Menu Test Ink", "color": {"c": 0, "m": 60, "y": 100, "k": 0}, "spot": true})).unwrap(); + app.run("view.separationsPreview", json!({"on": true})).unwrap(); + let visible = || proof::view().separations.unwrap(); + let all = visible(); + let mut panel = Panel::new(app, plates_section); + panel.secondary_click("Magenta"); + panel.click_menu_item("Hide Plate"); + assert_eq!(visible(), all.iter().filter(|n| n.as_str() != "Magenta").cloned().collect::>()); + panel.secondary_click("Magenta"); + panel.click_menu_item("Show Plate"); + assert!(visible().iter().any(|n| n == "Magenta")); + for _ in 0..2 { + panel.secondary_click("Menu Test Ink (spot)"); + panel.click_menu_item("Show Only This Plate"); + assert_eq!(visible(), ["Menu Test Ink"]); + } + panel.secondary_click("Menu Test Ink (spot)"); + panel.click_menu_item("Show All Plates"); + assert_eq!(visible(), all); + } + #[test] fn load_profile_only_offers_a_picker_that_returns_a_path() { use craft::host::ScriptedFiles; diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index aa49d934ac..cb3f4423b2 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -2560,6 +2560,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - Text Import Options' Character Set offers Shift JIS, GB2312, Chinese Big 5, Cyrillic, GB18030, Greek, Turkish, Baltic and Central European beside Unicode and ANSI, the plain-text encodings [the help page](https://helpx.adobe.com/illustrator/desktop/add-and-import-files/import-other-file-types/import-and-export-text.html) lists for placed text. `file.place {text: {characterSet}}` decodes each with its WHATWG Encoding Standard decoder. The mapping is VectorCraft's own: GB2312 reads as GBK, Cyrillic as windows-1251 (x-mac-cyrillic with `platform: "mac"`), and Greek, Turkish, Baltic and Central European as windows-1253, 1254, 1257 and 1250 on both platforms. A byte-order mark is read as ordinary bytes, a malformed sequence as U+FFFD, and the last set confirmed is remembered (`crates/engine/src/tests/textimport.rs`, `crates/ui-egui/src/dialogs/text_import.rs`). - A Shift-click with the loaded place cursor opens the current file's import options (text, DXF, PDF page or embedded PSD) and OK places it at the click, with Show Import Options on or off and for a cursor loaded by `file.place.queue` ([Place multiple files](https://web.archive.org/web/20210601162814/https://helpx.adobe.com/pdf/illustrator_reference.pdf)). VectorCraft's own rules: a file without such a dialog places as a click does, Cancel leaves the file unplaced, a Shift-drag places at the dragged size, and headless the Shift-click places as a click (`crates/tools/src/place.rs`, `crates/engine/src/tests/place.rs`, `crates/ui-egui/src/tests/place.rs`). - Separations Preview shows placed and embedded raster images on the visible plates, as it shows vector art (#4153): an RGB image's pixels are separated into process inks with the proof setup's intent, a CMYK image shows its own inks, a hidden plate's ink leaves the image, and with one plate visible the image shows that plate's ink as a grey. Raster images carry no spot ink, so a spot plate shown alone shows them as paper; a colorized image shows its color's plates. Emoji and other bitmap glyphs follow the same rule. The plate-filtered pixels and their reduced-size copies are kept apart from the image's own pixels, for each set of visible plates, proof setup and color settings, and with the preview off nothing changes. Evidence: `tests::colorize::separations_preview_shows_an_rgb_images_process_inks`, `separations_preview_shows_a_cmyk_images_own_inks`, `separations_preview_keeps_an_images_pixels_per_plate_set`. Print preview fidelity remains the open gap, so scores and hours are unchanged. + - In Separations Preview, each process or spot ink row has a menu to show or hide that plate, show only that plate, or show all plates. - In the Separations Preview panel, an Alt-click (Option-click on macOS) on the eye of the plate shown alone shows every plate again, spot plates included, as [the help page](https://helpx.adobe.com/illustrator/using/printing-color-separations.html) describes for a second modified click on the eye (`view.separationsPreview {soloToggle: plate}`); an Alt-click on a plate shown among others shows only that plate, as the help page describes for the first one. VectorCraft's own rules: an Alt-click on a hidden plate, on another plate while one shows alone or while no plate is shown shows only that plate, and `only` still shows just the named plate when repeated (`crates/engine/src/tests/colormgmt.rs`, `crates/ui-egui/src/panels/separations.rs`). - Desktop print transport uses `craft-print` for CUPS and modern Windows. Sheet composition, copies, separations and colour management remain in VectorCraft. The Print dialog's Media list also carries the Japanese papers — JIS B4 257 × 364 mm, JIS B5 182 × 257 mm and JIS B6 128 × 182 mm beside the ISO B4/B5 (250 × 353 and 176 × 250 mm, kept so settings and presets saved before them keep their paper), and はがき 100 × 148 mm, 往復はがき 148 × 200 mm, 封筒 長形3号 120 × 235 mm, 長形4号 90 × 225 mm, 角形2号 240 × 332 mm, 角形3号 216 × 277 mm and 四六判 127 × 188 mm; the JSON id or the dialog label names a paper, any case and spacing (`B5 (JIS)` or `b5jis`) (`crates/pdf/src/print/settings.rs`, `crates/pdf/src/tests/print.rs`). The print-preview and physical-device fidelity gaps remain, so print scores and hours are unchanged. - The Print dialog's Document Ink Options list shows an icon before each spot ink's name, and a click on it prints that one ink as process inks (on the Cyan, Magenta, Yellow and Black plates, with no plate of its own) or as a spot ink again, as [the help page](https://helpx.adobe.com/illustrator/using/printing-color-separations.html) describes for single spot colors. Other spot inks keep their plates, and spot gradient stops and DCS images' spot plates follow each ink's choice (`print.setup {settings: {output: {inks: [{name, convertToProcess: true}]}}}`, kept with the document and in print presets; `print.preview` lists every ink as `documentInks`). These are VectorCraft's own rules: Convert All Spot Colors to Process converts every spot ink and dims the icons while keeping each ink's own choice, a converted ink's Print, Frequency and Angle are dimmed and kept, and process inks and Registration have no icon. Evidence: `print::one_spot_ink_converts_to_process_and_the_others_keep_their_plates`, `print::converting_every_spot_ink_overrides_and_keeps_each_inks_own_choice`, `print::a_spot_gradient_stop_prints_its_process_plates`, `cmykimages::a_dcs_image_converts_only_the_spot_ink_chosen`, `tests::print::a_spot_ink_converted_to_process_is_saved_and_listed_without_a_plate`, `dialogs::tests_print::a_spot_inks_icon_converts_it_to_process_and_back`. Print scores and hours are unchanged.