From 56972deedacf6cf3bcdf5b7639f75fa9a54ed985 Mon Sep 17 00:00:00 2001 From: yoriswind Date: Mon, 16 Nov 2026 01:48:53 -0800 Subject: [PATCH 01/84] Add a color-mode menu to the gradient stop editor --- crates/ui-egui/src/dialogs/gradient_stop.rs | 11 +- crates/ui-egui/src/panels/color.rs | 29 +- .../tests/gradient_stop_color_mode_menu.rs | 444 ++++++++++++++++++ docs/gaps.md | 5 +- docs/roadmap.md | 5 +- docs/target-app-parity.md | 6 +- docs/ui-parity.md | 4 +- 7 files changed, 490 insertions(+), 14 deletions(-) create mode 100644 crates/ui-egui/tests/gradient_stop_color_mode_menu.rs diff --git a/crates/ui-egui/src/dialogs/gradient_stop.rs b/crates/ui-egui/src/dialogs/gradient_stop.rs index 63dcfa916b..07004c6202 100644 --- a/crates/ui-egui/src/dialogs/gradient_stop.rs +++ b/crates/ui-egui/src/dialogs/gradient_stop.rs @@ -102,6 +102,7 @@ fn show(app: &mut VectorcraftApp, ctx: &egui::Context) { let swatches = d.str("tab") == "swatches"; let mut tab = None; let mut eyedropper = false; + let mut mode_menu_pointer = false; let resp = egui::Area::new(area) .order(egui::Order::Foreground) .fixed_pos(pos) @@ -121,6 +122,9 @@ fn show(app: &mut VectorcraftApp, ctx: &egui::Context) { { eyedropper = true; } + if !swatches { + mode_menu_pointer = crate::panels::color::mode_button(app, ui); + } }); ui.add_space(6.0); if swatches { @@ -163,7 +167,12 @@ fn show(app: &mut VectorcraftApp, ctx: &egui::Context) { } // The click that opened the popover (the Gradient panel's colour chip) or the double-click // (a stop's chip) lands outside it: only a later click elsewhere closes it (#577). - if frame > opened && resp.clicked_elsewhere() && !ctx.input(|i| i.pointer.button_double_clicked(egui::PointerButton::Primary)) { + // The mode dropdown is a child of this popover, even where it extends beyond its rectangle. + if frame > opened + && !mode_menu_pointer + && resp.clicked_elsewhere() + && !ctx.input(|i| i.pointer.button_double_clicked(egui::PointerButton::Primary)) + { app.ui.dialog = None; } } diff --git a/crates/ui-egui/src/panels/color.rs b/crates/ui-egui/src/panels/color.rs index b156185ff3..d30b8e4ab2 100644 --- a/crates/ui-egui/src/panels/color.rs +++ b/crates/ui-egui/src/panels/color.rs @@ -881,6 +881,27 @@ pub(crate) fn show_sized(app: &mut VectorcraftApp, ui: &mut Ui, height: f32) { } } +/// The Color panel's mode choices, also used by the gradient stop editor. +fn mode_items(app: &mut VectorcraftApp, ui: &mut Ui, tgt: &Target) { + // Tint mode checks no colour mode: picking one makes the tint a process colour. + let cur = shown_mode(app, tgt.color().as_ref()); + for m in Mode::ALL { + if menu_item(ui, tl!(m.label()), true, m == cur && tgt.tint().is_none()) { + set_mode(app, tgt, m); + } + } +} + +/// A compact mode chooser. Reports pointer ownership of its dropdown so an enclosing popover +/// does not mistake a click on one of its rows for a click elsewhere. +pub(crate) fn mode_button(app: &mut VectorcraftApp, ui: &mut Ui) -> bool { + let tgt = target(app, ui); + let mode = shown_mode(app, tgt.color().as_ref()); + let label = if tgt.tint().is_some() { tl!("Tint") } else { tl!(mode.label()) }; + let (_, menu) = egui::containers::menu::MenuButton::from_button(egui::Button::new(label).small()).ui(ui, |ui| mode_items(app, ui, &tgt)); + menu.is_some_and(|m| m.response.container_contains_pointer()) +} + pub fn menu(app: &mut VectorcraftApp, ui: &mut Ui) { let hidden = app.ui.color_hide_options; if menu_item(ui, if hidden { tl!("Show Options") } else { tl!("Hide Options") }, true, false) { @@ -893,13 +914,7 @@ pub fn menu(app: &mut VectorcraftApp, ui: &mut Ui) { ui.separator(); let tgt = target(app, ui); let color = tgt.color(); - // Tint mode checks no colour mode: picking one makes the tint a process colour. - let cur = shown_mode(app, color.as_ref()); - for m in Mode::ALL { - if menu_item(ui, tl!(m.label()), true, m == cur && tgt.tint().is_none()) { - set_mode(app, &tgt, m); - } - } + mode_items(app, ui, &tgt); ui.separator(); let enabled = color.is_some() || super::active_mixed(app, ui.ctx()); for (label, invert) in [(tl!("Invert"), true), (tl!("Complement"), false)] { diff --git a/crates/ui-egui/tests/gradient_stop_color_mode_menu.rs b/crates/ui-egui/tests/gradient_stop_color_mode_menu.rs new file mode 100644 index 0000000000..3bb31a263d --- /dev/null +++ b/crates/ui-egui/tests/gradient_stop_color_mode_menu.rs @@ -0,0 +1,444 @@ +//! The stop/point popover uses the Color panel's real mode chooser. +// Integration tests may unwrap and panic (AGENTS.md, Robustness). +#![allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)] + +use std::sync::{Mutex, MutexGuard}; + +use egui::{Event, Key, Modifiers, PointerButton, Pos2, RawInput, Rect, Shape, pos2, vec2}; +use serde_json::{Value, json}; +use vectorcraft_color::{GradientPaint, Paint, cms}; +use vectorcraft_engine::Session; +use vectorcraft_ui_egui::{VectorcraftApp, i18n, panels::color::Mode, theme}; + +static UI_STATE: Mutex<()> = Mutex::new(()); +const MODES: [&str; 5] = ["Grayscale", "RGB", "HSB", "CMYK", "Web Safe RGB"]; +type FrameObserver = Box; + +struct GlobalState { + language: i18n::Lang, + colors: cms::ColorSettings, + _lock: MutexGuard<'static, ()>, +} + +impl GlobalState { + fn new() -> Self { + let lock = UI_STATE.lock().unwrap_or_else(|e| e.into_inner()); + let language = i18n::current(); + let colors = cms::active_settings(); + i18n::set_current(i18n::Lang::EN); + cms::set_active(&cms::ColorSettings { rgb: cms::SRGB.into(), ..Default::default() }).unwrap(); + Self { language, colors, _lock: lock } + } +} + +impl Drop for GlobalState { + fn drop(&mut self) { + cms::set_active(&self.colors).unwrap(); + i18n::set_current(self.language); + } +} + +fn key(key: Key, pressed: bool) -> Event { + Event::Key { key, physical_key: Some(key), pressed, repeat: false, modifiers: Modifiers::NONE } +} + +fn visit_shapes(shape: &Shape, clip: Rect, visit: &mut impl FnMut(&Shape, Rect)) { + if let Shape::Vec(shapes) = shape { + for shape in shapes { + visit_shapes(shape, clip, visit); + } + } else { + visit(shape, clip); + } +} + +struct Scene { + app: VectorcraftApp, + ctx: egui::Context, + last_output: egui::FullOutput, + // Optional test-frame observation consumes initial texture uploads before they are cleared. + on_frame: Option, + size: egui::Vec2, + time: f64, + freeform: bool, + buttons: Vec<(String, Rect)>, +} + +impl Scene { + /// No UI frames: an observer can attach before the first font upload. + fn new(size: egui::Vec2, freeform: bool) -> Self { + let mut app = VectorcraftApp::new(Session::new(), Default::default()); + app.run("app.language", json!({"lang": "en"})).unwrap(); + app.run("file.new", json!({"width": 600, "height": 400})).unwrap(); + app.run("shape.rectangle", json!({"x": 100, "y": 100, "width": 120, "height": 100})).unwrap(); + app.run( + "paint.setFill", + json!({"keepModel": true, "gradient": { + "kind": if freeform { "freeform" } else { "linear" }, + "stops": [{"offset": 0, "color": "#2468ac"}, {"offset": 1, "color": "#e09020"}] + }}), + ) + .unwrap(); + app.run("paint.setStroke", json!({"none": true, "focus": false})).unwrap(); + assert!(app.session.fill_active, "removing the stroke must retain the intended gradient fill proxy"); + assert!(matches!(app.session.proxy_paints().0, Paint::Gradient(_)), "the actual active fill, not fallback markers, is a gradient"); + app.select_tool("directSelection"); + if freeform { + app.run("paint.freeform.selectPoint", json!({"index": 0})).unwrap(); + } + app.run("window.panel", json!({"panel": "gradient"})).unwrap(); + let ctx = egui::Context::default(); + theme::install_fonts(&ctx); + egui_extras::install_image_loaders(&ctx); + ctx.enable_accesskit(); + Self { app, ctx, last_output: Default::default(), on_frame: None, size, time: 0.0, freeform, buttons: vec![] } + } + + fn frame(&mut self, events: Vec) { + self.time += 1.0 / 60.0; + // The normal host tick selects the App's language before painting, too. + i18n::set_current(self.app.ui_language()); + let mut raw = RawInput { + events, + time: Some(self.time), + focused: true, + screen_rect: Some(Rect::from_min_size(Pos2::ZERO, self.size)), + ..Default::default() + }; + self.app.raw_input_hook(&self.ctx, &mut raw); + let mut output = self.ctx.run_ui(raw, |ui| self.app.ui(ui)); + self.buttons.clear(); + let update = output.platform_output.accesskit_update.as_ref().expect("AccessKit enabled"); + for (_, node) in &update.nodes { + if let Some((label, bounds)) = node.label().zip(node.bounds()) { + self.buttons + .push((label.to_owned(), Rect::from_min_max(pos2(bounds.x0 as f32, bounds.y0 as f32), pos2(bounds.x1 as f32, bounds.y1 as f32)))); + } + } + if let Some(observer) = &mut self.on_frame { + observer(&self.ctx, &output); + } + output.textures_delta.clear(); + self.last_output = output; + } + + fn idle(&mut self, count: usize) { + for _ in 0..count { + self.frame(vec![]); + } + } + + fn click_with(&mut self, point: Pos2, modifiers: Modifiers) { + self.frame(vec![ + Event::ModifiersChanged(modifiers), + Event::PointerMoved(point), + Event::PointerButton { pos: point, button: PointerButton::Primary, pressed: true, modifiers }, + ]); + self.frame(vec![Event::PointerButton { pos: point, button: PointerButton::Primary, pressed: false, modifiers }]); + self.frame(vec![Event::ModifiersChanged(Modifiers::NONE)]); + } + + fn click(&mut self, point: Pos2) { + self.click_with(point, Modifiers::NONE); + } + + fn escape(&mut self) { + self.frame(vec![key(Key::Escape, true)]); + self.frame(vec![key(Key::Escape, false)]); + self.idle(2); + } + + fn popover(&self) -> Rect { + self.ctx.memory(|m| m.area_rect(egui::Id::unique("gradient-stop-popover"))).expect("actual painted popover area") + } + + fn assert_editor(&self) { + assert_eq!(self.app.ui.dialog.as_ref().map(|d| d.kind.as_str()), Some("gradientStop")); + } + + fn painted(&self, mut visitor: impl FnMut(&Shape, Rect)) { + for clipped in &self.last_output.shapes { + visit_shapes(&clipped.shape, clipped.clip_rect, &mut visitor); + } + } + + fn open_stop(&mut self) { + self.idle(8); + if self.freeform { + // The real Color: chip in freeform_section is the 18-point square next to its label. + let mut labels = vec![]; + let mut chips = vec![]; + self.painted(|shape, clip| match shape { + Shape::Text(text) if text.galley.text() == "Color:" => { + labels.push(text.galley.rect.translate(text.pos.to_vec2())); + } + Shape::Rect(rect) + if (rect.rect.width() - 18.0).abs() < 0.01 && (rect.rect.height() - 18.0).abs() < 0.01 && clip.contains(rect.rect.center()) => + { + chips.push(rect.rect) + } + _ => {} + }); + chips.retain(|chip| { + labels.iter().any(|label| { + chip.left() >= label.right() && chip.left() - label.right() < 20.0 && (chip.center().y - label.center().y).abs() < 10.0 + }) + }); + chips.dedup(); + assert_eq!(chips.len(), 1, "actual freeform Color chip, not a fabricated dialog: {chips:?}"); + self.click(chips[0].center()); + } else { + let mut markers = vec![]; + self.painted(|shape, clip| { + if let Shape::Path(path) = shape + && path.closed + && path.points.len() == 5 + { + let rect = Rect::from_points(&path.points); + if (rect.width() - 12.0).abs() < 0.01 + && (rect.height() - 15.0).abs() < 0.01 + && path.points[0].distance(pos2(rect.center().x, rect.top())) < 0.01 + && clip.contains(rect.center()) + { + markers.push(rect.center()); + } + } + }); + assert_eq!(markers.len(), 2, "real two-stop Gradient panel: {markers:?}"); + markers.sort_by(|a, b| a.x.total_cmp(&b.x)); + self.click(markers[0]); + self.click(markers[0]); + } + self.idle(3); + self.assert_editor(); + if self.freeform { + assert_eq!(self.app.session.selected_freeform_point(), Some(0)); + } else { + assert_eq!(self.app.session.selected_stop(), Some(0)); + } + } + + fn button(&self, label: &str) -> Rect { + let popover = self.popover(); + let matches: Vec<_> = self + .buttons + .iter() + .filter(|(text, rect)| text == label && rect.is_positive() && popover.contains(rect.center())) + .map(|(_, rect)| *rect) + .collect(); + assert_eq!(matches.len(), 1, "one actual accessible {label:?} button; labels: {:?}", self.buttons); + matches[0] + } + + fn open_mode(&mut self, label: &str) { + self.assert_editor(); + let button = self.button(label); + assert!(self.popover().contains(button.center())); + self.click(button.center()); + self.idle(3); + assert!(egui::Popup::is_any_open(&self.ctx), "actual child menu opens"); + self.assert_editor(); + } + + fn mode_rows(&self) -> Vec<(String, bool, Rect)> { + let mut rows: Vec<_> = self + .buttons + .iter() + .filter_map(|(text, rect)| { + let (label, checked) = if let Some(label) = text.strip_prefix("✓ ") { (label, true) } else { (text.strip_prefix(" ")?, false) }; + MODES.contains(&label).then_some((label.to_owned(), checked, *rect)) + }) + .collect(); + rows.sort_by(|a, b| a.2.top().total_cmp(&b.2.top())); + rows + } + + fn assert_modes(&self, current: Option<&str>) { + let rows = self.mode_rows(); + assert_eq!(rows.iter().map(|(label, _, _)| label.as_str()).collect::>(), MODES); + for (label, checked, rect) in rows { + assert_eq!(checked, current == Some(label.as_str()), "current row: {label}"); + assert!(Rect::from_min_size(Pos2::ZERO, self.size).contains(rect.center())); + } + } + + fn choose_mode(&mut self, label: &str) -> Rect { + let rows = self.mode_rows(); + let rect = rows.iter().find(|(text, _, _)| text == label).expect("actual offered mode").2; + self.click(rect.center()); + self.idle(3); + assert!(!egui::Popup::is_any_open(&self.ctx), "picking a mode closes only its dropdown"); + self.assert_editor(); + rect + } + + fn gradient(&self) -> GradientPaint { + let Paint::Gradient(g) = self.app.session.proxy_paints().0 else { panic!("gradient fill") }; + *g + } + + fn snapshot(&self) -> Value { + let state = self.app.session.active().unwrap(); + json!({"doc": state.doc.as_ref(), "selection": state.selection, + "undo": state.history.undo.iter().map(|e| json!({"label":e.label,"doc":e.doc.as_ref(),"selection":e.selection.as_ref()})).collect::>(), + "redo": state.history.redo.iter().map(|e| json!({"label":e.label,"doc":e.doc.as_ref(),"selection":e.selection.as_ref()})).collect::>(), + "step": state.history.step(), "stop": self.app.session.selected_stop(), "point": self.app.session.selected_freeform_point()}) + } + + fn geometry(&self) -> Value { + let state = self.app.session.active().unwrap(); + json!(state.selection.objects.iter().map(|id| &state.doc.node(*id).unwrap().kind).collect::>()) + } + + fn spectrum(&self) -> Rect { + let popover = self.popover(); + let mut found = vec![]; + self.painted(|shape, clip| { + if let Shape::Mesh(mesh) = shape + && mesh.vertices.len() == 73 * 13 + && mesh.indices.len() == 72 * 12 * 6 + { + let points: Vec<_> = mesh.vertices.iter().map(|v| v.pos).collect(); + let rect = Rect::from_points(&points); + if popover.contains(rect.center()) && clip.contains(rect.center()) { + found.push(rect); + } + } + }); + assert_eq!(found.len(), 1, "actual 72-by-12 Color spectrum mesh"); + found[0] + } +} + +#[test] +fn gradient_stop_mode_baseline_shift_and_menu_are_display_only() { + let _globals = GlobalState::new(); + let mut scene = Scene::new(vec2(960.0, 720.0), false); + scene.open_stop(); + let before = scene.snapshot(); + let original = scene.gradient(); + assert_eq!(original.gradient.stops[0].color.model(), cms::Model::Rgb); + // A legitimate existing control must succeed before the intended old-source failure. + scene.click_with(scene.spectrum().center(), Modifiers::SHIFT); + scene.idle(3); + assert_eq!(scene.app.ui.color_mode, Some(Mode::Hsb)); + assert_eq!(scene.snapshot(), before, "Shift cycling changes display, not art/history"); + scene.open_mode("HSB"); // Baseline: this actual chooser is absent on ed6f. + scene.assert_modes(Some("HSB")); + assert_eq!(scene.snapshot(), before, "opening the menu is not an edit"); + scene.escape(); + assert!(!egui::Popup::is_any_open(&scene.ctx)); + scene.assert_editor(); + assert_eq!(scene.snapshot(), before); + scene.open_mode("HSB"); + scene.choose_mode("RGB"); + scene.open_mode("RGB"); + scene.assert_modes(Some("RGB")); + scene.choose_mode("HSB"); + assert_eq!(scene.gradient(), original); + assert_eq!(scene.snapshot(), before, "RGB/HSB preserve native RGB and one-stop selection"); + scene.escape(); + assert!(scene.app.ui.dialog.is_none(), "after dropdown dismissal the next Escape closes the editor"); + assert_eq!(scene.snapshot(), before); +} + +#[test] +fn gradient_stop_mode_converts_only_selected_stop_and_unlinks_tint_with_one_undo() { + let _globals = GlobalState::new(); + for tint in [false, true] { + let mut scene = Scene::new(vec2(960.0, 720.0), false); + if tint { + scene.app.run("swatch.new", json!({"name":"Ink","color":{"c":0,"m":1,"y":0,"k":0},"spot":true})).unwrap(); + scene + .app + .run( + "paint.setFill", + json!({"gradient":{"stops":[ + {"offset":0,"swatch":"Ink","tint":50}, {"offset":1,"color":"#e09020"} + ]}}), + ) + .unwrap(); + } + scene.open_stop(); + let before = scene.snapshot(); + let original = scene.gradient(); + let geometry = scene.geometry(); + let undo = scene.app.session.active().unwrap().history.undo.len(); + if tint { + assert_eq!(original.gradient.stops[0].swatch.as_deref(), Some("Ink")); + assert!((original.gradient.stops[0].tint - 0.5).abs() < 1e-6); + } + scene.open_mode(if tint { "Tint" } else { "RGB" }); + scene.assert_modes(if tint { None } else { Some("RGB") }); + scene.choose_mode("CMYK"); + let converted = scene.gradient(); + assert_eq!(converted.gradient.stops[0].color.model(), cms::Model::Cmyk); + assert!(converted.gradient.stops[0].swatch.is_none(), "process mode unlinks a tint"); + let mut expected = original.clone(); + expected.gradient.stops[0].color = converted.gradient.stops[0].color; + expected.gradient.stops[0].swatch = None; + expected.gradient.stops[0].tint = 1.0; + expected.gradient.stops[0].plates = None; + assert_eq!(converted, expected, "other stops, placement and gradient settings are untouched"); + assert_eq!(scene.geometry(), geometry); + assert_eq!(scene.app.session.active().unwrap().history.undo.len(), undo + 1); + scene.app.run("edit.undo", json!({})).unwrap(); + assert_eq!(serde_json::to_value(scene.app.session.active().unwrap().doc.as_ref()).unwrap(), before["doc"]); + assert_eq!(scene.gradient(), original); + if !tint { + // Hide Options is the existing compact mixer; its child menu can outgrow the editor. + scene.app.run("ui.colorPanel", json!({"options": false})).unwrap(); + scene.idle(3); + scene.open_mode("RGB"); + scene.assert_modes(Some("RGB")); + let row = scene.mode_rows().into_iter().find(|(label, _, _)| label == "Web Safe RGB").unwrap().2; + let parent = scene.popover(); + assert!(!parent.contains(row.center()), "compact editor must expose a real child row outside itself: parent={parent:?}, row={row:?}"); + scene.choose_mode("Web Safe RGB"); + assert_eq!(scene.app.ui.color_mode, Some(Mode::WebSafe)); + assert_ne!( + scene.gradient().gradient.stops[0].color, + original.gradient.stops[0].color, + "the original non-web-safe RGB stop is actually converted" + ); + assert_eq!(scene.geometry(), geometry); + scene.app.run("edit.undo", json!({})).unwrap(); + assert_eq!(serde_json::to_value(scene.app.session.active().unwrap().doc.as_ref()).unwrap(), before["doc"]); + assert_eq!(scene.gradient(), original, "one Undo restores the pre-conversion paint"); + } + // A real outside click closes both editor and child, without another edit. + scene.idle(3); + // Undo restores art, while the chosen display mode remains a UI preference. + scene.open_mode(if tint { "Tint" } else { "Web Safe RGB" }); + let closed_boundary = scene.snapshot(); + let outside = pos2(2.0, scene.size.y - 2.0); + assert!(!scene.popover().contains(outside)); + assert!(scene.mode_rows().iter().all(|(_, _, r)| !r.contains(outside))); + scene.click(outside); + scene.idle(3); + assert!(scene.app.ui.dialog.is_none()); + assert!(!egui::Popup::is_any_open(&scene.ctx)); + assert_eq!(scene.snapshot(), closed_boundary); + } +} + +#[test] +fn gradient_stop_mode_freeform_point_uses_the_same_real_menu() { + let _globals = GlobalState::new(); + let mut scene = Scene::new(vec2(960.0, 720.0), true); + scene.open_stop(); + let before = scene.snapshot(); + let original = scene.gradient(); + scene.open_mode("RGB"); + scene.assert_modes(Some("RGB")); + scene.choose_mode("HSB"); + assert_eq!(scene.app.ui.color_mode, Some(Mode::Hsb)); + assert_eq!(scene.gradient(), original, "display-only point editing keeps every freeform point"); + assert_eq!(scene.snapshot(), before); + scene.open_mode("HSB"); + scene.escape(); + scene.assert_editor(); + scene.escape(); + assert!(scene.app.ui.dialog.is_none()); + assert_eq!(scene.snapshot(), before); +} diff --git a/docs/gaps.md b/docs/gaps.md index eda7bb21dd..1d921be864 100644 --- a/docs/gaps.md +++ b/docs/gaps.md @@ -1,6 +1,6 @@ # Gaps -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-15 · **Change:** minor (G4 type: modal Check Spelling dialog (Edit › Spelling › Check Spelling…), #4936; spell check complete; previously: Type: the Middle Eastern & South Asian composers are done as a per-paragraph choice with the Standard composers (#4935); G5: built-in Neon & Glow graphic style library (Cyan Neon, Magenta Laser, Amber Tube, Electric Lime, Pulse Violet, Cobalt Phosphor); estimate unchanged (3–13 h); previously: Tech Circuit brush library, G5; previously: G5: built-in Weather Icons symbol library (Sun, Moon, Cloud, Rain, Thunder, Snow); estimate 5–15 → 4–14 h; previously: 3D: the seams of white-light Extrude & Bevel, Inflate and Rotate, and the face seams of the 3D (Classic) effects, have round joins instead of miters; previously: PDF import: preserve Type 3 font text runs as named groups , or as live text in TextAs::Text mode if ToUnicode exists on non-colour fonts (TextAs::Outlines produces grouped outlines), #6740; scores and estimates unchanged; previously: icon-strip flyouts also resize from the top edge and the canvas-side top corner, keeping the moved top in workspaces (storytold/craft-libs#1094); scores and estimates unchanged; previously: #6865: oversized editing artboard import; Glyphs panel: Alternates for Current Selection applies an OpenType feature value (`salt=2`) to the selected letter alone, so an Arabic word stays joined, and Entire Font lists the unencoded glyphs, #5514; #6404: transform-aware Eyedropper character copying; scores and estimates unchanged; previously: G5: built-in Energy Beams brush library; estimate 5–15 → 4–14 h; previously minor: G5: built-in Skill Icons symbol library; estimate 6–16 → 5–15 h; previously minor: ruler double-click adds a guide at the pointer, #5239; G5: built-in Status Effects graphic style library; estimate 7–17 → 6–16 h; MCP docs catch-up for UI Frames and Map Markers; previously minor: G5: built-in Inventory Icons symbol library; estimate 8–18 → 7–17 h; previously minor: G9: `.ai` save names a variable font instance's design-space setting, #6388; previously minor: G5: built-in Game Trails brush library; estimate 9–19 → 8–18 h; previously minor: Edit › Edit Custom Dictionary…: its dialog adds, deletes and changes the custom dictionary's words, #4936; previously minor: docs tidy-up, no content change: stray notes at the top moved into the revision table; scores and estimates unchanged; previously minor: G5: built-in Game HUD graphic style library; estimate 10–20 → 9–19 h; previously minor: G5: built-in Map Markers symbol library; estimate 11–21 → 10–20 h; previously minor: right-click on type: Spelling › Auto Spell Check, with its check mark, #4936; previously minor: right-click on a word Auto Spell Check underlined: its suggestions, Ignore All and Add to Dictionary, #4936; previously minor: G2: Effect Gallery thumbnails and in-dialog preview; estimate 1–2 h → 0; Auto Spell Check: `edit.autoSpellCheck` underlines the unknown words, #4936; previously minor: PDF editable import preserves authored ActualText once, including empty/nested spans and authored ordering (#6165); cross-line/style layout remains approximate; scores and estimates unchanged; PDF marked-text export (#6309): compatible glyphs stay on one layout line with per-glyph offsets; scores and estimates unchanged; G5: built-in UI Frames symbol library with default 9-slice; estimate 11–21 h; previously minor: G5: dynamic symbol part on-canvas takes opacity, blend, gradient and pattern; docs Overlap/auto-corners sync; estimate 12–22 h; previously minor: interim macOS cursor delivery, #2292; native validation pending; scores and estimates unchanged; previously minor: Control bar › Snapping includes the existing Snap to Glyph and Alignment Guides toggles (#6164); scores and estimates unchanged; previously minor: G5 docs: Art brush Overlap, Pattern brush auto corners and Global Edit Shift-click leave-out moved from Missing to Done (code already shipped); previously minor: custom dictionary and Ignore All: `text.spelling.addWord`, `removeWord`, `changeWord`, `dictionary` and `ignoreAll`, #4936; previously minor: EPS import: embedded fonts (composite, Type 42, CID-keyed, Type 1, CFF FontSet) draw their glyphs; spell check engine: `text.spelling.check` and `text.spelling.suggest` on craft-proof, #4936; previously minor: floating tab groups collapse into the side icon rail and opened rail panels fold back into it, #5925 in part; G9: EPS gradients drawn as abutting strips import as one gradient, without seams; Tools stays beside the canvas with left-side panels; new gradients follow document color mode; Selection QoL: marquee modes and visible feedback, #5313; #3380 deletion-only review follow-up: independent survivors keep gradient placement, owned subpaths avoid discarded copies, and contracts/status/evidence are clarified; endpoint highlighting remains open; scores and estimates unchanged; Indian-language hyphenation review and license allowlist, #4947; opening a slow file shows a progress window, part of #5930; Hindi catalog and contributor loanword preferences; agent wording pass complete; wider native proofreading welcome; an image zoomed in on is separated, colorized or proofed only where it shows (#4155); scores and estimates unchanged; a document's first frame renders on the render worker, so opening a heavy file no longer freezes the window; scores and estimates unchanged; large images in CMYK documents are shrunk before they are separated into ink planes (#4155); scores and estimates unchanged; `.ai` paths with a Calligraphic brush open brushed, with the 6D Art Pen's channels, and Windows reads the pen's tilt and barrel rotation, #372; scores and estimates unchanged; Compound Shapes add-on, beyond Illustrator; scores and estimates unchanged; Contour add-on, beyond Illustrator; scores and estimates unchanged; a slow first frame is waited for instead of restarting without the graphics adapter, and the menu bar no longer waits for the installed fonts' scan; scores and estimates unchanged) · **Target:** Adobe Illustrator 2026 (30.x) +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-16 · **Change:** minor (Gradient stop editor: its Color tab offers the five Color panel modes (#7918); scores and estimates unchanged; previously: G4 type: modal Check Spelling dialog (Edit › Spelling › Check Spelling…), #4936; spell check complete; previously: Type: the Middle Eastern & South Asian composers are done as a per-paragraph choice with the Standard composers (#4935); G5: built-in Neon & Glow graphic style library (Cyan Neon, Magenta Laser, Amber Tube, Electric Lime, Pulse Violet, Cobalt Phosphor); estimate unchanged (3–13 h); previously: Tech Circuit brush library, G5; previously: G5: built-in Weather Icons symbol library (Sun, Moon, Cloud, Rain, Thunder, Snow); estimate 5–15 → 4–14 h; previously: 3D: the seams of white-light Extrude & Bevel, Inflate and Rotate, and the face seams of the 3D (Classic) effects, have round joins instead of miters; previously: PDF import: preserve Type 3 font text runs as named groups , or as live text in TextAs::Text mode if ToUnicode exists on non-colour fonts (TextAs::Outlines produces grouped outlines), #6740; scores and estimates unchanged; previously: icon-strip flyouts also resize from the top edge and the canvas-side top corner, keeping the moved top in workspaces (storytold/craft-libs#1094); scores and estimates unchanged; previously: #6865: oversized editing artboard import; Glyphs panel: Alternates for Current Selection applies an OpenType feature value (`salt=2`) to the selected letter alone, so an Arabic word stays joined, and Entire Font lists the unencoded glyphs, #5514; #6404: transform-aware Eyedropper character copying; scores and estimates unchanged; previously: G5: built-in Energy Beams brush library; estimate 5–15 → 4–14 h; previously minor: G5: built-in Skill Icons symbol library; estimate 6–16 → 5–15 h; previously minor: ruler double-click adds a guide at the pointer, #5239; G5: built-in Status Effects graphic style library; estimate 7–17 → 6–16 h; MCP docs catch-up for UI Frames and Map Markers; previously minor: G5: built-in Inventory Icons symbol library; estimate 8–18 → 7–17 h; previously minor: G9: `.ai` save names a variable font instance's design-space setting, #6388; previously minor: G5: built-in Game Trails brush library; estimate 9–19 → 8–18 h; previously minor: Edit › Edit Custom Dictionary…: its dialog adds, deletes and changes the custom dictionary's words, #4936; previously minor: docs tidy-up, no content change: stray notes at the top moved into the revision table; scores and estimates unchanged; previously minor: G5: built-in Game HUD graphic style library; estimate 10–20 → 9–19 h; previously minor: G5: built-in Map Markers symbol library; estimate 11–21 → 10–20 h; previously minor: right-click on type: Spelling › Auto Spell Check, with its check mark, #4936; previously minor: right-click on a word Auto Spell Check underlined: its suggestions, Ignore All and Add to Dictionary, #4936; previously minor: G2: Effect Gallery thumbnails and in-dialog preview; estimate 1–2 h → 0; Auto Spell Check: `edit.autoSpellCheck` underlines the unknown words, #4936; previously minor: PDF editable import preserves authored ActualText once, including empty/nested spans and authored ordering (#6165); cross-line/style layout remains approximate; scores and estimates unchanged; PDF marked-text export (#6309): compatible glyphs stay on one layout line with per-glyph offsets; scores and estimates unchanged; G5: built-in UI Frames symbol library with default 9-slice; estimate 11–21 h; previously minor: G5: dynamic symbol part on-canvas takes opacity, blend, gradient and pattern; docs Overlap/auto-corners sync; estimate 12–22 h; previously minor: interim macOS cursor delivery, #2292; native validation pending; scores and estimates unchanged; previously minor: Control bar › Snapping includes the existing Snap to Glyph and Alignment Guides toggles (#6164); scores and estimates unchanged; previously minor: G5 docs: Art brush Overlap, Pattern brush auto corners and Global Edit Shift-click leave-out moved from Missing to Done (code already shipped); previously minor: custom dictionary and Ignore All: `text.spelling.addWord`, `removeWord`, `changeWord`, `dictionary` and `ignoreAll`, #4936; previously minor: EPS import: embedded fonts (composite, Type 42, CID-keyed, Type 1, CFF FontSet) draw their glyphs; spell check engine: `text.spelling.check` and `text.spelling.suggest` on craft-proof, #4936; previously minor: floating tab groups collapse into the side icon rail and opened rail panels fold back into it, #5925 in part; G9: EPS gradients drawn as abutting strips import as one gradient, without seams; Tools stays beside the canvas with left-side panels; new gradients follow document color mode; Selection QoL: marquee modes and visible feedback, #5313; #3380 deletion-only review follow-up: independent survivors keep gradient placement, owned subpaths avoid discarded copies, and contracts/status/evidence are clarified; endpoint highlighting remains open; scores and estimates unchanged; Indian-language hyphenation review and license allowlist, #4947; opening a slow file shows a progress window, part of #5930; Hindi catalog and contributor loanword preferences; agent wording pass complete; wider native proofreading welcome; an image zoomed in on is separated, colorized or proofed only where it shows (#4155); scores and estimates unchanged; a document's first frame renders on the render worker, so opening a heavy file no longer freezes the window; scores and estimates unchanged; large images in CMYK documents are shrunk before they are separated into ink planes (#4155); scores and estimates unchanged; `.ai` paths with a Calligraphic brush open brushed, with the 6D Art Pen's channels, and Windows reads the pen's tilt and barrel rotation, #372; scores and estimates unchanged; Compound Shapes add-on, beyond Illustrator; scores and estimates unchanged; Contour add-on, beyond Illustrator; scores and estimates unchanged; a slow first frame is waited for instead of restarting without the graphics adapter, and the menu bar no longer waits for the installed fonts' scan; scores and estimates unchanged) · **Target:** Adobe Illustrator 2026 (30.x) ## Feature submission evidence @@ -118,6 +118,8 @@ from G14 and the budget run of G15: **~170–270 h** one agent, ~50–80 h wall ## G1 Interaction fidelity +- **Done (#7918):** The gradient stop editor’s Color tab offers the Color panel’s five color modes without Shift-clicking the spectrum, sharing its saved mode, conversions and tint unlinking. Mode selection keeps the editor open, with the menu taking Escape first. Evidence: `crates/ui-egui/tests/gradient_stop_color_mode_menu.rs`. Broader G1 scope and estimates unchanged. + macOS cursor delivery (#2292) is narrowed to a native host adapter using the existing artwork and aligned 1×/2× representations. Headless tests cover visible fallbacks, preparation and ownership; native focus/menu/handback timing, mixed displays, Spotlight and full-screen Spaces remain open validation work (see [hardware parity](hardware-parity.md)). This does not close the interaction-fidelity gap or change its score/estimate. - **Panel collapse controls (#5925, in part):** The small » in a floating tab-group header moves that group into the side icon rail, reusing the existing rail or creating one. An opened rail panel has the same control to fold its flyout back into the rail, including after a tab switch. Both controls preserve the tab group and its menu; other floating groups and full-width docked headers stay as they were. Pointer regressions in `crates/ui-egui/src/panel_docking/tests.rs` cover grouped tabs, reopening, separate groups, a missing rail, the menu and flyout closure after switching tabs; `native_tests.rs` covers the native-window click and removal of the empty palette. Scores and estimates unchanged. @@ -895,6 +897,7 @@ trap, and the defaults (0.25 pt, 100%, 40%) are VectorCraft's own, the pages giv | Date | Change | Summary | |---|---|---| +| 2026-11-16 | minor | Gradient stop editor: a compact Color-tab menu offers Grayscale, RGB, HSB, CMYK and Web Safe RGB, sharing the Color panel mode and conversion behavior (#7918). Choosing a mode keeps the editor open; Escape closes the menu first. Scores and estimates unchanged. | | 2026-11-14 | minor | Type: Middle Eastern & South Asian and Standard composers per paragraph (#4935): Paragraph panel menu, paragraph styles, `text.setFormat {composer}` and the native file; the Standard composers set Indic, Arabic and Hebrew type glyph by glyph. `.ai`, EPS and PDF files carry no composer. Scores and estimates unchanged. | | 2026-11-14 | minor | Tech Circuit adds three original procedural brushes (Circuit Trace, Bus Lines, Terminal Nodes); ten built-in brush libraries. G5 remaining estimate 3–13 h (estimated); parity scores and headline totals unchanged. | | 2026-11-12 | minor | 3D: The seams of Extrude & Bevel, Inflate and Rotate under a white light, and of the faces of Extrude & Bevel (Classic), Revolve (Classic) and Rotate (Classic), went from miter to round joins (the seams of Revolve and of colored lights, and 3D (Classic) Wireframe edges, were already round): no thorns on edge-on facets, and facets with no neighbour now have rounded convex corners ([three-d.md](three-d.md#seams)). Scores and estimates unchanged. | diff --git a/docs/roadmap.md b/docs/roadmap.md index fae091f647..fccdaba309 100644 --- a/docs/roadmap.md +++ b/docs/roadmap.md @@ -1,6 +1,6 @@ # Roadmap: milestones and what's next -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-16 · **Change:** minor (#8005: the Color spectrum fills a resized panel; scores and estimates unchanged; previously: M7: Check Spelling modal dialog (Edit › Spelling › Check Spelling…), #4936; spell check complete; previously: PDF import: stroked type keeps the line cap, line join and miter limit the file strokes it with, a glyph stroked otherwise than the run it joins coming in as a run of its own, #7741; M10/G5: Neon & Glow built-in graphic style library (Cyan Neon, Magenta Laser, Amber Tube, Electric Lime, Pulse Violet, Cobalt Phosphor); previously: Tech Circuit brush library, G5; previously: Graphic Styles list fills a taller panel, #2992; scores and estimates unchanged; previously: PDF import: glyphs in a span with an empty ActualText come in as outlines, #6971; scores and estimates unchanged; previously: library panels' lists fill a taller panel, #2992; scores and estimates unchanged; previously: Swatches list fills a taller panel, #1638; scores and estimates unchanged; previously: icon-strip flyouts also resize from the top edge and the canvas-side top corner, keeping the moved top in workspaces (storytold/craft-libs#1094); scores and estimates unchanged; previously: #6865: explicitly requested oversized editing artboard; Live Paint Bucket fills faces crossed in one drag (#6373); previously: #6404: transform-aware Eyedropper character copying; scores and estimates unchanged; previously: M10/G5: Energy Beams brush library; MCP docs list Energy Beams; previously minor: M10/G5: Skill Icons symbol library; MCP docs list Skill Icons; previously minor: M10/G5: Status Effects graphic style library; MCP docs catch-up for symbol libraries; previously minor: M10/G5: Inventory Icons built-in symbol library; previously minor: Edit › Edit Custom Dictionary…: its dialog adds, deletes and changes the custom dictionary's words, #4936; previously minor: M10/G5: Game HUD graphic style library; previously minor: resizable icon-strip flyouts and bottom-aligned panel footers, #5713; previously minor: M10/G5: Map Markers built-in symbol library; previously minor: right-click on type: Spelling › Auto Spell Check, with its check mark, #4936; previously minor: right-click on a word Auto Spell Check underlined: its suggestions, Ignore All and Add to Dictionary, #4936; previously minor: G2: Effect Gallery thumbnails and in-dialog preview are in; Auto Spell Check: `edit.autoSpellCheck` underlines the unknown words, #4936; previously minor: PDF editable import preserves authored ActualText once, including empty/nested spans and authored ordering (#6165); cross-line/style layout remains approximate; scores and estimates unchanged; PDF marked-text export (#6309): compatible glyphs stay on one layout line with per-glyph offsets; scores and estimates unchanged; interim macOS cursor delivery, #2292; native validation pending; scores and estimates unchanged; Control bar › Snapping includes the existing Snap to Glyph and Alignment Guides toggles (#6164); scores and estimates unchanged; custom dictionary and Ignore All: `text.spelling.addWord`, `removeWord`, `changeWord`, `dictionary` and `ignoreAll`, #4936; previously minor: EPS import: embedded fonts (composite, Type 42, CID-keyed, Type 1, CFF FontSet) draw their glyphs; spell check engine: `text.spelling.check` and `text.spelling.suggest` on craft-proof, #4936; previously minor: floating tab groups collapse into the side icon rail and opened rail panels fold back into it, #5925 in part; M4/M7: `.ai`/EPS type keeps its tab stops, and right-aligned lines with tabs lay out as the file's page, #6147; M4/M7: `.ai`/EPS type from the text document lays its lines out closer to the file's page, within limits, #6137; numeric fields step on wheel hover without taking keyboard focus, #5949; Character Styles panel: a double-click on a style's row opens its Character Style Options; the dialog keeps a fixed width and scrolls its sections, so its buttons stay on screen; Selection QoL: marquee modes and visible feedback, #5313; SVG CSS classes survive export and repeated import in all four styling modes (#2480); current-main integration retains event attributes and scripts; #3380 deletion-only review follow-up: independent survivors keep gradient placement, owned subpaths avoid discarded copies, and contracts/status/evidence are clarified; endpoint highlighting remains open; scores and estimates unchanged; Indian-language hyphenation review and license allowlist, #4947; Hindi catalog and contributor loanword preferences; full wording review in progress; Effect dialogs: a colour swatch beside a hex colour opens the Color Picker, #5365; shape tools move the selection from its centre point and turn it from the zone outside a box corner, #5477; scores and estimates unchanged) · **Target:** Adobe Illustrator 2026 (30.x) +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-16 · **Change:** minor (Gradient stop editor: its Color tab offers the five Color panel modes (#7918); scores and estimates unchanged; previously: #8005: the Color spectrum fills a resized panel; scores and estimates unchanged; previously: M7: Check Spelling modal dialog (Edit › Spelling › Check Spelling…), #4936; spell check complete; previously: PDF import: stroked type keeps the line cap, line join and miter limit the file strokes it with, a glyph stroked otherwise than the run it joins coming in as a run of its own, #7741; M10/G5: Neon & Glow built-in graphic style library (Cyan Neon, Magenta Laser, Amber Tube, Electric Lime, Pulse Violet, Cobalt Phosphor); previously: Tech Circuit brush library, G5; previously: Graphic Styles list fills a taller panel, #2992; scores and estimates unchanged; previously: PDF import: glyphs in a span with an empty ActualText come in as outlines, #6971; scores and estimates unchanged; previously: library panels' lists fill a taller panel, #2992; scores and estimates unchanged; previously: Swatches list fills a taller panel, #1638; scores and estimates unchanged; previously: icon-strip flyouts also resize from the top edge and the canvas-side top corner, keeping the moved top in workspaces (storytold/craft-libs#1094); scores and estimates unchanged; previously: #6865: explicitly requested oversized editing artboard; Live Paint Bucket fills faces crossed in one drag (#6373); previously: #6404: transform-aware Eyedropper character copying; scores and estimates unchanged; previously: M10/G5: Energy Beams brush library; MCP docs list Energy Beams; previously minor: M10/G5: Skill Icons symbol library; MCP docs list Skill Icons; previously minor: M10/G5: Status Effects graphic style library; MCP docs catch-up for symbol libraries; previously minor: M10/G5: Inventory Icons built-in symbol library; previously minor: Edit › Edit Custom Dictionary…: its dialog adds, deletes and changes the custom dictionary's words, #4936; previously minor: M10/G5: Game HUD graphic style library; previously minor: resizable icon-strip flyouts and bottom-aligned panel footers, #5713; previously minor: M10/G5: Map Markers built-in symbol library; previously minor: right-click on type: Spelling › Auto Spell Check, with its check mark, #4936; previously minor: right-click on a word Auto Spell Check underlined: its suggestions, Ignore All and Add to Dictionary, #4936; previously minor: G2: Effect Gallery thumbnails and in-dialog preview are in; Auto Spell Check: `edit.autoSpellCheck` underlines the unknown words, #4936; previously minor: PDF editable import preserves authored ActualText once, including empty/nested spans and authored ordering (#6165); cross-line/style layout remains approximate; scores and estimates unchanged; PDF marked-text export (#6309): compatible glyphs stay on one layout line with per-glyph offsets; scores and estimates unchanged; interim macOS cursor delivery, #2292; native validation pending; scores and estimates unchanged; Control bar › Snapping includes the existing Snap to Glyph and Alignment Guides toggles (#6164); scores and estimates unchanged; custom dictionary and Ignore All: `text.spelling.addWord`, `removeWord`, `changeWord`, `dictionary` and `ignoreAll`, #4936; previously minor: EPS import: embedded fonts (composite, Type 42, CID-keyed, Type 1, CFF FontSet) draw their glyphs; spell check engine: `text.spelling.check` and `text.spelling.suggest` on craft-proof, #4936; previously minor: floating tab groups collapse into the side icon rail and opened rail panels fold back into it, #5925 in part; M4/M7: `.ai`/EPS type keeps its tab stops, and right-aligned lines with tabs lay out as the file's page, #6147; M4/M7: `.ai`/EPS type from the text document lays its lines out closer to the file's page, within limits, #6137; numeric fields step on wheel hover without taking keyboard focus, #5949; Character Styles panel: a double-click on a style's row opens its Character Style Options; the dialog keeps a fixed width and scrolls its sections, so its buttons stay on screen; Selection QoL: marquee modes and visible feedback, #5313; SVG CSS classes survive export and repeated import in all four styling modes (#2480); current-main integration retains event attributes and scripts; #3380 deletion-only review follow-up: independent survivors keep gradient placement, owned subpaths avoid discarded copies, and contracts/status/evidence are clarified; endpoint highlighting remains open; scores and estimates unchanged; Indian-language hyphenation review and license allowlist, #4947; Hindi catalog and contributor loanword preferences; full wording review in progress; Effect dialogs: a colour swatch beside a hex colour opens the Color Picker, #5365; shape tools move the selection from its centre point and turn it from the zone outside a box corner, #5477; scores and estimates unchanged) · **Target:** Adobe Illustrator 2026 (30.x) > > Oversized artboard import update (2026-11-12): Explicit editing-data import retains a single artboard beyond a capped 14,400 pt PDF page (#6865). > @@ -159,7 +159,7 @@ Gujarati interface follow-up (2026-11-14): the catalog and zero/one plural rule | M0 | Skeleton + vertical slice | ✅ done | — | | M1 | Selection, transform, layers, MCP (common command tools, strict keys, session resources and version-aware result hints) | ✅ mostly done (document-tab artwork drag with lossless resource transfer and one target Undo; malformed MCP app replies discard the connection without replay, #1761; bounded control socket waits and connection-slot recovery, #1726; bounded synthetic control input, #1709; no-op anchor Align keeps Undo, Redo and saved state (#1180 follow-up); transform reference point snaps to anchors/centres; rotated objects keep a rotated bounding box and their angle; Free Transform, Scale and Reflect along a rotated box pending; the Transform fields take one Tab each, the W/H link after them) | 4–6 | | M2 | Drawing tools + smart guides | ✅ mostly done (#3380 deletion creates independent selected path pieces and keeps bounds-fitted gradients in place; endpoint highlighting remains open; Polygon/Star exact-size count persistence, with repeated-drag, tool-switch and Cancel regression coverage; Curvature point markers without direction handles (#1236, in part); Direct Selection segment click/Delete preserves neighboring edges, #1278; Flare, Reshape, Live Corners widget dragging and per-corner radii and kinds landed, on any path's corners; Shaper rough-shape recognition and orientation steps, the remaining Pen modifier nuances; Shaper Groups with editable sources and separate fill/stroke edits landed; custom ruler origin with drag preview, active-artboard reset, relative X/Y fields and native round-trip (#1212); construction widget/refinements pending); a shape just drawn moves by its centre point and turns from the zone outside a corner with its tool still active (#5477); Tangent and straight-segment perpendicular snapping use saved Smart Guides Geometric Guides preferences and Control bar quick access (#2537), including the existing Snap to Glyph and Alignment Guides toggles (#6164); no View submenu; Copy and Cut with the Pen or Curvature tool take the anchors a Cmd/Ctrl-lent Direct Selection picked (#6123) | 12–18 | -| M3 | Paint & appearance (swatches, color, gradient, stroke, appearance, transparency, styles) | ✅ done (M3.7–M3.98): swatches, groups, libraries, tints, Lab spots and Registration; Eyedropper copies transformed character dimensions (#6404) and styles highlighted text only (atomic transparency rejection); Eyedropper reads visible locked and outside-isolation sources (#1251); Color Picker, Color panel (its spectrum grows with a resized panel, #8005), Color Guide, Color Themes, Edit Colors and Recolor Artwork (screen-bounded Edit chip list, #3416); gradients that follow every transform, the annotator, linked stops, freeform gradients, focal points, gradients on strokes and Expand; visible strokes when paint is added to inherited None/zero-width art (#1253); stroke geometry, arrowheads, dashes fitted to corners, stroke on type, width profiles and the Width tool (Shift-double-click enables adjoining adjustment in Width Point Edit; finite-arithmetic follow-up regressions and full CI passed ([Validation evidence](target-app-parity.md#evidence-what-ships-today-by-area))), Scale Strokes and preview bounds; Appearance targeting, container appearance, target circles, Expand Appearance; knockout, isolation, blend accuracy, CMYK blending, overprint, Attributes, masks and clipping, Flatten Transparency; graphic styles, links and libraries; CSS library export preserves fractional linear and radial gradient stop positions. Left: freeform gradients in SVG/PDF, mixed spot/process gradients in SVG and PDF gradients mixing a spot color with RGB or Lab stops export as stops or process colors; PDF export writes dithered gradient fills with spot stops, and Perceptual spot gradients with RGB or Lab stops other than white or more than 4,096 stops on their curve, as images in process colors; confirm the Scale Strokes & Effects default; Recolor model selection is available through the engine and MCP only (#2520); the dialog retains its existing controls; Library panels' lists (swatch, Color Book, brush, symbol and graphic style libraries) fill a taller panel above its footer (#2992; scores and estimates unchanged); Graphic Styles list fills a taller panel above its footer (#2992; scores and estimates unchanged); Swatches list fills a taller panel above its footer (#1638; `the_list_fills_a_tall_panel_above_its_footer`; scores and estimates unchanged); | 4–8 | +| M3 | Paint & appearance (swatches, color, gradient, stroke, appearance, transparency, styles) | ✅ done (M3.7–M3.98): swatches, groups, libraries, tints, Lab spots and Registration; Eyedropper copies transformed character dimensions (#6404) and styles highlighted text only (atomic transparency rejection); Eyedropper reads visible locked and outside-isolation sources (#1251); Color Picker, Color panel (its spectrum grows with a resized panel, #8005), Color Guide, Color Themes, Edit Colors and Recolor Artwork (screen-bounded Edit chip list, #3416); gradients that follow every transform, the annotator, linked stops (the stop editor offers the five Color panel modes, #7918), freeform gradients, focal points, gradients on strokes and Expand; visible strokes when paint is added to inherited None/zero-width art (#1253); stroke geometry, arrowheads, dashes fitted to corners, stroke on type, width profiles and the Width tool (Shift-double-click enables adjoining adjustment in Width Point Edit; finite-arithmetic follow-up regressions and full CI passed ([Validation evidence](target-app-parity.md#evidence-what-ships-today-by-area))), Scale Strokes and preview bounds; Appearance targeting, container appearance, target circles, Expand Appearance; knockout, isolation, blend accuracy, CMYK blending, overprint, Attributes, masks and clipping, Flatten Transparency; graphic styles, links and libraries; CSS library export preserves fractional linear and radial gradient stop positions. Left: freeform gradients in SVG/PDF, mixed spot/process gradients in SVG and PDF gradients mixing a spot color with RGB or Lab stops export as stops or process colors; PDF export writes dithered gradient fills with spot stops, and Perceptual spot gradients with RGB or Lab stops other than white or more than 4,096 stops on their curve, as images in process colors; confirm the Scale Strokes & Effects default; Recolor model selection is available through the engine and MCP only (#2520); the dialog retains its existing controls; Library panels' lists (swatch, Color Book, brush, symbol and graphic style libraries) fill a taller panel above its footer (#2992; scores and estimates unchanged); Graphic Styles list fills a taller panel above its footer (#2992; scores and estimates unchanged); Swatches list fills a taller panel above its footer (#1638; `the_list_fills_a_tall_panel_above_its_footer`; scores and estimates unchanged); | 4–8 | | M4 | Files (native, SVG, PDF, raster, Export for Screens, clipboard interop) | PDF import: stroked type keeps the file's line cap, line join and miter limit (#7741; estimates unchanged); Rename artboards in Export for Screens (#7275); Explicit editing-data import keeps oversized capped-page artboards (#6865; estimates unchanged); Save refusal continuation (#6146): ordinary Save offers Save As; unchanged format keeps options, changed format opens its Save options; cancellation/automation isolation; focused UI regressions passed, native acceptance pending; PDF authored ActualText preserved once in editable import (#6165; first-glyph line/style, bounded input; estimates unchanged); PDF export keeps harakat and zero-advance Noto Arabic dot glyphs in one compatible batch per layout line, with per-glyph vertical offsets (#6309). `crates/pdf/src/tests/realtext.rs` (`mark_text_*`) checks decoded cluster mappings, mixed Arabic/Latin/digits, contour placement against outline export, vertical columns, differing path rotations and PDF/X-1a/3/4. Editable-text import preserves authored ActualText separately (#6165), with cross-line/style layout limits; separately styled or differently rotated clusters and external viewer search/copy remain outside this export-only evidence. `.ai`/EPS type from the text document keeps its paragraphs' tab stops (#6147); `.ai`/EPS type from the text document keeps auto leading per line, its hyphenation options, and may show more of the last lines the file sets in an area frame of its own, when growing the frame by its lines' deepest descent plus 0.05 pt shows them (#6137); ✅ done (M4.14–M4.98 on 2026-10-05): Save As/Save a Copy/Revert/templates, Data Recovery and background save, SVG import and export fidelity (units, text, symbols, filters, SVGZ, Preserve Editing, SVG Options), shared guarded PDF writer and windowed reader ([pdf-backend.md](pdf-backend.md)), PDF import (colours, layers, masks, editable text, security) and export (presets, marks, bleed, ICC and output intent, raster effects, subset fonts, PDF/X-1a, X-3 and X-4, PDF layers, overprint, page thumbnails, fast web view, PDF 1.3), Place and Links, Package, EPS and DXF in and out (EPS legacy mesh corners, vector opacity masks and raster page comparison verified; closed SPLINE flags round-trip and circular paths export as native CIRCLE/ARC, #1299), EMF/WMF, TIFF/BMP/Targa/PSD/GIF/PNG-8 export, Print and print presets, slices, Save for Web, TIFF in Export for Screens and Asset Export, clipboard flavours, File Info; AF.1–AF.4 add Affinity import (native layers, artboards, vectors, text and images from Affinity 1–3 files; the embedded preview only as a warned fallback; AF.4 expands current `.af` fixtures and every-board round-trip validation); EPS Save and Save As keep an opened EPS as EPS with its page frame and complete editable VectorCraft document (2026-10-26; G9 import fidelity unchanged). Left: DWG (use DXF), PSD placement as layers, overprint read back from PDF, Affinity export, polish; SVG CSS classes survive export and repeated import in all four styling modes (#2480); current-main integration retains event attributes and scripts; SVG CSS classes survive export and repeated import in all four styling modes (#2480); current-main integration retains event attributes and scripts; PDF import: glyphs inside a marked-content span with an empty `ActualText` come in as outlines in their fill and stroke, adding no text (#6971; scores and estimates unchanged); | 3–6 (existing scope; Affinity export unestimated) | | M5 | Performance | 🟡 background render + caches + MT done; `vectorcraft-cli bench` and `vectorcraft-cli perf` (budget suite); opaque solid-fill knockout paths draw once in hard-edge/supersampled raster export, with analytical-AA compositing unchanged; file format v2 opens 3× faster (50k paths: 722 → 244 ms); raster effects (glows, shadows, blur, feather) no longer force the whole frame single-threaded (filtered offscreen per effect, verified equal to the single-threaded reference); Craquelure/Mosaic Tiles/Stained Glass distance searches optimized with pixel-invariance checks and the `texture_drag_perf` probe (#1257); effect-heavy demos need a clean-machine benchmark; dirty-region rendering, GPU backend spike pending | 15–25 | | M6 | Path operations (Pathfinder, Shape Builder, offset…) | ✅ mostly done (live compound shapes: Make, Alt-click a Shape Mode, member modes, Release, Expand (#4522); single-result Pathfinder names and SVG IDs retained (#1293); Divide open-cutting-path geometry, appearance and history verified (#1307; existing segment cap remains); Simplify preview/counts and rewritten-path component selection verified (#1272; the slider opens at the Auto-Simplify level; a Direct Selection part of a path simplifies on its own); Compound appearance and member fill-rule edits verified (#1197); Boolean precision on almost-horizontal edges fixed and the property tests made deterministic; Shape Builder gap detection, large-offset bug open); Shape Builder Gap Detection shares Live Paint’s spatial gap finder and temporary merge bridges (#2526); Custom is capped at 72 pt in the existing options dialog | 3–6 | @@ -208,6 +208,7 @@ separate. Scores and hours unchanged. [Behavior and command details](development | Date | Change | Summary | |---|---|---| +| 2026-11-16 | minor | Gradient stop editor: a compact Color-tab menu offers Grayscale, RGB, HSB, CMYK and Web Safe RGB, sharing the Color panel mode and conversion behavior (#7918). Choosing a mode keeps the editor open; Escape closes the menu first. Scores and estimates unchanged. | | 2026-11-16 | minor | Color panel: the spectrum fills the vertical space of a resized panel, with options shown or hidden (#8005). Compact auto-fit flyouts and embedded mixers keep their existing size. Evidence: panels::color::tests::the_spectrum_grows_with_the_color_panel. Scores and estimates unchanged. | | 2026-11-15 | minor | PDF import: stroked type (text rendering modes 1, 2, 5 and 6, and glyphs under `ActualText`) keeps the line cap, line join and miter limit of the graphics state it is stroked with, as paths do, instead of butt caps, miter joins and a miter limit of 10; a glyph filled and then stroked otherwise than the run its fill joined comes in as a run of its own, so the glyphs before it keep their stroke (#7741; `imported_stroked_type_keeps_the_files_cap_join_and_miter_limit` in `crates/pdf/src/tests/textstroke.rs`). Scores and estimates unchanged. | | 2026-11-15 | minor | M10/G5: Neon & Glow built-in graphic style library (Cyan Neon, Magenta Laser, Amber Tube, Electric Lime, Pulse Violet, Cobalt Phosphor); estimates unchanged | diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 0782bacab9..74c1b43a81 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1,6 +1,6 @@ # Parity with Adobe Illustrator -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-16 · **Change:** minor (#8005: the Color spectrum fills a resized panel; scores and estimates unchanged; previously: Paragraph composers (#4935): the Paragraph panel menu and paragraph styles offer four composers, the Middle Eastern & South Asian Single-line and Every-line (how all type is set, and the default) and a Standard Single-line and Every-line that set Indic, Arabic and Hebrew type glyph by glyph as the font maps it, for legacy fonts that keep a script on Latin character codes; PDF import: stroked type keeps the line cap, line join and miter limit the file strokes it with, a glyph stroked otherwise than the run it joins coming in as a run of its own, #7741; G5: Neon & Glow joins built-in graphic style libraries (Cyan Neon, Magenta Laser, Amber Tube, Electric Lime, Pulse Violet, Cobalt Phosphor); scores and estimates unchanged; previously: Pencil ignores Smart Guides and Snap to Point and shows no Smart Guides, #7252; previously: Pencil continuation, straight-line and closing cursors; scores and estimates unchanged; previously: G5: Weather Icons joins built-in symbol libraries (Sun, Moon, Cloud, Rain, Thunder, Snow); scores and estimates unchanged; previously: a closed Pencil stroke closes with a straight segment; previously: Snap to Point with Smart Guides off draws no Smart Guides labels or lines, #7250; previously: 3D: the seams of Extrude & Bevel, Inflate and Rotate under a white light, and of the faces of Extrude & Bevel (Classic), Revolve (Classic) and Rotate (Classic), went from miter to round joins, so white-light 3D output is expected to differ from the 2026-10-17 comparison at facet corners (not measured: the scenes were not exported again); previously: `.ai` and EPS import: in layers that don't draw as the page, art that differs away from an envelope of type no longer costs it its editable type; it keeps its drawn art where, in the pixels it and its drawn art ink, the layers with it differ from the page more than its own check allows, or past the envelopes' share of the page check, #7141; Character panel: the Set Font Height Reference dropdown shows an icon before each reference, #6304; scores and estimates unchanged; previously: Envelopes: a top object's side whose pieces are all one curve split at anchors follows that curve's parameter, so a top object saved with its sides' curves in pieces draws as its `.ai` drawn art, #7097; scores and estimates unchanged; previously: Graphic Styles list fills a taller panel, #2992; scores and estimates unchanged; previously: PDF import: glyphs in a span with an empty ActualText come in as outlines, #6971; scores and estimates unchanged; previously: library panels' lists fill a taller panel, #2992; scores and estimates unchanged; previously: Swatches list fills a taller panel, #1638; scores and estimates unchanged; previously minor: Object › Rasterize with the Grayscale or Bitmap colour model makes a grayscale image, #6969; scores and estimates unchanged; previously minor: `.ai` and EPS import: type in an envelope with Distort Appearance is also tried mapped from the box of what it paints, miter tips and moved strokes included, after its glyphs grown by half its strokes' weight (#6824; #6617: Swatches panel menu: Show Recent Colors; scores unchanged; previously minor: icon-strip flyouts also resize from the top edge and the canvas-side top corner, keeping the moved top in workspaces (storytold/craft-libs#1094); scores and estimates unchanged; previously: #6865: explicitly requested oversized editing artboard; macOS: the canvas cursor stays after the pointer moves, #6362; scores and estimates unchanged; previously minor: Type tool: kerning at a caret at the start of a line moves the character after it, #5111; scores and estimates unchanged; previously minor: Rulers: the zero point dragged out of the rulers' corner snaps as a drawn point does; previously minor: Live Paint Bucket fills faces crossed in one drag (#6373); previously: #6404: transform-aware Eyedropper character copying; scores and estimates unchanged; previously: Envelopes: with Distort Appearance, type's strokes paint along the bent glyph outlines at their own weight, as users' `.ai` files draw them, which changes how VectorCraft's own envelopes of stroked type draw (#6644; scores and estimates unchanged); previously minor: G5: Energy Beams brush library; bundled content ~44% → ~46%; previously minor: G5: Skill Icons symbol library; bundled content ~42% → ~44%; previously minor: `.ai` and EPS import: an envelope saved in Edit Contents whose mesh lies away from its drawn art by a move opens live on that art (#6570; scores and estimates unchanged); previously minor: ruler double-click adds a guide at the pointer, #5239; G5: Status Effects graphic style library; bundled content ~40% → ~42%; MCP symbol libraries list UI Frames and Map Markers; previously minor: G5: Inventory Icons built-in symbol library; bundled content ~38% → ~40%; previously minor: `.ai` and EPS import: stroked type in an envelope maps from its glyphs grown by half its stroke (#3179; scores and estimates unchanged); previously minor: `.ai` and EPS import: warps of type open as mesh envelopes on their saved grid where VectorCraft's warp doesn't draw as their drawn art (#3179; scores and estimates unchanged); G5: Game Trails brush library; bundled content ~36% → ~38%; previously minor: Edit › Edit Custom Dictionary…: its dialog adds, deletes and changes the custom dictionary's words, #4936; previously minor: `.ai` and EPS import: envelopes of type open live where they draw as their drawn art and the layers with them draw as the page (#3179; scores and estimates unchanged); G5: Game HUD graphic style library; bundled content ~34% → ~36%; previously minor: Line Arrow arrowhead (#5421; scores and estimates unchanged); G5: Map Markers built-in symbol library; bundled content ~32% → ~34%; previously minor: right-click on type: Spelling › Auto Spell Check, with its check mark, #4936; previously minor: right-click on a word Auto Spell Check underlined: its suggestions, Ignore All and Add to Dictionary, #4936; previously minor: Canvas: a 3D effect changed on type or a group redraws where its solid was; Fit to Artwork Bounds and per-artboard SVG export build each solid once for all artboards; previously minor: Effect Gallery: a thumbnail for each filter and a preview area inside the dialog, on an original drawing; Raster effects 52% → 55%, hours 1–2 → none; headline numbers unchanged; Auto Spell Check: `edit.autoSpellCheck` underlines the unknown words, #4936; previously minor: PDF editable import preserves authored ActualText once, including empty/nested spans and authored ordering (#6165); cross-line/style layout remains approximate; scores and estimates unchanged; PDF marked-text export (#6309): compatible glyphs stay on one layout line with per-glyph offsets; scores and estimates unchanged; G5: UI Frames built-in symbol library with default 9-slice; bundled content ~32%; previously minor: G5: dynamic symbol part on-canvas opacity/blend/gradient/pattern; strokes remaining no longer lists Overlap/auto corners; symbols ~88%; previously minor: interim macOS cursor delivery, #2292; native validation pending; scores and estimates unchanged; previously minor: harakat paint fallback clarified; previously minor: current Guides feature-area rows consolidated using existing ruler evidence; scores and estimates unchanged; previously minor: Control bar › Snapping includes the existing Snap to Glyph and Alignment Guides toggles (#6164); scores and estimates unchanged; previously minor: G5 docs: Art brush Overlap and Pattern brush auto corners removed from strokes remaining; symbols remaining lists dynamic on-canvas beyond solid and guides outside the art; previously minor: custom dictionary and Ignore All: `text.spelling.addWord`, `removeWord`, `changeWord`, `dictionary` and `ignoreAll`, #4936; previously minor: EPS import: embedded fonts (composite, Type 42, CID-keyed, Type 1, CFF FontSet) draw their glyphs; spell check engine: `text.spelling.check` and `text.spelling.suggest` on craft-proof, #4936; previously minor: floating tab groups collapse into the side icon rail and opened rail panels fold back into it, #5925 in part; `.ai`/EPS type keeps its tab stops, and right-aligned lines with tabs lay out as the file's page, #6147; `.ai`/EPS type from the text document lays its lines out closer to the file's page, within limits, #6137; `.ai` and EPS import: older Art brush objects read; numeric fields step on wheel hover without taking keyboard focus, and a panel wheel turn cannot seed a canvas zoom glide, #5949; Character Styles panel: a double-click on a style's row opens its Character Style Options; the dialog keeps a fixed width and scrolls its sections, so its buttons stay on screen; Tools stays beside the canvas with left-side panels; new gradients follow document color mode; Selection QoL: marquee modes and visible feedback, #5313; SVG CSS classes survive export and repeated import in all four styling modes (#2480); current-main integration retains event attributes and scripts; #3380 deletion-only review follow-up: independent survivors keep gradient placement, owned subpaths avoid discarded copies, and contracts/status/evidence are clarified; endpoint highlighting remains open; scores and estimates unchanged; the canvas keeps selection outlines and anchors between frames; Indian-language hyphenation review and license allowlist, #4947; Stroke gradients: an arrowhead aligned to the tip is painted to the corners of its base, #5964; Drop Shadow and glow dialogs: spinner arrows, #5367, #5368; Stroke Weight Up and Down shortcuts, #5797; Hindi catalog and contributor loanword preferences; full wording review in progress; Properties in Edit Artboards: a Transform section with the reference point above the Artboards section, #5219; the Control bar's Stroke: and Opacity: links scrub their fields, #4088; an image zoomed in on is separated, colorized or proofed only where it shows (#4155); a document's first frame renders on the render worker, so opening a heavy file no longer freezes the window, #4155; Control bar Paragraph section with type selected, #5372; translating unchanged type reuses its glyph and character-stroke outlines; scores and estimates unchanged) · **Target:** Adobe Illustrator 2026 (30.x; public release notes through 30.7, August 2026; Units › East Asian Type acts, with Q and Ha units; scores unchanged) +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-16 · **Change:** minor (Gradient stop editor: its Color tab offers the five Color panel modes (#7918); scores and estimates unchanged; previously: #8005: the Color spectrum fills a resized panel; scores and estimates unchanged; previously: Paragraph composers (#4935): the Paragraph panel menu and paragraph styles offer four composers, the Middle Eastern & South Asian Single-line and Every-line (how all type is set, and the default) and a Standard Single-line and Every-line that set Indic, Arabic and Hebrew type glyph by glyph as the font maps it, for legacy fonts that keep a script on Latin character codes; PDF import: stroked type keeps the line cap, line join and miter limit the file strokes it with, a glyph stroked otherwise than the run it joins coming in as a run of its own, #7741; G5: Neon & Glow joins built-in graphic style libraries (Cyan Neon, Magenta Laser, Amber Tube, Electric Lime, Pulse Violet, Cobalt Phosphor); scores and estimates unchanged; previously: Pencil ignores Smart Guides and Snap to Point and shows no Smart Guides, #7252; previously: Pencil continuation, straight-line and closing cursors; scores and estimates unchanged; previously: G5: Weather Icons joins built-in symbol libraries (Sun, Moon, Cloud, Rain, Thunder, Snow); scores and estimates unchanged; previously: a closed Pencil stroke closes with a straight segment; previously: Snap to Point with Smart Guides off draws no Smart Guides labels or lines, #7250; previously: 3D: the seams of Extrude & Bevel, Inflate and Rotate under a white light, and of the faces of Extrude & Bevel (Classic), Revolve (Classic) and Rotate (Classic), went from miter to round joins, so white-light 3D output is expected to differ from the 2026-10-17 comparison at facet corners (not measured: the scenes were not exported again); previously: `.ai` and EPS import: in layers that don't draw as the page, art that differs away from an envelope of type no longer costs it its editable type; it keeps its drawn art where, in the pixels it and its drawn art ink, the layers with it differ from the page more than its own check allows, or past the envelopes' share of the page check, #7141; Character panel: the Set Font Height Reference dropdown shows an icon before each reference, #6304; scores and estimates unchanged; previously: Envelopes: a top object's side whose pieces are all one curve split at anchors follows that curve's parameter, so a top object saved with its sides' curves in pieces draws as its `.ai` drawn art, #7097; scores and estimates unchanged; previously: Graphic Styles list fills a taller panel, #2992; scores and estimates unchanged; previously: PDF import: glyphs in a span with an empty ActualText come in as outlines, #6971; scores and estimates unchanged; previously: library panels' lists fill a taller panel, #2992; scores and estimates unchanged; previously: Swatches list fills a taller panel, #1638; scores and estimates unchanged; previously minor: Object › Rasterize with the Grayscale or Bitmap colour model makes a grayscale image, #6969; scores and estimates unchanged; previously minor: `.ai` and EPS import: type in an envelope with Distort Appearance is also tried mapped from the box of what it paints, miter tips and moved strokes included, after its glyphs grown by half its strokes' weight (#6824; #6617: Swatches panel menu: Show Recent Colors; scores unchanged; previously minor: icon-strip flyouts also resize from the top edge and the canvas-side top corner, keeping the moved top in workspaces (storytold/craft-libs#1094); scores and estimates unchanged; previously: #6865: explicitly requested oversized editing artboard; macOS: the canvas cursor stays after the pointer moves, #6362; scores and estimates unchanged; previously minor: Type tool: kerning at a caret at the start of a line moves the character after it, #5111; scores and estimates unchanged; previously minor: Rulers: the zero point dragged out of the rulers' corner snaps as a drawn point does; previously minor: Live Paint Bucket fills faces crossed in one drag (#6373); previously: #6404: transform-aware Eyedropper character copying; scores and estimates unchanged; previously: Envelopes: with Distort Appearance, type's strokes paint along the bent glyph outlines at their own weight, as users' `.ai` files draw them, which changes how VectorCraft's own envelopes of stroked type draw (#6644; scores and estimates unchanged); previously minor: G5: Energy Beams brush library; bundled content ~44% → ~46%; previously minor: G5: Skill Icons symbol library; bundled content ~42% → ~44%; previously minor: `.ai` and EPS import: an envelope saved in Edit Contents whose mesh lies away from its drawn art by a move opens live on that art (#6570; scores and estimates unchanged); previously minor: ruler double-click adds a guide at the pointer, #5239; G5: Status Effects graphic style library; bundled content ~40% → ~42%; MCP symbol libraries list UI Frames and Map Markers; previously minor: G5: Inventory Icons built-in symbol library; bundled content ~38% → ~40%; previously minor: `.ai` and EPS import: stroked type in an envelope maps from its glyphs grown by half its stroke (#3179; scores and estimates unchanged); previously minor: `.ai` and EPS import: warps of type open as mesh envelopes on their saved grid where VectorCraft's warp doesn't draw as their drawn art (#3179; scores and estimates unchanged); G5: Game Trails brush library; bundled content ~36% → ~38%; previously minor: Edit › Edit Custom Dictionary…: its dialog adds, deletes and changes the custom dictionary's words, #4936; previously minor: `.ai` and EPS import: envelopes of type open live where they draw as their drawn art and the layers with them draw as the page (#3179; scores and estimates unchanged); G5: Game HUD graphic style library; bundled content ~34% → ~36%; previously minor: Line Arrow arrowhead (#5421; scores and estimates unchanged); G5: Map Markers built-in symbol library; bundled content ~32% → ~34%; previously minor: right-click on type: Spelling › Auto Spell Check, with its check mark, #4936; previously minor: right-click on a word Auto Spell Check underlined: its suggestions, Ignore All and Add to Dictionary, #4936; previously minor: Canvas: a 3D effect changed on type or a group redraws where its solid was; Fit to Artwork Bounds and per-artboard SVG export build each solid once for all artboards; previously minor: Effect Gallery: a thumbnail for each filter and a preview area inside the dialog, on an original drawing; Raster effects 52% → 55%, hours 1–2 → none; headline numbers unchanged; Auto Spell Check: `edit.autoSpellCheck` underlines the unknown words, #4936; previously minor: PDF editable import preserves authored ActualText once, including empty/nested spans and authored ordering (#6165); cross-line/style layout remains approximate; scores and estimates unchanged; PDF marked-text export (#6309): compatible glyphs stay on one layout line with per-glyph offsets; scores and estimates unchanged; G5: UI Frames built-in symbol library with default 9-slice; bundled content ~32%; previously minor: G5: dynamic symbol part on-canvas opacity/blend/gradient/pattern; strokes remaining no longer lists Overlap/auto corners; symbols ~88%; previously minor: interim macOS cursor delivery, #2292; native validation pending; scores and estimates unchanged; previously minor: harakat paint fallback clarified; previously minor: current Guides feature-area rows consolidated using existing ruler evidence; scores and estimates unchanged; previously minor: Control bar › Snapping includes the existing Snap to Glyph and Alignment Guides toggles (#6164); scores and estimates unchanged; previously minor: G5 docs: Art brush Overlap and Pattern brush auto corners removed from strokes remaining; symbols remaining lists dynamic on-canvas beyond solid and guides outside the art; previously minor: custom dictionary and Ignore All: `text.spelling.addWord`, `removeWord`, `changeWord`, `dictionary` and `ignoreAll`, #4936; previously minor: EPS import: embedded fonts (composite, Type 42, CID-keyed, Type 1, CFF FontSet) draw their glyphs; spell check engine: `text.spelling.check` and `text.spelling.suggest` on craft-proof, #4936; previously minor: floating tab groups collapse into the side icon rail and opened rail panels fold back into it, #5925 in part; `.ai`/EPS type keeps its tab stops, and right-aligned lines with tabs lay out as the file's page, #6147; `.ai`/EPS type from the text document lays its lines out closer to the file's page, within limits, #6137; `.ai` and EPS import: older Art brush objects read; numeric fields step on wheel hover without taking keyboard focus, and a panel wheel turn cannot seed a canvas zoom glide, #5949; Character Styles panel: a double-click on a style's row opens its Character Style Options; the dialog keeps a fixed width and scrolls its sections, so its buttons stay on screen; Tools stays beside the canvas with left-side panels; new gradients follow document color mode; Selection QoL: marquee modes and visible feedback, #5313; SVG CSS classes survive export and repeated import in all four styling modes (#2480); current-main integration retains event attributes and scripts; #3380 deletion-only review follow-up: independent survivors keep gradient placement, owned subpaths avoid discarded copies, and contracts/status/evidence are clarified; endpoint highlighting remains open; scores and estimates unchanged; the canvas keeps selection outlines and anchors between frames; Indian-language hyphenation review and license allowlist, #4947; Stroke gradients: an arrowhead aligned to the tip is painted to the corners of its base, #5964; Drop Shadow and glow dialogs: spinner arrows, #5367, #5368; Stroke Weight Up and Down shortcuts, #5797; Hindi catalog and contributor loanword preferences; full wording review in progress; Properties in Edit Artboards: a Transform section with the reference point above the Artboards section, #5219; the Control bar's Stroke: and Opacity: links scrub their fields, #4088; an image zoomed in on is separated, colorized or proofed only where it shows (#4155); a document's first frame renders on the render worker, so opening a heavy file no longer freezes the window, #4155; Control bar Paragraph section with type selected, #5372; translating unchanged type reuses its glyph and character-stroke outlines; scores and estimates unchanged) · **Target:** Adobe Illustrator 2026 (30.x; public release notes through 30.7, August 2026; Units › East Asian Type acts, with Q and Ha units; scores unchanged) > > Tech Circuit update (2026-11-14): three original procedural brushes; ten built-in brush libraries (G5). > @@ -249,7 +249,7 @@ dominate; 3D, graphs and automation are specialist). They sum to 105. Feature de | Selection, transform & align tools | 6 | 85% | Direct Selection segment click/Delete corrected (#1278); deletion splits an ordinary contour into selected sibling objects with bounds-fitted gradients kept in place (#3380, deletion only; `crates/engine/tests/it/delete_path_pieces.rs`); open-path anchor Delete keeps gaps; Select › Start Global Edit finds the paths, compound paths and symbol instances of the selected object's shape (Appearance, Size and artboard options) and gives an edit of one to all of them in proportion, as one undo step (#3521), and on a group the groups like it, an edit inside one reaching the same object in the others (#4939), and a Shift-click on a highlighted match leaves it out; the Align panel menu's Align to Glyph Bounds › Point Text and Area Text measure type by its glyphs' ink for Align and Distribute (#4231); remaining: Free Transform/Scale/Reflect along a rotated box, Global Edit of rotated copies, transform nuances (no-op anchor Align history regression-tested, #1180 follow-up) | 4–6 | estimated; Global Edit regression-tested (`crates/engine/src/tests/globaledit.rs`; Quick Action, menu label and Escape in `panels::properties::tests::start_global_edit_quick_action_and_escape`) | | Drawing tools (Pen, Curvature, Pencil, shapes, Shaper) | 7 | 85% | Shaper construction widget, Pencil/Pen nuances, Blob Brush options, Touch Type, Dimension tool; see [ui-parity.md](ui-parity.md) | 8–13 | estimated; Curvature point display regression-tested (#1236, in part); Polygon/Star exact-size count persistence regression-covered; Live Corners' Relative rounding done (#3091), score unchanged; Copy and Cut with the Pen or Curvature tool take the anchors a Cmd/Ctrl-lent Direct Selection picked (#6123), score and hours unchanged; the Pen, Smart Pen and Curvature tool show the measurement readout with the rubber band off (#7043), score, gaps and hours unchanged | | Path operations, Pathfinder, Shape Builder, Live Paint | 5 | 80% | Shape Builder on the reporter's file (#937: art past 4,096 segments is cut by lines again; unconfirmed on the file itself); gap detection shares Live Paint’s finder, with a 72 pt custom cap and the existing options; Live Paint Gap Options | 4–8 | estimated; Shape Builder Gap Detection shares Live Paint’s spatial gap finder and temporary merge bridges (#2526); Custom is capped at 72 pt in the existing options dialog (lowered from 86%: open issues); compound attributes regression-tested (#1197); single-result source names survive SVG export/import (#1293), with [SVG ID semantics](https://www.w3.org/TR/SVG2/struct.html#IDAttribute) and original-shape tests; Simplify component selection and preview regression-tested (#1272); Simplify of a Direct Selection part of a path regression-tested (`tests/simplify_part.rs`); Divide open-cutting-path geometry and appearance regression-tested (#1307); the Shape Builder's edge-source grid is bounded in memory and files a segment once per cell (`planar.rs` test `rect_index_holds_a_bounded_number_of_references`); live compound shapes (Make, Alt-click, member Shape Modes, Release, Expand, saved and exported) regression-tested (#4522); Live Paint Bucket face drags, including narrow faces and one Undo, regression-tested (#6373) | -| Colour, swatches, gradients, patterns, mesh, recolor | 7 | 92% | Eyedropper copies effective character dimensions across text transforms (#6404); 30.0's gradient additions are done (dither, perceptual blending, presets); freeform gradients in SVG/PDF, mixed spot/process gradients in SVG, PDF gradients mixing a spot color with RGB or Lab stops, and dithered spot gradient fills and Perceptual spot gradients with RGB or Lab stops other than white or more than 4,096 stops on their curve, which PDF export writes as images in process colors| 4–7 | estimated; Recolor model selection is available through the engine and MCP (#2520), and the dialog's color sliders (HSB, RGB, CMYK, Lab, Tint for a spot color) edit the selected row's new color in its mode, and the Edit tab's Global Adjust sliders (Saturation, Brightness, Temperature, Luminosity, -100% to 100%) change every recolored color at once (lowered from 96%: target moved); unpainted zero-width stroke restoration fixed (#1253), score and hours unchanged; Eyedropper source reads regression-tested (#1251); screen-bounded Recolor Edit chip list (#3416), score and hours unchanged; a point on a gradient mesh's outline locates on its edge on every side (#7006: `mesh_locate_takes_a_point_on_any_side_of_the_outline`, `mesh_add_line_exactly_on_the_edge_needs_no_tolerance`), score and hours unchanged; Color panel spectrum grows with the resized panel (#8005) | +| Colour, swatches, gradients, patterns, mesh, recolor | 7 | 92% | Eyedropper copies effective character dimensions across text transforms (#6404); 30.0's gradient additions are done (dither, perceptual blending, presets); freeform gradients in SVG/PDF, mixed spot/process gradients in SVG, PDF gradients mixing a spot color with RGB or Lab stops, and dithered spot gradient fills and Perceptual spot gradients with RGB or Lab stops other than white or more than 4,096 stops on their curve, which PDF export writes as images in process colors| 4–7 | estimated; Recolor model selection is available through the engine and MCP (#2520), and the dialog's color sliders (HSB, RGB, CMYK, Lab, Tint for a spot color) edit the selected row's new color in its mode, and the Edit tab's Global Adjust sliders (Saturation, Brightness, Temperature, Luminosity, -100% to 100%) change every recolored color at once (lowered from 96%: target moved); unpainted zero-width stroke restoration fixed (#1253), score and hours unchanged; Eyedropper source reads regression-tested (#1251); screen-bounded Recolor Edit chip list (#3416), score and hours unchanged; a point on a gradient mesh's outline locates on its edge on every side (#7006: `mesh_locate_takes_a_point_on_any_side_of_the_outline`, `mesh_add_line_exactly_on_the_edge_needs_no_tolerance`), score and hours unchanged; Color panel spectrum grows with the resized panel (#8005); gradient stop editor color-mode menu (#7918) | | Strokes, brushes, width profiles | 5 | 88% | Shift-double-click adjoining adjustment is implemented; brush libraries are done (ten generated libraries including Tech Circuit, Ink and Wash, Bristle Brushes, Game Trails, Energy Beams and Dry Media, User Defined, Other Library…, Save Brushes); Art brush Overlap and Pattern brush auto corners are done; remaining: pen pressure on macOS, Stylus Wheel, more built-in brush libraries, tilt, bearing and rotation for Art, Pattern and Bristle brushes and on native Wayland and the web | 8–15 | estimated; width-point creation and adjoining adjustment regression-tested; dialog layout reviewed; evidence below; finite-arithmetic follow-up regressions and full CI passed (evidence below) | | Appearance, transparency, graphic styles, masks | 5 | 97% | raster effect reach in preview bounds | 1–2 | estimated; Transform typing, sliders, preview, and undo are covered in `crates/ui-egui/src/panels/tests_appearance.rs` | | 3D and Materials (and Turntable) | 4 | ~25% | live Revolve with automatic smooth vector shading and default-on continuous circular caps, Extrude & Bevel (twist, taper, caps, five bevel shapes), Inflate and Rotate with Position presets (colored Inflate uses smooth membrane lighting; white-light Inflate retains its existing shading; Extrude & Bevel and Rotate retain planar shading; one to ten colored lights, shared neutral ambient, painter visibility); materials, light presets, shadows, ray tracing, the rest of 3D Classic (Map Art), Turntable views, textures, map art and shading in 3D export | 30–55 | estimated (Extrude & Bevel, Inflate and Rotate added 2026-10-12); every 3D seam has round joins (2026-11-12, [three-d.md](three-d.md#seams)), score, gaps and hours unchanged | @@ -1698,6 +1698,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - Hue Clockwise and Hue Counterclockwise, VectorCraft's own gradient methods, in the Gradient panel's Method menu and on `paint.editGradient` and `paint.setFill` (`method`: `hue-clockwise`, `hue-counterclockwise`): a linear, radial, conic or diamond gradient's colors mix around the hue wheel, with hue, saturation and brightness each changing evenly from one stop to the next and the hue angle keeping one direction, as the fixed-direction rules of [CSS Color 4](https://www.w3.org/TR/css-color-4/#hue-interpolation) do: falling with Hue Clockwise (red, magenta, blue), which is clockwise on the color wheels, and rising with Hue Counterclockwise (red, yellow, green). Hues less than half a color level apart count as one hue, so a color and its tint do not turn the wheel. A gray stop takes the hue of the stop it mixes with, and black its saturation too. The canvas and raster exports draw it through stops on that curve, within half a color level; Reverse Gradient turns the method the other way with the stops, so the ramp keeps its colors. SVG and PDF write it as an RGB image, EPS as a shading in process colors, and a legacy `.ai` file and the `.ai` editing data with the colors between its stops as stops of their own, with a warning. - Gradient spread, VectorCraft's own setting: Pad, Repeat or Reflect, with a Repeats count of 1 to 100, in the Gradient panel and on `paint.editGradient` and `paint.setFill`; Repeat and Reflect run a linear, radial, conic or diamond gradient's stops that many times along the vector and on past its ends, the Gradient tool marks where the runs meet, and SVG writes and reads `spreadMethod`, CSS writes repeating gradients, PDF writes a conic's sweep shading over one run and the other kinds with their stops repeated across the shape, as EPS, legacy `.ai` and the `.ai` editing data do. - The stop popover a double-click on a stop opens (the Gradient tool's annotator or the Gradient panel) has an eyedropper beside its Color and Swatches tabs: it closes the popover and samples the next colour clicked on the art into the stop, as the Gradient panel's eyedropper does (#4681). + - The stop editor’s Color tab has a compact menu named for the current mode: Grayscale, RGB, HSB, CMYK or Web Safe RGB (#7918). It shares the Color panel’s saved mode and color conversion, including making a linked tint a process color. A mode choice keeps the editor open; Escape closes the menu before the editor, and a click outside both closes the editor. The same controls edit a freeform point. Evidence: `crates/ui-egui/tests/gradient_stop_color_mode_menu.rs`. Cmd/Ctrl-click on the Gradient panel's Gradient Fill box or on the Tools panel's Gradient button resets the gradient of the active Fill or Stroke to the linear White, Black gradient, as one undo step ([Default keyboard shortcuts](https://web.archive.org/web/20260726060015/https://helpx.adobe.com/illustrator/using/default-keyboard-shortcuts.html)). With a gradient stop or a freeform gradient point selected, Alt-clicking a color swatch in the Swatches panel recolors it instead of the inactive Fill or Stroke. - **Freeform gradient colors in their own model:** Object ▸ Expand and Object ▸ Create Gradient Mesh (`object.mesh.create`) mix a freeform gradient's points in the color model they share: points of C50 M20 Y0 K10 give mesh points of C50 M20 Y0 K10, and RGB points keep their values in a working RGB space other than sRGB. The canvas, the gradient chips and the SVG, PDF, EPS and EMF writers mix the points in that model too. PDF and EPS write a gradient whose points are all CMYK, or all Gray in a CMYK file, as a CMYK image, which PDF's Output settings convert as they convert any CMYK image. Points in different models mix in display RGB (on the canvas in a CMYK document that shows transparency, as the inks of each point), and a CMYK document stores the result of Expand as CMYK through the color settings. Points colored along CMYK stops (`paint.editGradient {stops}`, or a CMYK gradient switched to freeform) are CMYK, and so are a point `paint.freeform.splitLine` adds between CMYK points and a point `paint.freeform.addPoint` adds without `color` to CMYK points. Public reference: [Gradients](https://web.archive.org/web/20250714042311/https://helpx.adobe.com/illustrator/using/gradients.html) and [Meshes](https://web.archive.org/web/20250812201019/https://helpx.adobe.com/illustrator/using/meshes.html), which do not state how colors in different models mix; the rule is VectorCraft's own. @@ -2651,6 +2652,7 @@ Edit › Copy and Cut put the selected ruler guides on the clipboard, with the s | Date | Change | Summary | |---|---|---| +| 2026-11-16 | minor | Gradient stop editor: a compact Color-tab menu offers Grayscale, RGB, HSB, CMYK and Web Safe RGB, sharing the Color panel mode and conversion behavior (#7918). Choosing a mode keeps the editor open; Escape closes the menu first. Scores and estimates unchanged. | | 2026-11-16 | minor | Color panel: the spectrum fills the vertical space of a resized panel, with options shown or hidden (#8005). Compact auto-fit flyouts and embedded mixers keep their existing size. Evidence: panels::color::tests::the_spectrum_grows_with_the_color_panel. Scores and estimates unchanged. | | 2026-11-14 | minor | Paragraph composers (#4935): `text.setFormat {composer}` and paragraph styles take `singleLine` and `everyLine` (the Middle Eastern & South Asian composers, what all type used and the default) and `standardSingleLine` and `standardEveryLine`, which break lines the same way and set a complex script (Indic, Arabic, Hebrew) glyph by glyph as the font maps its characters, with no conjuncts, reordering, marks placed or joining forms. The choice is per paragraph, saved in the native file only when it is not Every-line, and not written to `.ai`, EPS or PDF files, whose composer setting this app has no recorded format for. Scores and estimates unchanged. Tests `tests::composers`. | | 2026-11-14 | minor | G5: Weather Icons joins Basic Shapes, UI Frames, Map Markers, Inventory Icons and Skill Icons as a sixth built-in symbol library (Sun, Moon, Cloud, Rain, Thunder, Snow; original procedural vector symbols generated in code, no default 9-slice); area score and estimate unchanged. | diff --git a/docs/ui-parity.md b/docs/ui-parity.md index 8e06948b33..cac615d413 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -1,6 +1,6 @@ # UI and interaction parity -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-16 · **Change:** minor (#8005: the Color spectrum fills a resized panel; scores and estimates unchanged; previously: Pencil continuation, straight-line and closing cursors; scores and estimates unchanged; previously: Graphic Styles list fills a taller panel, #2992; scores and estimates unchanged; previously: library panels' lists fill a taller panel, #2992; scores and estimates unchanged; previously: Swatches list fills a taller panel, #1638; scores and estimates unchanged; previously: icon-strip flyouts also resize from the top edge and the canvas-side top corner, keeping the moved top in workspaces (storytold/craft-libs#1094); scores and estimates unchanged; previously: macOS: the canvas cursor stays after the pointer moves, #6362; scores and estimates unchanged; previously minor: Remove Background in the Contextual Task Bar, Properties › Quick Actions and the Control bar; previously minor: Ruler origin: the corner drag snaps as a drawn point does; previously minor: Live Paint Bucket fills faces crossed in one drag (#6373); previously: #6404: transform-aware Eyedropper character copying; scores and estimates unchanged; previously: Outline view: images and gradient meshes are picked on what Outline draws, so a click inside them reaches the path behind, #6437; previously minor: a middle-click on a document tab closes it, #6506; previously minor: Blob Brush: a round tip's preview is the outline of the area it adds, round at both ends, as the stroke it commits (#4343); scores and estimates unchanged; previously:; ruler double-click adds a guide at the pointer, #5239; G5: Inventory Icons built-in symbol library (four built-ins); previously minor: files that record no units open in Preferences › Units › General, #5820; previously minor: interim macOS cursor delivery, #2292; native validation pending; scores and estimates unchanged; Control bar › Snapping includes the existing Snap to Glyph and Alignment Guides toggles (#6164); scores and estimates unchanged; floating tab groups collapse into the side icon rail and opened rail panels fold back into it, #5925 in part; numeric fields step on wheel hover without taking keyboard focus, #5949; Character Styles panel: a double-click on a style's row opens its Character Style Options; the dialog keeps a fixed width and scrolls its sections, so its buttons stay on screen; Selection QoL: marquee modes and visible feedback, #5313; #3380 deletion-only review follow-up: independent survivors keep gradient placement, owned subpaths avoid discarded copies, and contracts/status/evidence are clarified; endpoint highlighting remains open; scores and estimates unchanged; Drop Shadow and glow dialogs: spinner arrows, #5367, #5368; Stroke Weight Up and Down shortcuts, #5797; Layers: Rename (`ui.rename`) opens the name field of the selected layer, group or object, #5324; Properties in Edit Artboards: Transform section above the Artboards section, #5219; scrubby labels: the Control bar's Stroke: and Opacity: links and the Properties panel's Stroke link scrub their fields, #4088; Properties: Quick Actions has Repeat Options for one selected repeat, #5181; Direct Selection: Shift-click picks several blend spine points, which drag together, #5285; Direct Selection: Cmd/Ctrl held lends the Selection tool and shows its bounding box, #3901; Join tool trims two crossing open paths and joins them at the crossing, #5844; Control bar: Paragraph: link and Align left/center/right while type is selected, #5372; shape tools: a press on the selection's centre point moves it and one in the rotate zone outside a box corner turns it, #5477; scores and estimates unchanged) · **Target:** Adobe Illustrator 2026 (30.x; Units › East Asian Type acts, with Q and Ha units; scores unchanged) +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-16 · **Change:** minor (Gradient stop editor: its Color tab offers the five Color panel modes (#7918); scores and estimates unchanged; previously: #8005: the Color spectrum fills a resized panel; scores and estimates unchanged; previously: Pencil continuation, straight-line and closing cursors; scores and estimates unchanged; previously: Graphic Styles list fills a taller panel, #2992; scores and estimates unchanged; previously: library panels' lists fill a taller panel, #2992; scores and estimates unchanged; previously: Swatches list fills a taller panel, #1638; scores and estimates unchanged; previously: icon-strip flyouts also resize from the top edge and the canvas-side top corner, keeping the moved top in workspaces (storytold/craft-libs#1094); scores and estimates unchanged; previously: macOS: the canvas cursor stays after the pointer moves, #6362; scores and estimates unchanged; previously minor: Remove Background in the Contextual Task Bar, Properties › Quick Actions and the Control bar; previously minor: Ruler origin: the corner drag snaps as a drawn point does; previously minor: Live Paint Bucket fills faces crossed in one drag (#6373); previously: #6404: transform-aware Eyedropper character copying; scores and estimates unchanged; previously: Outline view: images and gradient meshes are picked on what Outline draws, so a click inside them reaches the path behind, #6437; previously minor: a middle-click on a document tab closes it, #6506; previously minor: Blob Brush: a round tip's preview is the outline of the area it adds, round at both ends, as the stroke it commits (#4343); scores and estimates unchanged; previously:; ruler double-click adds a guide at the pointer, #5239; G5: Inventory Icons built-in symbol library (four built-ins); previously minor: files that record no units open in Preferences › Units › General, #5820; previously minor: interim macOS cursor delivery, #2292; native validation pending; scores and estimates unchanged; Control bar › Snapping includes the existing Snap to Glyph and Alignment Guides toggles (#6164); scores and estimates unchanged; floating tab groups collapse into the side icon rail and opened rail panels fold back into it, #5925 in part; numeric fields step on wheel hover without taking keyboard focus, #5949; Character Styles panel: a double-click on a style's row opens its Character Style Options; the dialog keeps a fixed width and scrolls its sections, so its buttons stay on screen; Selection QoL: marquee modes and visible feedback, #5313; #3380 deletion-only review follow-up: independent survivors keep gradient placement, owned subpaths avoid discarded copies, and contracts/status/evidence are clarified; endpoint highlighting remains open; scores and estimates unchanged; Drop Shadow and glow dialogs: spinner arrows, #5367, #5368; Stroke Weight Up and Down shortcuts, #5797; Layers: Rename (`ui.rename`) opens the name field of the selected layer, group or object, #5324; Properties in Edit Artboards: Transform section above the Artboards section, #5219; scrubby labels: the Control bar's Stroke: and Opacity: links and the Properties panel's Stroke link scrub their fields, #4088; Properties: Quick Actions has Repeat Options for one selected repeat, #5181; Direct Selection: Shift-click picks several blend spine points, which drag together, #5285; Direct Selection: Cmd/Ctrl held lends the Selection tool and shows its bounding box, #3901; Join tool trims two crossing open paths and joins them at the crossing, #5844; Control bar: Paragraph: link and Align left/center/right while type is selected, #5372; shape tools: a press on the selection's centre point moves it and one in the rotate zone outside a box corner turns it, #5477; scores and estimates unchanged) · **Target:** Adobe Illustrator 2026 (30.x; Units › East Asian Type acts, with Q and Ha units; scores unchanged) > > Tech Circuit update (2026-11-14): three original procedural brushes; ten built-in brush libraries (G5). > @@ -458,6 +458,7 @@ next unit in the order a right-click on a ruler lists them, from Feet back to Po | Gradient panel: Method, Classic or Perceptual (30.0) | done | Method menu under the Stroke buttons for linear and radial gradients (`paint.editGradient` `method`); [public source](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/create-and-edit-gradients/control-perceptual-interpolation-in-gradients.html); `panels::gradient` test | | Gradient panel: Presets (30.0) | done | Presets menu by library (theme) plus Saved: applies a preset to the gradient behind the active proxy, keeping its placement, one undo step; panel menu Save Gradient Preset…, Delete Gradient Preset, Hide/Show Presets (`gradient.presets.*`); `panels::gradient` tests | | Gradient panel: delete a stop | done | Delete Stop at the right end of the ramp deletes the selected stop, and a stop dragged down off the ramp is deleted on release, never below two stops, one undo step each; [Gradient panel options](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/create-and-edit-gradients/gradient-tool-and-panel.html); `panels::gradient` test | +| Gradient stop editor: Color mode menu | done | Compact current-mode menu offers Grayscale, RGB, HSB, CMYK and Web Safe RGB, sharing the Color panel mode and conversion; a choice keeps the editor open, Escape closes the menu first, and clicking outside both dismisses the editor (#7918); `crates/ui-egui/tests/gradient_stop_color_mode_menu.rs` | | Gradient tool: the annotator's end handle changes the length; Alt-drag changes the length and angle together | done | A plain drag keeps the end on the bar's line, at least 10 px from the start (VectorCraft's own minimum); Alt-drag moves it freely, Shift with Alt at 45° steps; [Default keyboard shortcuts](https://helpx.adobe.com/illustrator/using/default-keyboard-shortcuts.html); `xform::gradient` tests | | Workspaces (save, reset, switch); each remembers the layout changes made in it across switches and restarts until Reset | done | `UiState::workspace_changes` | | Opening a file: after 0.4 s a progress window with the file name, a moving bar (reading counts no steps), how many more files wait, Cancel (Esc: the file doesn't open) and Continue in Background; never over another dialog or progress window | done | #5930; `opening::show`, `file.cancelOpen`, `file.openInBackground`. Save, Place and Close still show only the status bar's spinner (Place and Save run off the UI thread; Close is immediate) | @@ -554,6 +555,7 @@ before release (#6373). [Paint faces and edges](https://helpx.adobe.com/illustra | Date | Change | Summary | |---|---|---| +| 2026-11-16 | minor | Gradient stop editor: a compact Color-tab menu offers Grayscale, RGB, HSB, CMYK and Web Safe RGB, sharing the Color panel mode and conversion behavior (#7918). Choosing a mode keeps the editor open; Escape closes the menu first. Scores and estimates unchanged. | | 2026-11-16 | minor | Color panel: the spectrum fills the vertical space of a resized panel, with options shown or hidden (#8005). Compact auto-fit flyouts and embedded mixers keep their existing size. Evidence: panels::color::tests::the_spectrum_grows_with_the_color_panel. Scores and estimates unchanged. | | 2026-11-14 | minor | Tech Circuit adds three original procedural brushes (Circuit Trace, Bus Lines, Terminal Nodes); ten built-in brush libraries. G5 remaining estimate 3–13 h (estimated); parity scores and headline totals unchanged. | | 2026-11-12 | minor | Numeric fields: a focus click released more than 1 pt from its press keeps the caret; a tap within 1 pt still selects the whole value (#6659, follow-up to #1326). Scores and estimates unchanged. | From a99db2ce13c7c2c558df76c6f38f5b2bd5a38b06 Mon Sep 17 00:00:00 2001 From: yoriswind Date: Mon, 23 Nov 2026 10:08:56 -0800 Subject: [PATCH 02/84] Select gradient mode buttons by their accessibility role --- crates/ui-egui/tests/gradient_stop_color_mode_menu.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/tests/gradient_stop_color_mode_menu.rs b/crates/ui-egui/tests/gradient_stop_color_mode_menu.rs index 3bb31a263d..dd6a7b3df5 100644 --- a/crates/ui-egui/tests/gradient_stop_color_mode_menu.rs +++ b/crates/ui-egui/tests/gradient_stop_color_mode_menu.rs @@ -110,7 +110,9 @@ impl Scene { self.buttons.clear(); let update = output.platform_output.accesskit_update.as_ref().expect("AccessKit enabled"); for (_, node) in &update.nodes { - if let Some((label, bounds)) = node.label().zip(node.bounds()) { + if node.role() == egui::accesskit::Role::Button + && let Some((label, bounds)) = node.label().zip(node.bounds()) + { self.buttons .push((label.to_owned(), Rect::from_min_max(pos2(bounds.x0 as f32, bounds.y0 as f32), pos2(bounds.x1 as f32, bounds.y1 as f32)))); } From 58e99f5fb3fd5bfc0708899ad3f16e8fb31e9f6c Mon Sep 17 00:00:00 2001 From: yoriswind Date: Thu, 26 Nov 2026 12:24:42 -0800 Subject: [PATCH 03/84] Format the native gradient stop interaction cases --- .../tests/gradient_stop_color_mode_menu.rs | 49 +++++++++++++------ 1 file changed, 33 insertions(+), 16 deletions(-) diff --git a/crates/ui-egui/tests/gradient_stop_color_mode_menu.rs b/crates/ui-egui/tests/gradient_stop_color_mode_menu.rs index 5e667c70cf..478d02b58b 100644 --- a/crates/ui-egui/tests/gradient_stop_color_mode_menu.rs +++ b/crates/ui-egui/tests/gradient_stop_color_mode_menu.rs @@ -108,7 +108,8 @@ impl Scene { self.app.ui(ui); }); let _ = self.app.frame_input(take_output(&self.ctx)); - self.nodes = output.platform_output.accesskit_update.as_ref().expect("AccessKit enabled").nodes.iter().map(|(_, node)| node.clone()).collect(); + self.nodes = + output.platform_output.accesskit_update.as_ref().expect("AccessKit enabled").nodes.iter().map(|(_, node)| node.clone()).collect(); output.textures_delta.clear(); } @@ -141,8 +142,11 @@ impl Scene { } fn popover(&self) -> Rect { - self.nodes.iter().find(|n| n.role() == Role::Dialog && n.label() == Some("Gradient stop")) - .and_then(Self::node_rect).expect("the actual native stop popover") + self.nodes + .iter() + .find(|n| n.role() == Role::Dialog && n.label() == Some("Gradient stop")) + .and_then(Self::node_rect) + .expect("the actual native stop popover") } fn editor_open(&self) -> bool { @@ -154,8 +158,7 @@ impl Scene { } fn child_open(&self) -> bool { - overlay::top(&self.ctx).and_then(|id| overlay::entry(&self.ctx, id)) - .is_some_and(|entry| !entry.exiting && entry.keys == OwnerClass::Menu) + overlay::top(&self.ctx).and_then(|id| overlay::entry(&self.ctx, id)).is_some_and(|entry| !entry.exiting && entry.keys == OwnerClass::Menu) } fn open_stop(&mut self) { @@ -175,8 +178,13 @@ impl Scene { fn button(&self, label: &str) -> Rect { let popover = self.popover(); - let matches: Vec<_> = self.nodes.iter().filter(|node| node.role() == Role::Button && node.label() == Some(label)) - .filter_map(Self::node_rect).filter(|rect| rect.is_positive() && popover.contains(rect.center())).collect(); + let matches: Vec<_> = self + .nodes + .iter() + .filter(|node| node.role() == Role::Button && node.label() == Some(label)) + .filter_map(Self::node_rect) + .filter(|rect| rect.is_positive() && popover.contains(rect.center())) + .collect(); assert_eq!(matches.len(), 1, "one actual native mode chooser {label:?}"); matches[0] } @@ -192,13 +200,17 @@ impl Scene { } fn mode_rows(&self) -> Vec<(String, bool, Rect)> { - let mut rows: Vec<_> = self.nodes.iter().filter_map(|node| { - let label = node.label()?; - if !matches!(node.role(), Role::MenuItem | Role::MenuItemRadio | Role::MenuItemCheckBox) || !MODES.contains(&label) { - return None; - } - Some((label.to_owned(), node.toggled() == Some(Toggled::True), Self::node_rect(node)?)) - }).collect(); + let mut rows: Vec<_> = self + .nodes + .iter() + .filter_map(|node| { + let label = node.label()?; + if !matches!(node.role(), Role::MenuItem | Role::MenuItemRadio | Role::MenuItemCheckBox) || !MODES.contains(&label) { + return None; + } + Some((label.to_owned(), node.toggled() == Some(Toggled::True), Self::node_rect(node)?)) + }) + .collect(); rows.sort_by(|a, b| a.2.top().total_cmp(&b.2.top())); rows } @@ -242,8 +254,13 @@ impl Scene { fn spectrum(&self) -> Rect { let popover = self.popover(); - let found: Vec<_> = self.nodes.iter().filter(|node| node.role() == Role::Group && node.label() == Some("Color Ramp")) - .filter_map(Self::node_rect).filter(|rect| popover.contains(rect.center())).collect(); + let found: Vec<_> = self + .nodes + .iter() + .filter(|node| node.role() == Role::Group && node.label() == Some("Color Ramp")) + .filter_map(Self::node_rect) + .filter(|rect| popover.contains(rect.center())) + .collect(); assert_eq!(found.len(), 1, "the actual native Color panel spectrum"); found[0] } From e19bb786f55b3f7d7aa8b8cced7f5aafe24a9c96 Mon Sep 17 00:00:00 2001 From: yoriswind Date: Thu, 26 Nov 2026 12:39:18 -0800 Subject: [PATCH 04/84] Use the current native menu trigger import --- crates/ui-egui/src/dialogs/gradient_stop.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/dialogs/gradient_stop.rs b/crates/ui-egui/src/dialogs/gradient_stop.rs index 37b70f2907..0c82b2af34 100644 --- a/crates/ui-egui/src/dialogs/gradient_stop.rs +++ b/crates/ui-egui/src/dialogs/gradient_stop.rs @@ -21,11 +21,11 @@ use craft::theme::Srgba; use craft::theme::variant::Tone; use craft::ui::buttons::Button; use craft::ui::choice::Segmented; -use craft::ui::contract::{Bind, Entry, PopupKind, Show as _, ShowContainer as _}; +use craft::ui::contract::{Bind, Entry, PopupKind, Show as _, ShowContainer as _, Trigger}; use craft::ui::dialog::{DialogId, DialogResult, DialogStack, FieldRefusal, StackDialog, dialog_id}; use craft::ui::form::Field; use craft::ui::layout_components::{Row, Stack}; -use craft::ui::menu::{Menu, MenuItem, Trigger}; +use craft::ui::menu::{Menu, MenuItem}; use craft::ui::notices::Notice; use craft::ui::popover::Popover; use craft::ui::runtime::env::{Env, Label, UnitKind}; From f2c9e05294c0ca2ea4b796385e4d91083efbf4ff Mon Sep 17 00:00:00 2001 From: yoriswind Date: Thu, 26 Nov 2026 13:28:13 -0800 Subject: [PATCH 05/84] Close the gradient editor with an outside-dismissed mode menu --- crates/ui-egui/src/dialogs/gradient_stop.rs | 15 +++++++++++---- .../tests/gradient_stop_color_mode_menu.rs | 3 ++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/crates/ui-egui/src/dialogs/gradient_stop.rs b/crates/ui-egui/src/dialogs/gradient_stop.rs index 0c82b2af34..407d44b8c5 100644 --- a/crates/ui-egui/src/dialogs/gradient_stop.rs +++ b/crates/ui-egui/src/dialogs/gradient_stop.rs @@ -218,6 +218,9 @@ impl StackDialog for GradientStopPopover { .at_point(*at) .close_on_enter(true) .show(ui, |ui, _| body(ui, feed, tab, panel, filed)); + if shown.inner == Some(true) { + return Some(DialogResult::Cancel); + } match shown.output.closed { Some(CloseReason::Enter) => Some(DialogResult::Ok(set.clone())), Some(_) => Some(DialogResult::Cancel), @@ -268,7 +271,8 @@ impl StackDialog for GradientStopPopover { /// The popover's body: the tabs and the eyedropper, the Color panel or the swatches, then opacity and location (a /// point: spread). What the user edits is filed in `filed`. -fn body(ui: &mut Ui, feed: &Feed, tab: &mut Tab, panel: &mut ColorPanelState, filed: &mut Filed) { +fn body(ui: &mut Ui, feed: &Feed, tab: &mut Tab, panel: &mut ColorPanelState, filed: &mut Filed) -> bool { + let mut outside = false; Stack::new().show(ui, |ui, _| { Row::new().show(ui, |ui, _| { let tabs = [ @@ -282,7 +286,7 @@ fn body(ui: &mut Ui, feed: &Feed, tab: &mut Tab, panel: &mut ColorPanelState, fi filed.eyedropper |= DropperButton::new(tip, Bind::given(false)).show(ui).edit.value() == Some(&true); } if *tab == Tab::Color { - mode_menu(ui, &feed.shown, panel.mode); + outside |= mode_menu(ui, &feed.shown, panel.mode); } }); match *tab { @@ -307,11 +311,12 @@ fn body(ui: &mut Ui, feed: &Feed, tab: &mut Tab, panel: &mut ColorPanelState, fi *amount = percent_field(ui, label.to_owned(), feed.amount).or(*amount); }); }); + outside } /// The Color panel's existing five mode commands. Native menu ownership keeps its parent popover /// open on a pick and gives the child the first Escape, including rows outside the parent bounds. -fn mode_menu(ui: &mut Ui, shown: &ColorPanelShown, fallback: ColorPanelMode) { +fn mode_menu(ui: &mut Ui, shown: &ColorPanelShown, fallback: ColorPanelMode) -> bool { let words = Env::of(ui).words::(); let label = match shown { ColorPanelShown::Mode(mode) => mode.label(&words), @@ -319,11 +324,13 @@ fn mode_menu(ui: &mut Ui, shown: &ColorPanelShown, fallback: ColorPanelMode) { _ => fallback.label(&words), }; let button = Button::new(label).popup(PopupKind::Menu).show(ui); - Menu::new(tl!("Color mode")).opened_by(&button, Trigger::Click).show(ui, |ui, _| { + let menu = Menu::new(tl!("Color mode")).opened_by(&button, Trigger::Click).show(ui, |ui, _| { for mode in ColorPanelMode::FILL_STROKE { MenuItem::command(mode.command()).show(ui); } }); + // The child absorbs an outside press before its parent sees it. Close both for that event only. + menu.output.closed == Some(CloseReason::Outside) } /// Document swatches as tiles: a pick gives the stop (or point) that colour. diff --git a/crates/ui-egui/tests/gradient_stop_color_mode_menu.rs b/crates/ui-egui/tests/gradient_stop_color_mode_menu.rs index 478d02b58b..d1e5a9f2eb 100644 --- a/crates/ui-egui/tests/gradient_stop_color_mode_menu.rs +++ b/crates/ui-egui/tests/gradient_stop_color_mode_menu.rs @@ -257,7 +257,8 @@ impl Scene { let found: Vec<_> = self .nodes .iter() - .filter(|node| node.role() == Role::Group && node.label() == Some("Color Ramp")) + // The component and its interactive bar share a name; only the bar carries the mode value. + .filter(|node| node.role() == Role::Group && node.label() == Some("Color Ramp") && node.value() == Some("RGB Sliders")) .filter_map(Self::node_rect) .filter(|rect| popover.contains(rect.center())) .collect(); From 4b029c657e15e7badf5d476ae80a443f0be96886 Mon Sep 17 00:00:00 2001 From: yoriswind Date: Thu, 26 Nov 2026 15:02:33 -0800 Subject: [PATCH 06/84] Use the current stroke paint API in Properties --- crates/ui-egui/src/panels/properties/appearance_section.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/ui-egui/src/panels/properties/appearance_section.rs b/crates/ui-egui/src/panels/properties/appearance_section.rs index cd71a0f035..e2ae112143 100644 --- a/crates/ui-egui/src/panels/properties/appearance_section.rs +++ b/crates/ui-egui/src/panels/properties/appearance_section.rs @@ -102,7 +102,7 @@ fn effect_delete(app: &mut VectorcraftApp, ui: &mut Ui, id: NodeId, effects: &[( /// active Appearance row in `PropertiesUi::edited_profiled`. False while the Type tool edits text or /// the Live Paint Bucket is active, when the list edits the stroke the panel shows. fn edited_strokes_profiled(app: &mut VectorcraftApp) -> bool { - if panels::character::text_editing(app).is_some() || app.session.bucket_paints() { + if panels::character::text_editing(app).is_some() || app.session.tool_paints(true) { return false; } let Some(st) = app.session.active() else { return false }; From f669763c4e337b55ffd58c0602bf9c090e276c00 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 26 Nov 2026 17:05:19 -0800 Subject: [PATCH 07/84] Download the File Info metadata template in the browser --- crates/ui-egui/src/dialogs/file_info.rs | 102 +++++++++++++++++++++++- 1 file changed, 101 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/dialogs/file_info.rs b/crates/ui-egui/src/dialogs/file_info.rs index 80439178a8..15b9ac79c7 100644 --- a/crates/ui-egui/src/dialogs/file_info.rs +++ b/crates/ui-egui/src/dialogs/file_info.rs @@ -113,6 +113,8 @@ enum Request { SaveTo(PathBuf), /// A browser picker returned a template larger than the import limit. TemplateTooLarge, + /// Download the current draft as a template, without requiring a filesystem path. + Download, /// Merge the template `source` into the fields as `mode` says. Import { source: Info, mode: &'static str }, } @@ -136,6 +138,7 @@ enum Chosen { #[derive(Default)] struct Templates { can_save: bool, + web_save: bool, can_open: bool, has_folder: bool, /// The metadata templates folder, where the save pick starts, once listed. @@ -221,6 +224,7 @@ impl Templates { } }); match chosen { + Some(Chosen::Pick(Pick::Save)) if self.web_save => self.requests.push(Request::Download), Some(Chosen::Pick(kind)) => self.pick(cx, kind, title), Some(Chosen::Template(file)) => wait_for_template(import, file), Some(Chosen::Folder) => self.requests.push(Request::Folder), @@ -567,6 +571,26 @@ fn save_template(app: &mut VectorcraftApp, picked: PathBuf, fields: Info) -> Res save(app).map(|_| ()) } +/// Save the draft through the browser's file service. Serializing it changes neither drawing nor draft. +fn download_template(app: &mut VectorcraftApp, fields: Info) -> Result<(), String> { + let title = text_of(&fields, "title"); + let stem = vectorcraft_engine::cmd::library::file_stem_for(if title.trim().is_empty() { "Metadata" } else { &title }); + let name = format!("{stem}.{XMP_EXT}"); + let result = app.run("file.info.saveTemplate", json!({"fields": fields}))?; + let data = result["data"].as_str().ok_or("the metadata template contains no data")?.as_bytes().to_vec(); + let request = PickRequest::save(PURPOSE).file_name(name).suggested_extension(XMP_EXT).filter(tl!("XMP metadata templates"), &[XMP_EXT]); + file_asks::save(app, request, data, file_asks::Owner::Free, |app, picked| { + match picked { + Picked::Downloaded(name) => app.status(format!("Saved {name}")), + Picked::Saved { path, .. } => app.status(format!("Saved {}", path.display())), + Picked::Failed(error) => return Err(error), + _ => {} + } + Ok(Value::Null) + }); + Ok(()) +} + /// Merge the template `source` names into the dialog's fields as `mode` says. fn import(app: &mut VectorcraftApp, d: &mut FileInfoDialog, source: Info, mode: &str) -> Result<(), String> { let mut p = Value::Object(source); @@ -587,10 +611,13 @@ pub(crate) fn pump(app: &mut VectorcraftApp, _ctx: &egui::Context) { // PLAN: fl.A9 lists no `file_info::pump`; the Templates menu needs the session, so hub-w2 adds this line to `dialogs::host::pump`. let Some(dialogs) = app.dialogs() else { return }; let id = dialog_id(KEY); - let (can_save, can_open, has_folder) = (file_asks::can(app, PickKind::Save), file_asks::can(app, PickKind::Open), has_templates_folder(app)); + let web_save = app.ui_ctx.as_ref().and_then(Host::try_of_ctx).is_some_and(|host| host.files().browser_saves()); + let (can_save, can_open, has_folder) = + (web_save || file_asks::can(app, PickKind::Save), file_asks::can(app, PickKind::Open), has_templates_folder(app)); let requests = dialogs.with(|host| { host.get_mut_by_id::(id).map(|d| { d.templates.can_save = can_save; + d.templates.web_save = web_save; d.templates.can_open = can_open; d.templates.has_folder = has_folder; d.take_requests() @@ -614,6 +641,10 @@ pub(crate) fn pump(app: &mut VectorcraftApp, _ctx: &egui::Context) { None => Ok(()), }, Request::TemplateTooLarge => Err(tl!("The metadata template is larger than 8 MB.").to_owned()), + Request::Download => match dialogs.with(|host| host.get_by_id::(id).map(FileInfoDialog::filed_fields)) { + Some(fields) => download_template(app, fields), + None => Ok(()), + }, Request::Import { source, mode } => { dialogs.with(|host| host.get_mut_by_id::(id).map(|d| import(app, d, source, mode))).unwrap_or(Ok(())) } @@ -662,6 +693,75 @@ mod tests { app.dialogs().unwrap().with(|host| host.held_state(dialog_id(KEY))) } + #[test] + fn browser_template_saves_export_the_draft_and_preserve_it_on_cancel_or_failure() { + use std::cell::RefCell; + use std::path::Path; + use std::rc::Rc; + use std::sync::Arc; + + use craft::host::{Picked, ScriptedFiles}; + use craft::ui::testing::{Fixture, Room}; + + let mut app = windowed(); + let files = Arc::new(ScriptedFiles::held().in_browser()); + crate::tests::picks::install_files(&mut app, files.clone()); + app.run("file.new", json!({"width": 200, "height": 200})).unwrap(); + let original = app.session.active().unwrap().doc.metadata.clone(); + let app = Rc::new(RefCell::new(app)); + let shown = Rc::clone(&app); + let mut fixture = Fixture::new(move |ui| crate::tests::picks::dialogs(&mut shown.borrow_mut(), ui)); + fixture.in_room(Room::Window); + let ctx = fixture.ctx().clone(); + { + let mut app = app.borrow_mut(); + app.ui_ctx = Some(ctx.clone()); + craft::host::Host::clone(&app.host).install(&ctx); + app.run("ui.fileInfoDialog", json!({})).unwrap(); + set(&app, "title", json!("Draft Template")).unwrap(); + set(&app, "author", json!("Ada")).unwrap(); + set(&app, PENDING, json!("print")).unwrap(); + } + fixture.settle(); + let draft = with_dialog(&app.borrow(), |d| d.filed_fields()).unwrap(); + for answer in [ + Picked::Saved { path: "draft.xmp".into(), file_type: None }, + Picked::Downloaded("draft.xmp".into()), + Picked::Cancelled, + Picked::Failed("download refused".into()), + ] { + let before = files.requests().len(); + let menu = fixture.by_label("Templates").expect("the Templates menu"); + fixture.click(&menu).settle(); + let save = fixture.by_label("Save Metadata Template…").expect("browser hosts can save the draft"); + fixture.click(&save).settle(); + assert_eq!(files.requests().len(), before + 1, "one save per action"); + let request = files.requests().pop().unwrap(); + assert_eq!(request.kind, craft::host::PickKind::Save); + assert!(request.file_name.as_deref().is_some_and(|name| name.ends_with(".xmp"))); + app.borrow_mut().ui.status = "before the answer".into(); + assert!(files.answer(answer.clone()).is_some()); + crate::file_asks::poll(&mut app.borrow_mut()); + fixture.settle(); + let app = app.borrow(); + match answer { + Picked::Cancelled => assert_eq!(app.ui.status, "before the answer"), + Picked::Failed(_) => assert_eq!(app.ui.status, "download refused"), + _ => assert!(app.ui.status.starts_with("Saved ")), + } + assert_eq!(with_dialog(&app, |d| d.filed_fields()).unwrap(), draft); + let document = app.session.active().unwrap(); + assert_eq!(document.doc.metadata, original); + assert!(document.history.undo.is_empty()); + assert!(document.path.is_none(), "saving a template does not save the drawing"); + } + let xmp = files.file(Path::new("draft.xmp")).expect("the service received the XMP bytes"); + let template = vectorcraft_pdf::read_template(&xmp).expect("the saved draft is a metadata template"); + assert_eq!(template.title.as_deref(), Some("Draft Template")); + assert_eq!(template.author.as_deref(), Some("Ada")); + assert_eq!(template.keywords, Some(vec!["print".into()])); + } + #[test] fn file_info_draws_and_ok_is_one_undo_step() { let mut app = windowed(); From af2894bd55b0c6471ea6f5a975acd59daf3fdfa3 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 26 Nov 2026 17:12:04 -0800 Subject: [PATCH 08/84] Translate the Saturate Intensity label --- crates/ui-egui/src/dialogs/saturate.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/dialogs/saturate.rs b/crates/ui-egui/src/dialogs/saturate.rs index 704776fc48..1a3a6c8310 100644 --- a/crates/ui-egui/src/dialogs/saturate.rs +++ b/crates/ui-egui/src/dialogs/saturate.rs @@ -46,9 +46,9 @@ fn params(fields: &DialogFields) -> Value { } fn rows() -> Vec { - vec![Param::custom("intensity", "Intensity", |ui, fields, _cx| { + vec![Param::custom("intensity", tl!("Intensity"), |ui, fields, _cx| { // The rail runs from grey to a fully saturated colour. - percent_row(ui, fields, "intensity", "Intensity", |x| Srgba::from(c32(&Color::from_hsb(12.0, x, 0.85)))); + percent_row(ui, fields, "intensity", tl!("Intensity"), |x| Srgba::from(c32(&Color::from_hsb(12.0, x, 0.85)))); ui.response() })] } From 9cfe94a9332ac99dec2a13f6430e05243588d3b1 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 26 Nov 2026 17:16:34 -0800 Subject: [PATCH 09/84] Keep Gradient swatch actions aligned with the active drawing --- crates/ui-egui/src/panels/gradient.rs | 17 +++++++------- crates/ui-egui/src/panels/gradient/tests.rs | 26 ++++++++++++++++++++- 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/crates/ui-egui/src/panels/gradient.rs b/crates/ui-egui/src/panels/gradient.rs index fbe030d45a..ce32696fce 100644 --- a/crates/ui-egui/src/panels/gradient.rs +++ b/crates/ui-egui/src/panels/gradient.rs @@ -266,8 +266,8 @@ pub(crate) fn reset_to_linear_white_black(app: &mut VectorcraftApp) { } /// Save the gradient as a swatch; its stops keep their color models. -fn save_to_swatches(app: &mut VectorcraftApp, g: &GradientPaint) { - app.run("swatch.new", super::swatch_paint_params(&Paint::Gradient(Box::new(g.clone())))).ok(); +fn save_to_swatches(app: &mut VectorcraftApp, g: &GradientPaint) -> Result<(), String> { + app.run("swatch.new", super::swatch_paint_params(&Paint::Gradient(Box::new(g.clone())))).map(drop) } /// The document's gradient swatches (groups included): name and gradient. @@ -658,10 +658,10 @@ fn fill_box(app: &mut VectorcraftApp, ui: &mut Ui, g: &GradientPaint, is_grad: b } } Divider::horizontal().show(ui); - save = MenuItem::new(tl!("Save to Swatches")).enabled(is_grad).show(ui).ran; + save = MenuItem::new(tl!("Save to Swatches")).enabled(is_grad && crate::menus::enabled(app, "swatch.new")).show(ui).ran; }); - if save { - save_to_swatches(app, g); + if save && let Err(error) = save_to_swatches(app, g) { + app.status(error); } if let Some(name) = chosen { super::apply_click(app, ui, json!({ "swatch": name })); @@ -903,7 +903,7 @@ pub(crate) fn menu_states(app: &VectorcraftApp, states: &mut CommandStates) { let has = current(app).is_some(); let toggle = |key: &str, show: &str, hide: &str| CommandState::new().title(if part_hidden(app, key) { show } else { hide }); states.set(MENU_OPTIONS, toggle(HIDE_OPTIONS, tl!("Show Options"), tl!("Hide Options"))); - states.set(MENU_ADD_TO_SWATCHES, CommandState::new().title(tl!("Add to Swatches")).enabled(has)); + states.set(MENU_ADD_TO_SWATCHES, CommandState::new().title(tl!("Add to Swatches")).enabled(has && crate::menus::enabled(app, "swatch.new"))); states.set(MENU_REVERSE, CommandState::new().title(tl!("Reverse Gradient")).enabled(has)); states.set(MENU_RESET, CommandState::new().title(tl!("Reset to White, Black"))); states.set(MENU_PRESETS, toggle(HIDE_PRESETS, tl!("Show Presets"), tl!("Hide Presets"))); @@ -922,9 +922,8 @@ pub(crate) fn run(app: &mut VectorcraftApp, id: &str, _params: &Value) -> Option set_part_hidden(app, key, hide); } MENU_ADD_TO_SWATCHES => { - if let Some(g) = current(app) { - save_to_swatches(app, &g); - } + let outcome = current(app).ok_or_else(|| tl!("No gradient to save").to_owned()).and_then(|g| save_to_swatches(app, &g)); + return Some(outcome.map(|()| Value::Null)); } MENU_REVERSE => edit(app, json!({"reverse": true}), Live::Released), MENU_RESET => set_stops(app, &Gradient::default().stops, None, Live::Released), diff --git a/crates/ui-egui/src/panels/gradient/tests.rs b/crates/ui-egui/src/panels/gradient/tests.rs index 040031e59a..00c56f82a2 100644 --- a/crates/ui-egui/src/panels/gradient/tests.rs +++ b/crates/ui-egui/src/panels/gradient/tests.rs @@ -9,6 +9,30 @@ use vectorcraft_engine::Session; use super::*; use crate::tests::panel_harness::{Place, Shown, floated}; +#[test] +fn add_to_swatches_requires_a_drawing_even_when_the_default_gradient_remains() { + let enabled = |app: &VectorcraftApp| { + let mut states = CommandStates::new(); + menu_states(app, &mut states); + states.get(&CommandRef::new(MENU_ADD_TO_SWATCHES)).is_some_and(CommandState::is_enabled) + }; + let mut app = app(json!({"gradient": {}})); + app.run("select.none", json!({})).unwrap(); + app.run("paint.setFill", json!({"gradient": {}})).unwrap(); + assert!(enabled(&app)); + app.session.execute("file.close", &json!({"index": 0})).unwrap(); + assert!(current(&app).is_some(), "the default gradient remains visible without a drawing"); + assert!(!enabled(&app), "there is no drawing to receive a swatch"); + assert!(app.run(MENU_ADD_TO_SWATCHES, json!({})).is_err()); + + app.run("file.new", json!({"width": 100, "height": 100})).unwrap(); + app.run("paint.setFill", json!({"gradient": {}})).unwrap(); + assert!(enabled(&app)); + let before = app.session.active().unwrap().doc.swatches.len(); + run(&mut app, MENU_ADD_TO_SWATCHES, &json!({})).unwrap().unwrap(); + assert_eq!(app.session.active().unwrap().doc.swatches.len(), before + 1); +} + #[test] fn dropped_colours_recolour_or_add_an_opaque_stop() { let mut g = Gradient::default(); @@ -78,7 +102,7 @@ fn a_gradient_saved_as_a_swatch_keeps_its_stops_models_in_a_cmyk_document() { let g = current(&app).expect("a gradient fill"); let colors = |g: &GradientPaint| g.gradient.stops.iter().map(|s| s.color).collect::>(); assert_eq!(colors(&g), [Color::rgb8(255, 128, 0), Color::cmyk(0.0, 0.0, 0.0, 1.0)]); - save_to_swatches(&mut app, &g); + save_to_swatches(&mut app, &g).unwrap(); let Some(Paint::Gradient(saved)) = app.session.doc().unwrap().doc.swatches.last().map(|w| w.paint.clone()) else { panic!("a gradient swatch") }; assert_eq!(colors(&saved), colors(&g)); } From ace53d3c35262a98ea2aba4061516531a1cfca51 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 26 Nov 2026 17:21:29 -0800 Subject: [PATCH 10/84] Retire Convert to Indexed Color after Revert --- crates/ui-egui/src/dialogs/indexed_color.rs | 53 ++++++++++++++++++--- 1 file changed, 47 insertions(+), 6 deletions(-) diff --git a/crates/ui-egui/src/dialogs/indexed_color.rs b/crates/ui-egui/src/dialogs/indexed_color.rs index b823cd2e71..1f1523fdf6 100644 --- a/crates/ui-egui/src/dialogs/indexed_color.rs +++ b/crates/ui-egui/src/dialogs/indexed_color.rs @@ -25,13 +25,22 @@ const PREVIEW_LABEL: &str = "Convert to Indexed Color"; pub(crate) struct Open { document: u64, + reverts: u64, opening: Arc<()>, preview: LivePreview, } impl Open { fn on_original_drawing(&self, app: &VectorcraftApp) -> bool { - app.session.active().is_some_and(|st| st.uid == self.document) + self.check_drawing(app).is_ok() + } + + fn check_drawing(&self, app: &VectorcraftApp) -> Result<(), &'static str> { + let st = app.session.active().filter(|st| st.uid == self.document).ok_or(tl!("Return to the original drawing to convert its images"))?; + if st.reverts != self.reverts { + return Err(tl!("Reopen Convert to Indexed Color after reverting the drawing")); + } + Ok(()) } fn cancel_preview(self, app: &mut VectorcraftApp) { @@ -86,7 +95,7 @@ pub fn open(app: &mut VectorcraftApp) { app.status("no window".to_string()); return; }; - let Some(document) = app.session.active().map(|st| st.uid) else { + let Some((document, reverts)) = app.session.active().map(|st| (st.uid, st.reverts)) else { app.status(tl!("Open a drawing to convert its images")); return; }; @@ -98,9 +107,7 @@ pub fn open(app: &mut VectorcraftApp) { let cancelled = Arc::clone(&opening); let ok = |app: &mut VectorcraftApp, r: &ParamResult| { let open = app.object_dialogs.indexed.as_ref().ok_or("the Indexed Color dialog is gone")?; - if !open.on_original_drawing(app) { - return Err(tl!("Return to the original drawing to convert its images").into()); - } + open.check_drawing(app)?; if other_preview(app) { app.keep_typing()?; if other_preview(app) { @@ -123,7 +130,7 @@ pub fn open(app: &mut VectorcraftApp) { } }); if open_held_with(app, dialog, ok, HeldOptions { parent: None, cancel: Some(cancel) }).is_some() { - app.object_dialogs.indexed = Some(Open { document, opening, preview: LivePreview::default() }); + app.object_dialogs.indexed = Some(Open { document, reverts, opening, preview: LivePreview::default() }); } else { app.status("no window".to_string()); } @@ -265,4 +272,38 @@ mod tests { crate::dialogs::host::pump(&mut app, &ctx); assert!(palette(&app, source).indexed_png()); } + + #[test] + fn indexed_color_preview_and_ok_leave_reloaded_pixels_unchanged() { + let mut app = crate::testing::windowed(VectorcraftApp::new(Session::new(), Default::default())); + app.services.read = Some(Box::new(|path| std::fs::read(path).map_err(|e| e.to_string()))); + app.services.write = Some(Box::new(|path, bytes| std::fs::write(path, bytes).map_err(|e| e.to_string()))); + let dir = vectorcraft_testkit::TempDir::new("indexed-color-image-revert"); + let image = add_raster(&mut app); + app.run("file.saveAs", json!({"path": dir.join("raster.vectorcraft")})).unwrap(); + app.run("shape.rectangle", json!({"x": 10, "y": 10, "width": 20, "height": 20})).unwrap(); + app.run("select.set", json!({"ids": [image.0]})).unwrap(); + open(&mut app); + let st = app.session.active().unwrap(); + let version = (st.uid, st.reverts); + app.run("file.revert", json!({"confirmed": true})).unwrap(); + let st = app.session.active().unwrap(); + assert_eq!(st.uid, version.0); + assert_ne!(st.reverts, version.1); + let undo = st.history.undo.len(); + app.run("select.set", json!({"ids": [image.0]})).unwrap(); + let before = palette(&app, image).rgba().unwrap().2; + + let id = dialog_id(KIND); + crate::tests::picks::answer_dialog( + &mut app, + id, + &[("reduction", json!("blackWhite")), ("dither", json!("none")), ("preview", json!(true))], + false, + ); + assert_eq!(palette(&app, image).rgba().unwrap().2, before, "old Preview leaves the saved pixels in place"); + crate::tests::picks::answer_dialog(&mut app, id, &[("preview", json!(false))], true); + assert_eq!(palette(&app, image).rgba().unwrap().2, before, "old OK leaves the saved pixels in place"); + assert_eq!(app.session.active().unwrap().history.undo.len(), undo); + } } From 4e7d8bc9dd536f901b40778714f44581e8410b96 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 26 Nov 2026 17:27:38 -0800 Subject: [PATCH 11/84] Reproduce stale Delete Symbol approvals after File Revert --- crates/ui-egui/src/panels/symbols/tests.rs | 48 ++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/crates/ui-egui/src/panels/symbols/tests.rs b/crates/ui-egui/src/panels/symbols/tests.rs index 3f52c73fc8..a0bf50d8dc 100644 --- a/crates/ui-egui/src/panels/symbols/tests.rs +++ b/crates/ui-egui/src/panels/symbols/tests.rs @@ -1438,6 +1438,54 @@ fn a_stale_delete_symbol_question_deletes_nothing() { assert_eq!(art(&app, "Dot"), (1, 0)); } +fn refuses_symbol_approval_after_revert(name: &str, choice: PromptChoice, after_fresh_approval: (usize, usize)) { + let mut app = windowed(leaf_and_dot()); + let file = std::env::temp_dir().join(format!("vectorcraft-symbol-delete-{name}-{choice:?}-{}.vectorcraft", std::process::id())); + app.services.read = Some(Box::new(|path| std::fs::read(path).map_err(|err| err.to_string()))); + app.services.write = Some(Box::new(|path, bytes| std::fs::write(path, bytes).map_err(|err| err.to_string()))); + app.run("file.saveAs", json!({"path": file.to_string_lossy()})).unwrap(); + let leaf = instance_of(&app, "Leaf").unwrap(); + let st = app.session.active().unwrap(); + let (uid, reverts) = (st.uid, st.reverts); + + app.run("symbol.place", json!({"name": "Leaf"})).unwrap(); + assert_eq!(art(&app, "Leaf"), (2, 0)); + symbol_delete::ask(&mut app, name, false); + assert_eq!(delete_question(&app), Some(name == "Leaf")); + app.run("file.revert", json!({"confirmed": true})).unwrap(); + let _ = std::fs::remove_file(file); + let st = app.session.active().unwrap(); + assert_eq!((st.uid, st.reverts), (uid, reverts + 1)); + assert_eq!(instance_of(&app, "Leaf"), Some(leaf)); + assert_eq!(art(&app, "Leaf"), (1, 0)); + let undo = st.history.undo.len(); + + choose(&mut app, choice); + assert_eq!(symbols(&mut app), ["Leaf", "Dot"], "an old approval keeps the restored symbols"); + assert_eq!(art(&app, "Leaf"), (1, 0), "the restored instance stays unmodified"); + assert_eq!(app.session.active().unwrap().history.undo.len(), undo); + + symbol_delete::ask(&mut app, name, false); + choose(&mut app, choice); + assert!(!symbols(&mut app).iter().any(|symbol| symbol == name)); + assert_eq!(art(&app, "Leaf"), after_fresh_approval); +} + +#[test] +fn old_delete_symbol_yes_keeps_the_symbol_restored_by_revert() { + refuses_symbol_approval_after_revert("Dot", PromptChoice::Proceed, (1, 0)); +} + +#[test] +fn old_expand_instances_keeps_the_instance_restored_by_revert() { + refuses_symbol_approval_after_revert("Leaf", PromptChoice::Proceed, (0, 1)); +} + +#[test] +fn old_delete_instances_keeps_the_instance_restored_by_revert() { + refuses_symbol_approval_after_revert("Leaf", PromptChoice::Alternate, (0, 0)); +} + /// The panel menu's Reset Transformation and the Control bar's Reset are enabled only while a /// selected instance's scale, rotation or shear differs from its symbol's, and give the /// instance its symbol's again. From 4fd139e5af318b5db992df9439bb974a89dbe0be Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 26 Nov 2026 17:28:50 -0800 Subject: [PATCH 12/84] Keep pending Delete Symbol approvals off reverted contents --- crates/ui-egui/src/dialogs/symbol_delete.rs | 37 +++++++++++++-------- crates/ui-egui/src/panels/symbols/tests.rs | 1 + 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/crates/ui-egui/src/dialogs/symbol_delete.rs b/crates/ui-egui/src/dialogs/symbol_delete.rs index dfee6d6427..1a4e06b1f8 100644 --- a/crates/ui-egui/src/dialogs/symbol_delete.rs +++ b/crates/ui-egui/src/dialogs/symbol_delete.rs @@ -2,10 +2,10 @@ //! selected symbol?" with Yes and No ([`KIND`]); a symbol with placed instances gets Expand //! Instances, Delete Instances and Cancel ([`USED`]). //! -//! The question carries the [`vectorcraft_engine::DocState::uid`] of the document it was asked in and -//! the symbol names. Yes or either Instances button deletes the symbol only while that document is -//! the active one and still has the symbol; an unused symbol that has gained instances since asks -//! the in-use question instead. +//! The question carries the opening document, its revert generation, and the symbol names. Yes or +//! either Instances button deletes the symbol only while that document is active, has not been +//! reverted, and still has the symbol. An unused symbol that has gained instances asks the in-use +//! question instead. use craft::ui::dialog::{PromptChoice, StandardPrompt}; use serde_json::{Value, json}; @@ -28,6 +28,7 @@ enum Target { /// whether it is the in-use question. struct Ask { doc: u64, + reverts: u64, target: Target, used: bool, } @@ -42,7 +43,7 @@ crate::dialogs::confirm::wrapped_dialog!(SymbolQuestion, StandardPrompt, KIND); /// what becomes of them; an unused one is deleted at once with `now` (Alt-click on the panel's /// button) and asked about otherwise. pub(crate) fn ask(app: &mut VectorcraftApp, name: &str, now: bool) { - let Some(uid) = app.session.active().map(|st| st.uid) else { return }; + let Some((uid, reverts)) = app.session.active().map(|st| (st.uid, st.reverts)) else { return }; match instances(app, uid, name) { None => {} Some(0) if now => { @@ -50,7 +51,7 @@ pub(crate) fn ask(app: &mut VectorcraftApp, name: &str, now: bool) { app.status(e); } } - Some(n) => open(app, Ask { doc: uid, target: Target::One(name.to_string()), used: n > 0 }), + Some(n) => open(app, Ask { doc: uid, reverts, target: Target::One(name.to_string()), used: n > 0 }), } } @@ -58,12 +59,12 @@ pub(crate) fn ask(app: &mut VectorcraftApp, name: &str, now: bool) { /// ("Delete the selected symbols?", or the singular for one), or at once with `now`. Only those still /// unused then (`symbol.unused`: brush art, patterns and nested instances count) go, in one undo step. pub(crate) fn ask_many(app: &mut VectorcraftApp, names: &[String], now: bool) { - let Some(uid) = app.session.active().map(|st| st.uid) else { return }; + let Some((uid, reverts)) = app.session.active().map(|st| (st.uid, st.reverts)) else { return }; if now { // An error already went to the status bar. let _ = delete_unused(app, uid, names); } else { - open(app, Ask { doc: uid, target: Target::Many(names.to_vec()), used: false }); + open(app, Ask { doc: uid, reverts, target: Target::Many(names.to_vec()), used: false }); } } @@ -109,12 +110,20 @@ pub(crate) fn pump(app: &mut VectorcraftApp, _ctx: &egui::Context) { // The host lock is released before any command runs. let Some(mut answer) = dialogs.with(|host| host.take::()).and_then(|result| result.ok()) else { return }; let Some(ask) = answer.take_tag::() else { return }; - let r = match (ask.used, answer.choice) { - (false, PromptChoice::Proceed) => confirm_unused(app, ask), - (true, PromptChoice::Proceed) => confirm_used(app, ask, true), - (true, PromptChoice::Alternate) => confirm_used(app, ask, false), + let expand_instances = match (ask.used, answer.choice) { + (false, PromptChoice::Proceed) => None, + (true, PromptChoice::Proceed) => Some(true), + (true, PromptChoice::Alternate) => Some(false), _ => return, }; + if app.session.active().is_some_and(|st| st.uid == ask.doc && st.reverts != ask.reverts) { + app.status(tl!("The document was reverted. Reopen this dialog to continue.")); + return; + } + let r = match expand_instances { + Some(expand) => confirm_used(app, ask, expand), + None => confirm_unused(app, ask), + }; if let Err(e) = r { app.status(e); } @@ -132,14 +141,14 @@ fn instances(app: &mut VectorcraftApp, uid: u64, name: &str) -> Option { /// Yes: deletes the symbol, or asks the in-use question when it has gained instances. fn confirm_unused(app: &mut VectorcraftApp, ask: Ask) -> Result { - let Ask { doc, target, .. } = ask; + let Ask { doc, reverts, target, .. } = ask; match target { Target::Many(names) => delete_unused(app, doc, &names), Target::One(name) => match instances(app, doc, &name) { None => Ok(Value::Null), Some(0) => app.run("symbol.delete", json!({ "name": name })), Some(_) => { - open(app, Ask { doc, target: Target::One(name), used: true }); + open(app, Ask { doc, reverts, target: Target::One(name), used: true }); Ok(Value::Null) } }, diff --git a/crates/ui-egui/src/panels/symbols/tests.rs b/crates/ui-egui/src/panels/symbols/tests.rs index a0bf50d8dc..9c16d0b761 100644 --- a/crates/ui-egui/src/panels/symbols/tests.rs +++ b/crates/ui-egui/src/panels/symbols/tests.rs @@ -1464,6 +1464,7 @@ fn refuses_symbol_approval_after_revert(name: &str, choice: PromptChoice, after_ assert_eq!(symbols(&mut app), ["Leaf", "Dot"], "an old approval keeps the restored symbols"); assert_eq!(art(&app, "Leaf"), (1, 0), "the restored instance stays unmodified"); assert_eq!(app.session.active().unwrap().history.undo.len(), undo); + assert_eq!(app.ui.status, "The document was reverted. Reopen this dialog to continue."); symbol_delete::ask(&mut app, name, false); choose(&mut app, choice); From 89323603d9e8d1abb38c5c564b8d248188e8f48a Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 26 Nov 2026 17:37:07 -0800 Subject: [PATCH 13/84] Preserve SVG Filter encoding from browser files --- crates/engine/src/cmd.rs | 1 + crates/engine/src/cmd/svgfilter.rs | 20 +++++++++++------ crates/engine/src/tests/svgfilter.rs | 28 ++++++++++++++++++++++++ crates/ui-egui/src/dialogs/svg_filter.rs | 24 +++++++++++++++++++- 4 files changed, 65 insertions(+), 8 deletions(-) diff --git a/crates/engine/src/cmd.rs b/crates/engine/src/cmd.rs index 587f60eb11..fbe46f41c8 100644 --- a/crates/engine/src/cmd.rs +++ b/crates/engine/src/cmd.rs @@ -97,6 +97,7 @@ mod style; pub use style::styled_node; pub mod stylelib; mod svgfilter; +pub use svgfilter::MAX_IMPORT_BYTES as MAX_SVG_FILTER_IMPORT_BYTES; mod swatch; pub mod swatchlib; pub(crate) mod symboledit; diff --git a/crates/engine/src/cmd/svgfilter.rs b/crates/engine/src/cmd/svgfilter.rs index 43af8bce35..40e5926f48 100644 --- a/crates/engine/src/cmd/svgfilter.rs +++ b/crates/engine/src/cmd/svgfilter.rs @@ -17,7 +17,7 @@ use super::fileio::{absolute_path, read_file_head}; use super::{CommandSpec, Result, Session, bad, cmd, has_doc, text_param}; /// The largest SVG file Import SVG Filter reads. -const MAX_IMPORT_BYTES: usize = 16 << 20; +pub const MAX_IMPORT_BYTES: usize = 16 << 20; pub fn specs() -> Vec { vec![ @@ -53,7 +53,7 @@ pub fn specs() -> Vec { "Import SVG Filter…", [], None, - "{path?|svg?} add the elements of an SVG file (at most 16 MB; not SVGZ; its first 256 filters) or of SVG text to the document's SVG filters, as one undo step; a filter whose name the document already has, and one svgFilter.define would refuse, is left out; objects whose effect names an added filter draw with it → {added: [names…], skipped: count, filters}", + "{path?|svg?|dataBase64?} add the elements of an SVG file (at most 16 MB; not SVGZ; its first 256 filters), SVG text or base64-encoded file bytes to the document's SVG filters, as one undo step; file bytes keep their UTF-8, BOM-marked UTF-16 or declared ISO 8859-1 encoding. A filter whose name the document already has, and one svgFilter.define would refuse, is left out; objects whose effect names an added filter draw with it → {added: [names…], skipped: count, filters}", has_doc, import ), @@ -197,13 +197,19 @@ fn delete(s: &mut Session, p: &Value) -> Result { Ok(json!({ "filters": filters_json(&s.doc()?.doc) })) } -/// The bytes of `p`'s `path` (an SVG file, read up to [`MAX_IMPORT_BYTES`]) or `svg`. +/// The bytes of `p`'s `path`, `svg` text or `dataBase64`, up to [`MAX_IMPORT_BYTES`]. fn import_bytes(p: &Value, cmd: &str) -> Result> { - let bytes = match (text_param(p, "path", cmd)?, text_param(p, "svg", cmd)?) { + let bytes = match (text_param(p, "path", cmd)?, text_param(p, "svg", cmd)?, text_param(p, "dataBase64", cmd)?) { // One byte past the cap is enough to refuse the file below. - (Some(path), _) => read_file_head(&absolute_path(path), MAX_IMPORT_BYTES + 1)?, - (None, Some(svg)) => svg.as_bytes().to_vec(), - _ => return Err(bad(cmd, "give `path`, an SVG file, or `svg`, SVG text")), + (Some(path), _, _) => read_file_head(&absolute_path(path), MAX_IMPORT_BYTES + 1)?, + (None, Some(svg), _) => svg.as_bytes().to_vec(), + (None, None, Some(encoded)) => { + if vectorcraft_format::base64_decoded_len(encoded) > MAX_IMPORT_BYTES as u64 { + return Err(bad(cmd, format!("the SVG file is larger than {MAX_IMPORT_BYTES} bytes"))); + } + vectorcraft_format::base64_decode(encoded).ok_or_else(|| bad(cmd, "bad dataBase64"))? + } + _ => return Err(bad(cmd, "give `path`, an SVG file, `svg`, SVG text, or `dataBase64`, file bytes")), }; if bytes.len() > MAX_IMPORT_BYTES { return Err(bad(cmd, format!("the SVG file is larger than {MAX_IMPORT_BYTES} bytes"))); diff --git a/crates/engine/src/tests/svgfilter.rs b/crates/engine/src/tests/svgfilter.rs index 611c9bfd1f..c668366ef9 100644 --- a/crates/engine/src/tests/svgfilter.rs +++ b/crates/engine/src/tests/svgfilter.rs @@ -34,6 +34,34 @@ fn names(s: &mut Session) -> Vec { const BLUR: &str = r#""#; const SHIFT: &str = r#""#; +#[test] +fn byte_import_keeps_svg_encodings_and_uses_one_undo_step() { + let svg = r#""#; + let utf16: Vec = [0xff, 0xfe].into_iter().chain(svg.encode_utf16().flat_map(u16::to_le_bytes)).collect(); + let latin1: Vec = format!("{svg}").chars().map(|c| c as u8).collect(); + for bytes in [svg.as_bytes().to_vec(), utf16, latin1] { + let mut s = session(); + let out = run(&mut s, "svgFilter.import", json!({"dataBase64": vectorcraft_format::base64_encode(&bytes)})); + assert_eq!(out["added"], json!(["café"])); + assert_eq!(names(&mut s), ["café"]); + assert_eq!(steps(&s), 1); + run(&mut s, "edit.undo", json!({})); + assert!(names(&mut s).is_empty()); + } +} + +#[test] +fn byte_import_refuses_invalid_oversized_and_compressed_files_without_an_edit() { + let mut s = session(); + assert!(err(&mut s, "svgFilter.import", json!({"dataBase64": "!"})).contains("dataBase64")); + assert!(err(&mut s, "svgFilter.import", json!({"dataBase64": 3})).contains("must be a string")); + for bytes in [vec![0xff], vec![b' '; (16 << 20) + 1], vectorcraft_svg::compress("")] { + assert!(s.execute("svgFilter.import", &json!({"dataBase64": vectorcraft_format::base64_encode(&bytes)})).is_err()); + assert!(names(&mut s).is_empty()); + assert_eq!(steps(&s), 0); + } +} + #[test] fn filters_are_defined_edited_and_deleted_in_one_undo_step_each() { let mut s = session(); diff --git a/crates/ui-egui/src/dialogs/svg_filter.rs b/crates/ui-egui/src/dialogs/svg_filter.rs index aaf3021f6d..22388092d3 100644 --- a/crates/ui-egui/src/dialogs/svg_filter.rs +++ b/crates/ui-egui/src/dialogs/svg_filter.rs @@ -474,7 +474,10 @@ fn ask_import(app: &mut VectorcraftApp, source: Option>) -> Value { // The browser answers with the file's contents, not a path. Picked::Contents(files) => { let (_, bytes) = files.first().ok_or("cancelled")?; - json!({ "svg": String::from_utf8_lossy(bytes) }) + if bytes.len() > vectorcraft_engine::cmd::MAX_SVG_FILTER_IMPORT_BYTES { + return Err("The SVG file is larger than 16 MB".into()); + } + json!({ "dataBase64": vectorcraft_format::base64_encode(bytes) }) } other => json!({ "path": other.first_path().ok_or("cancelled")?.to_string_lossy() }), }; @@ -499,6 +502,25 @@ mod tests { const SHIFT: &str = r#""#; + #[test] + fn browser_filter_import_keeps_the_picked_file_encoding() { + let svg = r#""#; + let utf16: Vec = [0xfe, 0xff].into_iter().chain(svg.encode_utf16().flat_map(u16::to_be_bytes)).collect(); + let latin1: Vec = format!("{svg}").chars().map(|c| c as u8).collect(); + for bytes in [utf16, latin1] { + let mut app = app(); + let picker = scripted(&mut app); + let ctx = app.ui_ctx.clone().unwrap(); + open(&mut app, &json!({})).unwrap(); + import_file(&mut app).unwrap(); + picker.answer_contents(&[("filter.svg", &bytes)]); + poll(&mut app, &ctx); + assert_eq!(app.session.active().unwrap().doc.svg_filters[0].name, "café"); + assert_eq!(fields(&app)[SELECTED], "café"); + assert_eq!(app.session.active().unwrap().history.undo.len(), 1); + } + } + fn app() -> VectorcraftApp { let mut app = crate::testing::windowed(VectorcraftApp::new(Session::new(), Default::default())); app.session.execute("file.new", &json!({"width": 100, "height": 100})).unwrap(); From e872b91c009e426e54bf084773c4861f65a88f00 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 26 Nov 2026 17:37:18 -0800 Subject: [PATCH 14/84] Reproduce stale Kinsoku Shori approval after File Revert --- .../ui-egui/src/dialogs/kinsoku_sets/tests.rs | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/crates/ui-egui/src/dialogs/kinsoku_sets/tests.rs b/crates/ui-egui/src/dialogs/kinsoku_sets/tests.rs index 887dbbc202..c026cf4c3b 100644 --- a/crates/ui-egui/src/dialogs/kinsoku_sets/tests.rs +++ b/crates/ui-egui/src/dialogs/kinsoku_sets/tests.rs @@ -226,6 +226,46 @@ fn ok_sets_the_document_the_dialog_opened_on() { assert!(app.session.documents().iter().all(|d| d.doc.kinsoku_sets.is_empty())); } +#[test] +fn old_ok_keeps_restored_kinsoku_rules_and_the_current_tab() { + let mut app = app(); + app.run("type.kinsokuSets.set", json!({"sets": [{"name": "Custom", "cannotStart": "ゝ"}]})).unwrap(); + let file = std::env::temp_dir().join(format!("vectorcraft-kinsoku-revert-{}.vectorcraft", std::process::id())); + app.services.read = Some(Box::new(|path| std::fs::read(path).map_err(|err| err.to_string()))); + app.services.write = Some(Box::new(|path, bytes| std::fs::write(path, bytes).map_err(|err| err.to_string()))); + app.run("file.saveAs", json!({"path": file.to_string_lossy()})).unwrap(); + let st = app.session.active().unwrap(); + let (uid, reverts) = (st.uid, st.reverts); + + app.run("type.kinsokuSets.set", json!({"sets": [{"name": "Custom", "cannotStart": "ゞ"}]})).unwrap(); + open(&mut app).unwrap(); + set(&app, "cannotStart", json!("ー")); + app.run("file.revert", json!({"confirmed": true})).unwrap(); + let _ = std::fs::remove_file(file); + let st = app.session.active().unwrap(); + assert_eq!((st.uid, st.reverts), (uid, reverts + 1)); + assert_eq!(doc_sets(&app)[0].cannot_start, ['ゝ']); + let undo = steps(&app); + app.run("file.new", json!({"width": 200, "height": 200})).unwrap(); + let other = app.session.active().unwrap().uid; + assert_ne!(uid, other); + + pump(&mut app); + let restored = app.session.documents().iter().find(|st| st.uid == uid).unwrap(); + assert_eq!(restored.doc.kinsoku_sets[0].cannot_start, ['ゝ'], "an old OK must keep the saved line-breaking rule"); + assert_eq!(restored.history.undo.len(), undo); + assert_eq!(app.session.active().unwrap().uid, other, "a stale OK does not activate the original tab"); + assert!(is_open(&app)); + cancel(&mut app); + + assert!(app.session.set_active(0)); + open(&mut app).unwrap(); + set(&app, "cannotStart", json!("ー")); + pump(&mut app); + assert!(!is_open(&app)); + assert_eq!(doc_sets(&app)[0].cannot_start, ['ー'], "a fresh draft can edit the restored rule"); +} + /// OK keeps a set the document gained while the dialog was open, after the dialog's sets, and a /// set deleted in the dialog stays deleted. A `sets` field that is not a list of sets keeps the /// dialog open and leaves the document's sets as they are, and New refuses to start from it. From a0873ba727f6b09990976a0a833967f50a3b9585 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 26 Nov 2026 17:41:05 -0800 Subject: [PATCH 15/84] Retire File Info drafts after Revert --- crates/ui-egui/src/dialogs/file_info.rs | 52 +++++++++++++++++++++---- 1 file changed, 45 insertions(+), 7 deletions(-) diff --git a/crates/ui-egui/src/dialogs/file_info.rs b/crates/ui-egui/src/dialogs/file_info.rs index 80439178a8..6a5afd2664 100644 --- a/crates/ui-egui/src/dialogs/file_info.rs +++ b/crates/ui-egui/src/dialogs/file_info.rs @@ -55,10 +55,12 @@ type Info = Map; pub fn open(app: &mut VectorcraftApp) -> Result { let fields = app.session.execute("file.info", &json!({})).map_err(|e| e.to_string())?; let fields = fields.as_object().cloned().ok_or("file.info gave no fields")?; - let document = app.session.active().ok_or("no document")?.uid; - let ok = |app: &mut VectorcraftApp, (document, fields): &(u64, Info)| { - if !app.session.active().is_some_and(|active| active.uid == *document) { - return Err(tl!("File Info can only change the document it was opened for.").to_owned()); + let source = app.session.active().ok_or("no document")?; + let document = (source.uid, source.reverts); + let ok = |app: &mut VectorcraftApp, ((uid, generation), fields): &((u64, u64), Info)| { + let source = app.session.active().filter(|st| st.uid == *uid).ok_or(tl!("File Info can only change the document it was opened for."))?; + if source.reverts != *generation { + return Err(tl!("Reopen File Info after reverting the drawing").into()); } app.run("file.info", Value::Object(fields.clone())).map(|_| ()) }; @@ -232,7 +234,7 @@ impl Templates { /// The File Info dialog: a form over the fields `file.info` reports, whose OK is held for the app. pub(crate) struct FileInfoDialog { id: DialogId, - document: u64, + document: (u64, u64), open: bool, /// OK files its answer for the app instead of closing ([`HoldsOk::held_ok`]). hold: bool, @@ -248,7 +250,7 @@ pub(crate) struct FileInfoDialog { } impl FileInfoDialog { - fn new(document: u64, value: Info) -> Self { + fn new(document: (u64, u64), value: Info) -> Self { FileInfoDialog { id: dialog_id(KEY), document, @@ -390,7 +392,7 @@ fn import_options(ui: &mut egui::Ui, mode: &mut &'static str) -> Option { } impl HoldsOk for FileInfoDialog { - type Answer = (u64, Info); + type Answer = ((u64, u64), Info); fn held_ok(mut self) -> Self { self.hold = true; @@ -652,6 +654,42 @@ mod tests { app.dialogs().unwrap().with(|host| host.set_json_field(&ctx, dialog_id(KEY), field, value)) } + #[test] + fn stale_file_info_cannot_replace_metadata_restored_by_revert() { + let mut app = windowed(); + app.services.read = Some(Box::new(|path| std::fs::read(path).map_err(|e| e.to_string()))); + app.services.write = Some(Box::new(|path, bytes| std::fs::write(path, bytes).map_err(|e| e.to_string()))); + let dir = vectorcraft_testkit::TempDir::new("file-info-metadata-revert"); + app.run("file.new", json!({"width": 200, "height": 200})).unwrap(); + app.run("file.info", json!({"title": "Saved Title"})).unwrap(); + app.run("file.saveAs", json!({"path": dir.join("metadata.vectorcraft")})).unwrap(); + let saved = &app.session.active().unwrap().doc; + let (saved_title, saved_metadata) = (saved.info_title().to_owned(), saved.metadata.clone()); + app.run("file.info", json!({"title": "Unsaved Title"})).unwrap(); + app.run("ui.fileInfoDialog", json!({})).unwrap(); + set(&app, "title", json!("Old Draft")).unwrap(); + let source = app.session.active().unwrap(); + let (uid, generation) = (source.uid, source.reverts); + + app.run("file.revert", json!({"confirmed": true})).unwrap(); + let reverted = app.session.active().unwrap(); + assert_eq!(reverted.uid, uid); + assert_ne!(reverted.reverts, generation); + assert_eq!(reverted.doc.info_title(), saved_title); + assert_eq!(reverted.doc.metadata, saved_metadata); + let undo = reverted.history.undo.len(); + crate::tests::picks::answer_dialog(&mut app, dialog_id(KEY), &[], true); + let reverted = app.session.active().unwrap(); + assert_eq!(reverted.doc.info_title(), saved_title); + assert_eq!(reverted.doc.metadata, saved_metadata); + assert_eq!(reverted.history.undo.len(), undo); + assert!(matches!(app.dialogs().unwrap().with(|h| h.held_state(dialog_id(KEY))), Some(HeldOk::Refused(_)))); + + app.run("ui.fileInfoDialog", json!({})).unwrap(); + crate::tests::picks::answer_dialog(&mut app, dialog_id(KEY), &[("title", json!("Fresh Title"))], true); + assert_eq!(app.run("file.info", json!({})).unwrap()["title"], json!("Fresh Title")); + } + /// Presses OK: the dialog files its fields, and the frames after it run the app's OK and close an accepted dialog /// (a second OK would file a refused answer again). Whether it closed. fn press_ok(app: &mut VectorcraftApp) -> bool { From d2f726ecee1f3d84624295aa5cfaed77428df088 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 26 Nov 2026 17:41:32 -0800 Subject: [PATCH 16/84] Use existing translations in Adjust Color Balance --- crates/ui-egui/src/dialogs/color_balance.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/crates/ui-egui/src/dialogs/color_balance.rs b/crates/ui-egui/src/dialogs/color_balance.rs index 76a5e62ad0..b1b23618f4 100644 --- a/crates/ui-egui/src/dialogs/color_balance.rs +++ b/crates/ui-egui/src/dialogs/color_balance.rs @@ -157,7 +157,7 @@ fn slot(dialogs: &mut ColorDialogs) -> &mut Option { /// Open the dialog with every channel at 0, adjusting fills and strokes. pub fn open(app: &mut VectorcraftApp) { - ADJUST.open(app); + Adjust { label: tl!(ADJUST.label), ..ADJUST }.open(app); } /// Previews the open dialog; one line of `dialogs::host::pump`. @@ -214,22 +214,22 @@ fn track(key: &str, x: f32) -> Srgba { fn channels(ui: &mut egui::Ui, fields: &mut DialogFields, _cx: &mut CustomContext) -> egui::Response { super::form::stacked(ui, fields, |ui, fields| { for (key, label) in mode(fields).channels { - percent_row(ui, fields, key, label, |x| track(key, x)); + percent_row(ui, fields, key, tl!(label), |x| track(key, x)); } }) } fn rows() -> Vec { - let modes = MODES.iter().map(|m| (m.id.to_owned(), Label::from(m.label))).collect(); + let modes = MODES.iter().map(|m| (m.id.to_owned(), Label::from(tl!(m.label)))).collect(); let with_model = MODES.iter().map(|m| m.id).filter(|id| *id != GLOBAL); vec![ - Param::new("mode", "Color Mode", ParamKind::choice(modes, Some("rgb".to_owned()))), - Param::new("convert", "Convert", ParamKind::bool(false)).enabled_when_in("mode", with_model), - Param::read_only_text("note", "", "Shifts the tints of global and spot colors; other colors stay.").visible_when("mode", GLOBAL), + Param::new("mode", tl!("Color Mode"), ParamKind::choice(modes, Some("rgb".to_owned()))), + Param::new("convert", tl!("Convert"), ParamKind::bool(false)).enabled_when_in("mode", with_model), + Param::read_only_text("note", "", tl!("Shifts the tints of global and spot colors; other colors stay.")).visible_when("mode", GLOBAL), Param::custom("channels", "Channels", channels).companions(channel_keys()), Param::section("Adjust Options"), - Param::new("fill", "Fill", ParamKind::bool(true)), - Param::new("stroke", "Stroke", ParamKind::bool(true)), + Param::new("fill", tl!("Fill"), ParamKind::bool(true)), + Param::new("stroke", tl!("Stroke"), ParamKind::bool(true)), ] } From d6c14e36612333f122496bb179d3d3796fa9169e Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 26 Nov 2026 17:35:19 -0800 Subject: [PATCH 17/84] Exercise Graph Data after File Revert --- crates/ui-egui/src/dialogs/graph_data.rs | 56 ++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/crates/ui-egui/src/dialogs/graph_data.rs b/crates/ui-egui/src/dialogs/graph_data.rs index 9cf40d3319..ae58ce2ad6 100644 --- a/crates/ui-egui/src/dialogs/graph_data.rs +++ b/crates/ui-egui/src/dialogs/graph_data.rs @@ -922,6 +922,62 @@ mod tests { assert_eq!(read(&app, |dialog| dialog.sheet.grid.clone()), expected); } + fn stale_sheet_after_file_revert(test: &str) -> (VectorcraftApp, u64, Value) { + struct SavedFile(std::path::PathBuf); + impl Drop for SavedFile { + fn drop(&mut self) { + let _ = std::fs::remove_file(&self.0); + } + } + + let (mut app, id) = app_with(",Original\nQ1,1", "column"); + app.services.read = Some(Box::new(|path| std::fs::read(path).map_err(|e| e.to_string()))); + app.services.write = Some(Box::new(|path, bytes| std::fs::write(path, bytes).map_err(|e| e.to_string()))); + let path = SavedFile(std::env::temp_dir().join(format!("vc-ui-graph-data-revert-{}-{test}.vectorcraft", std::process::id()))); + app.run("file.saveAs", json!({"path": path.0})).unwrap(); + assert!(path.0.is_file()); + let saved = data(&mut app, id); + app.run("graph.setData", json!({"id": id, "series": ["Unsaved"], "categories": ["Q2"], "rows": [[3.0]]})).unwrap(); + assert_ne!(data(&mut app, id), saved); + app.run("select.set", json!({"ids": [id]})).unwrap(); + open(&mut app).unwrap(); + set_field(&app, "grid", json!([["", "Draft"], ["Q2", "9"]])).unwrap(); + let state = app.session.active().unwrap(); + let (uid, reverts) = (state.uid, state.reverts); + app.run("file.revert", json!({"confirmed": true})).unwrap(); + let state = app.session.active().unwrap(); + assert_eq!((state.uid, state.reverts), (uid, reverts + 1)); + app.run("select.set", json!({"ids": [id]})).unwrap(); + assert_eq!(data(&mut app, id), saved, "the restored graph uses the same ID"); + (app, id, saved) + } + + #[test] + fn graph_data_after_file_revert_cannot_apply_the_old_draft() { + let (mut app, id, saved) = stale_sheet_after_file_revert("apply"); + let undo = app.session.active().unwrap().history.undo.len(); + apply_through_host(&mut app); + assert_eq!(data(&mut app, id), saved); + assert_eq!(app.session.active().unwrap().history.undo.len(), undo); + assert!(matches!(read(&app, GraphDataDialog::held_state), Some(HeldOk::Refused(_)))); + + app.run("select.set", json!({"ids": [id]})).unwrap(); + open(&mut app).unwrap(); + set_field(&app, "grid", json!([["", "Fresh"], ["Q3", "7"]])).unwrap(); + apply_through_host(&mut app); + assert_eq!(data(&mut app, id)["rows"], json!([[7.0]])); + } + + #[test] + fn graph_data_after_file_revert_keeps_the_old_sheet_on_worksheet_revert() { + let (mut app, id, saved) = stale_sheet_after_file_revert("worksheet"); + let draft = read(&app, |dialog| dialog.sheet.grid.clone()); + edit(&app, |dialog| dialog.actions.push(Action::Revert)); + pump(&mut app, &crate::testing::ui_context()); + assert_eq!(read(&app, |dialog| dialog.sheet.grid.clone()), draft); + assert_eq!(data(&mut app, id), saved); + } + /// The app with the window drawn each frame as the shell draws it. // PLAN: the shell's own frame (hub-w2) replaces `host.run` here, and runs `file_asks::poll` (files-w7) itself. fn harness(app: VectorcraftApp) -> Harness { From 579aa6cf5f634de43e2c6a4831c363fb88ac2d28 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 26 Nov 2026 17:50:50 -0800 Subject: [PATCH 18/84] Restore localized Paragraph alignment and spacing controls --- crates/ui-egui/src/panels/paragraph.rs | 39 ++++++- crates/ui-egui/src/panels/paragraph/tests.rs | 114 +++++++++++++++++++ 2 files changed, 147 insertions(+), 6 deletions(-) diff --git a/crates/ui-egui/src/panels/paragraph.rs b/crates/ui-egui/src/panels/paragraph.rs index 26102b5311..6b93911427 100644 --- a/crates/ui-egui/src/panels/paragraph.rs +++ b/crates/ui-egui/src/panels/paragraph.rs @@ -8,8 +8,9 @@ // PLAN: assumed import paths for the framework items below (behavior::{IconId, Mixed}, keymap::CommandRef, // text::ui::character, ui::{buttons, choice::Select, controls::Checkbox, menu, popover, runtime::access::PopupKind}). use craft::behavior::{IconId, Mixed}; +use craft::i18n::WordSet as _; use craft::keymap::CommandRef; -use craft::text::ui::character::{DirectionRow, ParagraphChange, ParagraphControls, ParagraphDirection, ParagraphValues, TextAlign}; +use craft::text::ui::character::{DirectionRow, ParagraphChange, ParagraphControls, ParagraphDirection, ParagraphValues, ParagraphWords, TextAlign}; use craft::ui::buttons::{IconButton, PopupMark, ToggleButton}; use craft::ui::choice::Checkbox; use craft::ui::contract::{Bind, Entry, MemoProps, Props as _, Show as _, ShowContainer as _, Trigger}; @@ -21,6 +22,7 @@ use craft::ui::popover::Popover; use craft::ui::primitives::{Glyph, IconSpec}; use craft::ui::runtime::access::PopupKind; use craft::ui::runtime::commands::{CommandState, CommandStates}; +use craft::ui::runtime::env::{WordRows, WordsOverride, with_env}; use craft::ui::style::UiTokens; use egui::{Color32, Painter, Rect, Stroke, Ui, vec2}; use serde_json::{Value, json}; @@ -821,6 +823,30 @@ fn kinsoku_row(app: &mut VectorcraftApp, ui: &mut Ui) { } } +/// Maps the toolkit's different English names to the translations already in the app catalogs. +fn localized_control_words() -> WordRows { + [ + ("paragraph.left", ALIGNMENTS[0].2), + ("paragraph.center", ALIGNMENTS[1].2), + ("paragraph.right", ALIGNMENTS[2].2), + ("paragraph.justifyLeft", ALIGNMENTS[3].2), + ("paragraph.justifyCenter", ALIGNMENTS[4].2), + ("paragraph.justifyRight", ALIGNMENTS[5].2), + ("paragraph.justifyAll", ALIGNMENTS[6].2), + ("paragraph.spaceBefore", "Space Before Paragraph"), + ("paragraph.spaceAfter", "Space After Paragraph"), + ] + .into_iter() + .filter_map(|(id, source)| { + let translated = tl!(source); + if translated == source { + return None; + } + ParagraphWords::word(id).map(|word| (word, translated)) + }) + .fold(WordRows::new(), |rows, (word, translated)| rows.row(word, translated)) +} + pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) { let Some((_, para)) = text_style(app) else { super::empty_state(ui, "pilcrow", tl!("No text selected"), tl!("Select a text object to edit its paragraph attributes.")); @@ -831,11 +857,12 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) { // Paragraph direction, with the Middle Eastern (Indic) options. let direction = if app.session.prefs.show_indic_options { DirectionRow::Explicit } else { DirectionRow::Hidden }; // Indents and paragraph spacing are distances (General); type sizes follow Units ▸ Type. - let out = ParagraphControls::new(tl!("Paragraph"), &shown) - .unit(doc_unit(app.session.general_unit())) - .hyphenate(!hidden) - .direction_row(direction) - .show_with(ui, |ui| lists_row(app, ui)); + let controls = + ParagraphControls::new(tl!("Paragraph"), &shown).unit(doc_unit(app.session.general_unit())).hyphenate(!hidden).direction_row(direction); + let words = localized_control_words(); + let show = |ui: &mut Ui| controls.show_with(ui, |ui| lists_row(app, ui)); + let out = + if words.iter().next().is_some() { with_env(ui, |overrides| overrides.words = Some(WordsOverride::Overlay(words)), show) } else { show(ui) }; for event in &out.edits { edits::apply_event(app, event, &EditPath::Scope, &mut |app, change, _| apply(app, change)); } diff --git a/crates/ui-egui/src/panels/paragraph/tests.rs b/crates/ui-egui/src/panels/paragraph/tests.rs index 0d56471f6d..6bdf50ca0b 100644 --- a/crates/ui-egui/src/panels/paragraph/tests.rs +++ b/crates/ui-egui/src/panels/paragraph/tests.rs @@ -25,6 +25,120 @@ fn editing_text(text: &str) -> (VectorcraftApp, Value) { (app, id) } +/// The minimum-width Paragraph dock keeps translated alignment and spacing controls usable. +#[test] +fn compact_paragraph_dock_keeps_localized_alignment_and_spacing_usable() { + use craft::behavior::dock::{DockEdge, Node, Workspace}; + use egui::accesskit::Role; + use egui::{Event, Key, Modifiers, PointerButton, Pos2, pos2}; + use std::sync::Arc; + + let width = crate::panel_docking::PANEL_MIN_WIDTH; + let screen = Rect::from_min_size(Pos2::ZERO, vec2(1600.0, 1000.0)); + let mut untranslated = Vec::new(); + for lang in ["en", "de", "fr", "pt-br"] { + let mut app = VectorcraftApp::new(Session::new(), Default::default()); + app.session.prefs.interface_language = lang.into(); + app.run("file.new", json!({"width": 400, "height": 300})).unwrap(); + let id = + app.run("text.create", json!({"x": 20, "y": 50, "text": "First\nSecond", "area": {"width": 180, "height": 100}})).unwrap()["id"].clone(); + app.run("select.set", json!({"ids": [id]})).unwrap(); + app.run("window.panel", json!({"panel": "paragraph"})).unwrap(); + app.run("window.panel.dock", json!({"panel": "paragraph", "column": true})).unwrap(); + app.run("window.panel.activate", json!({"panel": "paragraph"})).unwrap(); + + let ws = &app.ui.dock_workspace; + let mut layout = ws.layout().clone(); + let path = layout.dock_path(DockEdge::End).unwrap(); + let mut node = layout.root.as_mut().unwrap(); + for second_child in path { + let Node::Split { first, second, .. } = node else { panic!("end dock path") }; + node = if second_child { second } else { first }; + } + let Node::Dock { columns, .. } = node else { panic!("end dock") }; + let column = columns.iter_mut().find(|column| column.groups.iter().any(|group| group.panels.iter().any(|p| p == "paragraph"))).unwrap(); + assert!(!column.iconic); + column.width = Some(width); + let next = Workspace::from_parts(layout, ws.hidden().to_vec(), ws.floated().to_vec()); + Arc::make_mut(&mut app.ui.dock_workspace).replace(next); + + let ctx = crate::testing::ui_context(); + ctx.enable_accesskit(); + let mut time = 0.0; + let mut frame = |app: &mut VectorcraftApp, mut events: Vec, modifiers| { + time += 0.05; + events.insert(0, Event::ModifiersChanged(modifiers)); + let input = egui::RawInput { time: Some(time), events, screen_rect: Some(screen), ..Default::default() }; + crate::testing::app_frame(app, &ctx, input).platform_output.accesskit_update.map_or_else(Vec::new, |update| update.nodes) + }; + for _ in 0..7 { + frame(&mut app, Vec::new(), Modifiers::NONE); + } + let nodes = frame(&mut app, Vec::new(), Modifiers::NONE); + let rect = + |node: &egui::accesskit::Node| node.bounds().map(|b| Rect::from_min_max(pos2(b.x0 as f32, b.y0 as f32), pos2(b.x1 as f32, b.y1 as f32))); + let title = crate::i18n::t("Paragraph"); + let (_, body_node) = nodes.iter().find(|(_, node)| node.role() == Role::TabPanel && node.label() == Some(title)).unwrap(); + let body = rect(body_node).unwrap(); + assert!((body.width() - width).abs() < 1.0, "{lang}: {body:?}"); + + let mut descendants = Vec::new(); + let mut todo = body_node.children().to_vec(); + while let Some(id) = todo.pop() { + let Some((_, node)) = nodes.iter().find(|(key, _)| *key == id) else { continue }; + todo.extend(node.children()); + if let (Some(label), Some(bounds)) = (node.label(), rect(node)) { + descendants.push((label, node.role(), bounds)); + } + } + let mut control = |names: [&str; 2], role: Option| { + let (label, _, bounds) = descendants + .iter() + .find(|(label, kind, _)| { + role.is_none_or(|expected| *kind == expected) && names.iter().any(|name| *label == *name || *label == crate::i18n::t(name)) + }) + .unwrap_or_else(|| panic!("{lang}: no {names:?} with role {role:?}")); + assert!(bounds.is_positive() && body.expand(0.5).contains_rect(*bounds), "{lang}: {label} {bounds:?} outside {body:?}"); + let expected = crate::i18n::t(names[1]); + if expected != names[1] && *label != expected { + untranslated.push(format!("{lang}: {label:?}, expected {expected:?}")); + } + bounds.center() + }; + for names in [ + ["Left align text", "Align left"], + ["Right align text", "Align right"], + ["Justify last left", "Justify with last line aligned left"], + ["Justify last centered", "Justify with last line aligned center"], + ["Justify last right", "Justify with last line aligned right"], + ["Justify all", "Justify all lines"], + ] { + control(names, None); + } + let center = control(["Center text", "Align center"], None); + let before = control(["Add space before paragraph", "Space Before Paragraph"], Some(Role::SpinButton)); + let after = control(["Add space after paragraph", "Space After Paragraph"], Some(Role::SpinButton)); + let button = |pos, pressed| Event::PointerButton { pos, button: PointerButton::Primary, pressed, modifiers: Modifiers::NONE }; + let key = |key, modifiers, pressed| Event::Key { key, physical_key: None, pressed, repeat: false, modifiers }; + frame(&mut app, vec![Event::PointerMoved(center), button(center, true)], Modifiers::NONE); + frame(&mut app, vec![button(center, false)], Modifiers::NONE); + frame(&mut app, Vec::new(), Modifiers::NONE); + assert_eq!(selected(&app), [Justify::Center], "{lang}: pointer changed alignment"); + for (at, input) in [(before, "12"), (after, "18")] { + frame(&mut app, vec![Event::PointerMoved(at), button(at, true)], Modifiers::NONE); + frame(&mut app, vec![button(at, false)], Modifiers::NONE); + frame(&mut app, vec![key(Key::A, Modifiers::COMMAND, true)], Modifiers::COMMAND); + frame(&mut app, vec![key(Key::A, Modifiers::COMMAND, false), Event::Text(input.to_owned())], Modifiers::NONE); + frame(&mut app, vec![key(Key::Enter, Modifiers::NONE, true)], Modifiers::NONE); + frame(&mut app, vec![key(Key::Enter, Modifiers::NONE, false)], Modifiers::NONE); + } + assert_eq!(shared_para_field(&app, |p| p.space_before), Some(12.0), "{lang}: keyboard updated before"); + assert_eq!(shared_para_field(&app, |p| p.space_after), Some(18.0), "{lang}: keyboard updated after"); + crate::i18n::set_current(crate::i18n::Lang::EN); + } + assert!(untranslated.is_empty(), "lost Paragraph translations: {untranslated:?}"); +} + fn select_range(app: &mut VectorcraftApp, start: usize, end: usize) { app.session.set_tool_option("select", &json!({"start": start, "end": end})); } From eb153ab46e34017b233aeaff90d375cedf5b6aaa Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 26 Nov 2026 17:35:19 -0800 Subject: [PATCH 19/84] Keep Graph Data tied to the drawing it opened on --- crates/ui-egui/src/dialogs/graph_data.rs | 53 ++++++++++++++---------- 1 file changed, 32 insertions(+), 21 deletions(-) diff --git a/crates/ui-egui/src/dialogs/graph_data.rs b/crates/ui-egui/src/dialogs/graph_data.rs index ae58ce2ad6..1eb37190e5 100644 --- a/crates/ui-egui/src/dialogs/graph_data.rs +++ b/crates/ui-egui/src/dialogs/graph_data.rs @@ -51,6 +51,7 @@ use crate::file_asks::{self, Owner}; /// The dialog kind of Graph Data, the key of its dialog on the host. pub const KIND: &str = "graphData"; const WRONG_DOCUMENT: &str = "Graph Data belongs to the document that opened this sheet."; +const REVERTED_DOCUMENT: &str = "Reopen Graph Data after reverting the drawing."; /// The sheet's size: a row of labels over a graph's categories, a column of labels before its /// series; the least rows it shows. @@ -71,13 +72,11 @@ const ROW_H: f32 = 19.0; pub fn open(app: &mut VectorcraftApp) -> Result { // The query fails without a graph selected, with the engine's own message. let v = app.session.execute("graph.setData", &json!({})).map_err(|e| e.to_string())?; - let document = app.session.active().ok_or("no document open")?.uid; - let graph = app.session.active().and_then(|st| st.selection.objects.iter().find_map(|id| graph_of(&st.doc, *id)).map(|id| (st, id))); - let scatter = graph.is_some_and(|(st, id)| { - st.doc.node(id).and_then(|n| n.extras().graph.as_deref()).is_some_and(|g| g.kind == vectorcraft_doc::GraphKind::Scatter) - }); - let id = graph.map(|(_, id)| id.0); - let dialog = GraphDataDialog::new(grid_from_data(&v), document, id, scatter, can_import(app)); + let st = app.session.active().ok_or("no document open")?; + let graph = st.selection.objects.iter().find_map(|id| graph_of(&st.doc, *id)); + let scatter = graph + .is_some_and(|id| st.doc.node(id).and_then(|n| n.extras().graph.as_deref()).is_some_and(|g| g.kind == vectorcraft_doc::GraphKind::Scatter)); + let dialog = GraphDataDialog::new(grid_from_data(&v), st.uid, st.reverts, graph.map(|id| id.0), scatter, can_import(app)); let dialogs = app.dialogs().ok_or("no window to show the dialog in")?; dialogs.with(|host| host.open(dialog)); Ok(Value::Null) @@ -437,6 +436,7 @@ fn import(app: &mut VectorcraftApp, owner: &Arc<()>, picked: Picked) -> Result, import_owner: Arc<()>, apply: Option, @@ -448,26 +448,29 @@ struct Asks { pub(crate) fn pump(app: &mut VectorcraftApp, _ctx: &egui::Context) { let Some(dialogs) = app.dialogs() else { return }; let can = can_import(app); - let active = app.session.active().map(|doc| doc.uid); + let active = app.session.active().map(|doc| (doc.uid, doc.reverts)); let asked = dialogs.with(|host| { host.get_mut::().map(|d| { d.can_import = can; - if active == Some(d.document) { + if active == Some((d.document, d.reverts)) { d.held.clear_refusal(); } d.take_asks() }) }); - let Some(Asks { document, graph, import_owner, apply: filed, actions }) = asked else { return }; - let same_document = active == Some(document); + let Some(Asks { document, reverts, graph, import_owner, apply: filed, actions }) = asked else { return }; + let refusal = match active { + Some((uid, current_reverts)) if uid == document => (current_reverts != reverts).then_some(tl!(REVERTED_DOCUMENT)), + _ => Some(tl!(WRONG_DOCUMENT)), + }; if let Some(sheet) = filed { - let answer = if same_document { + let answer = if let Some(reason) = refusal { + Err(Label::from(reason)) + } else { if let Err(e) = apply(app, &sheet, graph) { app.status(e); } Ok(()) - } else { - Err(Label::from(tl!(WRONG_DOCUMENT))) }; dialogs.with(|host| host.get_mut::().map(|dialog| dialog.applied(answer))); } @@ -489,13 +492,18 @@ pub(crate) fn pump(app: &mut VectorcraftApp, _ctx: &egui::Context) { move |app, picked| import(app, &owner, picked), ); } - Action::Revert if !same_document => app.status(tl!(WRONG_DOCUMENT).to_owned()), - Action::Revert => match graph_grid(app, graph) { - Ok(grid) => { - dialogs.with(|host| host.get_mut::().map(|d| d.replace(grid))); + Action::Revert => { + if let Some(reason) = refusal { + app.status(reason.to_owned()); + } else { + match graph_grid(app, graph) { + Ok(grid) => { + dialogs.with(|host| host.get_mut::().map(|d| d.replace(grid))); + } + Err(e) => app.status(e), + } } - Err(e) => app.status(e), - }, + } } } } @@ -675,6 +683,7 @@ pub(crate) struct GraphDataDialog { state: GridState, entry: Entry, document: u64, + reverts: u64, /// The graph the sheet opened on. graph: Option, scatter: bool, @@ -687,7 +696,7 @@ pub(crate) struct GraphDataDialog { impl GraphDataDialog { /// The window over `grid`, the data of `graph`; Switch x/y is on for a `scatter` graph. - fn new(grid: Grid, document: u64, graph: Option, scatter: bool, can_import: bool) -> Self { + fn new(grid: Grid, document: u64, reverts: u64, graph: Option, scatter: bool, can_import: bool) -> Self { let sheet = Sheet { grid, ..Sheet::default() }; let state = GridState::new(CellSelection::cell(CellAt::new(0, 1)), 1.0); let mut entry = Entry { text: String::new(), at: (0, 1) }; @@ -699,6 +708,7 @@ impl GraphDataDialog { state, entry, document, + reverts, graph, scatter, can_import, @@ -712,6 +722,7 @@ impl GraphDataDialog { fn take_asks(&mut self) -> Asks { Asks { document: self.document, + reverts: self.reverts, graph: self.graph, import_owner: self.import_owner.clone(), apply: self.held.take(), From be9a97a9c76eb075cbfc1cba0ab56b5e352a3249 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 26 Nov 2026 17:38:29 -0800 Subject: [PATCH 20/84] Refuse older Kinsoku Shori drafts after File Revert --- crates/ui-egui/src/dialogs/kinsoku_sets.rs | 27 ++++++++++++------- .../ui-egui/src/dialogs/kinsoku_sets/tests.rs | 3 ++- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/crates/ui-egui/src/dialogs/kinsoku_sets.rs b/crates/ui-egui/src/dialogs/kinsoku_sets.rs index 6eb690989d..8c9c5075f5 100644 --- a/crates/ui-egui/src/dialogs/kinsoku_sets.rs +++ b/crates/ui-egui/src/dialogs/kinsoku_sets.rs @@ -55,7 +55,8 @@ fn categories() -> [(&'static str, &'static str); 4] { /// What OK files for the pump: the document the dialog opened on, the names of its sets then, and the sets. #[derive(Clone)] struct Request { - doc: Option, + doc: u64, + reverts: u64, opened: Vec, sets: Value, } @@ -63,8 +64,9 @@ struct Request { /// The Kinsoku Shori Settings dialog on the host. pub(crate) struct KinsokuDialog { id: DialogId, - /// The uid of the document the dialog opened on, which OK sets the sets of. - doc: Option, + /// The drawing and its saved-content generation when the dialog opened. + doc: u64, + reverts: u64, /// The names of that document's sets when the dialog opened: OK keeps the sets the document gained /// since, after the dialog's own, and New's suggestion skips these names. opened: Vec, @@ -84,7 +86,7 @@ pub(crate) struct KinsokuDialog { /// Open Kinsoku Shori Settings on the active document's custom sets, the first one picked. pub fn open(app: &mut VectorcraftApp) -> Result { let st = app.session.active().ok_or("no document open")?; - let dialog = KinsokuDialog::new(st.uid, st.doc.kinsoku_sets.iter()); + let dialog = KinsokuDialog::new(st.uid, st.reverts, st.doc.kinsoku_sets.iter()); app.dialogs().ok_or("no window")?.with(|host| host.open(dialog)); Ok(Value::Null) } @@ -176,10 +178,11 @@ fn text_of(field: &str, value: &Value) -> Result { } impl KinsokuDialog { - fn new<'a>(doc: u64, document_sets: impl Iterator + Clone) -> Self { + fn new<'a>(doc: u64, reverts: u64, document_sets: impl Iterator + Clone) -> Self { let mut d = KinsokuDialog { id: dialog_id(COMMAND), - doc: Some(doc), + doc, + reverts, opened: document_sets.clone().map(|k| k.name.clone()).collect(), sets: Value::Array(document_sets.map(listed).collect()), selected: 0, @@ -340,7 +343,7 @@ impl KinsokuDialog { } self.commit(); self.problem = None; - self.held.file(Request { doc: self.doc, opened: self.opened.clone(), sets: self.sets.clone() }); + self.held.file(Request { doc: self.doc, reverts: self.reverts, opened: self.opened.clone(), sets: self.sets.clone() }); } /// The answer OK filed, once. @@ -517,7 +520,7 @@ pub(crate) fn pump(app: &mut VectorcraftApp, ctx: &Context) { let Some(host) = app.dialogs() else { return }; let Some(request) = host.with(|h| h.get_mut::().and_then(KinsokuDialog::take_ok)) else { return }; let answer = apply(app, &request); - let gone = answer.is_err() && !app.session.documents().iter().any(|d| Some(d.uid) == request.doc); + let gone = answer.is_err() && !app.session.documents().iter().any(|d| d.uid == request.doc); // The command ran outside the host's lock, which a dialog's own methods take. host.with(|h| { if let Some(d) = h.get_mut::() { @@ -530,8 +533,12 @@ pub(crate) fn pump(app: &mut VectorcraftApp, ctx: &Context) { } fn apply(app: &mut VectorcraftApp, request: &Request) -> Result<(), String> { - if app.session.active().map(|st| st.uid) != request.doc { - let index = app.session.documents().iter().position(|d| Some(d.uid) == request.doc).ok_or("that document is no longer open")?; + let (index, document) = + app.session.documents().iter().enumerate().find(|(_, st)| st.uid == request.doc).ok_or("that document is no longer open")?; + if document.reverts != request.reverts { + return Err(tl!("The document was reverted. Reopen this dialog to continue.").into()); + } + if app.session.active().is_none_or(|st| st.uid != request.doc) { app.run("document.activate", json!({ "index": index }))?; } // A `sets` that is not a list of sets goes to the command as it is, which refuses it. diff --git a/crates/ui-egui/src/dialogs/kinsoku_sets/tests.rs b/crates/ui-egui/src/dialogs/kinsoku_sets/tests.rs index c026cf4c3b..7d1755f51c 100644 --- a/crates/ui-egui/src/dialogs/kinsoku_sets/tests.rs +++ b/crates/ui-egui/src/dialogs/kinsoku_sets/tests.rs @@ -256,7 +256,8 @@ fn old_ok_keeps_restored_kinsoku_rules_and_the_current_tab() { assert_eq!(restored.history.undo.len(), undo); assert_eq!(app.session.active().unwrap().uid, other, "a stale OK does not activate the original tab"); assert!(is_open(&app)); - cancel(&mut app); + dialog(&app, |d| assert_eq!(d.problem.as_deref(), Some("The document was reverted. Reopen this dialog to continue."))); + cancel(&app); assert!(app.session.set_active(0)); open(&mut app).unwrap(); From e8f812659033f8924767ac77fc618cba71bf9a61 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 26 Nov 2026 17:58:45 -0800 Subject: [PATCH 21/84] Reproduce Symbol Options applying to changed art and reverted definitions --- crates/ui-egui/src/dialogs/symbol_options.rs | 67 +++++++++++++++++++- 1 file changed, 66 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/dialogs/symbol_options.rs b/crates/ui-egui/src/dialogs/symbol_options.rs index 470f78e55e..89e2e0135a 100644 --- a/crates/ui-egui/src/dialogs/symbol_options.rs +++ b/crates/ui-egui/src/dialogs/symbol_options.rs @@ -195,10 +195,12 @@ fn merge(into: &mut Value, extra: Value) { #[cfg(test)] mod document_tests { use craft::ui::dialog::dialog_id; + use vectorcraft_doc::NodeId; use vectorcraft_engine::Session; - use super::super::tests_warp::{accept, set, windowed}; + use super::super::tests_warp::{accept, dismiss, set, windowed}; use super::*; + use crate::tests::picks::answer_dialog; #[test] fn editing_symbol_options_does_not_rename_another_drawings_symbol() { @@ -225,4 +227,67 @@ mod document_tests { accept(&mut app, id); assert!(app.session.active().unwrap().doc.symbols.iter().any(|symbol| symbol.name == "Source badge")); } + + #[test] + fn new_symbol_does_not_replace_art_selected_after_opening() { + let mut app = windowed(VectorcraftApp::new(Session::new(), Default::default())); + app.run("file.new", json!({"width": 200, "height": 200})).unwrap(); + let original = app.run("shape.rectangle", json!({"x": 0, "y": 0, "width": 30, "height": 30})).unwrap()["id"].as_u64().unwrap(); + let other = app.run("shape.rectangle", json!({"x": 60, "y": 0, "width": 50, "height": 50})).unwrap()["id"].as_u64().unwrap(); + app.run("select.set", json!({"ids": [original]})).unwrap(); + open(&mut app, false).unwrap(); + let id = dialog_id(KIND); + set(&app, id, "name", json!("Badge")); + app.run("select.set", json!({"ids": [other]})).unwrap(); + let before = app.session.active().unwrap().doc.clone(); + let undo = app.session.active().unwrap().history.undo.len(); + + answer_dialog(&mut app, id, &[], true); + assert_eq!(app.session.active().unwrap().doc, before, "OK cannot turn the later selection into a symbol"); + assert_eq!(app.session.active().unwrap().history.undo.len(), undo); + + app.run("select.set", json!({"ids": [original]})).unwrap(); + answer_dialog(&mut app, id, &[], true); + let symbols = app.run("symbol.list", json!({})).unwrap(); + assert_eq!(symbols["symbols"][0]["name"], "Badge"); + assert_eq!(symbols["symbols"][0]["size"], json!([30.0, 30.0]), "the original art becomes the symbol"); + assert!(app.session.active().unwrap().doc.node(NodeId(other)).is_some(), "the unrelated rectangle remains"); + } + + #[test] + fn editing_symbol_options_keeps_the_definition_restored_by_revert() { + let mut app = windowed(VectorcraftApp::new(Session::new(), Default::default())); + app.run("file.new", json!({"width": 200, "height": 200})).unwrap(); + app.run("shape.rectangle", json!({"x": 0, "y": 0, "width": 30, "height": 30})).unwrap(); + app.run("symbol.new", json!({"name": "Badge"})).unwrap(); + let file = std::env::temp_dir().join(format!("vectorcraft-symbol-options-revert-{}.vectorcraft", std::process::id())); + app.services.read = Some(Box::new(|path| std::fs::read(path).map_err(|err| err.to_string()))); + app.services.write = Some(Box::new(|path, bytes| std::fs::write(path, bytes).map_err(|err| err.to_string()))); + app.run("file.saveAs", json!({"path": file.to_string_lossy()})).unwrap(); + let st = app.session.active().unwrap(); + let (uid, reverts) = (st.uid, st.reverts); + + app.run("symbol.options", json!({"name": "Badge", "registration": 0})).unwrap(); + open_edit(&mut app, Some("Badge")).unwrap(); + let id = dialog_id(KIND); + set(&app, id, "name", json!("Edited badge")); + app.run("file.revert", json!({"confirmed": true})).unwrap(); + let _ = std::fs::remove_file(file); + let st = app.session.active().unwrap(); + assert_eq!((st.uid, st.reverts), (uid, reverts + 1)); + assert_eq!(st.doc.symbol_registration("Badge").0, 4); + let restored = st.doc.clone(); + let undo = st.history.undo.len(); + + answer_dialog(&mut app, id, &[], true); + assert_eq!(app.session.active().unwrap().doc.symbols[0].name, "Badge", "the restored symbol keeps its name"); + assert_eq!(app.session.active().unwrap().doc, restored); + assert_eq!(app.session.active().unwrap().history.undo.len(), undo); + + dismiss(&mut app, id); + open_edit(&mut app, Some("Badge")).unwrap(); + set(&app, id, "name", json!("New badge")); + accept(&mut app, id); + assert_eq!(app.session.active().unwrap().doc.symbols[0].name, "New badge"); + } } From 79d9e1e1ab6f73a5f7bba8273c19286a93ba50a4 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 26 Nov 2026 17:59:31 -0800 Subject: [PATCH 22/84] Guard Symbol Options against later selections and reverted drawings --- crates/ui-egui/src/dialogs/symbol_options.rs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/crates/ui-egui/src/dialogs/symbol_options.rs b/crates/ui-egui/src/dialogs/symbol_options.rs index 89e2e0135a..e4282e51e6 100644 --- a/crates/ui-egui/src/dialogs/symbol_options.rs +++ b/crates/ui-egui/src/dialogs/symbol_options.rs @@ -12,6 +12,8 @@ //! Help: //! . +use std::collections::HashSet; + use craft::ui::contract::{Bind, Outcome as _, Show as _}; use craft::ui::patterns::form_dialogs::{DialogFields, FieldValue, HostedParamDialog, Param, ParamDialog, ParamKind, ParamResult}; use craft::ui::pickers::{Anchor9, ReferencePoint, ReferencePointLook}; @@ -100,13 +102,23 @@ fn rows(name: &str) -> Vec { /// edited), applies the fields to it; `keep_art` leaves the selection as ordinary art for a new one; /// `opened` are the guides the dialog opened with. fn open_dialog(app: &mut VectorcraftApp, fields: DialogFields, edit: Option, keep_art: bool, opened: [f64; 4]) -> Result { - let document = app.session.active().ok_or("no document open")?.uid; + let st = app.session.active().ok_or("no document open")?; + let (document, reverts) = (st.uid, st.reverts); + let selection = edit.is_none().then(|| st.selection.objects.iter().copied().collect::>()); let ctx = app.ui_ctx.clone().ok_or("no window")?; let name = fields.text("name").unwrap_or_default().to_string(); let dialog = HostedParamDialog::new(&ctx, KIND, fields, move |_| ParamDialog::new(KIND, tl!("Symbol Options"), rows(&name))); let ok = move |app: &mut VectorcraftApp, result: &ParamResult| -> Result<(), String> { - if !app.session.active().is_some_and(|active| active.uid == document) { - return Err(tl!("This symbol belongs to the document that opened the dialog.").to_owned()); + let Some(active) = app.session.active().filter(|st| st.uid == document) else { + return Err(tl!("This symbol belongs to the document that opened the dialog.").into()); + }; + if active.reverts != reverts { + return Err(tl!("The document was reverted. Reopen this dialog to continue.").into()); + } + if let Some(selection) = &selection + && (active.selection.objects.len() != selection.len() || active.selection.objects.iter().any(|id| !selection.contains(id))) + { + return Err(tl!("The selected artwork changed. Restore the selection to continue.").into()); } let f = &result.fields; let name = f.text("name").unwrap_or_default().trim().to_string(); @@ -243,7 +255,7 @@ mod document_tests { let undo = app.session.active().unwrap().history.undo.len(); answer_dialog(&mut app, id, &[], true); - assert_eq!(app.session.active().unwrap().doc, before, "OK cannot turn the later selection into a symbol"); + assert!(app.session.active().unwrap().doc == before, "OK cannot turn the later selection into a symbol"); assert_eq!(app.session.active().unwrap().history.undo.len(), undo); app.run("select.set", json!({"ids": [original]})).unwrap(); From 50be08fb0b8bc6f163f2f1a0359c194ffba971d0 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 26 Nov 2026 18:08:51 -0800 Subject: [PATCH 23/84] Require fresh Save for Web approval after Revert --- crates/ui-egui/src/dialogs/save_for_web.rs | 32 ++++++++++------- .../ui-egui/src/dialogs/save_for_web/tests.rs | 36 +++++++++++++++++++ 2 files changed, 55 insertions(+), 13 deletions(-) diff --git a/crates/ui-egui/src/dialogs/save_for_web.rs b/crates/ui-egui/src/dialogs/save_for_web.rs index e7afa2c556..bd1c548175 100644 --- a/crates/ui-egui/src/dialogs/save_for_web.rs +++ b/crates/ui-egui/src/dialogs/save_for_web.rs @@ -42,7 +42,7 @@ const WRONG_DOCUMENT: &str = "Save for Web belongs to the document that opened t /// What the open dialog's pump keeps between frames: data keyed by its inputs, never UI state. #[derive(Default)] pub(crate) struct WebExport { - document: Option, + document: Option<(u64, u64)>, opening: Arc<()>, /// The rendering of the art before optimisation, by [`render_key`]. render: Option<(String, Result, String>)>, @@ -186,7 +186,8 @@ fn settings_of(options: &SaveForWebOptions, table: &Value, kept: &Value, path: O /// Open on the document's active artboard, keeping the other remembered settings. pub fn open(app: &mut VectorcraftApp) -> Result { - let document = app.session.active().ok_or("no document")?.uid; + let active = app.session.active().ok_or("no document")?; + let document = (active.uid, active.reverts); let host = app.dialogs().ok_or("no window")?; let ctx = app.ui_ctx.clone().ok_or("no window")?; // Settle a completed opening while its settings and source are still available. @@ -461,8 +462,13 @@ fn on_dialog(host: &craft::ui::shell::WindowDialogs, f: impl FnOnce(&mut Host host.with(|h| h.get_mut::().map(f)) } -fn on_original_document(app: &VectorcraftApp) -> bool { - app.session.active().is_some_and(|active| app.web_export.document == Some(active.uid)) +fn document_problem(app: &VectorcraftApp) -> Option<&'static str> { + match (app.web_export.document, app.session.active()) { + (Some((uid, reverts)), Some(active)) if uid == active.uid => { + (reverts != active.reverts).then(|| tl!("The document was reverted. Reopen this dialog to continue.")) + } + _ => Some(tl!(WRONG_DOCUMENT)), + } } /// Answers the open dialog once per frame: its result when it closed, else its requests. @@ -479,7 +485,7 @@ pub(crate) fn pump(app: &mut VectorcraftApp, ctx: &egui::Context) { _ => {} } let Some(asked) = on_dialog(&host, Asked::take) else { return }; - if !on_original_document(app) { + if let Some(reason) = document_problem(app) { let restore = asked.tables.iter().any(|event| matches!(event.edit, ColorTableEdit::Restore)); if restore { color_table::restore(&mut app.web_export.table); @@ -494,7 +500,7 @@ pub(crate) fn pump(app: &mut VectorcraftApp, ctx: &egui::Context) { update_presets(app, &host, asked.presets, restore); if requested { on_dialog(&host, HostedSaveForWeb::cancel_requests); - app.status(tl!(WRONG_DOCUMENT).to_owned()); + app.status(reason); } return; } @@ -595,8 +601,8 @@ pub(crate) fn take_palette_pick(app: &mut VectorcraftApp, parent: DialogId, key: let Some(options) = host.with(|h| h.get_mut_by_id::(parent).map(|d| d.current().clone())) else { return false; }; - if !on_original_document(app) { - app.status(tl!(WRONG_DOCUMENT).to_owned()); + if let Some(reason) = document_problem(app) { + app.status(reason); return true; } let rgb = |c: Srgba| { @@ -736,11 +742,11 @@ fn ask_path(app: &mut VectorcraftApp, host: &craft::ui::shell::WindowDialogs, id if !Arc::ptr_eq(&opening, &app.web_export.opening) { return Ok(Value::Null); } - if !on_original_document(app) { + if let Some(reason) = document_problem(app) { if let Some(host) = app.dialogs() { on_dialog(&host, HostedSaveForWeb::cancel_requests); } - app.status(tl!(WRONG_DOCUMENT).to_owned()); + app.status(reason); return Ok(Value::Null); } match picked.first_path() { @@ -765,12 +771,12 @@ fn answer_path(app: &VectorcraftApp, id: DialogId, key: &str, path: PathBuf) { /// The dialog closed with Save… or Done: the settings are remembered, and with a path the files are /// written. Failures show in the status line; the dialog has closed. fn finish(app: &mut VectorcraftApp, result: SaveForWebResult) { - let wrong_document = result.path.is_some() && !on_original_document(app); + let problem = document_problem(app).filter(|_| result.path.is_some()); let table = std::mem::take(&mut app.web_export.table); let kept = std::mem::take(&mut app.web_export.kept); app.web_export = WebExport::default(); - if wrong_document { - return app.status(tl!(WRONG_DOCUMENT).to_owned()); + if let Some(reason) = problem { + return app.status(reason); } let params = settings_of(&result.options, &table, &kept, None); if let Err(e) = app.run("webExport.settings", params.clone()) { diff --git a/crates/ui-egui/src/dialogs/save_for_web/tests.rs b/crates/ui-egui/src/dialogs/save_for_web/tests.rs index b030f110db..6c79fb69da 100644 --- a/crates/ui-egui/src/dialogs/save_for_web/tests.rs +++ b/crates/ui-egui/src/dialogs/save_for_web/tests.rs @@ -355,6 +355,42 @@ fn save_for_web_does_not_write_another_drawing_when_the_picker_returns() { assert!(dir.join("Untitled-1.png").exists()); } +#[test] +fn save_for_web_requires_a_fresh_approval_after_file_revert() { + let dir = vectorcraft_testkit::TempDir::new("sfw-revert-output"); + let source = vectorcraft_testkit::TempDir::new("sfw-revert-drawing"); + let (mut app, _) = app(dir.as_ref(), false); + app.services.read = Some(Box::new(|path| std::fs::read(path).map_err(|e| e.to_string()))); + let path = source.join("Source.vectorcraft"); + app.run("file.saveAs", json!({"path": path})).unwrap(); + app.run("shape.rectangle", json!({"x": 5, "y": 5, "width": 10, "height": 10})).unwrap(); + let original = app.session.active().unwrap(); + let (uid, reverts) = (original.uid, original.reverts); + app.run("file.saveForWeb", json!({})).unwrap(); + set(&mut app, "format", json!("png24")); + let ctx = app.ui_ctx.clone().unwrap(); + let dialog = id(&app); + host(&app).with(|h| h.confirm_by_id(&ctx, dialog)); + settle(&mut app); + + app.run("file.revert", json!({"confirmed": true})).unwrap(); + let current = app.session.active().unwrap(); + assert_eq!((current.uid, current.reverts), (uid, reverts + 1)); + answer_saves(&mut app); + settle(&mut app); + assert_eq!(std::fs::read_dir(dir.as_ref()).unwrap().count(), 0); + assert_eq!(app.ui.status, "The document was reverted. Reopen this dialog to continue."); + + close(&mut app); + settle(&mut app); + app.run("file.saveForWeb", json!({})).unwrap(); + set(&mut app, "format", json!("png24")); + save(&mut app); + let outputs: Vec<_> = std::fs::read_dir(dir.as_ref()).unwrap().map(|entry| entry.unwrap().path()).collect(); + assert_eq!(outputs.len(), 1); + assert!(std::fs::read(&outputs[0]).unwrap().starts_with(b"\x89PNG")); +} + /// The remembered Transparency Dither, which the dialog does not show, reaches the file Save writes /// and stays remembered after Done. #[test] From 8390031f73f53997dc23c48f8053ea32cfbc2152 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 26 Nov 2026 18:09:49 -0800 Subject: [PATCH 24/84] Open browser-picked swatch libraries from Recolor Artwork --- crates/ui-egui/src/dialogs/recolor.rs | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/crates/ui-egui/src/dialogs/recolor.rs b/crates/ui-egui/src/dialogs/recolor.rs index a377869b5b..1ed93cc403 100644 --- a/crates/ui-egui/src/dialogs/recolor.rs +++ b/crates/ui-egui/src/dialogs/recolor.rs @@ -123,7 +123,6 @@ use std::sync::{Arc, Weak}; use craft::behavior::edit_history::{EditHistory, Step}; use craft::behavior::{ColumnKey, ColumnWidth, EditEvent, IconId, Mixed, Selection, SelectionChange, keyed}; use craft::color_ui::ui::{ChannelRow, ChannelUnit, ColorPanelMode, DiscRadius, patch_at}; -use craft::host::PickRequest; use craft::theme::variant::Tone; use craft::theme::{ModelValues, Rgba, Srgba}; use craft::ui::buttons::{IconButton, ToggleButton}; @@ -1632,11 +1631,9 @@ fn randomize(app: &mut VectorcraftApp, d: &mut Fields, sb: bool) { /// Other Library…: import a library (.ase, .acb, .gpl, .vcswatches or a document's swatches) and /// limit to it. fn pick_library(app: &mut VectorcraftApp, opening: Arc<()>) { - let request = builtin_open_filters().fold(PickRequest::open("library"), |request, (name, exts)| request.filter(name, exts)); // A loaded library belongs to the session. The Limit to Library choice belongs to the opening that asked. - crate::file_asks::ask(app, request, crate::file_asks::Owner::Free, move |app, picked| { - let Some(path) = picked.first_path() else { return Ok(Value::Null) }; - let r = app.run("swatch.library.load", json!({ "path": path }))?; + let _ = crate::panels::library_panel::pick_library_file(app, None, builtin_open_filters().collect(), move |app, source| { + let r = app.run("swatch.library.load", source)?; let library = r["library"].clone(); if let Some(dialogs) = app.dialogs() { dialogs.with(|host| { @@ -3208,6 +3205,21 @@ mod tests { (rc, opening, other) } + #[test] + fn other_library_accepts_browser_contents_and_selects_the_loaded_library() { + let (mut rc, _, _) = two_red_drawings(); + let picker = crate::tests::picks::scripted(&mut rc.app()); + rc.settled().click_label("Other Library…").frame(); + assert_eq!(picker.requests().len(), 1); + let bytes = b"GIMP Palette\nName: Recolor Browser Palette\n#\n255 0 0\tRecolor Red\n"; + picker.answer_contents(&[("Recolor Browser Palette.gpl", bytes)]); + crate::file_asks::poll(&mut rc.app()); + rc.frame(); + let selected = rc.fields().str("limitTo"); + assert!(!selected.is_empty(), "Other Library selects the imported library"); + assert!(swatchlib::limit_palette(&rc.app().session, &selected).is_some()); + } + #[test] fn recolor_preview_does_not_change_the_other_drawings_art() { let (mut rc, opening, other) = two_red_drawings(); From f86528b23096e38bb60d99137e84e49ffc47283b Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 26 Nov 2026 18:17:09 -0800 Subject: [PATCH 25/84] Retire Bullets and Numbering drafts after Revert --- .../ui-egui/src/dialogs/bullets_numbering.rs | 46 ++++++++++++++++--- 1 file changed, 40 insertions(+), 6 deletions(-) diff --git a/crates/ui-egui/src/dialogs/bullets_numbering.rs b/crates/ui-egui/src/dialogs/bullets_numbering.rs index 2b85bb6394..9bff24d03e 100644 --- a/crates/ui-egui/src/dialogs/bullets_numbering.rs +++ b/crates/ui-egui/src/dialogs/bullets_numbering.rs @@ -135,7 +135,7 @@ pub(crate) struct BulletsDialog { /// The preview from the opening drawing and the interaction that owns its undo snapshot. pub(crate) struct Preview { - document: u64, + document: (u64, u64), live: LivePreview, selection: Option>, } @@ -144,13 +144,13 @@ impl Preview { fn owns_interaction(&self, app: &VectorcraftApp) -> bool { let Some(selection) = &self.selection else { return false }; app.session.active().is_some_and(|state| { - state.uid == self.document + (state.uid, state.reverts) == self.document && state.interaction.as_ref().is_some_and(|interaction| selection.as_ptr() == Arc::as_ptr(&interaction.selection)) }) } fn update(&mut self, app: &mut VectorcraftApp, fields: Map) { - let Some(state) = app.session.active().filter(|state| state.uid == self.document) else { return }; + let Some(state) = app.session.active().filter(|state| (state.uid, state.reverts) == self.document) else { return }; if !self.owns_interaction(app) { self.live = LivePreview::default(); self.selection = None; @@ -175,8 +175,11 @@ impl Preview { } return Ok(()); } - if app.session.active().is_none_or(|state| state.uid != self.document) { + let Some(state) = app.session.active().filter(|state| state.uid == self.document.0) else { return Err(tl!("Bullets and Numbering can only change the document where it was opened.").to_owned()); + }; + if state.reverts != self.document.1 { + return Err(tl!("The document was reverted. Reopen this dialog to continue.").to_owned()); } if app.session.in_interaction() && !self.owns_interaction(app) { return Err(tl!("Finish the active edit before applying Bullets and Numbering.").to_owned()); @@ -211,7 +214,8 @@ pub fn open(app: &mut VectorcraftApp, p: &Value) -> Result { Some(v) => Some(v.as_str().and_then(ListTab::of).ok_or_else(|| format!("`{key}` must be one of {}", TABS.join(", ")))?), }; crate::panels::character::text_style(app).ok_or("select some type first")?; - let document = app.session.active().ok_or("no document")?.uid; + let active = app.session.active().ok_or("no document")?; + let document = (active.uid, active.reverts); // A dialog this one replaces leaves its preview on the type: end it, so the values read below are the document's own. if let Some(old) = app.bullets_preview.take() { old.cancel(app); @@ -617,7 +621,7 @@ impl StackDialog for BulletsDialog { pub(crate) fn pump(app: &mut VectorcraftApp, _ctx: &Context) { let Some(host) = app.dialogs() else { return }; let Some(mut preview) = app.bullets_preview.take() else { return }; - let active_document = app.session.active().is_some_and(|state| state.uid == preview.document); + let active_document = app.session.active().is_some_and(|state| (state.uid, state.reverts) == preview.document); let lengths = crate::canvas::general_lengths(app); let Some((fields, answer)) = host.with(|h| { h.get_mut::().map(|d| { @@ -804,6 +808,36 @@ mod tests { assert_eq!(first(&app, id).0, Some(ParaList::numbered(NumberStyle::Arabic))); } + #[test] + fn bullets_preview_and_ok_leave_restored_paragraphs_unchanged() { + let (mut app, id) = app(); + let dir = vectorcraft_testkit::TempDir::new("bullets-revert"); + app.services.read = Some(Box::new(|path| std::fs::read(path).map_err(|e| e.to_string()))); + app.services.write = Some(Box::new(|path, bytes| std::fs::write(path, bytes).map_err(|e| e.to_string()))); + let saved = paras(&app, id); + app.run("file.saveAs", json!({"path": dir.join("Paragraphs.vectorcraft")})).unwrap(); + app.run("text.setFormat", json!({"ids": [id], "leftIndent": 19})).unwrap(); + let drawing = app.session.active().unwrap(); + let (uid, reverts) = (drawing.uid, drawing.reverts); + app.run("ui.bulletsAndNumbering", json!({})).unwrap(); + pick_preset(&mut app, "bullet", Some("square")); + frame(&mut app); + assert_eq!(first(&app, id).0, Some(ParaList::bulleted(Bullet::Square))); + + app.run("file.revert", json!({"confirmed": true})).unwrap(); + app.run("select.set", json!({"ids": [id]})).unwrap(); + let restored = app.session.active().unwrap(); + assert_eq!((restored.uid, restored.reverts), (uid, reverts + 1)); + let undo = restored.history.undo.len(); + frame(&mut app); + assert_eq!(paras(&app, id), saved); + assert!(!app.session.in_interaction()); + press_ok(&mut app); + assert!(with_dialog(&app, |dialog| matches!(dialog.held.state(), Some(HeldOk::Refused(_))))); + assert_eq!(paras(&app, id), saved); + assert_eq!(app.session.active().unwrap().history.undo.len(), undo); + } + #[test] fn bullets_cancel_keeps_the_other_drawings_pending_edit() { let (mut app, id) = app(); From d5f7883d1495ad13ba0f9cf9f004ab94f2968a6c Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 26 Nov 2026 18:17:09 -0800 Subject: [PATCH 26/84] Require a fresh New Brush opening after Revert --- crates/ui-egui/src/dialogs/brush_options.rs | 10 ++++-- crates/ui-egui/src/dialogs/new_brush.rs | 35 +++++++++++++++++++-- 2 files changed, 40 insertions(+), 5 deletions(-) diff --git a/crates/ui-egui/src/dialogs/brush_options.rs b/crates/ui-egui/src/dialogs/brush_options.rs index 310eba4a6a..3dbeece787 100644 --- a/crates/ui-egui/src/dialogs/brush_options.rs +++ b/crates/ui-egui/src/dialogs/brush_options.rs @@ -164,7 +164,7 @@ pub fn open(app: &mut VectorcraftApp, name: Option<&str>) -> Result, object_keys: Option<&[&str]>) -> Result { let source = app.session.active().ok_or("no document open")?; - let document = source.uid; + let (document, reverts) = (source.uid, source.reverts); let ty = f.get("__type").and_then(Value::as_str).unwrap_or_default(); let object = object_keys.is_some(); let ctx = app.ui_ctx.clone().ok_or("no window")?; @@ -195,8 +195,12 @@ fn open_dialog(app: &mut VectorcraftApp, f: &Map, object_keys: Op .held_ok(); app.ui.brush_options = Some( host::open_held(app, dialog, move |app, result: &ParamResult| { - if !object && app.session.active().is_none_or(|st| st.uid != document) { - return Err(tl!("Return to the original drawing to edit its brush").into()); + match app.session.active().filter(|st| st.uid == document) { + Some(source) if source.reverts != reverts => { + return Err(tl!("The document was reverted. Reopen this dialog to continue.").into()); + } + None if !object => return Err(tl!("Return to the original drawing to edit its brush").into()), + _ => {} } ok(app, result) }) diff --git a/crates/ui-egui/src/dialogs/new_brush.rs b/crates/ui-egui/src/dialogs/new_brush.rs index 7fcb8ca726..81659dda3c 100644 --- a/crates/ui-egui/src/dialogs/new_brush.rs +++ b/crates/ui-egui/src/dialogs/new_brush.rs @@ -25,7 +25,7 @@ const TYPES: [&str; 5] = ["calligraphic", "scatter", "art", "bristle", "pattern" /// It starts on Art when there is art, and it starts on Calligraphic otherwise. pub fn open(app: &mut VectorcraftApp, ids: Option) -> Result { let st = app.session.active().ok_or("no document open")?; - let document = st.uid; + let (document, reverts) = (st.uid, st.reverts); let art = match &ids { Some(ids) => ids.as_array().is_some_and(|a| !a.is_empty()), None => !st.selection.is_empty(), @@ -38,8 +38,11 @@ pub fn open(app: &mut VectorcraftApp, ids: Option) -> Result Date: Thu, 26 Nov 2026 18:17:09 -0800 Subject: [PATCH 27/84] Require fresh New Color Group choices after Revert --- crates/ui-egui/src/dialogs/new_color_group.rs | 37 ++++++++++++++++++- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/dialogs/new_color_group.rs b/crates/ui-egui/src/dialogs/new_color_group.rs index 421d3a3d59..56073beaf9 100644 --- a/crates/ui-egui/src/dialogs/new_color_group.rs +++ b/crates/ui-egui/src/dialogs/new_color_group.rs @@ -18,7 +18,7 @@ pub const KIND: &str = "newColorGroup"; /// art is selected and no swatches are. pub fn open(app: &mut VectorcraftApp, swatches: Vec) -> Result { let st = app.session.active().ok_or("no document open")?; - let document = st.uid; + let (document, reverts) = (st.uid, st.reverts); let art = !st.selection.is_empty(); let mut fields = DialogFields::new(); fields.set("name", st.doc.free_swatch_name("Color Group")); @@ -38,8 +38,11 @@ pub fn open(app: &mut VectorcraftApp, swatches: Vec) -> Result Result<(), String> { - if !app.session.active().is_some_and(|active| active.uid == document) { + let Some(source) = app.session.active().filter(|active| active.uid == document) else { return Err(tl!("Create this color group in the document that opened the dialog.").to_owned()); + }; + if source.reverts != reverts { + return Err(tl!("The document was reverted. Reopen this dialog to continue.").to_owned()); } app.run("swatch.newGroup", params(&answer.fields, &swatches)).map(|_| ()) }; @@ -65,6 +68,36 @@ mod tests { use super::*; + #[test] + fn a_color_group_draft_cannot_change_the_drawing_restored_by_revert() { + for swatches in [vec!["Saved Ink".to_owned()], Vec::new()] { + let dir = vectorcraft_testkit::TempDir::new("new-color-group-revert"); + let mut app = crate::testing::windowed(VectorcraftApp::new(Session::new(), Default::default())); + app.services.read = Some(Box::new(|path| std::fs::read(path).map_err(|e| e.to_string()))); + app.services.write = Some(Box::new(|path, bytes| std::fs::write(path, bytes).map_err(|e| e.to_string()))); + app.run("file.new", json!({"width": 200, "height": 200})).unwrap(); + let id = app.run("shape.rectangle", json!({"x": 10, "y": 10, "width": 40, "height": 40})).unwrap()["id"].clone(); + app.run("paint.setFill", json!({"ids": [id], "color": "#123456"})).unwrap(); + app.run("swatch.new", json!({"name": "Saved Ink", "color": "#446688"})).unwrap(); + app.run("file.saveAs", json!({"path": dir.join("Saved.vectorcraft")})).unwrap(); + app.run("paint.setFill", json!({"ids": [id], "color": "#abcdef"})).unwrap(); + app.run("select.set", json!({"ids": [id]})).unwrap(); + let before = app.session.active().unwrap(); + let (uid, reverts) = (before.uid, before.reverts); + open(&mut app, swatches).unwrap(); + app.run("file.revert", json!({"confirmed": true})).unwrap(); + app.run("select.set", json!({"ids": [id]})).unwrap(); + let loaded = app.session.active().unwrap(); + assert_eq!((loaded.uid, loaded.reverts), (uid, reverts + 1)); + let (saved, undo) = (loaded.doc.clone(), loaded.history.undo.len()); + let refused = crate::dialogs::tests_export::try_confirm(&mut app); + let current = app.session.active().unwrap(); + assert_eq!(current.doc, saved); + assert_eq!(current.history.undo.len(), undo); + assert_eq!(refused.unwrap_err(), "The document was reverted. Reopen this dialog to continue."); + } + } + #[test] fn color_group_does_not_convert_the_other_drawings_artwork() { let mut app = crate::testing::windowed(VectorcraftApp::new(Session::new(), Default::default())); From a97ae973ceb1a9112b08d714d62aa8819d004c49 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 26 Nov 2026 18:19:14 -0800 Subject: [PATCH 28/84] Keep linked Canvas swatch drops in their source drawing --- crates/ui-egui/src/canvas/drops.rs | 11 ++++- crates/ui-egui/src/canvas/drops/tests.rs | 57 ++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/canvas/drops.rs b/crates/ui-egui/src/canvas/drops.rs index e432b42759..2be7e422af 100644 --- a/crates/ui-egui/src/canvas/drops.rs +++ b/crates/ui-egui/src/canvas/drops.rs @@ -353,7 +353,7 @@ pub(crate) fn apply_drop(app: &mut VectorcraftApp, drop: &Dropped) -> Result<(), run(app, "graphicStyle.apply", json!({"name": style.name, "ids": [top], "add": drop.op == DropOperation::Copy})) } Payload::Style(_) => Ok(()), - Payload::Panel(drag @ PanelDrag::Paint { params, paint, .. }) if !params.is_null() => { + Payload::Panel(drag @ PanelDrag::Paint { params, paint, rows, .. }) if !params.is_null() => { if let Some(color) = paint.color() && crate::panels::proxy_cmd(app, false) == "paint.setFill" && let Some((id, points)) = selected_mesh_drop(app, at, zoom) @@ -362,7 +362,14 @@ pub(crate) fn apply_drop(app: &mut VectorcraftApp, drop: &Dropped) -> Result<(), return run(app, "object.mesh.setPointColor", params); } let Some(hit) = hit() else { return Ok(()) }; - let Some(mut params) = drag.paint_drop_params(app.session.active().map(|st| st.uid)) else { return Ok(()) }; + let destination = app.session.active().map(|st| st.uid); + if rows.as_ref().is_some_and(|rows| !rows.unlinked_process_color && destination.is_some_and(|uid| uid != rows.document)) + && paint.color().is_some() + && !paint.is_registration() + { + return Err(tl!("A linked color swatch can only be applied in its own document.").into()); + } + let Some(mut params) = drag.paint_drop_params(destination) else { return Ok(()) }; params["ids"] = json!([owner(app, &hit)?]); params["focus"] = json!(false); let cmd = crate::panels::proxy_cmd(app, false); diff --git a/crates/ui-egui/src/canvas/drops/tests.rs b/crates/ui-egui/src/canvas/drops/tests.rs index 6060043515..1f1934a3f0 100644 --- a/crates/ui-egui/src/canvas/drops/tests.rs +++ b/crates/ui-egui/src/canvas/drops/tests.rs @@ -331,6 +331,63 @@ fn a_swatch_drag_keeps_its_color_after_next_document() { assert_eq!(app.session.active().unwrap().doc.node(target).unwrap().appearance.fill_paint(), source); } +#[test] +fn linked_swatch_drops_stay_in_their_source_document() { + use crate::tests::panel_harness::Panel; + use craft::ui::contract::Role; + use craft::ui::runtime::drag; + use egui::{Key, Modifiers}; + + for spot in [false, true] { + for (different_drawing, same_name) in [(false, false), (true, false), (true, true)] { + let mut app = VectorcraftApp::new(Session::new(), Default::default()); + let name = "Shared Swatch"; + app.run("file.new", json!({"width": 200, "height": 200})).unwrap(); + app.run("swatch.new", json!({"name": name, "color": "#ff0000", "global": true, "spot": spot})).unwrap(); + if different_drawing { + app.run("file.new", json!({"width": 200, "height": 200})).unwrap(); + } + if same_name { + app.run("swatch.new", json!({"name": name, "color": "#0000ff", "global": true})).unwrap(); + } + let target = NodeId(app.run("shape.rectangle", json!({"x": 50, "y": 50, "width": 100, "height": 100})).unwrap()["id"].as_u64().unwrap()); + app.run("paint.setFill", json!({"color": "#00ff00"})).unwrap(); + let destination = app.session.active().unwrap().uid; + if different_drawing { + app.run("window.previousDocument", json!({})).unwrap(); + } + let mut panel = Panel::new(app, |app, ui| { + app.sync_views(); + ui.allocate_ui_with_layout(egui::vec2(280.0, 480.0), egui::Layout::top_down(egui::Align::Min), |ui| { + crate::panels::swatches::show(app, ui); + }); + canvas::show(app, ui); + }); + let label = "Shared Swatch, #ff0000"; + let from = panel.rect(label).center(); + let to = panel.app().canvas_view().unwrap().to_screen(Point::new(100.0, 100.0)); + panel.drag_hold_role(label, Role::LIST_ITEM, to - from); + assert!(drag::active::(panel.ctx()).is_some(), "the Swatches row starts a paint drag"); + if different_drawing { + panel.key(Key::F6, Modifiers::COMMAND); + } + assert_eq!(panel.app().session.active().unwrap().uid, destination); + assert!(drag::active::(panel.ctx()).is_some(), "the drag stays active"); + panel.release(); + let app = panel.app(); + let doc = &app.session.active().unwrap().doc; + let fill = doc.node(target).unwrap().appearance.fill_paint(); + if different_drawing { + assert_eq!(fill, Paint::solid(Color::rgb8(0, 255, 0)), "the destination fill stays unchanged"); + assert_eq!(app.ui.status, "A linked color swatch can only be applied in its own document."); + assert_eq!(doc.swatch(name).and_then(|s| s.paint.color()), same_name.then_some(Color::rgb8(0, 0, 255))); + } else { + assert_eq!(fill, doc.tint_paint(name, 1.0).unwrap(), "the fill remains linked to its swatch"); + } + } + } +} + #[test] fn a_color_dropped_on_a_selected_mesh_recolors_the_point_or_patch_under_it() { use vectorcraft_doc::GradientMesh; From 57492ee0869b377aac47cd1d2d7a73092bf41c22 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 26 Nov 2026 18:24:47 -0800 Subject: [PATCH 29/84] Keep Live Paint Gap Options with its opened drawing contents --- crates/ui-egui/src/dialogs/live_paint_gaps.rs | 62 ++++++++++++++++--- 1 file changed, 53 insertions(+), 9 deletions(-) diff --git a/crates/ui-egui/src/dialogs/live_paint_gaps.rs b/crates/ui-egui/src/dialogs/live_paint_gaps.rs index f03b2167e5..388ded4a68 100644 --- a/crates/ui-egui/src/dialogs/live_paint_gaps.rs +++ b/crates/ui-egui/src/dialogs/live_paint_gaps.rs @@ -52,15 +52,15 @@ pub(super) static SPEC: OptionSpec = OptionSpec { pub(crate) struct Open { /// The dialog the preview belongs to. pub id: DialogId, - /// The document that owns the preview interaction. - document: u64, + /// The drawing and loaded contents that own the preview interaction. + document: (u64, u64), /// The preview the options run as. pub preview: LivePreview, } impl Open { fn cancel(self, app: &mut VectorcraftApp) { - if app.session.active().is_some_and(|active| active.uid == self.document) { + if app.session.active().is_some_and(|active| (active.uid, active.reverts) == self.document) { self.preview.cancel(app); } } @@ -69,7 +69,7 @@ impl Open { /// Open Gap Options on the selected Live Paint groups, filled in from the first one's options. pub fn open(app: &mut VectorcraftApp) -> Result { let active = app.session.active().ok_or("select a Live Paint group")?; - let document = active.uid; + let (document, reverts) = (active.uid, active.reverts); let groups: Vec = active .selection .objects @@ -87,13 +87,13 @@ pub fn open(app: &mut VectorcraftApp) -> Result { let fields = [("detect", o["detect"].clone()), ("size", json!(size)), ("custom", custom), ("color", o["color"].clone()), ("closeGaps", json!(false))]; let values = Map::from_iter(fields.map(|(key, value)| (key.to_owned(), value))); - option_form::open(app, &SPEC, values, json!({ "ids": groups, "document": document })).ok_or("no window")?; + option_form::open(app, &SPEC, values, json!({ "ids": groups, "document": document, "reverts": reverts })).ok_or("no window")?; Ok(Value::Null) } -fn original_document(app: &VectorcraftApp, extra: &Value) -> Option { - let document = extra["document"].as_u64()?; - app.session.active().filter(|active| active.uid == document).map(|_| document) +fn original_document(app: &VectorcraftApp, extra: &Value) -> Option<(u64, u64)> { + let document = (extra["document"].as_u64()?, extra["reverts"].as_u64()?); + app.session.active().filter(|active| (active.uid, active.reverts) == document).map(|_| document) } /// `livePaint.gapOptions` parameters from the values and the groups in `extra`. @@ -128,7 +128,13 @@ fn body(ui: &mut egui::Ui, rows: &mut Rows<'_>) { /// OK: keep the previewed options as one undo step; with no preview running they run as one. fn run(app: &mut VectorcraftApp, values: &Map, extra: &Value) -> Result { - let document = original_document(app, extra).ok_or_else(|| tl!(WRONG_DOCUMENT).to_owned())?; + let document = original_document(app, extra).ok_or_else(|| { + if app.session.active().is_some_and(|active| extra["document"].as_u64() == Some(active.uid)) { + tl!("The document was reverted. Reopen this dialog to continue.").to_owned() + } else { + tl!(WRONG_DOCUMENT).to_owned() + } + })?; let preview = app.object_dialogs.gaps.take().filter(|open| open.document == document).map_or_else(LivePreview::default, |open| open.preview); preview.commit(app, CMD, params(values, extra)) } @@ -338,6 +344,44 @@ mod tests { assert_eq!(options(&app, group), GapOptions::default()); } + #[test] + fn gap_preview_and_ok_do_not_edit_live_paint_restored_by_revert() { + let mut app = app(); + let dir = vectorcraft_testkit::TempDir::new("live-paint-gap-revert"); + app.services.read = Some(Box::new(|path| std::fs::read(path).map_err(|e| e.to_string()))); + app.services.write = Some(Box::new(|path, bytes| std::fs::write(path, bytes).map_err(|e| e.to_string()))); + let group = gapped_group(&mut app); + let saved = options(&app, group); + app.run("file.saveAs", json!({"path": dir.join("Live Paint.vectorcraft")})).unwrap(); + app.run("shape.rectangle", json!({"x": 140, "y": 140, "width": 20, "height": 20})).unwrap(); + app.run("select.set", json!({"ids": [group]})).unwrap(); + app.run("ui.livePaintGapOptions", json!({})).unwrap(); + set(&app, "detect", json!(true)).unwrap(); + set(&app, "preview", json!(true)).unwrap(); + pump_all(&mut app); + assert!(options(&app, group).detect); + + let source = app.session.active().unwrap(); + let (uid, reverts) = (source.uid, source.reverts); + app.run("file.revert", json!({"confirmed": true})).unwrap(); + let current = app.session.active().unwrap(); + assert_eq!((current.uid, current.reverts), (uid, reverts + 1)); + let undo = current.history.undo.len(); + pump_all(&mut app); + assert_eq!(options(&app, group), saved); + assert!(overlays(&app).is_empty()); + assert!(!press_ok(&mut app)); + assert_eq!(options(&app, group), saved); + assert_eq!(app.session.active().unwrap().history.undo.len(), undo); + cancel(&mut app); + + app.run("select.set", json!({"ids": [group]})).unwrap(); + app.run("ui.livePaintGapOptions", json!({})).unwrap(); + set(&app, "detect", json!(true)).unwrap(); + assert!(press_ok(&mut app)); + assert!(options(&app, group).detect); + } + #[test] fn the_menu_item_opens_gap_options_which_preview_the_gaps_and_ok_keeps_them() { let mut app = app(); From 20bbbcde5bbea80fb2a9e85aec5006a582bc6254 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 26 Nov 2026 18:22:38 -0800 Subject: [PATCH 30/84] Effects: translate built-in settings labels --- crates/ui-egui/src/dialogs/effect_params.rs | 71 ++++++++++++++++++++- 1 file changed, 68 insertions(+), 3 deletions(-) diff --git a/crates/ui-egui/src/dialogs/effect_params.rs b/crates/ui-egui/src/dialogs/effect_params.rs index 5876d9265e..10028d3c4b 100644 --- a/crates/ui-egui/src/dialogs/effect_params.rs +++ b/crates/ui-egui/src/dialogs/effect_params.rs @@ -103,15 +103,22 @@ pub(crate) fn effect_params(cx: &EffectCx, fields: &DialogFields) -> Vec } } -/// One row per default of an effect without a builder: the JSON type of the default decides the -/// kind, and the rows follow the effect's parameter documentation. +/// One row per default of a built-in effect without a builder: the JSON type of the default decides +/// the kind, labels use the UI language, and the rows follow the effect's parameter documentation. pub(super) fn generic(cx: &EffectCx, fields: &DialogFields) -> Vec { let id = cx.id.as_str(); let Some(info) = vectorcraft_effects::effect_info(id) else { return Vec::new() }; let relative = fields.contains("relative") && effect_rows::is_relative(fields); let mut defaults: Vec<(&String, &Value)> = info.defaults.as_object().into_iter().flatten().collect(); defaults.sort_by_key(|(key, _)| doc_rank(info.params, key)); - defaults.into_iter().filter_map(|(key, default)| generic_row(cx, key, default, relative)).collect() + defaults + .into_iter() + .filter_map(|(key, default)| { + let mut row = generic_row(cx, key, default, relative)?; + row.label = tl!(row.label.as_str()).to_owned().into(); + Some(row) + }) + .collect() } /// One row per stored value of an effect that has no rows of its own (a plug-in no longer @@ -294,3 +301,61 @@ pub(super) fn doc_rank(doc: &str, key: &str) -> usize { .find(|at| starts(*at) && doc.get(at + key.len()..).is_some_and(|rest| rest.starts_with(':') || rest.starts_with("?:"))) .unwrap_or(usize::MAX) } + +#[cfg(test)] +mod tests { + use egui::{Event, Modifiers, PointerButton, Pos2, RawInput, Rect, pos2, vec2}; + use serde_json::json; + use vectorcraft_doc::NodeId; + use vectorcraft_engine::Session; + + use crate::VectorcraftApp; + + #[test] + fn gallery_cutout_setting_uses_its_localized_label() { + let viewport = Rect::from_min_size(Pos2::ZERO, vec2(800.0, 500.0)); + let mut shown_labels = Vec::new(); + for (language, expected) in [("en", "Levels"), ("de", "Stufen"), ("ja", "レベル数")] { + let mut app = crate::testing::windowed(VectorcraftApp::new(Session::new(), Default::default())); + app.session.prefs.interface_language = language.to_owned(); + let lang = app.ui_language(); + let ctx = app.ui_ctx.clone().unwrap(); + let mut time = 0.0; + let mut frame = |app: &mut VectorcraftApp, events: Vec| { + ctx.enable_accesskit(); + time += 0.1; + crate::testing::app_frame(app, &ctx, RawInput { events, time: Some(time), screen_rect: Some(viewport), ..Default::default() }) + }; + app.run("file.new", json!({"width": 200, "height": 200})).unwrap(); + let square = app.run("shape.rectangle", json!({"x": 10, "y": 10, "width": 40, "height": 40})).unwrap()["id"].as_u64().unwrap(); + frame(&mut app, vec![]); + assert_eq!(ctx.content_rect(), viewport); + app.run("ui.effectGalleryDialog", json!({})).unwrap(); + frame(&mut app, vec![]); + let nodes = frame(&mut app, vec![]).platform_output.accesskit_update.unwrap().nodes; + let filter = crate::i18n::effect_name(lang, "artistic.cutout").unwrap(); + let bounds = nodes.iter().filter(|(_, node)| node.label() == Some(filter.as_str())).find_map(|(_, node)| node.bounds()).unwrap(); + let at = pos2((bounds.x0 + bounds.x1) as f32 * 0.5, (bounds.y0 + bounds.y1) as f32 * 0.5); + assert!(viewport.contains(at), "{language}: Cutout is reachable"); + frame(&mut app, vec![Event::PointerMoved(at)]); + for pressed in [true, false] { + frame(&mut app, vec![Event::PointerButton { pos: at, button: PointerButton::Primary, pressed, modifiers: Modifiers::NONE }]); + } + frame(&mut app, vec![]); + let output = frame(&mut app, vec![]); + let state = app.session.active().unwrap(); + let affected = &state.doc.node(NodeId(square)).unwrap().appearance.effects; + assert_eq!(affected.first().map(|effect| effect.id.as_str()), Some("artistic.cutout"), "{language}: Cutout is previewed"); + + let nodes = output.platform_output.accesskit_update.unwrap().nodes; + let found = [expected, "Levels"].into_iter().find(|label| { + nodes + .iter() + .any(|(_, node)| node.label() == Some(*label) && node.bounds().is_some_and(|b| viewport.contains(pos2(b.x0 as f32, b.y0 as f32)))) + }); + eprintln!("{language}: expected {expected:?}, found {found:?}"); + shown_labels.push(found); + } + assert_eq!(shown_labels, [Some("Levels"), Some("Stufen"), Some("レベル数")]); + } +} From 52a43e75b02b4da9256506cd37fa6e635e2b154b Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 26 Nov 2026 18:27:17 -0800 Subject: [PATCH 31/84] Reproduce Smart Punctuation applying past Selected Text Only --- .../ui-egui/src/dialogs/smart_punctuation.rs | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/crates/ui-egui/src/dialogs/smart_punctuation.rs b/crates/ui-egui/src/dialogs/smart_punctuation.rs index 9e68c0507b..f7d3ae4d08 100644 --- a/crates/ui-egui/src/dialogs/smart_punctuation.rs +++ b/crates/ui-egui/src/dialogs/smart_punctuation.rs @@ -208,4 +208,47 @@ mod tests { app.run("document.activate", json!({"index": 0})).unwrap(); assert_eq!(plain(&app, source), "a--b"); } + + fn selected_text_pair() -> (VectorcraftApp, u64, u64) { + let (mut app, selected) = app_with_text("a--b"); + let other = app.run("text.create", json!({"x": 10, "y": 70, "text": "c--d", "font": "Source Sans 3"})).unwrap()["id"].as_u64().unwrap(); + app.run("select.set", json!({"ids": [selected]})).unwrap(); + open(&mut app).unwrap(); + assert_eq!(entry(&app, COMMAND).unwrap().fields.unwrap()["scope"], "selection"); + (app, selected, other) + } + + #[test] + fn selected_text_only_does_not_expand_to_the_document_after_clearing_selection() { + let (mut app, selected, other) = selected_text_pair(); + let undo = app.session.active().unwrap().history.undo.len(); + app.run("select.none", json!({})).unwrap(); + assert_eq!(entry(&app, COMMAND).unwrap().fields.unwrap()["scope"], "selection"); + + let answer = super::super::tests_export::try_confirm(&mut app); + assert_eq!([plain(&app, selected), plain(&app, other)], ["a--b", "c--d"], "Selected Text Only must not expand to the document"); + assert_eq!(app.session.active().unwrap().history.undo.len(), undo); + assert!(answer.is_err()); + + app.run("select.set", json!({"ids": [selected]})).unwrap(); + ok(&mut app); + assert_eq!([plain(&app, selected), plain(&app, other)], ["a–b", "c--d"], "retry changes only the original selection"); + } + + #[test] + fn selected_text_only_refuses_later_art_but_entire_document_still_works() { + let (mut app, selected, other) = selected_text_pair(); + app.run("select.set", json!({"ids": [other]})).unwrap(); + let undo = app.session.active().unwrap().history.undo.len(); + + let answer = super::super::tests_export::try_confirm(&mut app); + assert_eq!([plain(&app, selected), plain(&app, other)], ["a--b", "c--d"], "Selected Text Only must not change later artwork"); + assert_eq!(app.session.active().unwrap().history.undo.len(), undo); + assert!(answer.is_err()); + + set(&app, "scope", json!("document")); + ok(&mut app); + assert_eq!([plain(&app, selected), plain(&app, other)], ["a–b", "c–d"], "an explicit Entire Document still works"); + assert_eq!(app.session.active().unwrap().history.undo.len(), undo + 1); + } } From 9173525fca772610ee03a5a9fa3e33202b9b1f00 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 26 Nov 2026 18:28:08 -0800 Subject: [PATCH 32/84] Bind Smart Punctuation Selected Text Only to the opening selection --- .../ui-egui/src/dialogs/smart_punctuation.rs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/crates/ui-egui/src/dialogs/smart_punctuation.rs b/crates/ui-egui/src/dialogs/smart_punctuation.rs index f7d3ae4d08..c3c1549d2a 100644 --- a/crates/ui-egui/src/dialogs/smart_punctuation.rs +++ b/crates/ui-egui/src/dialogs/smart_punctuation.rs @@ -6,6 +6,8 @@ //! Fields: the switches `fiLigatures`, `flLigatures`, `quotes`, `spaces`, `dashes`, `ellipsis` and //! `fractions`, `scope` (`selection` or `document`) and `report`. +use std::collections::HashSet; + use craft::ui::contract::{Bind, SaveKey}; use craft::ui::patterns::form_dialogs::{DialogFields, FieldValue, HostedParamDialog, Param, ParamDialog, ParamKind, ParamResult}; use craft::ui::runtime::env::Label; @@ -51,6 +53,7 @@ pub fn open(app: &mut VectorcraftApp) -> Result { let source = app.session.active().ok_or("no document")?; let document = source.uid; let selected = !source.selection.is_empty(); + let selection = source.selection.objects.iter().copied().collect::>(); let mut params: Vec = options() .into_iter() .map(|(key, _, label)| Param::new(key, label, ParamKind::bool(matches!(key, "quotes" | "dashes" | "ellipsis")))) @@ -72,10 +75,18 @@ pub fn open(app: &mut VectorcraftApp) -> Result { ctx.data_mut(|data| data.insert_temp(owner, document)); let ok = move |app: &mut VectorcraftApp, result: &ParamResult| -> Result<(), String> { let document = ctx.data(|data| data.get_temp::(owner)); - if app.session.active().is_none_or(|st| Some(st.uid) != document) { + let Some(active) = app.session.active().filter(|st| Some(st.uid) == document) else { return Err(tl!("Return to the original drawing to replace its punctuation").into()); + }; + let params = params_of(result); + if params["scope"] == "selection" + && (active.selection.is_empty() + || active.selection.objects.len() != selection.len() + || active.selection.objects.iter().any(|id| !selection.contains(id))) + { + return Err(tl!("The selected text changed. Restore the selection to continue.").into()); } - let r = app.run(COMMAND, params_of(result))?; + let r = app.run(COMMAND, params)?; result.remember(&ctx); if result.fields.bool("report") == Some(true) { let lines: Vec = options() @@ -228,7 +239,7 @@ mod tests { let answer = super::super::tests_export::try_confirm(&mut app); assert_eq!([plain(&app, selected), plain(&app, other)], ["a--b", "c--d"], "Selected Text Only must not expand to the document"); assert_eq!(app.session.active().unwrap().history.undo.len(), undo); - assert!(answer.is_err()); + assert_eq!(answer, Err("The selected text changed. Restore the selection to continue.".into())); app.run("select.set", json!({"ids": [selected]})).unwrap(); ok(&mut app); @@ -244,7 +255,7 @@ mod tests { let answer = super::super::tests_export::try_confirm(&mut app); assert_eq!([plain(&app, selected), plain(&app, other)], ["a--b", "c--d"], "Selected Text Only must not change later artwork"); assert_eq!(app.session.active().unwrap().history.undo.len(), undo); - assert!(answer.is_err()); + assert_eq!(answer, Err("The selected text changed. Restore the selection to continue.".into())); set(&app, "scope", json!("document")); ok(&mut app); From 165233bb579f80c18bd6699539dd35cf3c62cb9c Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 26 Nov 2026 18:29:01 -0800 Subject: [PATCH 33/84] Keep Define Grid options with the drawing contents that opened them --- .../ui-egui/src/dialogs/perspective_grid.rs | 16 +++++---- .../ui-egui/src/dialogs/tests_perspective.rs | 33 +++++++++++++++++++ 2 files changed, 43 insertions(+), 6 deletions(-) diff --git a/crates/ui-egui/src/dialogs/perspective_grid.rs b/crates/ui-egui/src/dialogs/perspective_grid.rs index d75a811a74..f899a9d7e9 100644 --- a/crates/ui-egui/src/dialogs/perspective_grid.rs +++ b/crates/ui-egui/src/dialogs/perspective_grid.rs @@ -134,7 +134,7 @@ fn open_on(app: &mut VectorcraftApp, def: GridDefinition, mode: GridMode) -> Res let dialog = GridDialog::new( def, mode, - app.session.active().map(|st| st.uid), + app.session.active().map(|st| (st.uid, st.reverts)), (general_lengths(app).pixels_per_inch, app.session.prefs.numbers_without_units_are_points), app.session.perspective_presets(), app.session.new_perspective_preset_name(), @@ -172,8 +172,8 @@ pub fn open_edit(app: &mut VectorcraftApp, original: Option<&str>, base: &str) - pub(super) struct GridDialog { id: DialogId, mode: GridMode, - /// The document whose grid Define Grid edits. - source_document: Option, + /// The document and loaded contents whose grid Define Grid edits. + source_document: Option<(u64, u64)>, draft: GridDraft, /// The presets the Preset row offers, as the document and the preferences have them. presets: Vec, @@ -196,7 +196,7 @@ impl GridDialog { fn new( def: GridDefinition, mode: GridMode, - source_document: Option, + source_document: Option<(u64, u64)>, (ppi, bare_points): (f64, bool), presets: Vec, new_name: String, @@ -527,12 +527,16 @@ enum Next { Presets(String), } -fn file(app: &mut VectorcraftApp, mode: &GridMode, source_document: Option, def: &GridDefinition) -> Result { +fn file(app: &mut VectorcraftApp, mode: &GridMode, source_document: Option<(u64, u64)>, def: &GridDefinition) -> Result { let mut params = serde_json::to_value(def).map_err(|e| e.to_string())?; if *mode == GridMode::Define { - if app.session.active().map(|st| st.uid) != source_document { + let active = app.session.active().map(|st| (st.uid, st.reverts)); + if active.map(|(uid, _)| uid) != source_document.map(|(uid, _)| uid) { return Err(tl!("Define Grid can only change the document where it was opened.").to_owned()); } + if active != source_document { + return Err(tl!("The document was reverted. Reopen this dialog to continue.").to_owned()); + } app.run("perspective.grid.define", params)?; return Ok(Next::Close); } diff --git a/crates/ui-egui/src/dialogs/tests_perspective.rs b/crates/ui-egui/src/dialogs/tests_perspective.rs index abbd37dfb7..ce286be347 100644 --- a/crates/ui-egui/src/dialogs/tests_perspective.rs +++ b/crates/ui-egui/src/dialogs/tests_perspective.rs @@ -137,6 +137,39 @@ fn define_grid_applies_only_to_the_document_where_it_opened() { assert_eq!(grid(&app).right_color.hex(), "#112233"); } +#[test] +fn define_grid_requires_a_fresh_opening_after_native_revert() { + let mut app = app(); + let dir = vectorcraft_testkit::TempDir::new("define-grid-revert"); + app.services.read = Some(Box::new(|path| std::fs::read(path).map_err(|e| e.to_string()))); + app.services.write = Some(Box::new(|path, bytes| std::fs::write(path, bytes).map_err(|e| e.to_string()))); + app.run("perspective.grid.define", json!({"rightColor": "#123456"})).unwrap(); + app.run("file.saveAs", json!({"path": dir.join("Grid.vectorcraft")})).unwrap(); + app.run("perspective.grid.define", json!({"rightColor": "#765432"})).unwrap(); + let source = app.session.active().unwrap(); + let (uid, reverts) = (source.uid, source.reverts); + app.run("ui.perspectiveGridDialog", json!({})).unwrap(); + set(&mut app, "rightColor", json!("#abcdef")).unwrap(); + + app.run("file.revert", json!({"confirmed": true})).unwrap(); + let restored = app.session.active().unwrap(); + assert_eq!((restored.uid, restored.reverts), (uid, reverts + 1)); + let undo = restored.history.undo.len(); + ok(&mut app); + assert_eq!(grid(&app).right_color.hex(), "#123456"); + assert_eq!(app.session.active().unwrap().history.undo.len(), undo); + let id = dialog_id(super::perspective_grid::KIND); + assert!(matches!(host(&app, |h| h.held_state(id)), Some(HeldOk::Refused(_)))); + + let ctx = window(&app); + assert!(host(&app, |h| h.cancel_by_id(&ctx, id))); + frame(&mut app); + app.run("ui.perspectiveGridDialog", json!({})).unwrap(); + set(&mut app, "rightColor", json!("#abcdef")).unwrap(); + ok(&mut app); + assert_eq!(grid(&app).right_color.hex(), "#abcdef"); +} + #[test] fn define_grid_loads_and_saves_presets() { let mut app = app(); From 3e104f461e22cd9728b397edfae8dcb8609aee17 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 26 Nov 2026 18:41:40 -0800 Subject: [PATCH 34/84] Keep Justification drafts off restored paragraphs --- crates/ui-egui/src/dialogs/justification.rs | 46 ++++++++++++++++++--- 1 file changed, 41 insertions(+), 5 deletions(-) diff --git a/crates/ui-egui/src/dialogs/justification.rs b/crates/ui-egui/src/dialogs/justification.rs index 5b97daaedd..221cabd889 100644 --- a/crates/ui-egui/src/dialogs/justification.rs +++ b/crates/ui-egui/src/dialogs/justification.rs @@ -37,7 +37,7 @@ pub(crate) struct Open { /// The dialog on the host. pub id: DialogId, /// The drawing that owns the text IDs and the preview. - document: u64, + document: (u64, u64), /// The preview on the canvas. pub preview: LivePreview, /// The `ids`, `start` and `end` the dialog's `text.setFormat` acts on. @@ -51,7 +51,7 @@ pub(crate) struct Open { impl Open { fn in_opening_document(&self, app: &VectorcraftApp) -> bool { - app.session.active().is_some_and(|st| st.uid == self.document) + app.session.active().is_some_and(|st| (st.uid, st.reverts) == self.document) } } @@ -116,7 +116,8 @@ fn form(fields: &DialogFields) -> ParamDialog<'_> { /// Open Justification on the paragraph attributes the Paragraph panel shows. pub fn open(app: &mut VectorcraftApp) -> Result { crate::panels::character::text_style(app).ok_or("select some type first")?; - let document = app.session.active().ok_or("no document open")?.uid; + let active = app.session.active().ok_or("no document open")?; + let document = (active.uid, active.reverts); // While typing, the dialog acts on the paragraphs of the text being edited. let mut targets = json!({}); let mut story = None; @@ -146,8 +147,13 @@ pub fn open(app: &mut VectorcraftApp) -> Result { let id = super::host::open_held(app, dialog, |app, result| { let Some(open) = app.justification.take() else { return Ok(()) }; if !open.in_opening_document(app) { + let message = if app.session.active().is_some_and(|st| st.uid == open.document.0) { + tl!("The document was reverted. Reopen this dialog to continue.") + } else { + tl!("This dialog was opened in a different document.") + }; app.justification = Some(open); - return Err(tl!("This dialog was opened in a different document.").to_owned()); + return Err(message.to_owned()); } let p = params(app, &result.fields, &open); if !changes(&p) { @@ -213,7 +219,7 @@ pub(crate) fn pump(app: &mut VectorcraftApp, _ctx: &egui::Context) { let Some(mut open) = app.justification.take() else { return }; let shown = app.dialogs().and_then(|d| d.with(|h| h.get_mut_by_id::(open.id).map(|d| (d.is_previewing(), d.fields().clone())))); - // A document switch ends that document's preview. The active drawing may have started a different one. + // A document switch or revert ends the opening preview. The active drawing may have started a different one. if !open.in_opening_document(app) { if shown.is_some() { open.preview = LivePreview::default(); @@ -512,4 +518,34 @@ mod tests { assert_eq!(paras(&app, id).0.justification.auto_leading, 190.0); assert!(app.session.in_interaction()); } + + #[test] + fn justification_does_not_preview_or_apply_after_revert() { + let (mut app, id) = app(); + let dir = vectorcraft_testkit::TempDir::new("justification-revert"); + app.services.read = Some(Box::new(|path| std::fs::read(path).map_err(|e| e.to_string()))); + app.services.write = Some(Box::new(|path, bytes| std::fs::write(path, bytes).map_err(|e| e.to_string()))); + app.run("file.saveAs", json!({"path": dir.join("Art.vectorcraft")})).unwrap(); + app.run("text.setFormat", json!({"ids": [id], "autoLeading": 145})).unwrap(); + app.run("ui.justification", json!({})).unwrap(); + driver::set(&mut app, "autoLeading", json!(180)); + driver::set(&mut app, "preview", json!(true)); + driver::pump(&mut app); + assert_eq!(paras(&app, id).0.justification.auto_leading, 180.0); + + app.run("file.revert", json!({"confirmed": true})).unwrap(); + app.run("select.set", json!({"ids": [id]})).unwrap(); + driver::pump(&mut app); + assert_eq!(paras(&app, id).0.justification.auto_leading, 120.0); + let dialog = craft::ui::dialog::dialog_id(KIND); + crate::tests::picks::answer_dialog(&mut app, dialog, &[], true); + assert_eq!(paras(&app, id).0.justification.auto_leading, 120.0); + assert!(matches!(app.dialogs().unwrap().with(|h| h.held_state(dialog)), Some(craft::ui::dialog::HeldOk::Refused(_)))); + + driver::cancel(&mut app); + app.run("ui.justification", json!({})).unwrap(); + driver::set(&mut app, "autoLeading", json!(180)); + driver::ok(&mut app); + assert_eq!(paras(&app, id).0.justification.auto_leading, 180.0); + } } From 789bd7a21094d3443a98b6e65fee8cc26437cb94 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 26 Nov 2026 18:41:41 -0800 Subject: [PATCH 35/84] Retire Flare Tool Options tied to restored artwork --- crates/ui-egui/src/dialogs/flare_options.rs | 37 +++++++++++++++++++-- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/crates/ui-egui/src/dialogs/flare_options.rs b/crates/ui-egui/src/dialogs/flare_options.rs index d479b57368..b67116b3a8 100644 --- a/crates/ui-egui/src/dialogs/flare_options.rs +++ b/crates/ui-egui/src/dialogs/flare_options.rs @@ -42,7 +42,7 @@ pub(crate) struct Open { /// The hosted dialog. id: DialogId, opening: Arc<()>, - document: Option, + document: Option<(u64, u64)>, /// Where a click opened it, to draw a flare there on OK. click: Option, /// The selected flares (ids) and the settings the dialog opened with, to change them on OK. @@ -55,7 +55,7 @@ const PREVIEW_LABEL: &str = "Flare"; impl Open { fn on_original_drawing(&self, app: &VectorcraftApp) -> bool { - self.preview.is_none() || app.session.active().map(|st| st.uid) == self.document + self.preview.is_none() || app.session.active().map(|st| (st.uid, st.reverts)) == self.document } fn cancel_preview(self, app: &mut VectorcraftApp) { @@ -132,7 +132,7 @@ pub fn open(app: &mut VectorcraftApp, at: Option) -> Value { let dialog = HostedParamDialog::new(&ctx, KIND, fields, move |fields| { ParamDialog::new(KIND, tl!("Flare Tool Options"), params(lengths)).values(Bind::bound(fields)).previews(previews).reset_to(defaults.clone()) }); - let document = app.session.active().map(|st| st.uid); + let document = app.session.active().map(|st| (st.uid, st.reverts)); match open_held_with(app, dialog, ok, held) { Some(id) => app.object_dialogs.flare = Some(Open { id, opening, document, click: at, edit, preview: previews.then(LivePreview::default) }), None => app.status("no window"), @@ -301,6 +301,9 @@ pub(crate) fn pump(app: &mut VectorcraftApp, _ctx: &egui::Context) { fn ok(app: &mut VectorcraftApp, result: &ParamResult) -> Result<(), String> { let open = app.object_dialogs.flare.as_ref().ok_or("the Flare Tool Options dialog is gone")?; if !open.on_original_drawing(app) { + if app.session.active().map(|st| st.uid) == open.document.map(|(uid, _)| uid) { + return Err(tl!("The document was reverted. Reopen this dialog to continue.").into()); + } return Err(tl!("Return to the original drawing to place or edit the flare").into()); } if open.preview.is_some() && other_preview(app) { @@ -544,4 +547,32 @@ mod tests { let parts = flare_parts(&app); assert_eq!((parts.iter().filter(|p| *p == "Ring").count(), parts.iter().any(|p| p == "Rays")), (10, true), "{parts:?}"); } + + #[test] + fn a_pending_flare_does_not_draw_on_restored_art() { + let mut app = app(); + let dir = vectorcraft_testkit::TempDir::new("flare-revert"); + app.services.read = Some(Box::new(|path| std::fs::read(path).map_err(|e| e.to_string()))); + app.services.write = Some(Box::new(|path, bytes| std::fs::write(path, bytes).map_err(|e| e.to_string()))); + app.run("file.saveAs", json!({"path": dir.join("Art.vectorcraft")})).unwrap(); + app.run("shape.ellipse", json!({"x": 5, "y": 5, "width": 20, "height": 20})).unwrap(); + let count = |app: &VectorcraftApp| app.session.active().unwrap().doc.layers[0].children().unwrap().len(); + open(&mut app, Some(Point::new(100.0, 110.0))); + pump(&mut app); + assert_eq!(count(&app), 2, "the original art and the flare preview"); + + app.run("file.revert", json!({"confirmed": true})).unwrap(); + pump(&mut app); + assert_eq!(count(&app), 0, "the old preview leaves the restored art alone"); + let options = app.session.tool_options_of("flare"); + press_ok(&mut app); + assert_eq!(count(&app), 0, "the old approval leaves the restored art alone"); + assert_eq!(app.session.tool_options_of("flare"), options); + assert!(app.object_dialogs.flare.is_some()); + + press_cancel(&mut app); + open(&mut app, Some(Point::new(100.0, 110.0))); + press_ok(&mut app); + assert_eq!(count(&app), 1); + } } From f8f5755b6e1b75656b30f3e7230ae737404dc83b Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 26 Nov 2026 18:45:16 -0800 Subject: [PATCH 36/84] Guard Graph Column and Marker drafts after File Revert --- crates/ui-egui/src/dialogs/graph_design.rs | 70 +++++++++++++++++++--- 1 file changed, 61 insertions(+), 9 deletions(-) diff --git a/crates/ui-egui/src/dialogs/graph_design.rs b/crates/ui-egui/src/dialogs/graph_design.rs index 04e5e7f0a8..d0302d1e41 100644 --- a/crates/ui-egui/src/dialogs/graph_design.rs +++ b/crates/ui-egui/src/dialogs/graph_design.rs @@ -252,8 +252,11 @@ pub(crate) enum Answer { impl Answer { /// Runs the command; the refusal is its error. fn run(&self, app: &mut VectorcraftApp, target: &GraphTarget) -> Result<(), Label> { - if !target.in_active_document(app) { + let Some(active) = app.session.active().filter(|active| active.uid == target.document.0) else { return Err(Label::from(tl!("This graph design belongs to the document that opened the dialog."))); + }; + if active.reverts != target.document.1 { + return Err(Label::from(tl!("The document was reverted. Reopen this dialog to continue."))); } let design = |d: &Option| json!({ "design": d.as_ref().map(|d| d.name.as_str()), "library": library_of(d.as_ref()) }); let (command, mut params) = match self { @@ -281,21 +284,18 @@ impl Answer { /// The graph and picked series the Column or Marker form opened for. #[derive(Clone)] struct GraphTarget { - document: u64, + document: (u64, u64), graph: u64, series: Vec, } impl GraphTarget { fn selected(app: &VectorcraftApp) -> Result { - let document = app.session.active().ok_or("no document open")?.uid; + let active = app.session.active().ok_or("no document open")?; + let document = (active.uid, active.reverts); let selected = vectorcraft_engine::graph_type_subject(&app.session).map_err(|error| error.to_string())?; Ok(Self { document, graph: selected.id.0, series: selected.series }) } - - fn in_active_document(&self, app: &VectorcraftApp) -> bool { - app.session.active().is_some_and(|active| active.uid == self.document) - } } /// A loaded library's document, for the thumbnails of its designs. @@ -409,7 +409,7 @@ pub(crate) struct GraphDesignDialog { struct Work { actions: Vec, answer: Option<(Answer, GraphTarget)>, - document: Option, + document: Option<(u64, u64)>, } impl GraphDesignDialog { @@ -854,7 +854,7 @@ pub(crate) fn pump(app: &mut VectorcraftApp, ctx: &egui::Context) { } } let answered = work.answer.map(|(answer, target)| answer.run(app, &target)); - let same_document = work.document.is_none_or(|document| app.session.active().is_some_and(|active| active.uid == document)); + let same_document = work.document.is_none_or(|document| app.session.active().is_some_and(|active| (active.uid, active.reverts) == document)); let lists = if same_document { Lists::read(app).ok() } else { None }; dialogs.with(|host| { if let Some(dialog) = host.get_mut::() { @@ -956,6 +956,58 @@ mod tests { } } + fn a_graph_design_draft_after_file_revert(graph_kind: &str, command: &str) { + struct SavedFile(std::path::PathBuf); + impl Drop for SavedFile { + fn drop(&mut self) { + let _ = std::fs::remove_file(&self.0); + } + } + + let (mut app, ctx) = app_with_design(); + select_graph(&mut app, graph_kind); + let graph = app.session.active().unwrap().selection.objects[0].0; + app.services.read = Some(Box::new(|path| std::fs::read(path).map_err(|e| e.to_string()))); + app.services.write = Some(Box::new(|path, bytes| std::fs::write(path, bytes).map_err(|e| e.to_string()))); + let path = SavedFile(std::env::temp_dir().join(format!("vc-ui-graph-design-revert-{}-{graph_kind}.vectorcraft", std::process::id()))); + app.run("file.saveAs", json!({"path": path.0})).unwrap(); + assert!(path.0.is_file()); + app.run("shape.rectangle", json!({"x": 20, "y": 20, "width": 20, "height": 20})).unwrap(); + app.run("select.set", json!({"ids": [graph]})).unwrap(); + crate::menus::invoke(&mut app, command, json!({})); + set(&app, &ctx, "selected", json!("New Design")).unwrap(); + let state = app.session.active().unwrap(); + let (uid, reverts) = (state.uid, state.reverts); + app.run("file.revert", json!({"confirmed": true})).unwrap(); + let state = app.session.active().unwrap(); + assert_eq!((state.uid, state.reverts), (uid, reverts + 1)); + app.run("select.set", json!({"ids": [graph]})).unwrap(); + let selected_design = |app: &mut VectorcraftApp| app.session.execute(command, &json!({"id": graph})).unwrap()["design"].clone(); + assert_eq!(selected_design(&mut app), Value::Null); + let undo = app.session.active().unwrap().history.undo.len(); + + app.dialogs().unwrap().with(|host| host.confirm::(&ctx)); + super::pump(&mut app, &ctx); + assert_eq!(selected_design(&mut app), Value::Null, "the stale draft must leave the restored graph's design alone"); + assert_eq!(app.session.active().unwrap().history.undo.len(), undo); + assert_eq!(fields(&app)["selected"], "New Design", "the refused answer still shows the draft"); + + crate::menus::invoke(&mut app, command, json!({})); + set(&app, &ctx, "selected", json!("New Design")).unwrap(); + ok(&mut app, &ctx); + assert_eq!(selected_design(&mut app), "New Design", "a fresh draft applies to the restored graph"); + } + + #[test] + fn graph_column_draft_after_file_revert_leaves_the_restored_columns_alone() { + a_graph_design_draft_after_file_revert("column", "graph.column"); + } + + #[test] + fn graph_marker_draft_after_file_revert_leaves_the_restored_markers_alone() { + a_graph_design_draft_after_file_revert("line", "graph.marker"); + } + #[test] fn graph_design_footer_ok_applies_column_and_marker_designs_unless_dismissed() { for (graph_type, command, dismiss) in [("column", "graph.column", false), ("line", "graph.marker", false), ("column", "graph.column", true)] { From c94fc92484bd7cc0ec3628a591776cec5be259df Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 26 Nov 2026 18:45:16 -0800 Subject: [PATCH 37/84] Keep Recolor Artwork previews with their opening drawing contents --- crates/ui-egui/src/dialogs/recolor.rs | 59 ++++++++++++++++++++++++--- 1 file changed, 54 insertions(+), 5 deletions(-) diff --git a/crates/ui-egui/src/dialogs/recolor.rs b/crates/ui-egui/src/dialogs/recolor.rs index a377869b5b..4d9e350ec4 100644 --- a/crates/ui-egui/src/dialogs/recolor.rs +++ b/crates/ui-egui/src/dialogs/recolor.rs @@ -260,6 +260,7 @@ pub(crate) struct Open { /// The dialog on the window's host. pub id: DialogId, document: u64, + reverts: u64, /// The preview the pump runs and OK commits. pub preview: LivePreview, /// The selection snapshot identifies the interaction that ran the preview. @@ -270,14 +271,17 @@ impl Open { fn owns_preview(&self, app: &VectorcraftApp) -> bool { let Some(selection) = &self.preview_selection else { return false }; app.session.active().is_some_and(|state| { - state.uid == self.document + (state.uid, state.reverts) == (self.document, self.reverts) && state.interaction.as_ref().is_some_and(|interaction| selection.as_ptr() == Arc::as_ptr(&interaction.selection)) }) } fn problem(&self, app: &VectorcraftApp) -> Option<&'static str> { - if app.session.active().is_none_or(|state| state.uid != self.document) { - Some("Return to the document where Recolor Artwork opened.") + let Some(state) = app.session.active().filter(|state| state.uid == self.document) else { + return Some("Return to the document where Recolor Artwork opened."); + }; + if state.reverts != self.reverts { + Some("The document was reverted. Reopen this dialog to continue.") } else if app.session.in_interaction() && !self.owns_preview(app) { Some("Finish the active edit before applying Recolor Artwork.") } else { @@ -338,7 +342,7 @@ pub fn open(app: &mut VectorcraftApp, p: &Value) -> Result { // A Recolor Artwork still open is replaced: its preview goes before the group's colours are read. cancel_open(app); let st = app.session.active().ok_or("no document open")?; - let document = st.uid; + let (document, reverts) = (st.uid, st.reverts); let group_colors: Option> = match group { Some(g) => { let g = st.doc.swatch_groups.iter().find(|x| x.name == g).ok_or_else(|| format!("no colour group `{g}`"))?; @@ -377,7 +381,7 @@ pub fn open(app: &mut VectorcraftApp, p: &Value) -> Result { let dialog = RecolorDialog::new(app, d); let options = HeldOptions { cancel: Some(Box::new(cancelled)), ..HeldOptions::default() }; let id = open_held_with(app, dialog, confirm, options).ok_or("no window to show Recolor Artwork in")?; - app.color_dialogs.recolor = Some(Open { id, document, preview: LivePreview::default(), preview_selection: None }); + app.color_dialogs.recolor = Some(Open { id, document, reverts, preview: LivePreview::default(), preview_selection: None }); Ok(Value::Null) } @@ -3281,6 +3285,51 @@ mod tests { assert!(group_hex(&rc.app(), "Shared").is_none()); } + #[test] + fn recolor_after_file_revert_does_not_restart_the_discarded_preview() { + struct SavedFile(std::path::PathBuf); + impl Drop for SavedFile { + fn drop(&mut self) { + let _ = std::fs::remove_file(&self.0); + } + } + + let mut app = app(120); + let shape = square(&mut app, 10.0, "#ff0000"); + app.services.read = Some(Box::new(|path| std::fs::read(path).map_err(|e| e.to_string()))); + app.services.write = Some(Box::new(|path, bytes| std::fs::write(path, bytes).map_err(|e| e.to_string()))); + let path = SavedFile(std::env::temp_dir().join(format!("vc-ui-recolor-revert-{}.vectorcraft", std::process::id()))); + app.run("file.saveAs", json!({"path": path.0})).unwrap(); + assert!(path.0.is_file()); + square(&mut app, 60.0, "#0000ff"); + app.run("select.set", json!({"ids": [shape]})).unwrap(); + let mut rc = opened(app, json!({})); + rc.set("method", json!(Method::Exact.id())).unwrap(); + rc.frame(); + rc.set("rows", json!([{"from": ["rgb 255 0 0"], "to": "rgb 0 255 0"}])).unwrap(); + rc.frame(); + assert_eq!(fill_hex(&rc, shape), "#00ff00", "the original preview is active"); + + { + let mut app = rc.app(); + let state = app.session.active().unwrap(); + let (uid, reverts) = (state.uid, state.reverts); + app.run("file.revert", json!({"confirmed": true})).unwrap(); + let state = app.session.active().unwrap(); + assert_eq!((state.uid, state.reverts), (uid, reverts + 1)); + assert!(state.doc.node(vectorcraft_doc::NodeId(shape)).is_some()); + app.run("select.set", json!({"ids": [shape]})).unwrap(); + } + assert_eq!(fill_hex(&rc, shape), "#ff0000"); + let history = undo_len(&rc.app()); + rc.frame(); + assert_eq!(fill_hex(&rc, shape), "#ff0000", "an open preview must leave the saved red fill alone"); + assert!(!rc.app().session.in_interaction()); + assert!(rc.confirm().is_err() && rc.is_open(), "the old draft cannot be applied"); + assert_eq!(fill_hex(&rc, shape), "#ff0000"); + assert_eq!(undo_len(&rc.app()), history); + } + #[test] fn recolor_dialog_keeps_the_default_model_without_an_extra_dropdown() { let rc = opened(app(100), json!({"colors": ["#ff8000"]})); From 9f73c4e3908e42f0895f5a70219366be4ce7151e Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 26 Nov 2026 18:49:24 -0800 Subject: [PATCH 38/84] Restore localized reference-point corner names in dialogs --- .../src/dialogs/objects_on_path_options.rs | 140 ++++++++++++++++++ crates/ui-egui/src/dialogs/tool_options.rs | 27 +++- 2 files changed, 165 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/dialogs/objects_on_path_options.rs b/crates/ui-egui/src/dialogs/objects_on_path_options.rs index 2233691bf2..cfc699334e 100644 --- a/crates/ui-egui/src/dialogs/objects_on_path_options.rs +++ b/crates/ui-egui/src/dialogs/objects_on_path_options.rs @@ -58,3 +58,143 @@ pub fn open(app: &mut VectorcraftApp) -> Value { } json!({ "dialog": KIND }) } + +/// The compact tool options expose translated Pivot corners and accept actual edits. +#[cfg(test)] +#[test] +fn compact_objects_on_path_options_pivot_rotate_reset_and_save() { + use egui::accesskit::{Node, Role, TreeUpdate}; + use egui::{Event, Key, Modifiers, PointerButton, Pos2, RawInput, Rect, pos2, vec2}; + use vectorcraft_engine::Session; + + fn bounds(node: &Node) -> Option { + let b = node.bounds()?; + Some(Rect::from_min_max(pos2(b.x0 as f32, b.y0 as f32), pos2(b.x1 as f32, b.y1 as f32))) + } + + fn plain_label(label: &str) -> &str { + label.trim_end().trim_end_matches([':', ':']).trim_end() + } + + const PIVOT_NAMES: [&str; 9] = ["Top Left", "Top", "Top Right", "Left", "Center", "Right", "Bottom Left", "Bottom", "Bottom Right"]; + let screen = Rect::from_min_size(Pos2::ZERO, vec2(800.0, 500.0)); + let mut untranslated = Vec::new(); + for lang in ["en", "de", "fr", "ja"] { + let mut app = crate::testing::windowed(VectorcraftApp::new(Session::new(), Default::default())); + app.session.prefs.interface_language = lang.into(); + app.run("file.new", json!({"width": 400, "height": 300})).unwrap(); + app.run("tool.setOption", json!({"tool": TOOL, "values": {"pivot": 1,"rotate": 17}})).unwrap(); + let ctx = app.ui_ctx.clone().unwrap(); + let mut time = 0.0; + let mut frame = |app: &mut VectorcraftApp, events: Vec| { + time += 0.1; + let raw = RawInput { events, time: Some(time), screen_rect: Some(screen), focused: true, ..Default::default() }; + crate::testing::app_frame(app, &ctx, raw).platform_output.accesskit_update.unwrap() + }; + let settle = |app: &mut VectorcraftApp, frame: &mut dyn FnMut(&mut VectorcraftApp, Vec) -> TreeUpdate| { + for _ in 0..5 { + frame(app, vec![]); + } + frame(app, vec![]) + }; + let click = |app: &mut VectorcraftApp, frame: &mut dyn FnMut(&mut VectorcraftApp, Vec) -> TreeUpdate, pos| { + frame(app, vec![Event::PointerMoved(pos)]); + for pressed in [true, false] { + frame(app, vec![Event::PointerButton { pos, button: PointerButton::Primary, pressed, modifiers: Modifiers::NONE }]); + } + frame(app, vec![]); + }; + let press = |app: &mut VectorcraftApp, frame: &mut dyn FnMut(&mut VectorcraftApp, Vec) -> TreeUpdate, key, modifiers| { + for pressed in [true, false] { + frame(app, vec![Event::ModifiersChanged(modifiers), Event::Key { key, physical_key: None, pressed, repeat: false, modifiers }]); + } + }; + let draft = |app: &VectorcraftApp| { + app.dialogs() + .unwrap() + .with(|host| host.get::().map(|d| (d.fields().int("pivot").unwrap(), d.fields().number("rotate").unwrap()))) + }; + let actual = |app: &VectorcraftApp| { + let options = app.session.tool_options_of(TOOL); + (options["pivot"].as_i64().unwrap(), options["rotate"].as_f64().unwrap()) + }; + settle(&mut app, &mut frame); + for save in [false, true] { + assert_eq!(app.run("tool.options", json!({"tool": TOOL})).unwrap()["dialog"], KIND); + let tree = settle(&mut app, &mut frame); + let by_name = |role, label: &str| { + tree.nodes + .iter() + .find(|(_, n)| { + n.role() == role + && n.label().is_some_and(|actual| { + plain_label(actual) == plain_label(label) + || (role == Role::RadioGroup && plain_label(actual) == plain_label(crate::i18n::t("Pivot:"))) + }) + }) + .and_then(|(_, n)| bounds(n)) + .unwrap_or_else(|| { + let names: Vec<_> = tree.nodes.iter().filter(|(_, n)| n.role() == role).filter_map(|(_, n)| n.label()).collect(); + panic!("{lang}: missing {role:?} {label:?} in {names:?}") + }) + }; + let title = tool_options::title(TOOL); + let modal = by_name(Role::Dialog, title.as_str()); + let picker = by_name(Role::RadioGroup, crate::i18n::t("Reference Point")); + let rotate = by_name(Role::SpinButton, crate::i18n::t("Rotate:")); + let reset = by_name(Role::Button, crate::i18n::t("Reset")); + let footer = by_name(Role::Button, crate::i18n::t(if save { "Save" } else { "Cancel" })); + assert!(screen.expand(0.5).contains_rect(modal), "{lang}: modal {modal:?} off screen"); + for rect in [picker, rotate, reset, footer] { + assert!(rect.is_positive() && modal.expand(0.5).contains_rect(rect), "{lang}: {rect:?} outside modal {modal:?}"); + } + let mut cells: Vec<_> = tree + .nodes + .iter() + .filter(|(_, n)| n.role() == Role::RadioButton) + .filter_map(|(_, n)| Some((n.label()?, bounds(n)?))) + .filter(|(_, rect)| picker.expand(0.5).contains(rect.center())) + .collect(); + cells.sort_by(|(_, a), (_, b)| a.center().y.total_cmp(&b.center().y).then(a.center().x.total_cmp(&b.center().x))); + eprintln!( + "{lang}, save {save}: modal {modal:?}, pivot {picker:?}, cells {cells:?}, Rotate {rotate:?}, Reset {reset:?}, footer {footer:?}" + ); + assert_eq!(cells.len(), 9, "{lang}: all Pivot options"); + if save { + for ((name, _), legacy) in cells.iter().zip(PIVOT_NAMES) { + let expected = crate::i18n::t(legacy); + if expected != legacy && *name != expected { + untranslated.push(format!("{lang}: {name:?} instead of {expected:?}")); + } + } + } + assert!(cells.iter().all(|(_, cell)| picker.expand(0.5).contains_rect(*cell)), "{lang}: all cells lie in the picker"); + assert_eq!(draft(&app), Some((1, 17.0)), "{lang}: opens from saved tool preferences"); + click(&mut app, &mut frame, cells[8].1.center()); + assert_eq!(draft(&app), Some((8, 17.0)), "{lang}: bottom-right physical pointer"); + click(&mut app, &mut frame, rotate.center()); + press(&mut app, &mut frame, Key::A, Modifiers::COMMAND); + frame(&mut app, vec![Event::ModifiersChanged(Modifiers::NONE), Event::Text("42".to_owned())]); + press(&mut app, &mut frame, Key::Tab, Modifiers::NONE); + settle(&mut app, &mut frame); + assert_eq!(draft(&app), Some((8, 42.0)), "{lang}: real Rotate keyboard edit"); + if !save { + click(&mut app, &mut frame, reset.center()); + assert_eq!(draft(&app), Some((4, 0.0)), "{lang}: pointer Reset keeps the dialog open and resets both settings"); + } + assert_eq!(actual(&app), (1, 17.0), "{lang}: only a draft before accepting"); + click(&mut app, &mut frame, footer.center()); + settle(&mut app, &mut frame); + assert_eq!(draft(&app), None, "{lang}: footer closes the dialog"); + assert_eq!(actual(&app), if save { (8, 42.0) } else { (1, 17.0) }, "{lang}: footer persistence"); + } + app.run("tool.options", json!({"tool": TOOL})).unwrap(); + settle(&mut app, &mut frame); + assert_eq!(draft(&app), Some((8, 42.0)), "{lang}: reopened saved values"); + press(&mut app, &mut frame, Key::Escape, Modifiers::NONE); + settle(&mut app, &mut frame); + assert_eq!(draft(&app), None, "{lang}: Escape dismisses reopened options"); + crate::i18n::set_current(crate::i18n::Lang::EN); + } + assert!(untranslated.is_empty(), "localized Pivot names were lost: {untranslated:?}"); +} diff --git a/crates/ui-egui/src/dialogs/tool_options.rs b/crates/ui-egui/src/dialogs/tool_options.rs index 8617273aa3..f83ddd7ee9 100644 --- a/crates/ui-egui/src/dialogs/tool_options.rs +++ b/crates/ui-egui/src/dialogs/tool_options.rs @@ -4,10 +4,11 @@ // PLAN: ui-egui reaches the framework through `craft::..`; the crate's Cargo.toml needs the `craft` dependency // (hub-w1 owns the manifest). use craft::behavior::Anchor9; +use craft::i18n::Word; use craft::ui::contract::{Bind, Show as _}; use craft::ui::patterns::form_dialogs::{DialogFields, Param}; use craft::ui::pickers::{ReferencePoint, ReferencePointLook}; -use craft::ui::runtime::env::Label; +use craft::ui::runtime::env::{Label, WordRows, WordsOverride, with_env}; use serde_json::{Map, Value, json}; use vectorcraft_doc::Unit; @@ -30,13 +31,35 @@ pub(crate) fn reference_index(fields: &DialogFields, key: &str) -> usize { fields.int(key).map_or(0, |n| n.clamp(0, 8) as usize) } +/// The dialog reference picker's corner labels use the app catalog's existing title-case keys. +fn localized_reference_corners() -> WordRows { + [ + (Word::keyed("referencePoint.topLeft", "Top left"), "Top Left"), + (Word::keyed("referencePoint.topRight", "Top right"), "Top Right"), + (Word::keyed("referencePoint.bottomLeft", "Bottom left"), "Bottom Left"), + (Word::keyed("referencePoint.bottomRight", "Bottom right"), "Bottom Right"), + ] + .into_iter() + .fold(WordRows::new(), |rows, (word, source)| { + let translated = tl!(source); + if translated == source { rows } else { rows.row(word, translated) } + }) +} + /// A row of the nine-point reference picker over the index `key` holds ([`reference_index`]). pub(crate) fn reference_param(key: &str, label: impl Into