From eb3b83f5096f915ca195ac518f882080af4c5e28 Mon Sep 17 00:00:00 2001 From: Carlo1911 <17356993+Carlo1911@users.noreply.github.com> Date: Tue, 24 Nov 2026 17:28:14 -0500 Subject: [PATCH 01/25] Missing Fonts: a folder search finds the file of a PostScript name split into family and style (#9242) A document names Gilroy-Black as the family Gilroy in the style Black. WantedFonts only indexed and checked the family name, so a file whose own family is Gilroy-Black, with no style, was never offered, although FontDb::canonical finds that face by its PostScript name once it is cataloged. The joined family and style is now indexed and accepted against a face's PostScript or full name. Co-Authored-By: Claude Sonnet 5.5 --- crates/text/src/fontdb/wanted.rs | 16 ++++++++++++++-- crates/text/src/tests/sysfonts.rs | 18 ++++++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/crates/text/src/fontdb/wanted.rs b/crates/text/src/fontdb/wanted.rs index 31539737ad..0e6c4dfbaf 100644 --- a/crates/text/src/fontdb/wanted.rs +++ b/crates/text/src/fontdb/wanted.rs @@ -35,7 +35,7 @@ impl WantedFonts { pub fn new(fonts: &[WantedFont]) -> Self { let mut by_name: HashMap> = HashMap::new(); for (i, w) in fonts.iter().enumerate() { - let mut names = vec![w.family.to_ascii_lowercase(), norm(&w.family)]; + let mut names = vec![w.family.to_ascii_lowercase(), norm(&w.family), joined(w)]; names.extend(w.installed.as_ref().map(|c| c.to_ascii_lowercase())); names.sort(); names.dedup(); @@ -137,5 +137,17 @@ fn provides(w: &WantedFont, faces: &[FaceStyle]) -> bool { return true; } // A legacy family with another style: that style of the family. - faces.iter().find(|f| f.keys.legacy.iter().any(|(family, _)| *family == key)).is_some_and(|f| styled(&f.family)) + if faces.iter().find(|f| f.keys.legacy.iter().any(|(family, _)| *family == key)).is_some_and(|f| styled(&f.family)) { + return true; + } + // A family and style split from a PostScript name by an importer that didn't have the font + // (`Gilroy-Black` → Gilroy, Black), as `FontDb::canonical` joins them again: a face whose + // PostScript or full name is that name, whatever family and style the file gives it. + let joined = joined(w); + !sk.is_empty() && faces.iter().any(|f| f.keys.postscript.contains(&joined) || f.keys.full_names.contains(&joined)) +} + +/// The family and style of `w` as one normalized name (`Gilroy` and `Black` → `gilroyblack`). +fn joined(w: &WantedFont) -> String { + format!("{}{}", norm(&w.family), norm(&w.style)) } diff --git a/crates/text/src/tests/sysfonts.rs b/crates/text/src/tests/sysfonts.rs index c469b48ead..452accaf8a 100644 --- a/crates/text/src/tests/sysfonts.rs +++ b/crates/text/src/tests/sysfonts.rs @@ -1201,3 +1201,21 @@ fn a_name_asked_for_before_its_font_is_installed_finds_it_after_a_rescan() { } let _ = std::fs::remove_dir_all(dir); } + +/// A document names `Gilroy-Black` as the family Gilroy in the style Black. A file whose own family is +/// `Gilroy-Black`, with no style, is that face, once cataloged and in a search of a folder. +#[test] +fn a_search_finds_the_file_of_a_postscript_name_split_into_family_and_style() { + let data = named(&[(3, EN, 1, "Gilroy-Black"), (3, EN, 4, "Gilroy-Black"), (3, EN, 6, "Gilroy-Black")]); + let dir = std::env::temp_dir().join(format!("vc-sysfonts-{}-split-ps", std::process::id())); + std::fs::create_dir_all(&dir).unwrap(); + let file = dir.join("Gilroy-Black.ttf"); + std::fs::write(&file, &data).unwrap(); + let db = FontDb::with_font_dirs(vec![dir.clone()]); + let (face, matched) = db.resolve("Gilroy", "Black").unwrap(); + assert_eq!(matched, FontMatch::Exact, "{face:?}"); + let wanted = |style: &str| WantedFonts::new(&[WantedFont { family: "Gilroy".into(), style: style.into(), installed: None }]); + assert_eq!(wanted("Black").provided_by(&file), [0]); + assert!(wanted("Bold").provided_by(&file).is_empty(), "another style of the family is another file"); + let _ = std::fs::remove_dir_all(dir); +} From 990c8b2d26ac60953c204f808eb804448b0e34dd Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 28 Nov 2026 08:37:27 -0800 Subject: [PATCH 02/25] Fonts: test the full-name and empty-style cases of the split PostScript name search The folder search test now also checks a file that carries the joined name only as its full name, and that a wanted font without a style is not offered a file through the joined name. --- crates/text/src/tests/sysfonts.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/crates/text/src/tests/sysfonts.rs b/crates/text/src/tests/sysfonts.rs index bb0173c019..f456a29926 100644 --- a/crates/text/src/tests/sysfonts.rs +++ b/crates/text/src/tests/sysfonts.rs @@ -1255,5 +1255,12 @@ fn a_search_finds_the_file_of_a_postscript_name_split_into_family_and_style() { let wanted = |style: &str| WantedFonts::new(&[WantedFont { family: "Gilroy".into(), style: style.into(), installed: None }]); assert_eq!(wanted("Black").provided_by(&file), [0]); assert!(wanted("Bold").provided_by(&file).is_empty(), "another style of the family is another file"); + assert!(wanted("").provided_by(&file).is_empty(), "without a style, the family alone is not the PostScript name"); + // A file that carries the joined name only as its full name is found the same way. + let data = named(&[(3, EN, 1, "Gilroy Heavy"), (3, EN, 4, "Gilroy Heavy"), (3, EN, 6, "GilroyHvy")]); + let file = dir.join("Gilroy-Heavy.ttf"); + std::fs::write(&file, &data).unwrap(); + assert_eq!(wanted("Heavy").provided_by(&file), [0]); + assert!(wanted("Black").provided_by(&file).is_empty()); let _ = std::fs::remove_dir_all(dir); } From cd1d4ed86410e44f6f7cf7854c11e144507de6cd Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 28 Nov 2026 09:21:11 -0800 Subject: [PATCH 03/25] App bar: Discord, search and workspace switcher stand an item gap apart The title bar laid the app bar's right-hand controls out at the body's row gap (5 pt in the compact sizes), so the hovered search button's highlight came within 5 pt of the Discord button and the workspace switcher. They now sit in a row at space.gap.item, the gap the framework gives neighboring controls in a bar. The ranked controls still leave the bar whole, Discord first, as the window narrows. --- crates/ui-egui/src/chrome.rs | 19 +++++++++++-------- crates/ui-egui/src/chrome/tests.rs | 22 ++++++++++++++++++++++ 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/crates/ui-egui/src/chrome.rs b/crates/ui-egui/src/chrome.rs index 52d92c7df6..291177c9e2 100644 --- a/crates/ui-egui/src/chrome.rs +++ b/crates/ui-egui/src/chrome.rs @@ -6,7 +6,7 @@ use std::cell::RefCell; use craft::behavior::IconId; use craft::menu::MenuBarUi; use craft::ui::buttons::{Button, IconButton, ToggleButton}; -use craft::ui::contract::{Bind, BodyCx, Props, Show, ShowContainer}; +use craft::ui::contract::{Bind, BodyCx, Gap, Props, Show, ShowContainer}; use craft::ui::display::Picture; use craft::ui::layout_components::Row; use craft::ui::primitives::IconSpec; @@ -114,17 +114,20 @@ fn leading(ui: &mut Ui, app: &mut VectorcraftApp) { } /// The end of the bar: each ranked control in a row of its own, which the fitted title bar gives up whole, lowest rank -/// first, before the menus narrow. +/// first, before the menus narrow. The controls are `space.gap.item` apart, the gap between neighboring controls in a +/// bar. fn trailing(ui: &mut Ui, app: &mut VectorcraftApp) { let safe = vectorcraft_plugins::safe_mode::active(); - for t in Trailing::SHOWN.into_iter().filter(|t| safe || *t != Trailing::Safe) { - match t.rank() { - Some(rank) => { - Row::new().fit_rank(rank).show(ui, |ui, _| t.show(app, ui)); + Row::new().gap(Gap::Item).show(ui, |ui, _| { + for t in Trailing::SHOWN.into_iter().filter(|t| safe || *t != Trailing::Safe) { + match t.rank() { + Some(rank) => { + Row::new().fit_rank(rank).show(ui, |ui, _| t.show(app, ui)); + } + None => t.show(app, ui), } - None => t.show(app, ui), } - } + }); } /// The application bar, the body of the shell's title bar: brand mark, Home and menus, then Discord, diff --git a/crates/ui-egui/src/chrome/tests.rs b/crates/ui-egui/src/chrome/tests.rs index 0caf6ca592..a06ee63300 100644 --- a/crates/ui-egui/src/chrome/tests.rs +++ b/crates/ui-egui/src/chrome/tests.rs @@ -473,6 +473,28 @@ fn the_app_bar_gives_up_its_right_hand_controls_in_order() { assert!(widest.zip(narrowest).is_some_and(|(w, n)| n >= w - 0.5), "the search keeps its width until it goes: {search_widths:?}"); } +/// The app bar's right-hand controls stand at least `space.gap.item` apart, the gap between neighboring controls in a +/// bar, so a hovered control's highlight does not touch the one beside it. +#[test] +fn the_app_bar_keeps_its_right_hand_controls_an_item_gap_apart() { + crate::i18n::set_current(crate::i18n::Lang::EN); + let app = crate::VectorcraftApp::new(Session::new(), Default::default()); + let gap = Rc::new(std::cell::Cell::new(0.0_f32)); + let read = Rc::clone(&gap); + let mut bar = Shown::new(app, egui::vec2(1600.0, 600.0), move |app, ui| { + read.set(craft::ui::runtime::env::Env::of(ui).tokens.space.gap.item); + app.ui(ui); + }); + bar.frame(Vec::new()).frame(Vec::new()); + assert!(gap.get() > 0.0, "the item gap is read from the theme"); + let controls = ["Discord", "Search commands", "Choose a workspace"]; + let rects: Vec = controls.iter().map(|c| bar.starting(c).unwrap_or_else(|| panic!("{c} shows")).rect).collect(); + for pair in rects.windows(2) { + let between = pair[1].left() - pair[0].right(); + assert!(between >= gap.get() - 0.5, "neighboring controls {pair:?} are {between} apart, under the item gap {}", gap.get()); + } +} + /// A text the status bar painted, with where it lies. #[derive(Debug)] struct StatusText { From 745a0d5b7b977defdd49fb23d056b2ff14ed2a29 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 28 Nov 2026 09:26:23 -0800 Subject: [PATCH 04/25] UI: canvas chrome clears the scroll bar and the empty navigator - The Rotate View compass of a turned view sits left of the vertical scroll bar. It was placed in the canvas's top right corner, where the scroll bar drew over most of it. - With no document open, the status bar's artboard navigator shows a dash instead of an empty box. --- crates/ui-egui/src/canvas.rs | 13 ++++++++++++- crates/ui-egui/src/chrome/status_bar.rs | 20 ++++++++++++++++++-- crates/ui-egui/src/tests/rotateview.rs | 20 ++++++++++++++++++++ 3 files changed, 50 insertions(+), 3 deletions(-) diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs index cb9ab68bd1..2efe7e984a 100644 --- a/crates/ui-egui/src/canvas.rs +++ b/crates/ui-egui/src/canvas.rs @@ -395,7 +395,7 @@ fn compass(app: &VectorcraftApp, ui: &mut Ui, space: &CanvasSpace) -> Option Option egui::Rect { + if app.ui.screen_mode >= 2 { + return rect; + } + let env = Env::of(ui); + let strip = env.tokens.size.icon.md + env.tokens.space.gap.tight; + egui::Rect::from_min_max(rect.min, egui::pos2((rect.right() - strip).max(rect.left()), rect.bottom())) +} + /// The scroll bars along the right and bottom edges (Normal and Full Screen with Menu Bar): the view /// a thumb drag or page press moved. fn scroll_bars(app: &mut VectorcraftApp, ui: &mut Ui, space: &CanvasSpace) -> Option { diff --git a/crates/ui-egui/src/chrome/status_bar.rs b/crates/ui-egui/src/chrome/status_bar.rs index 460a6ed51f..9848d86f1a 100644 --- a/crates/ui-egui/src/chrome/status_bar.rs +++ b/crates/ui-egui/src/chrome/status_bar.rs @@ -120,8 +120,15 @@ pub fn status_bar(app: &mut VectorcraftApp, ui: &mut Ui) { } } Field::new(tl!("Artboard")).side(SideLabel::new().kind(LabelKind::Hidden)).show(ui, |ui, _| { - if let Some(i) = - Select::new(tl!("Artboard"), Bind::given(cur), &boards).look(SelectLook::Filled).enabled(nab > 0).show(ui).events.committed().copied() + // With no document the navigator shows a dash, as the info readout does. + if let Some(i) = Select::new(tl!("Artboard"), Bind::given(cur), &boards) + .placeholder("\u{2013}") + .look(SelectLook::Filled) + .enabled(nab > 0) + .show(ui) + .events + .committed() + .copied() { go = Some(json!(i)); } @@ -264,6 +271,15 @@ mod tests { assert_eq!(app.session.active().unwrap().history.undo.len(), undo); } } + + #[test] + fn with_no_document_the_artboard_navigator_shows_a_dash() { + let app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default()); + let mut panel = Panel::new(app, status_bar); + panel.room(egui::vec2(1200.0, 300.0)); + panel.frame(); + assert_eq!(panel.value_role("Artboard", Role::COMBO_BOX).as_deref(), Some("\u{2013}"), "the empty navigator reads as a dash"); + } } /// What the bar shows as work in progress: the running script, then background jobs, opens and places. The first diff --git a/crates/ui-egui/src/tests/rotateview.rs b/crates/ui-egui/src/tests/rotateview.rs index 03ae5cc7a9..fdf58bcdcb 100644 --- a/crates/ui-egui/src/tests/rotateview.rs +++ b/crates/ui-egui/src/tests/rotateview.rs @@ -318,6 +318,26 @@ fn rotate_view_to_selection_squares_the_view_to_the_selected_object() { assert!(square_on_screen(&app)); } +/// The Rotate View compass of a turned view sits clear of the vertical scroll bar, so the bar does not cover it. +#[test] +fn the_rotate_view_compass_is_clear_of_the_vertical_scroll_bar() { + let mut w = Window::new(); + w.ctx.enable_accesskit(); + w.after(0.0, vec![]); + let out = w.after(0.0, vec![]); + let nodes = out.platform_output.accesskit_update.as_ref().map_or(&[][..], |u| &u.nodes[..]); + let bounds = |label: &str| { + nodes + .iter() + .find(|(_, n)| n.label() == Some(label)) + .and_then(|(_, n)| n.bounds()) + .map(|b| egui::Rect::from_min_max(egui::pos2(b.x0 as f32, b.y0 as f32), egui::pos2(b.x1 as f32, b.y1 as f32))) + .unwrap_or_else(|| panic!("no {label} in the access tree")) + }; + let (compass, bar) = (bounds("Rotation compass"), bounds("Vertical scroll bar")); + assert!(compass.right() <= bar.left(), "the compass {compass:?} reaches under the scroll bar {bar:?}"); +} + /// The window, with a 400 × 300 document whose view is turned to 30°, and the Selection tool. Each /// frame comes the given number of seconds, zero or more, after the one before it. struct Window { From 69e8a0a39214b7456e6f7f4f6ac1d402a41a5366 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 28 Nov 2026 09:33:49 -0800 Subject: [PATCH 05/25] Fonts: offer a split PostScript name's file only when installing it resolves the name The joined-name check now matches the face's PostScript name only, as `FontDb::canonical` does for cataloged faces, so a file that carries the joined name only as a full name is no longer offered. A legacy family of the wanted name now decides the result, looking for the style in the family of each of its faces, since `canonical` does not join the name when the legacy family resolves it. Tests cover the full-name and legacy cases against `FontDb::resolve`, and a collection whose faces share a legacy family in either order. --- crates/text/src/fontdb/wanted.rs | 14 +++++---- crates/text/src/tests/sysfonts.rs | 48 +++++++++++++++++++++++++++---- 2 files changed, 51 insertions(+), 11 deletions(-) diff --git a/crates/text/src/fontdb/wanted.rs b/crates/text/src/fontdb/wanted.rs index 0e6c4dfbaf..8d72bdc3ab 100644 --- a/crates/text/src/fontdb/wanted.rs +++ b/crates/text/src/fontdb/wanted.rs @@ -136,15 +136,19 @@ fn provides(w: &WantedFont, faces: &[FaceStyle]) -> bool { }) { return true; } - // A legacy family with another style: that style of the family. - if faces.iter().find(|f| f.keys.legacy.iter().any(|(family, _)| *family == key)).is_some_and(|f| styled(&f.family)) { - return true; + // A legacy family with another style: that style of the family, among every face of the + // legacy family (in a collection they can be of different families). Once installed, the + // legacy family resolves the name, and `FontDb::canonical` doesn't join it. + let mut legacy = faces.iter().filter(|f| f.keys.legacy.iter().any(|(family, _)| *family == key)).peekable(); + if legacy.peek().is_some() { + return legacy.any(|f| styled(&f.family)); } // A family and style split from a PostScript name by an importer that didn't have the font // (`Gilroy-Black` → Gilroy, Black), as `FontDb::canonical` joins them again: a face whose - // PostScript or full name is that name, whatever family and style the file gives it. + // PostScript name is that name, whatever family and style the file gives it. Of a cataloged + // face, `canonical` reads the PostScript name only, so a full name alone isn't enough. let joined = joined(w); - !sk.is_empty() && faces.iter().any(|f| f.keys.postscript.contains(&joined) || f.keys.full_names.contains(&joined)) + !sk.is_empty() && faces.iter().any(|f| f.keys.postscript.contains(&joined)) } /// The family and style of `w` as one normalized name (`Gilroy` and `Black` → `gilroyblack`). diff --git a/crates/text/src/tests/sysfonts.rs b/crates/text/src/tests/sysfonts.rs index f456a29926..2f15ffe119 100644 --- a/crates/text/src/tests/sysfonts.rs +++ b/crates/text/src/tests/sysfonts.rs @@ -1256,11 +1256,47 @@ fn a_search_finds_the_file_of_a_postscript_name_split_into_family_and_style() { assert_eq!(wanted("Black").provided_by(&file), [0]); assert!(wanted("Bold").provided_by(&file).is_empty(), "another style of the family is another file"); assert!(wanted("").provided_by(&file).is_empty(), "without a style, the family alone is not the PostScript name"); - // A file that carries the joined name only as its full name is found the same way. - let data = named(&[(3, EN, 1, "Gilroy Heavy"), (3, EN, 4, "Gilroy Heavy"), (3, EN, 6, "GilroyHvy")]); - let file = dir.join("Gilroy-Heavy.ttf"); - std::fs::write(&file, &data).unwrap(); - assert_eq!(wanted("Heavy").provided_by(&file), [0]); - assert!(wanted("Black").provided_by(&file).is_empty()); let _ = std::fs::remove_dir_all(dir); + // The search offers a file only when installing it resolves the name exactly: not when the + // joined name is only a full name, and not when a legacy family of the same name resolves it + // first, to another style. + let cases = [ + ("full-name", vec![(3, EN, 1, "Gilroy Black"), (3, EN, 4, "Gilroy Black"), (3, EN, 6, "GilroyBlk")]), + ( + "legacy", + vec![(3, EN, 1, "Gilroy"), (3, EN, 2, "Regular"), (3, EN, 16, "Gilroy Display"), (3, EN, 17, "Regular"), (3, EN, 6, "Gilroy-Black")], + ), + ]; + for (name, records) in cases { + let dir = std::env::temp_dir().join(format!("vc-sysfonts-{}-split-ps-{name}", std::process::id())); + std::fs::create_dir_all(&dir).unwrap(); + let file = dir.join(format!("{name}.ttf")); + std::fs::write(&file, named(&records)).unwrap(); + let db = FontDb::with_font_dirs(vec![dir.clone()]); + let exact = db.resolve("Gilroy", "Black").is_some_and(|(_, matched)| matched == FontMatch::Exact); + assert!(!exact, "{name}: installing the file doesn't resolve Gilroy Black exactly"); + assert!(wanted("Black").provided_by(&file).is_empty(), "{name}: so the search doesn't offer it"); + let _ = std::fs::remove_dir_all(dir); + } +} + +/// In a collection whose faces share a legacy family but not a typographic one, the search looks +/// for the style asked for in each face's family, in either order. +#[test] +fn a_search_finds_a_style_among_the_faces_of_a_shared_legacy_family() { + let regular = named(&[(3, EN, 1, "Gilroy"), (3, EN, 2, "Regular"), (3, EN, 16, "Gilroy Text"), (3, EN, 17, "Regular")]); + let black = + named(&[(3, EN, 1, "Gilroy"), (3, EN, 2, "Regular"), (3, EN, 16, "Gilroy Display"), (3, EN, 17, "Black"), (3, EN, 6, "Gilroy-Black")]); + for (order, faces) in [("regular-first", [regular.clone(), black.clone()]), ("black-first", [black.clone(), regular.clone()])] { + let dir = std::env::temp_dir().join(format!("vc-sysfonts-{}-shared-legacy-{order}", std::process::id())); + std::fs::create_dir_all(&dir).unwrap(); + let file = dir.join("shared.ttc"); + std::fs::write(&file, collection(&faces)).unwrap(); + let db = FontDb::with_font_dirs(vec![dir.clone()]); + let (face, matched) = db.resolve("Gilroy", "Black").unwrap(); + assert_eq!(matched, FontMatch::Exact, "{order}: {face:?}"); + let wanted = WantedFonts::new(&[WantedFont { family: "Gilroy".into(), style: "Black".into(), installed: None }]); + assert_eq!(wanted.provided_by(&file), [0], "{order}"); + let _ = std::fs::remove_dir_all(dir); + } } From 2eb79ddfb44eda2eed9479ef8d2bc8dab2411fb6 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 28 Nov 2026 09:34:39 -0800 Subject: [PATCH 06/25] Smart Guides: a move lines up geometric edges with Use Preview Bounds on With Use Preview Bounds on, a move lined up the outside of the selection's stroke with the other art's geometric bounds, which Smart Guides always use for the targets. A stroked object then stopped half a stroke short of the edge it showed a guide for, or overlapped it by that much. The moved selection's geometric bounds now line up with the targets' geometric bounds whatever Use Preview Bounds says. Snap to Grid, Snap to Pixel and the ruler guides still use the bounds the bounding box shows. Part of #6436. --- crates/tools/src/select.rs | 10 ++++++--- crates/tools/src/select/tests.rs | 36 ++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 3 deletions(-) diff --git a/crates/tools/src/select.rs b/crates/tools/src/select.rs index f921b19fea..7510358fc4 100644 --- a/crates/tools/src/select.rs +++ b/crates/tools/src/select.rs @@ -262,6 +262,9 @@ fn distance_overlays(cx: &ToolContext, to: DistanceTo) -> Vec { /// it snaps to the original too. pub(crate) struct MoveSnap { bounds: Option, + /// The selection's geometric bounds, which Smart Guides line up with the other art's geometric + /// bounds and space evenly between them, whether Use Preview Bounds is on or off (#6436). + edges: Option, targets: Option, points: Option, /// The targets and points for a copy, gathered with the others before the previews move the @@ -300,6 +303,7 @@ impl MoveSnap { let points = |exclude: &[NodeId]| if cx.snap_to_grid { None } else { Targets::snap_to_point(cx, exclude) }; Self { bounds: selection_bounds(cx), + edges: guides.then(|| cx.doc.bounds_of(&cx.selection.objects, false)).flatten(), targets: guides.then(|| for_move(cx, &cx.selection.objects)), points: points(&cx.selection.objects), copy_targets: guides.then(|| for_move(cx, &[])), @@ -312,7 +316,7 @@ impl MoveSnap { /// Snap to Grid and Snap to Pixel alone, for a move whose box is `bounds`: the grid lands an /// edge of the box on a gridline, and pixels put its top-left on whole pixels. pub(crate) fn grid_only(bounds: Option) -> Self { - Self { bounds, targets: None, points: None, copy_targets: None, copy_points: None, rulers: None, by_edge: false } + Self { bounds, edges: None, targets: None, points: None, copy_targets: None, copy_points: None, rulers: None, by_edge: false } } /// The ruler guides stopped showing since the move began (View › Hide Guides, or Trim View, @@ -353,7 +357,7 @@ impl MoveSnap { // The grabbed anchor landed on a path or a crossing, which a ruler guide does not pull // it off. let mut on_path = false; - if let (Some(t), Some(b)) = (targets, self.bounds) { + if let (Some(t), Some(b)) = (targets, self.edges) { // The point the selection was grabbed by, near another object's anchor or centre, // lands on it, rather than the bounds lining up a little beside it (#955). if t.has_point_near(start + d, cx.snap_tol()) { @@ -434,7 +438,7 @@ impl MoveSnap { d = q - start; guides = ov; } - if let (Some(t), Some(b)) = (targets, self.bounds) { + if let (Some(t), Some(b)) = (targets, self.edges) { if t.has_point_near(start + d, cx.snap_tol()) { let (q, ov) = t.snap_point_along(start + d, u, cx.snap_tol()); d = q - start; diff --git a/crates/tools/src/select/tests.rs b/crates/tools/src/select/tests.rs index d575fda573..e74e3d9163 100644 --- a/crates/tools/src/select/tests.rs +++ b/crates/tools/src/select/tests.rs @@ -1255,6 +1255,42 @@ fn an_alt_copy_snaps_to_the_original_left_behind() { assert_eq!(dx(&t.pointer(&c, &ev(PointerKind::Drag, 253.0, 150.0))), 103.0); } +/// With Use Preview Bounds on, Smart Guides line up the moved selection's geometric bounds with +/// the other art's, as they do with it off: an edge lands exactly on the other path's edge, and the +/// edge of a stroke does not pull it there (#6436). +#[test] +fn a_move_lines_up_geometric_edges_with_use_preview_bounds_on() { + use vectorcraft_color::{Color, Paint}; + use vectorcraft_doc::{Appearance, Node}; + // An artboard whose edges and center are out of reach, and two rectangles stroked 20 pt. + let mut d = Document::new(1000.0, 1000.0); + let l = d.layers[0].id; + let mut add = |r: Rect| { + let id = d.alloc_id(); + let wide = Appearance::basic(Paint::solid(Color::WHITE), Paint::solid(Color::BLACK), 20.0); + d.insert(Some(l), 0, Node::path(id, vectorcraft_geom::shapes::rectangle(r), wide)).unwrap(); + id + }; + let a = add(Rect::new(100.0, 100.0, 200.0, 200.0)); + add(Rect::new(300.0, 100.0, 400.0, 200.0)); + let s = Selection { objects: vec![a], ..Default::default() }; + let p = paint(); + for preview in [false, true] { + let c = ToolContext { preview_bounds: preview, ..cx(&d, &s, &p) }; + let dragged = |to: f64| { + let mut t = SelectionTool::default(); + t.pointer(&c, &ev(PointerKind::Down, 150.0, 150.0)); + let a = t.pointer(&c, &ev(PointerKind::Drag, to, 150.0)); + let Some(Action::Preview(_, v)) = a.last() else { panic!("{a:?}") }; + (v["matrix"][4].as_f64().unwrap(), v["matrix"][5].as_f64().unwrap()) + }; + // The right edge, 1 pt short of the other rectangle's left edge (x = 300), lands on it. + assert_eq!(dragged(249.0), (100.0, 0.0), "preview {preview}"); + // 9 pt short, it stays where it is dragged, though the edge of its stroke is 1 pt past there. + assert_eq!(dragged(241.0), (91.0, 0.0), "preview {preview}"); + } +} + /// Smart Guides › Snap to Last Location: a move that comes within Snapping Tolerance of where it /// began goes back there, labeled "last location", a Shift move too; farther out, with the option /// or Smart Guides off, it stays where it is dragged, and an Alt copy snaps as it does with the From c7893667de56f834ffb92ae5aa0848fa91438059 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 28 Nov 2026 09:35:35 -0800 Subject: [PATCH 07/25] Fix #5311: on Wayland with no cursor theme, the tool cursor is not painted beside the system pointer The framework port removed the check for a missing cursor theme. The framework's cursor service paints a tool cursor only while the shell has Caps::SYSTEM_CURSOR, and the shell always had it on Linux. On a Wayland session where no cursor theme loads, winit cannot hide or set the pointer, so the compositor's pointer stayed and the tool cursor was painted next to it. cursor_theme.rs gets theme_usable and theme_missing back, and shell_caps leaves out Caps::SYSTEM_CURSOR on Wayland when no theme loads. The window then shows the system pointer alone, as it did before the port (#5734). Sessions with a cursor theme, X11 and XWayland are unchanged. --- apps/vectorcraft/src/cursor_theme.rs | 111 +++++++++++++++++++++++++++ apps/vectorcraft/src/main.rs | 5 ++ 2 files changed, 116 insertions(+) diff --git a/apps/vectorcraft/src/cursor_theme.rs b/apps/vectorcraft/src/cursor_theme.rs index b23d1099db..ce044dded4 100644 --- a/apps/vectorcraft/src/cursor_theme.rs +++ b/apps/vectorcraft/src/cursor_theme.rs @@ -7,11 +7,17 @@ //! fails in a Flatpak sandbox (`XCURSOR_PATH` unset, no cursor theme in the runtime) and where the //! `default` theme is a dangling symlink; the desktop's own setting names a theme that loads. //! +//! Where no cursor theme can be found at all (KDE or sway without gsettings), the env fix does +//! nothing: [`shell_caps`] leaves out [`Caps::SYSTEM_CURSOR`], and the framework keeps the system +//! pointer and paints no tool cursor beside it (#5311). +//! //! This reads the desktop's cursor theme and size and sets what the user left unset, once, before //! any thread starts and before the window opens. #![cfg_attr(not(target_os = "linux"), allow(dead_code))] +use craft::host::target::Caps; use std::ffi::OsString; +use std::path::{Path, PathBuf}; /// Where a Flatpak sandbox mounts the host's cursor themes (user and system). const FLATPAK_HOST_ICONS: [&str; 2] = ["/run/host/user-share/icons", "/run/host/share/icons"]; @@ -48,6 +54,74 @@ pub fn plan(var: impl Fn(&str) -> Option, host_icons: &[&str], desktop out } +/// Xcursor's default search path when `XCURSOR_PATH` is unset (relative entries are in `$HOME`). +const DEFAULT_ICON_DIRS: [&str; 5] = ["~/.local/share/icons", "~/.icons", "/usr/share/icons", "/usr/share/pixmaps", "/usr/X11R6/lib/X11/icons"]; + +/// The themes `index.theme` lists after `Inherits=`. +fn inherits(index: &str) -> Vec { + index + .lines() + .find_map(|l| l.trim().strip_prefix("Inherits=")) + .map(|v| v.split([',', ';']).map(|t| t.trim().to_owned()).filter(|t| !t.is_empty()).collect()) + .unwrap_or_default() +} + +/// Can Xcursor load a pointer for the environment's theme (`XCURSOR_THEME`, else `default`)? It does +/// when the theme, or one it inherits from, has a `default` or `left_ptr` cursor file in a folder of +/// `XCURSOR_PATH` (else Xcursor's default folders). `read` returns a file's text, `exists` tells +/// whether a file is there. +pub fn theme_usable( + var: impl Fn(&str) -> Option, + home: Option<&Path>, + read: impl Fn(&Path) -> Option, + exists: impl Fn(&Path) -> bool, +) -> bool { + let dirs: Vec = match var("XCURSOR_PATH").filter(|v| !v.is_empty()) { + Some(v) => std::env::split_paths(&v).collect(), + None => DEFAULT_ICON_DIRS + .iter() + .filter_map(|d| match d.strip_prefix("~/") { + Some(rest) => home.map(|h| h.join(rest)), + None => Some(PathBuf::from(d)), + }) + .collect(), + }; + let first = var("XCURSOR_THEME").and_then(|v| v.into_string().ok()).filter(|t| !t.is_empty()).unwrap_or_else(|| "default".into()); + let mut todo = vec![first]; + let mut seen: Vec = Vec::new(); + while let Some(theme) = todo.pop() { + // Bounded: themes inherit in short chains, and a cycle must end. + if seen.contains(&theme) || seen.len() >= 16 { + continue; + } + for dir in &dirs { + let base = dir.join(&theme); + if ["default", "left_ptr"].iter().any(|c| exists(&base.join("cursors").join(c))) { + return true; + } + if let Some(index) = read(&base.join("index.theme")) { + todo.extend(inherits(&index)); + } + } + seen.push(theme); + } + false +} + +/// On this machine, after [`apply`]: is there no cursor theme Xcursor can load? Then winit never +/// sets a pointer, and a hidden system pointer does not come back (#2450). +pub fn theme_missing() -> bool { + let home = std::env::var_os("HOME").filter(|h| !h.is_empty()).map(PathBuf::from); + !theme_usable(|n| std::env::var_os(n), home.as_deref(), |p| std::fs::read_to_string(p).ok(), |p| p.exists()) +} + +/// The shell's capabilities `caps`, without [`Caps::SYSTEM_CURSOR`] when the window opens on +/// Wayland and `theme_missing` finds no cursor theme. The framework then keeps the system pointer +/// and paints no tool cursor beside it (#5311). `theme_missing` runs only on Wayland. +pub fn shell_caps(caps: Caps, wayland: bool, theme_missing: impl FnOnce() -> bool) -> Caps { + if wayland && theme_missing() { caps.difference(Caps::SYSTEM_CURSOR) } else { caps } +} + /// The value of a `gsettings get` line: `'Adwaita'` becomes `Adwaita`, `24` stays `24`. fn gsettings_value(output: &str) -> &str { output.trim().trim_matches('\'') @@ -113,6 +187,43 @@ mod tests { assert!(plan(env(&[("WAYLAND_DISPLAY", "wayland-0")]), &[], odd).is_empty()); } + #[test] + fn a_theme_is_usable_directly_or_through_inherits_and_missing_otherwise() { + let files = ["/i/Bibata/cursors/left_ptr", "/i/Breeze/index.theme", "/i/Loop/index.theme"]; + // Compared as paths, so the joins match on Windows too, where they use `\`. + let exists = |p: &Path| files.iter().any(|f| Path::new(f) == p); + let read = |p: &Path| { + if p == Path::new("/i/Breeze/index.theme") { + Some("[Icon Theme]\nInherits=Other, Bibata\n".to_owned()) + } else if p == Path::new("/i/Loop/index.theme") { + Some("Inherits=Loop\n".to_owned()) + } else { + None + } + }; + let with = |theme: &'static str| { + move |n: &str| (n == "XCURSOR_PATH").then(|| OsString::from("/i")).or((n == "XCURSOR_THEME").then(|| OsString::from(theme))) + }; + assert!(theme_usable(with("Bibata"), None, read, exists)); + assert!(theme_usable(with("Breeze"), None, read, exists)); + // No such theme, a theme without cursors, an inheritance loop: nothing to load. + assert!(!theme_usable(with("Nope"), None, read, exists)); + assert!(!theme_usable(with("Loop"), None, read, exists)); + // Unset: Xcursor's default folders and the `default` theme. + assert!(!theme_usable(|_| None, Some(Path::new("/home/u")), read, exists)); + } + + #[test] + fn without_a_cursor_theme_on_wayland_the_system_pointer_stays_alone() { + let native = Caps::native(craft::host::target::Os::Linux); + assert!(native.contains(Caps::SYSTEM_CURSOR)); + let without = shell_caps(native, true, || true); + assert!(!without.contains(Caps::SYSTEM_CURSOR), "Wayland with no cursor theme: no painted cursor beside the system pointer"); + assert_eq!(without.union(Caps::SYSTEM_CURSOR), native, "only the system cursor is left out"); + assert_eq!(shell_caps(native, true, || false), native, "Wayland with a theme"); + assert_eq!(shell_caps(native, false, || panic!("the theme is looked up only on Wayland")), native, "X11 and XWayland"); + } + #[test] fn gsettings_output_is_unquoted() { assert_eq!(gsettings_value("'Adwaita'\n"), "Adwaita"); diff --git a/apps/vectorcraft/src/main.rs b/apps/vectorcraft/src/main.rs index 872753f9d7..7812264ac0 100644 --- a/apps/vectorcraft/src/main.rs +++ b/apps/vectorcraft/src/main.rs @@ -667,6 +667,11 @@ fn main() -> std::process::ExitCode { // framework decides the frame for that backend, from the platform, `VECTORCRAFT_TITLEBAR` and // Preferences › User Interface › System Title Bar. let shell_info = if forced_to_x11 { ShellInfo::current().backend(Backend::X11) } else { ShellInfo::current() }; + // On Wayland with no cursor theme, the system pointer stays and no tool cursor is painted + // beside it (#2450, #5311). + let wayland = !forced_to_x11 && Backend::from_env() == Backend::Wayland; + let caps = cursor_theme::shell_caps(shell_info.caps, wayland, cursor_theme::theme_missing); + let shell_info = shell_info.caps(caps); let titlebar_pref = if engine_pref("systemTitleBar").and_then(|v| v.as_bool()).unwrap_or(false) { TitleBarPref::System } else { TitleBarPref::Integrated }; let decision = decide_for(Prefix::new("VECTORCRAFT"), shell_info.backend, titlebar_pref); From 84d8e06f8ac248963694b6f786f0a038fa64d1c4 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 28 Nov 2026 09:36:34 -0800 Subject: [PATCH 08/25] Global Edit: options popover groups its options a stack gap apart The Global Edit Options popover (Properties panel and Control bar) laid its two captions, five options and the Results line out as one flat column, so the On Artboards caption sat closer to the Size option than to its own options. Match and On Artboards are now field groups in a stack with the framework's stack gap between the groups and before the Results line. Clicks are kept and run after the stack returns. --- .../panels/properties/appearance_section.rs | 59 +++++++++++-------- crates/ui-egui/src/panels/properties/tests.rs | 28 +++++++++ 2 files changed, 64 insertions(+), 23 deletions(-) diff --git a/crates/ui-egui/src/panels/properties/appearance_section.rs b/crates/ui-egui/src/panels/properties/appearance_section.rs index bd0c4d68b2..9d31bb0385 100644 --- a/crates/ui-egui/src/panels/properties/appearance_section.rs +++ b/crates/ui-egui/src/panels/properties/appearance_section.rs @@ -5,10 +5,10 @@ use craft::behavior::IconId; use craft::keymap::CommandRef; use craft::ui::buttons::{Button, IconButton}; use craft::ui::choice::Checkbox; -use craft::ui::contract::{Bind, LabelScheme, Props as _, Show as _, ShowContainer as _, Sizing, Trigger, clicked}; +use craft::ui::contract::{Bind, Gap, LabelScheme, Props as _, Show as _, ShowContainer as _, Sizing, Trigger, clicked}; use craft::ui::display::{Elide, Shade, Text}; -use craft::ui::form::Field; -use craft::ui::layout_components::Row; +use craft::ui::form::{Field, FieldGroup}; +use craft::ui::layout_components::{Row, Stack}; use craft::ui::menu::Menu; use craft::ui::popover::Popover; use craft::ui::style::TypeRole; @@ -194,27 +194,40 @@ pub(crate) fn global_edit_options(app: &mut VectorcraftApp, ui: &mut Ui) { let caption = |ui: &mut Ui, text: &'static str| { Text::new(text).role(TypeRole::Caption).shade(Shade::Muted).show(ui); }; - caption(ui, tl!("Match")); - if let Some(on) = option_check(ui, tl!("Appearance"), o.appearance) { - set(app, json!({ "appearance": on })); + let results = global_edit_results(global_edit_count(app)); + // Each group is its caption over its options a row gap apart; the groups and the Results line are a stack gap + // apart. A click is kept and run after the stack returns. + let mut changes = Vec::new(); + Stack::new().gap(Gap::Stack).show(ui, |ui, _| { + FieldGroup::new(tl!("Match")).show(ui, |ui, _| { + caption(ui, tl!("Match")); + if let Some(on) = option_check(ui, tl!("Appearance"), o.appearance) { + changes.push(json!({ "appearance": on })); + } + if let Some(on) = option_check(ui, tl!("Size"), o.size) { + changes.push(json!({ "size": on })); + } + }); + FieldGroup::new(tl!("On Artboards")).show(ui, |ui, _| { + caption(ui, tl!("On Artboards")); + if let Some(all) = option_check(ui, tl!("All Artboards"), o.artboards.is_none()) { + changes.push(json!({ "artboards": if all { "all" } else { "1" } })); + } + if let Some(range) = &o.artboards { + let typed = Field::new(tl!("Range:")).show(ui, |ui, _| TextField::new(tl!("Range:"), Bind::given(range.clone())).show(ui)).inner; + if let Some(range) = typed.and_then(|t| t.events.committed().cloned()) { + changes.push(json!({ "artboards": range })); + } + } + if let Some(on) = option_check(ui, tl!("Include Objects On Canvas"), o.include_canvas) { + changes.push(json!({ "includeCanvas": on })); + } + }); + Text::new(results.clone()).shade(Shade::Muted).show(ui); + }); + for p in changes { + set(app, p); } - if let Some(on) = option_check(ui, tl!("Size"), o.size) { - set(app, json!({ "size": on })); - } - caption(ui, tl!("On Artboards")); - if let Some(all) = option_check(ui, tl!("All Artboards"), o.artboards.is_none()) { - set(app, json!({ "artboards": if all { "all" } else { "1" } })); - } - if let Some(range) = &o.artboards { - let typed = Field::new(tl!("Range:")).show(ui, |ui, _| TextField::new(tl!("Range:"), Bind::given(range.clone())).show(ui)).inner; - if let Some(range) = typed.and_then(|t| t.events.committed().cloned()) { - set(app, json!({ "artboards": range })); - } - } - if let Some(on) = option_check(ui, tl!("Include Objects On Canvas"), o.include_canvas) { - set(app, json!({ "includeCanvas": on })); - } - Text::new(global_edit_results(global_edit_count(app))).shade(Shade::Muted).show(ui); } /// The options' line with how many objects Start Global Edit would take, in the interface language. diff --git a/crates/ui-egui/src/panels/properties/tests.rs b/crates/ui-egui/src/panels/properties/tests.rs index ea8850d332..bb90289aef 100644 --- a/crates/ui-egui/src/panels/properties/tests.rs +++ b/crates/ui-egui/src/panels/properties/tests.rs @@ -181,6 +181,34 @@ fn global_edit_starting_closes_the_quick_action_options() { assert!(!panel.app().ui.properties_panel.global_edit_open && !panel.shows(&results), "the options stay closed once Global Edit stops"); } +/// The Global Edit Options are two groups, Match and On Artboards, and the Results line: the On Artboards caption is a +/// stack gap below the Size option, and the Results line a stack gap below Include Objects On Canvas. +#[test] +fn global_edit_options_groups_are_a_stack_gap_apart() { + use craft::ui::contract::Role; + crate::i18n::set_current(crate::i18n::Lang::EN); + let stack = std::rc::Rc::new(std::cell::Cell::new(0.0)); + let seen = std::rc::Rc::clone(&stack); + craft::ui::testing::Fixture::new(move |ui| seen.set(craft::ui::runtime::env::Env::of(ui).tokens.space.gap.stack)).frame(vec![]); + let stack = stack.get(); + assert!(stack > 0.0, "the interface resolved its stack gap"); + let mut app = new_app(); + let a = rect(&mut app, 20.0, 20.0, 40.0, 40.0); + rect(&mut app, 200.0, 20.0, 40.0, 40.0); + app.run("select.set", json!({"ids": [a]})).unwrap(); + let mut panel = Panel::new(app, super::appearance_section::global_edit_row); + panel.click("Global Edit Options"); + let results = global_edit_results(2); + assert!(panel.shows(&results), "the options open"); + let size = panel.rect_role("Size", Role::CHECK_BOX); + let caption = panel.rect_role("On Artboards", Role::LABEL); + let canvas = panel.rect_role("Include Objects On Canvas", Role::CHECK_BOX); + let line = panel.rect(&results); + let (above, below) = (caption.top() - size.bottom(), line.top() - canvas.bottom()); + assert!(above >= stack - 0.5, "On Artboards is {above} below Size, under the stack gap {stack}"); + assert!(below >= stack - 0.5, "Results is {below} below the last option, under the stack gap {stack}"); +} + /// The options' Results count is found once per document revision, options and selected /// object, not every frame; another selected object or other options find it again. #[test] From 84eef86c0afa571d5acfb952e849b306bff571bd Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 28 Nov 2026 09:39:38 -0800 Subject: [PATCH 09/25] UI: dialog option rows stand beside or under their choice - Transform effect: the Scale, Move and Rotate rows span the dialog instead of sitting behind a "Transform" label, and Reflect X, Reflect Y and Random show their names (the boxes were unlabeled). - Transform Each: the reference point picker shows its name. - Zig Zag, Roughen and Tweak: Relative and Absolute stand on one line, and so do Smooth and Corner. - Corners: Relative and Absolute stand on one line. - Drop Shadow: the color well stands under Color and the Darkness field under Darkness. - Print: the Range field stands under the Range choice instead of after Ignore Artboards. Each uses the form's own radio layouts (options_in_row, under_option) and plain check box rows. Tests in tests/dialog_layout.rs check where the dialogs paint these rows. --- crates/ui-egui/src/dialogs/corners.rs | 7 +- crates/ui-egui/src/dialogs/effect_rows.rs | 18 ++- crates/ui-egui/src/dialogs/print.rs | 5 +- crates/ui-egui/src/dialogs/transform_each.rs | 11 +- crates/ui-egui/src/tests.rs | 1 + crates/ui-egui/src/tests/dialog_layout.rs | 138 +++++++++++++++++++ 6 files changed, 169 insertions(+), 11 deletions(-) create mode 100644 crates/ui-egui/src/tests/dialog_layout.rs diff --git a/crates/ui-egui/src/dialogs/corners.rs b/crates/ui-egui/src/dialogs/corners.rs index 9c4ee9e4f4..1f330a64b6 100644 --- a/crates/ui-egui/src/dialogs/corners.rs +++ b/crates/ui-egui/src/dialogs/corners.rs @@ -87,8 +87,11 @@ fn dialog<'a>(relative: bool, lengths: LengthUnits) -> ParamDialog<'a> { Param::number("radius", tl!("Radius:"), 0.0, 1.0, 3).length(lengths).bounds(Some(0.0), None) }; let radii = vec![("relative".to_owned(), tl!("Relative").into()), ("absolute".to_owned(), tl!("Absolute").into())]; - let params = - vec![Param::new("kind", tl!("Corner:"), ParamKind::radio(kinds, None)), Param::new("radii", "", ParamKind::radio(radii, None)), radius]; + let params = vec![ + Param::new("kind", tl!("Corner:"), ParamKind::radio(kinds, None)), + Param::new("radii", "", ParamKind::radio(radii, None)).options_in_row(), + radius, + ]; ParamDialog::new(KIND, tl!("Corners"), params) } diff --git a/crates/ui-egui/src/dialogs/effect_rows.rs b/crates/ui-egui/src/dialogs/effect_rows.rs index e8eeacd29c..9ba4858116 100644 --- a/crates/ui-egui/src/dialogs/effect_rows.rs +++ b/crates/ui-egui/src/dialogs/effect_rows.rs @@ -58,7 +58,7 @@ fn sized_row(key: &str, label: Label, default: f64, relative: bool, lengths: Len /// the flag's JSON values, which `form::json_of` writes back as a bool. pub(super) fn relative_radio(label: impl Into