DesignCraft: An open-source page and layout design editor written by scratch in pure Rust
Merge origin/main into codex/compact-object-control-bar
moppeeerda7a457c9522
diff --cc ROADMAP.mdindex 2e80a6db1,d60a6bf49..e04d90486--- a/ROADMAP.md+++ b/ROADMAP.md@@@ -153,11 -438,16 +438,18 @@@ Newest first- **2026-10-12** · The Effects panel shows the level its settings apply to ("Group: Color Dodge 100%") and, as in InDesign, Isolate Blending and Knockout Group for a selected group. No readiness percentage change.- **2026-10-11** · Properties gains InDesign's Pathfinder section (Add, Subtract, Intersect, Exclude Overlap, Minus Back) with several objects selected; section titles and icon buttons have accessible names. No readiness percentage change.- **2026-10-12** · The Eyedropper samples a placed image: clicking the photo with text (or objects) selected fills them with the image's colour under the pointer, as an unnamed colour (`color.sample`), as in InDesign. Images on locked layers can be sampled. No readiness percentage change.+- **2026-10-11** · Advanced workspace's object Control panel compacted into aligned two-row+ groups (#255): spinners, fill/stroke chips, proportion links, corners, Auto-Fit, alignment.+ - **2026-10-12** · The section marker character shows its section's marker text on document pages (nothing when the section has none) instead of the word "Section", which stays on parent pages; editing the marker recomposes (#556). No readiness percentage change.+ - **2026-10-12** · On screen, blend modes blend with the objects below and not with the paper, as in InDesign and in PDF export: a Color Dodge or Screen object over blank paper shows as it is. No readiness percentage change.+ - **2026-10-12** · A gradient feather on a group fades the group as one, on screen and in PDF. Before, the screen ignored it, and PDF masked the group with a box of zero size because a group has no path of its own. No readiness percentage change.+ - **2026-10-12** · In a CMYK transparency blend space (print documents), blend modes blend in CMYK on screen as in InDesign. Color Dodge with 100% K text turns coloured areas under it white and leaves the paper alone, where RGB blending changed almost nothing. PDF export already did this. No readiness percentage change.+ - **2026-10-11** · Moving a sheared and rotated text frame no longer leaves trails of text behind: canvas repaints cover the frame's whole text box, not just its outline. No readiness percentage change.- **2026-10-12** · Words in capitals hyphenate like capitalized words (FERRUM COM-MODI), as in InDesign; Hyphenate Capitalized Words off keeps them whole. No readiness percentage change.+ - **2026-10-12** · Load Swatches refuses an `.ase` file with more than 100,000 colors, and `swatch.load` merges a file of 100,000 colors in under 0.1 s (it took 9.6 s of CPU in a test build). No readiness percentage change.- **2026-10-11** · `transform.move {copy}`, Edit › Duplicate and Step and Repeat return the copies' ids, so a script can go on with them. No readiness percentage change.- **2026-10-11** · `object.fill` and `object.stroke` refuse a swatch name the document doesn't have (it painted nothing) and suggest the name meant (`Paper` → `[Paper]`). No readiness percentage change.+ - **2026-10-13** · Dropping an `.ase` file on the window loads its swatches, as Load Swatches does (the drop failed with "Can't Place the File"). No readiness percentage change.- **2026-10-11 (printing):** `file.printers` and `file.print` use craft-libs/craft-print for CUPS and Windows. DesignCraft retains PDF export, page selection, spreads, marks and bleed; dry runs create no temporary PDF or print job. Windows selects matching or default driver paper and shrinks oversized sheets without enlarging smaller ones; queue duplex defaults are preserved. Headless tests exercise exported bytes, job settings, dry runs and refusals; shared native Windows CI passes, including paused-queue submission and cleanup. PostScript, production print controls and physical output validation remain open. No readiness percentage change.- **2026-10-10 (UI.4–UI.5):** Panel tabs can move into other groups, split the dock, float, resize and return to their saved locations through shared docking transactions. Layouts persist in custom workspaces; UI and control commands share the same validated action path. Shared pane geometry and widget-state theme application retain all five palettes and local fonts. Split panes send keyboard input only to the focused canvas and scope contextual toolbar IDs per pane. No readiness percentage change.diff --cc crates/ui-egui/src/chrome.rsindex 8f9fcb454,439fb3932..b3c4b027d--- a/crates/ui-egui/src/chrome.rs+++ b/crates/ui-egui/src/chrome.rs@@@ -182,16 -177,303 +177,105 @@@ pub fn control_bar(app: &mut DesignAppui.horizontal_top(|ui| {let text_mode =matches!(app.session.tool_id(), "type" | "verticalType") || app.session.active().is_some_and(|d| d.selection.text.is_some());- if text_mode {+ if app.session.tool_id() == "page" {+ control_page(app, ui);+ } else if text_mode {control_text(app, ui);} else {- control_object(app, ui);+ crate::object_control::show(app, ui);}});});});}+ /// The Control panel with the Page tool, as InDesign's: reference point, X/Y, W/H, page-size+ /// preset, orientation, Liquid Page Rule and Show Parent Page Overlay, for+ /// the page the Page tool selected (else the page in view). W/H keep the reference point in place.+ fn control_page(app: &mut DesignApp, ui: &mut egui::Ui) {+ let lang = app.ui.language.clone();+ let Some(st) = app.session.active() else { return };+ let units = st.doc.settings.horizontal_units;+ let Some(page) = st.selection.page.or_else(|| crate::canvas::current_page(app)) else { return };+ let Some(st) = app.session.active() else { return };+ let d = st.doc.clone();+ let Some((si, pi)) = d.page_loc(page) else { return };+ let pg = d.spreads[si].pages[pi].clone();+ let n = page + 1;+ // Reference point: W/H edits keep it in place.+ let (r, _) = ui.allocate_exact_size(vec2(30.0, 44.0), Sense::hover());+ if let Some(p) = panels::properties::ref_point_proxy(ui, egui::Rect::from_center_size(r.center(), vec2(27.0, 27.0)), app.ui.ref_point) {+ app.ui.ref_point = p;+ }+ let anchor = app.ui.ref_point.min(8);+ let (fx, fy) = ((anchor % 3) as f64 / 2.0, (anchor / 3) as f64 / 2.0);+ // The reference point's position: from the spine across, from the top down.+ let (x, y) = (pg.x - d.spreads[si].spine_x() + fx * pg.width, fy * pg.height);+ egui::Grid::new("ctl_page_xywh").num_columns(4).spacing(vec2(4.0, 4.0)).show(ui, |ui| {+ caption(ui, crate::i18n::tr(&lang, "X:"));+ // Pages don't move within their spread yet.+ ui.add_enabled_ui(false, |ui| measure(ui, "cpx", Some(x), units, 64.0));+ caption(ui, crate::i18n::tr(&lang, "W:"));+ if let Some(v) = measure(ui, "cpw", Some(pg.width), units, 64.0) {+ let _ = app.run("layout.pageSize", json!({"pages": [n], "width": v, "anchor": anchor}));+ }+ ui.end_row();+ caption(ui, crate::i18n::tr(&lang, "Y:"));+ ui.add_enabled_ui(false, |ui| measure(ui, "cpy", Some(y), units, 64.0));+ caption(ui, crate::i18n::tr(&lang, "H:"));+ if let Some(v) = measure(ui, "cph", Some(pg.height), units, 64.0) {+ let _ = app.run("layout.pageSize", json!({"pages": [n], "height": v, "anchor": anchor}));+ }+ ui.end_row();+ });+ vsep(ui);+ // Page-size preset and orientation.+ let landscape = pg.width > pg.height;+ ui.vertical(|ui| {+ let cur = panels::properties::preset_name(pg.width, pg.height);+ egui::ComboBox::from_id_salt("ctl_page_preset").selected_text(crate::rtl::widget(ui, crate::i18n::tr(&lang, cur))).width(130.0).show_ui(+ ui,+ |ui| {+ for (name, w, h) in panels::properties::PAGE_PRESETS {+ if ui.selectable_label(cur == *name, crate::rtl::widget(ui, crate::i18n::tr(&lang, name))).clicked() {+ let (w, h) = if landscape { (h, w) } else { (w, h) };+ let _ = app.run("layout.pageSize", json!({"pages": [n], "width": w, "height": h, "anchor": anchor}));+ }+ }+ },+ );+ ui.horizontal(|ui| {+ for (icon, tip, want) in [("orient-portrait", "Portrait", false), ("orient-landscape", "Landscape", true)] {+ if crate::widgets::icon_toggle(ui, icon, landscape == want, crate::i18n::tr(&lang, tip)).clicked() && landscape != want {+ let _ = app.run("layout.pageSize", json!({"pages": [n], "width": pg.height, "height": pg.width, "anchor": anchor}));+ }+ }+ });+ });+ vsep(ui);+ ui.vertical(|ui| {+ caption(ui, crate::i18n::tr(&lang, "Liquid Page Rule:"));+ let label = panels::interactive::liquid_rule_label(pg.liquid);+ egui::ComboBox::from_id_salt("ctl_page_rule").selected_text(crate::rtl::widget(ui, crate::i18n::tr(&lang, label))).width(150.0).show_ui(+ ui,+ |ui| {+ for (r, l) in panels::interactive::LIQUID_RULES {+ if ui.selectable_label(pg.liquid == r, crate::rtl::widget(ui, crate::i18n::tr(&lang, l))).clicked() && pg.liquid != r {+ let _ = app.run("liquid.pageRule", json!({"rule": r, "pages": [n]}));+ }+ }+ },+ );+ });+ vsep(ui);+ ui.vertical(|ui| {+ let mut overlay = pg.show_parent_overlay;+ if ui.checkbox(&mut overlay, crate::rtl::widget(ui, crate::i18n::tr(&lang, "Show Parent Page Overlay"))).changed() {+ let _ = app.run("layout.pageOptions", json!({"pages": [n], "showParentOverlay": overlay}));+ }+ });+ }+-/// A field label drawn as a tool icon (hover for its name).-fn icon_caption(ui: &mut egui::Ui, icon: &str, tip: &str) {- let (r, resp) = ui.allocate_exact_size(vec2(16.0, 16.0), Sense::hover());- icons::paint(ui.painter(), r, icon, Tokens::get(ui.ctx()).icon);- resp.on_hover_ui(|ui| {- crate::rtl::label(ui, tip);- });-}--fn control_object(app: &mut DesignApp, ui: &mut egui::Ui) {- let units = app.session.active().map(|d| d.doc.settings.horizontal_units).unwrap_or(Unit::Picas);- let info = panels::sel_info(app);- // Reference point proxy.- let (r, _) = ui.allocate_exact_size(vec2(30.0, 44.0), Sense::hover());- let t = Tokens::get(ui.ctx());- icons::paint(ui.painter(), egui::Rect::from_center_size(r.center(), vec2(26.0, 26.0)), "ref-point", t.icon);- ui.painter().rect_filled(egui::Rect::from_center_size(r.center() + vec2(-7.8, -7.8), vec2(4.0, 4.0)), 0.0, t.text_strong);- let (x, y, w, h) = match &info {- Some(SelInfo { page_rect, .. }) => (Some(page_rect.x0), Some(page_rect.y0), Some(page_rect.width()), Some(page_rect.height())),- None => (None, None, None, None),- };- egui::Grid::new("ctl_xywh").num_columns(4).spacing(vec2(4.0, 4.0)).show(ui, |ui| {- caption(ui, crate::i18n::tr(&app.ui.language, "X:"));- if let Some(v) = measure(ui, "cx", x, units, 64.0) {- let _ = app.run("transform.set", json!({"x": v}));- }- caption(ui, crate::i18n::tr(&app.ui.language, "W:"));- if let Some(v) = measure(ui, "cw", w, units, 64.0) {- let _ = app.run("transform.set", json!({"width": v}));- }- ui.end_row();- caption(ui, crate::i18n::tr(&app.ui.language, "Y:"));- if let Some(v) = measure(ui, "cy", y, units, 64.0) {- let _ = app.run("transform.set", json!({"y": v}));- }- caption(ui, crate::i18n::tr(&app.ui.language, "H:"));- if let Some(v) = measure(ui, "ch", h, units, 64.0) {- let _ = app.run("transform.set", json!({"height": v}));- }- ui.end_row();- });- vsep(ui);- // Scale, rotation and shear (absolute; see Transformations are Totals).- let tv = if info.is_some() { app.session.execute("transform.info", &json!({})).ok() } else { None };- let tv_get = |k: &str| tv.as_ref().and_then(|v| v[k].as_f64());- egui::Grid::new("ctl_srs").num_columns(4).spacing(vec2(4.0, 4.0)).show(ui, |ui| {- icon_caption(ui, "tool-scale", crate::i18n::tr(&app.ui.language, "Scale X Percentage"));- if let Some(v) = number(ui, "csx", tv_get("scaleX"), "%", 56.0, 1) {- let _ = app.run("transform.set", json!({"scaleX": v}));- }- icon_caption(ui, "tool-rotate", crate::i18n::tr(&app.ui.language, "Rotation Angle"));- if let Some(v) = number(ui, "crot", tv_get("rotation"), "°", 50.0, 1) {- let _ = app.run("transform.set", json!({"rotation": v}));- }- ui.end_row();- icon_caption(ui, "tool-scale", crate::i18n::tr(&app.ui.language, "Scale Y Percentage"));- if let Some(v) = number(ui, "csy", tv_get("scaleY"), "%", 56.0, 1) {- let _ = app.run("transform.set", json!({"scaleY": v}));- }- icon_caption(ui, "tool-shear", crate::i18n::tr(&app.ui.language, "Shear X Angle"));- if let Some(v) = number(ui, "cshr", tv_get("shear"), "°", 50.0, 1) {- let _ = app.run("transform.set", json!({"shear": v}));- }- ui.end_row();- });- vsep(ui);- // Rotate / flip.- ui.vertical(|ui| {- ui.horizontal(|ui| {- if icons::button(ui, "tool-rotate", 20.0, false, crate::i18n::tr(&app.ui.language, "Rotate 90° Counterclockwise")).clicked() {- let _ = app.run("transform.rotate", json!({"angle": 90}));- }- if ui- .small_button("⇋")- .on_hover_ui(|ui| {- crate::rtl::label(ui, crate::i18n::tr(&app.ui.language, "Flip Horizontal"));- })- .clicked()- {- let _ = app.run("transform.flip", json!({"axis": "horizontal"}));- }- });- ui.horizontal(|ui| {- if ui- .small_button("↻")- .on_hover_ui(|ui| {- crate::rtl::label(ui, crate::i18n::tr(&app.ui.language, "Rotate 90° Clockwise"));- })- .clicked()- {- let _ = app.run("transform.rotate", json!({"angle": -90}));- }- if ui- .small_button("⇵")- .on_hover_ui(|ui| {- crate::rtl::label(ui, crate::i18n::tr(&app.ui.language, "Flip Vertical"));- })- .clicked()- {- let _ = app.run("transform.flip", json!({"axis": "vertical"}));- }- });- });- vsep(ui);- // Fill / stroke.- ui.vertical(|ui| {- ui.horizontal(|ui| {- caption(ui, crate::i18n::tr(&app.ui.language, "Fill"));- panels::swatch_picker(app, ui, "ctlfill", info.as_ref().map(|i| i.fill.clone()), |app, name| {- let _ = app.run("object.fill", json!({"swatch": name}));- });- });- ui.horizontal(|ui| {- caption(ui, crate::i18n::tr(&app.ui.language, "Stroke"));- panels::swatch_picker(app, ui, "ctlstroke", info.as_ref().map(|i| i.stroke.clone()), |app, name| {- let _ = app.run("object.stroke", json!({"swatch": name}));- });- if let Some(v) = number(ui, "csw", info.as_ref().map(|i| i.stroke_weight), " pt", 46.0, 3) {- let _ = app.run("object.stroke", json!({"weight": v}));- }- });- });- vsep(ui);- // Opacity, fx.- ui.vertical(|ui| {- ui.horizontal(|ui| {- caption(ui, crate::i18n::tr(&app.ui.language, "Opacity"));- if let Some(v) = number(ui, "cop", info.as_ref().map(|i| i.opacity * 100.0), "%", 42.0, 0) {- let _ = app.run("object.opacity", json!({"opacity": v / 100.0}));- }- });- ui.horizontal(|ui| {- if icons::button(ui, "panel-effects", 20.0, info.as_ref().is_some_and(|i| i.shadow), crate::i18n::tr(&app.ui.language, "Drop Shadow"))- .clicked()- {- let _ = app.run("object.dropShadow", json!({}));- }- });- });- vsep(ui);- // Fitting.- ui.vertical(|ui| {- ui.horizontal(|ui| {- for (icon, mode, tip) in [- ("fit-fill", "fillProportionally", "Fill Frame Proportionally"),- ("fit-prop", "fitProportionally", "Fit Content Proportionally"),- ("fit-content", "fitContentToFrame", "Fit Content to Frame"),- ] {- if icons::button(ui, icon, 20.0, false, tip).clicked() {- let _ = app.run("object.fit", json!({"mode": mode}));- }- }- });- ui.horizontal(|ui| {- for (icon, mode, tip) in [("fit-frame", "fitFrameToContent", "Fit Frame to Content"), ("fit-center", "centerContent", "Center Content")] {- if icons::button(ui, icon, 20.0, false, tip).clicked() {- let _ = app.run("object.fit", json!({"mode": mode}));- }- }- });- });- vsep(ui);- // Text wrap.- ui.vertical(|ui| {- ui.horizontal(|ui| {- for (icon, mode, tip) in [- ("wrap-none", "none", "No Text Wrap"),- ("wrap-bbox", "boundingBox", "Wrap Around Bounding Box"),- ("wrap-contour", "contour", "Wrap Around Object Shape"),- ] {- let on = info.as_ref().is_some_and(|i| i.wrap == mode);- if icons::button(ui, icon, 20.0, on, tip).clicked() {- let _ = app.run("object.textWrap", json!({"mode": mode}));- }- }- });- ui.horizontal(|ui| {- for (icon, mode, tip) in [("wrap-jump", "jumpObject", "Jump Object"), ("wrap-next", "jumpToNextColumn", "Jump to Next Column")] {- let on = info.as_ref().is_some_and(|i| i.wrap == mode);- if icons::button(ui, icon, 20.0, on, tip).clicked() {- let _ = app.run("object.textWrap", json!({"mode": mode}));- }- }- });- });- if let Some(i) = &info- && let Some(cols) = i.columns- {- vsep(ui);- ui.vertical(|ui| {- caption(ui, crate::i18n::tr(&app.ui.language, "Columns"));- if let Some(v) = number(ui, "ccols", Some(cols as f64), "", 36.0, 0) {- let _ = app.run("object.textFrameOptions", json!({"columns": v.max(1.0) as u64}));- }- });- }-}-fn control_text(app: &mut DesignApp, ui: &mut egui::Ui) {let t = Tokens::get(ui.ctx());let attrs = panels::text_attrs(app);diff --cc crates/ui-egui/src/lib.rsindex a3b088ad5,59c7ebb59..dae002d10--- a/crates/ui-egui/src/lib.rs+++ b/crates/ui-egui/src/lib.rs@@@ -16,7 -17,7 +17,8 @@@ pub mod dockpub mod i18n;pub mod icons;pub mod menus;+ mod modal_drag;+mod object_control;mod panel_docking;pub mod panels;mod prefs;diff --cc crates/ui-egui/src/panels/mod.rsindex 2a07f34ed,c88ae30a3..17291c10f--- a/crates/ui-egui/src/panels/mod.rs+++ b/crates/ui-egui/src/panels/mod.rs@@@ -181,49 -252,56 +252,66 @@@ pub fn swatch_menu_row(ui: &mut egui::Uresp.clicked()}+ /// The list in a swatch popup → the swatch picked. It is as wide as its longest name (within+ /// limits), and its rows stop short of the scroll bar that floats over the list's edge.+ pub fn swatch_list(ui: &mut egui::Ui, doc: &designcraft_doc::Document, current: &str) -> Option<String> {+ let font = swatch_menu_font();+ let widest = doc+ .swatches+ .iter()+ .map(|sw| ui.painter().layout_no_wrap(sw.name.clone(), font.clone(), egui::Color32::PLACEHOLDER).size().x)+ .fold(0.0, f32::max);+ let scroll = &ui.spacing().scroll;+ let bar = scroll.bar_inner_margin + scroll.bar_width + scroll.bar_outer_margin;+ let width = (SWATCH_MENU_TEXT_X + widest + 10.0 + bar).clamp(200.0, 360.0);+ ui.set_min_width(width);+ ui.set_max_width(width);+ let mut picked = None;+ egui::ScrollArea::vertical().max_height(320.0).show(ui, |ui| {+ for sw in &doc.swatches {+ if swatch_menu_row(ui, doc, &sw.name, current, width - bar) {+ picked = Some(sw.name.clone());+ ui.close();+ }+ }+ });+ picked+ }+-/// A swatch dropdown showing a chip and name; `on_pick` gets the chosen swatch name.-pub fn swatch_picker(app: &mut DesignApp, ui: &mut egui::Ui, id: &str, current: Option<String>, on_pick: impl FnOnce(&mut DesignApp, String)) {- let Some(doc) = app.session.active().map(|d| d.doc.clone()) else { return };+/// A swatch dropdown showing a chip and name; `on_pick` gets the chosen swatch name. Returns the+/// chip's response (`None` without a document), for a caller to label or annotate.+pub fn swatch_picker(+ app: &mut DesignApp,+ ui: &mut egui::Ui,+ id: &str,+ current: Option<String>,+ on_pick: impl FnOnce(&mut DesignApp, String),+) -> Option<egui::Response> {+ let doc = app.session.active().map(|d| d.doc.clone())?;let cur = current.unwrap_or_default();let (c, g) = crate::widgets::swatch_colors(&doc, &cur, 1.0);let mut picked = None;- ui.push_id(id, |ui| {- let (r, resp) = ui.allocate_exact_size(vec2(30.0, 18.0), egui::Sense::click());- crate::widgets::paint_chip(- ui.painter(),- egui::Rect::from_min_size(r.min, vec2(18.0, 18.0)),- if cur.is_empty() { Some(egui::Color32::GRAY) } else { c },- g,- );- crate::icons::paint(- ui.painter(),- egui::Rect::from_min_size(r.min + vec2(18.0, 3.0), vec2(12.0, 12.0)),- "chevron-down",- Tokens::get(ui.ctx()).icon,- );- egui::Popup::menu(&resp).show(|ui| {- picked = swatch_list(ui, &doc, &cur);- });- });+ let resp = ui+ .push_id(id, |ui| {+ let (r, resp) = ui.allocate_exact_size(vec2(30.0, 18.0), egui::Sense::click());+ crate::widgets::paint_chip(+ ui.painter(),+ egui::Rect::from_min_size(r.min, vec2(18.0, 18.0)),+ if cur.is_empty() { Some(egui::Color32::GRAY) } else { c },+ g,+ );+ crate::icons::paint(+ ui.painter(),+ egui::Rect::from_min_size(r.min + vec2(18.0, 3.0), vec2(12.0, 12.0)),+ "chevron-down",+ Tokens::get(ui.ctx()).icon,+ );+ egui::Popup::menu(&resp).show(|ui| {- ui.set_min_width(200.0);- ui.set_max_width(280.0);- egui::ScrollArea::vertical().max_height(320.0).show(ui, |ui| {- for sw in &doc.swatches {- if swatch_menu_row(ui, &doc, &sw.name, &cur) {- picked = Some(sw.name.clone());- ui.close();- }- }- });++ picked = swatch_list(ui, &doc, &cur);+ });+ resp+ })+ .inner;if let Some(p) = picked {on_pick(app, p);}@@@ -709,3 -786,89 +797,91 @@@ mod font_menu_ui_tests}}}++ #[cfg(test)]+ mod swatch_list_tests {+ use super::*;++ fn rects(shapes: &[egui::epaint::ClippedShape]) -> Vec<(egui::Rect, egui::Color32)> {+ fn walk(s: &egui::Shape, out: &mut Vec<(egui::Rect, egui::Color32)>) {+ match s {+ egui::Shape::Rect(r) => out.push((r.rect, r.fill)),+ egui::Shape::Vec(v) => v.iter().for_each(|s| walk(s, out)),+ _ => {}+ }+ }+ let mut out = vec![];+ shapes.iter().for_each(|s| walk(&s.shape, &mut out));+ out+ }++ fn texts(shapes: &[egui::epaint::ClippedShape]) -> Vec<(String, egui::Rect)> {+ fn walk(s: &egui::Shape, out: &mut Vec<(String, egui::Rect)>) {+ match s {+ egui::Shape::Text(t) => out.push((t.galley.job.text.clone(), t.visual_bounding_rect())),+ egui::Shape::Vec(v) => v.iter().for_each(|s| walk(s, out)),+ _ => {}+ }+ }+ let mut out = vec![];+ shapes.iter().for_each(|s| walk(&s.shape, &mut out));+ out+ }++ #[test]+ fn the_swatch_under_the_pointer_is_highlighted_and_names_clear_the_scroll_bar() {+ let mut app = DesignApp::new(designcraft_engine::Session::new(), crate::Services::default());+ app.run("file.new", serde_json::json!({})).unwrap();+ // A long name, as process swatches have.+ app.run("swatch.create", serde_json::json!({"name": "C=15 M=100 Y=100 K=0 Long Name", "color": {"c": 15, "m": 100, "y": 100, "k": 0}}))+ .unwrap();+ let long = "C=15 M=100 Y=100 K=0 Long Name";+ let ctx = egui::Context::default();+ crate::theme::install_fonts(&ctx, "");+ let tokens = Tokens::for_brightness(crate::theme::Brightness::MediumDark);+ crate::theme::apply(&ctx, &tokens);+ let mut time = 0.0;+ let mut frame = |app: &mut DesignApp, events: Vec<egui::Event>| {+ time += 0.1;+ let raw = egui::RawInput {+ screen_rect: Some(egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(800.0, 700.0))),+ time: Some(time),+ events,+ ..Default::default()+ };- let mut out = ctx.run_ui(raw, |ui| swatch_picker(app, ui, "list", Some("[Black]".into()), |_, _| {}));++ let mut out = ctx.run_ui(raw, |ui| {++ swatch_picker(app, ui, "list", Some("[Black]".into()), |_, _| {});++ });+ out.textures_delta.clear();+ out.shapes+ };+ frame(&mut app, vec![]);+ let chip = egui::pos2(17.0, 17.0);+ for pressed in [true, false] {+ frame(+ &mut app,+ vec![+ egui::Event::PointerMoved(chip),+ egui::Event::PointerButton { pos: chip, button: egui::PointerButton::Primary, pressed, modifiers: Default::default() },+ ],+ );+ }+ let shapes = frame(&mut app, vec![]);+ let (_, name) = texts(&shapes).into_iter().find(|(t, _)| t == "[Registration]").expect("the list is open");+ let pointer = name.center();+ frame(&mut app, vec![egui::Event::PointerMoved(pointer)]);+ let shapes = frame(&mut app, vec![]);+ let all = rects(&shapes);+ let (row, _) = *all.iter().find(|(r, c)| *c == tokens.accent_strong && r.contains(pointer)).expect("the hovered row is highlighted");+ let (list, _) = *all+ .iter()+ .filter(|(r, c)| *c == tokens.panel && r.contains_rect(row))+ .min_by(|a, b| a.0.area().total_cmp(&b.0.area()))+ .expect("the popup");+ let scroll = ctx.global_style().spacing.scroll;+ assert!(row.right() + scroll.bar_width <= list.right(), "rows {row:?} stop short of the scroll bar in {list:?}");+ let (_, long_rect) = texts(&shapes).into_iter().find(|(t, _)| t == long).unwrap();+ assert!(long_rect.right() <= row.right(), "the longest name {long_rect:?} fits its row {row:?}");+ assert!(texts(&shapes).iter().any(|(t, r)| t == "[Black]" && r.right() <= row.right()));+ }+ }