From 9a0a9846e8608cfaea2f3218dc77cf56ae1a427e Mon Sep 17 00:00:00 2001 From: yoriswind Date: Fri, 13 Nov 2026 22:39:54 -0800 Subject: [PATCH 1/2] M3: Show Color spectrum mode on hover (#7235) --- crates/ui-egui/src/panels/color.rs | 2 +- .../ui-egui/tests/color_working_components.rs | 124 +++++++++++++++++- docs/roadmap.md | 2 + docs/target-app-parity.md | 2 + 4 files changed, 128 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/panels/color.rs b/crates/ui-egui/src/panels/color.rs index 0ad9c369fd..8b0340e18f 100644 --- a/crates/ui-egui/src/panels/color.rs +++ b/crates/ui-egui/src/panels/color.rs @@ -655,7 +655,7 @@ enum SpectrumHit { fn spectrum(ui: &mut Ui, mode: Mode, size: egui::Vec2) -> Option { let t = Tokens::get(ui.ctx()); let (r, _) = ui.allocate_exact_size(size, Sense::hover()); - let resp = ui.interact(r, ui.scope_id().with("color-spectrum"), Sense::click_and_drag()); + let resp = ui.interact(r, ui.scope_id().with("color-spectrum"), Sense::click_and_drag()).on_hover_text(mode.label()); ui.painter().add(widgets::color_mesh(r, (72, 12), &|x, y| to32(&spectrum_at(mode, x, y)))); ui.painter().rect_stroke(r, 0.0, Stroke::new(1.0, t.border), StrokeKind::Outside); if let Some(p) = resp.hover_pos() { diff --git a/crates/ui-egui/tests/color_working_components.rs b/crates/ui-egui/tests/color_working_components.rs index 83b0e01267..5bde152bde 100644 --- a/crates/ui-egui/tests/color_working_components.rs +++ b/crates/ui-egui/tests/color_working_components.rs @@ -4,12 +4,14 @@ use std::sync::{Mutex, MutexGuard}; +use egui::{Rect, vec2}; use serde_json::json; use vectorcraft_color::Color; use vectorcraft_color::cms::{self, ColorSettings, DISPLAY_P3, PROPHOTO_RGB, SRGB, WIDE_GAMUT_RGB}; use vectorcraft_engine::Session; +use vectorcraft_tools::params::color_json; use vectorcraft_ui_egui::VectorcraftApp; -use vectorcraft_ui_egui::panels::color::{Mode, components, from_components, hex_digits, parse_hex, web_safe}; +use vectorcraft_ui_egui::panels::color::{Mode, components, convert_to, from_components, hex_digits, parse_hex, show, web_safe}; // This integration binary contains only these tests; its app-wide CMS is independent of other // test binaries. Serialize its cases and restore settings even when an assertion fails. @@ -186,3 +188,123 @@ fn color_panel_slider_preserves_native_channels_and_undo() { harness.state_mut().run("edit.undo", json!({})).unwrap(); native(harness.state().session.proxy_paints().0.color().unwrap(), [0.5, 0.3, 0.2]); } + +/// An ordinary selected rectangle for Color panel hover and Shift-click checks. +fn spectrum_app() -> VectorcraftApp { + let mut app = VectorcraftApp::new(Session::new(), Default::default()); + app.run("file.new", json!({"width": 200, "height": 200})).unwrap(); + app.run("shape.rectangle", json!({"x": 10, "y": 10, "width": 50, "height": 50})).unwrap(); + app +} + +/// Every string actually painted by a headless frame, including a settled hover tooltip. +fn spectrum_painted_texts(output: &egui::FullOutput) -> Vec { + fn collect(shape: &egui::Shape, texts: &mut Vec) { + match shape { + egui::Shape::Text(t) => texts.push(t.galley.text().to_string()), + egui::Shape::Vec(shapes) => shapes.iter().for_each(|shape| collect(shape, texts)), + _ => {} + } + } + let mut texts = vec![]; + output.shapes.iter().for_each(|shape| collect(&shape.shape, &mut texts)); + texts +} + +/// Draw the real Color panel and return a point over its spectrum and the frame's text. +fn spectrum_frame( + app: &mut VectorcraftApp, + ctx: &egui::Context, + time: f64, + events: Vec, + modifiers: egui::Modifiers, +) -> (egui::Pos2, Vec) { + let screen = Rect::from_min_size(egui::Pos2::ZERO, vec2(260.0, 700.0)); + let events = std::iter::once(egui::Event::ModifiersChanged(modifiers)).chain(events).collect(); + let mut at = None; + let input = egui::RawInput { screen_rect: Some(screen), time: Some(time), events, ..Default::default() }; + let mut output = ctx.run_ui(input, |ui| { + show(app, ui); + at = if app.ui.color_hide_options { + // The existing hidden-options spectrum test uses this point right of the proxy. + let row = ui.min_rect(); + Some(egui::pos2(row.right() - 4.0, row.center().y)) + } else { + ctx.read_response(ui.scope_id().with("color-spectrum")).map(|r| r.rect.center()) + }; + }); + output.textures_delta.clear(); + (at.expect("the spectrum is drawn"), spectrum_painted_texts(&output)) +} + +/// The panel's drawn text after the pointer has rested on or away from the spectrum. +fn spectrum_hover_texts(app: &mut VectorcraftApp, ctx: &egui::Context, over: bool) -> (egui::Pos2, Vec) { + let away = egui::pos2(255.0, 695.0); + let time = ctx.input(|i| i.time) + 1.0; + let none = egui::Modifiers::NONE; + let (at, _) = spectrum_frame(app, ctx, time, vec![egui::Event::PointerMoved(away)], none); + let pos = if over { at } else { away }; + spectrum_frame(app, ctx, time + 0.1, vec![egui::Event::PointerMoved(pos)], none); + // Allow the tooltip delay and its following layout pass, as the Appearance panel tests do. + spectrum_frame(app, ctx, time + 2.0, vec![], none); + (at, spectrum_frame(app, ctx, time + 2.1, vec![], none).1) +} + +#[test] +fn spectrum_tooltip_names_its_displayed_mode() { + let _space = WorkingSpace::new(SRGB); + for hidden in [false, true] { + for mode in [Mode::Grayscale, Mode::Rgb, Mode::Hsb, Mode::Cmyk, Mode::WebSafe, Mode::Lab] { + let mut app = spectrum_app(); + let color = convert_to(mode, &Color::rgb8(51, 102, 153)); + app.run("paint.setFill", json!({"color": color_json(&color), "keepModel": true})).unwrap(); + // Lab follows the selected paint even when the stored mode is RGB. + app.ui.color_mode = Some(if mode == Mode::Lab { Mode::Rgb } else { mode }); + app.ui.color_hide_options = hidden; + let ctx = egui::Context::default(); + ctx.global_style_mut(|style| style.interaction.tooltip_delay = 0.1); + let paints = app.session.proxy_paints(); + let undo = app.session.active().unwrap().history.undo.len(); + let (_, away) = spectrum_hover_texts(&mut app, &ctx, false); + assert!(!away.iter().any(|text| text == mode.label()), "{mode:?}, hidden {hidden}: no tooltip away from the spectrum: {away:?}"); + let (_, hovered) = spectrum_hover_texts(&mut app, &ctx, true); + assert_eq!( + hovered.iter().filter(|text| text.as_str() == mode.label()).count(), + 1, + "{mode:?}, hidden {hidden}: the tooltip names the displayed mode: {hovered:?}" + ); + let (_, away) = spectrum_hover_texts(&mut app, &ctx, false); + assert!(!away.iter().any(|text| text == mode.label()), "{mode:?}, hidden {hidden}: the tooltip hides again: {away:?}"); + assert_eq!(app.session.proxy_paints(), paints, "hovering changes no paint"); + assert_eq!(app.session.active().unwrap().history.undo.len(), undo, "hovering adds no undo step"); + } + } +} + +#[test] +fn spectrum_tooltip_follows_shift_cycle_without_painting() { + let _space = WorkingSpace::new(SRGB); + for hidden in [false, true] { + let mut app = spectrum_app(); + app.run("paint.setFill", json!({"color": "#336699"})).unwrap(); + app.ui.color_mode = Some(Mode::Rgb); + app.ui.color_hide_options = hidden; + let ctx = egui::Context::default(); + ctx.global_style_mut(|style| style.interaction.tooltip_delay = 0.1); + let paints = app.session.proxy_paints(); + let undo = app.session.active().unwrap().history.undo.len(); + let (pos, hovered) = spectrum_hover_texts(&mut app, &ctx, true); + assert!(hovered.iter().any(|text| text == "RGB")); + let modifiers = egui::Modifiers::SHIFT; + let button = |pressed| egui::Event::PointerButton { pos, button: egui::PointerButton::Primary, pressed, modifiers }; + let time = ctx.input(|i| i.time) + 1.0; + spectrum_frame(&mut app, &ctx, time, vec![egui::Event::PointerMoved(pos), button(true)], modifiers); + spectrum_frame(&mut app, &ctx, time + 0.1, vec![button(false)], modifiers); + spectrum_frame(&mut app, &ctx, time + 0.2, vec![], egui::Modifiers::NONE); + assert_eq!(app.ui.color_mode, Some(Mode::Hsb)); + let (_, hovered) = spectrum_hover_texts(&mut app, &ctx, true); + assert!(hovered.iter().any(|text| text == "HSB") && !hovered.iter().any(|text| text == "RGB"), "hidden {hidden}: {hovered:?}"); + assert_eq!(app.session.proxy_paints(), paints, "RGB to HSB changes no paint"); + assert_eq!(app.session.active().unwrap().history.undo.len(), undo, "cycling to HSB adds no undo step"); + } +} diff --git a/docs/roadmap.md b/docs/roadmap.md index 74dac90ec8..83ba7b326e 100644 --- a/docs/roadmap.md +++ b/docs/roadmap.md @@ -1,5 +1,7 @@ # Roadmap: milestones and what's next +The Color panel spectrum shows its current color mode on hover, including after Shift-clicking to switch modes and with Hide Options enabled (part of #7235). Spectrum rendering and vertical resizing remain open. Scores and estimates unchanged. + > **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-13 · **Change:** minor (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). diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 296bd84b2b..91f749fc4b 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1,5 +1,7 @@ # Parity with Adobe Illustrator +The Color panel spectrum shows its current color mode on hover, including after Shift-clicking to switch modes and with Hide Options enabled (part of #7235). Spectrum rendering and vertical resizing remain open. Scores and estimates unchanged. + > **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-13 · **Change:** minor (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) > > Oversized artboard import update (2026-11-12): Explicit editing-data import retains a single artboard beyond a capped 14,400 pt PDF page (#6865). From 2515725d8796fdba2d5dff374d6d53eff8e7db94 Mon Sep 17 00:00:00 2001 From: yoriswind Date: Sat, 14 Nov 2026 00:20:47 -0800 Subject: [PATCH 2/2] M3: Translate Color spectrum mode tooltip --- crates/ui-egui/src/panels/color.rs | 2 +- .../ui-egui/tests/color_working_components.rs | 46 +++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/panels/color.rs b/crates/ui-egui/src/panels/color.rs index 8b0340e18f..71677ffb1c 100644 --- a/crates/ui-egui/src/panels/color.rs +++ b/crates/ui-egui/src/panels/color.rs @@ -655,7 +655,7 @@ enum SpectrumHit { fn spectrum(ui: &mut Ui, mode: Mode, size: egui::Vec2) -> Option { let t = Tokens::get(ui.ctx()); let (r, _) = ui.allocate_exact_size(size, Sense::hover()); - let resp = ui.interact(r, ui.scope_id().with("color-spectrum"), Sense::click_and_drag()).on_hover_text(mode.label()); + let resp = ui.interact(r, ui.scope_id().with("color-spectrum"), Sense::click_and_drag()).on_hover_text(tl!(mode.label())); ui.painter().add(widgets::color_mesh(r, (72, 12), &|x, y| to32(&spectrum_at(mode, x, y)))); ui.painter().rect_stroke(r, 0.0, Stroke::new(1.0, t.border), StrokeKind::Outside); if let Some(p) = resp.hover_pos() { diff --git a/crates/ui-egui/tests/color_working_components.rs b/crates/ui-egui/tests/color_working_components.rs index 5bde152bde..0bf18bc721 100644 --- a/crates/ui-egui/tests/color_working_components.rs +++ b/crates/ui-egui/tests/color_working_components.rs @@ -308,3 +308,49 @@ fn spectrum_tooltip_follows_shift_cycle_without_painting() { assert_eq!(app.session.active().unwrap().history.undo.len(), undo, "cycling to HSB adds no undo step"); } } + +/// Spectrum hover text uses the selected UI language, in both panel layouts. +#[test] +fn spectrum_tooltip_uses_the_interface_language() { + use vectorcraft_ui_egui::i18n::{self, Lang}; + + // i18n is process-global in this integration binary. Every case holds the CMS lock. + // Restore the language before WorkingSpace releases that lock, including after a panic. + let _space = WorkingSpace::new(SRGB); + struct Language(Lang); + impl Drop for Language { + fn drop(&mut self) { + i18n::set_current(self.0); + } + } + let _language = Language(i18n::current()); + let german = Lang::from_code("de").unwrap(); + let mode = Mode::Grayscale; + let expected = "Graustufen"; + assert_eq!(i18n::tr(german, mode.label()), expected, "use an existing, distinct catalog translation"); + + for hidden in [false, true] { + let mut app = spectrum_app(); + app.session.prefs.interface_language = german.code().into(); + // The host normally does this in tick_frame; this harness draws the panel directly. + assert_eq!(app.ui_language(), german); + i18n::set_current(app.ui_language()); + let color = convert_to(mode, &Color::rgb8(51, 102, 153)); + app.run("paint.setFill", json!({"color": color_json(&color), "keepModel": true})).unwrap(); + app.ui.color_mode = Some(mode); + app.ui.color_hide_options = hidden; + let ctx = egui::Context::default(); + ctx.global_style_mut(|style| style.interaction.tooltip_delay = 0.1); + let paints = app.session.proxy_paints(); + let undo = app.session.active().unwrap().history.undo.len(); + let (_, away) = spectrum_hover_texts(&mut app, &ctx, false); + assert!(!away.iter().any(|text| text == expected), "hidden {hidden}: no translated tooltip away: {away:?}"); + let (_, hovered) = spectrum_hover_texts(&mut app, &ctx, true); + assert_eq!(hovered.iter().filter(|text| text.as_str() == expected).count(), 1, "hidden {hidden}: translated tooltip: {hovered:?}"); + assert!(!hovered.iter().any(|text| text == mode.label()), "hidden {hidden}: no untranslated tooltip: {hovered:?}"); + let (_, away) = spectrum_hover_texts(&mut app, &ctx, false); + assert!(!away.iter().any(|text| text == expected), "hidden {hidden}: translated tooltip hides again: {away:?}"); + assert_eq!(app.session.proxy_paints(), paints, "translated hover changes no paint"); + assert_eq!(app.session.active().unwrap().history.undo.len(), undo, "translated hover adds no undo step"); + } +}