From 799861166356e2039952daee09b4c6245d9e1ced Mon Sep 17 00:00:00 2001 From: mocenigo Date: Mon, 23 Nov 2026 19:44:49 +0100 Subject: [PATCH 01/21] pages: no horizontal scroll bar while the pages fit the view's width The view can't scroll sideways then (the offset is clamped to one value), so the bar only showed a thumb filling its track. It comes back when a zoom makes the pages wider. --- crates/pages/src/ui/view.rs | 2 ++ crates/pages/tests/it/views.rs | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/crates/pages/src/ui/view.rs b/crates/pages/src/ui/view.rs index 59bb08827..e8aee6298 100644 --- a/crates/pages/src/ui/view.rs +++ b/crates/pages/src/ui/view.rs @@ -912,6 +912,8 @@ fn run_pass(ui: &mut Ui, cx: &mut BodyCx<'_>, held: &mut Held<'_, PageViewState> let document = drawn_frame.document(&drawn); let (xs, ys) = (offset_range(geo.doc.x0, geo.doc.x1, vw), offset_range(geo.doc.y0, geo.doc.y1, vh)); let bars = CanvasScrollbars::new(words.scroll_bars.clone(), Bind::given(shown), DocRect::from_origin_size(Point::ZERO, document)); + // Pages that fit the view's width can't scroll sideways, so there is no horizontal bar. + let bars = if xs.0 >= xs.1 { bars.vertical_only() } else { bars }; // The tip names the page at the top of the view the thumb moved to: the bars ask for it once they know the move. let format = env.format(); let tip = |moved: &CanvasView| { diff --git a/crates/pages/tests/it/views.rs b/crates/pages/tests/it/views.rs index 8a8f04cd6..ccc69519e 100644 --- a/crates/pages/tests/it/views.rs +++ b/crates/pages/tests/it/views.rs @@ -49,6 +49,24 @@ fn layout_rig(count: usize, start: PageViewState) -> LayoutRig { (fixture, state, rects) } +/// Whether the view shows a horizontal scroll bar at `zoom` in a window 900 wide. +fn has_horizontal_bar(zoom: f64) -> bool { + let (fixture, _, _) = layout_rig( + 3, + state_with(|s| { + s.fit = Fit::None; + s.zoom = zoom; + }), + ); + fixture.by_role(Role::SCROLL_BAR).iter().any(|bar| bar.rect.width() > bar.rect.height()) +} + +#[trial] +fn the_horizontal_bar_shows_only_when_the_pages_are_wider_than_the_view() { + assert!(!has_horizontal_bar(0.5), "pages that fit the width need no horizontal bar"); + assert!(has_horizontal_bar(3.0), "pages wider than the view scroll sideways"); +} + #[trial] fn a_changed_zoom_keeps_the_page_at_the_top_in_place() { let (mut fixture, state, rects) = layout_rig( From e3385de040ea7cc7418d9eb9e47bee13c13c21a4 Mon Sep 17 00:00:00 2001 From: batistalucasv Date: Mon, 23 Nov 2026 23:37:10 -0300 Subject: [PATCH 02/21] font-manager: use filled warning triangle icon in FontPicker (storytold/wordcraft#7684) --- crates/font-manager/src/picker.rs | 2 +- crates/font-manager/tests/it/picker.rs | 58 +++++++++++++++++++ crates/ui-contract/icons/ATTRIBUTION.md | 2 +- crates/ui-contract/icons/icons.toml | 5 ++ .../icons/phosphor/warning-filled.svg | 1 + 5 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 crates/ui-contract/icons/phosphor/warning-filled.svg diff --git a/crates/font-manager/src/picker.rs b/crates/font-manager/src/picker.rs index 887faf69c..ee4dc6444 100644 --- a/crates/font-manager/src/picker.rs +++ b/crates/font-manager/src/picker.rs @@ -531,7 +531,7 @@ const TEXT: PartKey = PartKey::new("text"); const CHEVRON: PartKey = PartKey::new("chevron"); /// The mark before the chevron of a shown font that is not installed; its tooltip is the note. const WARNING: PartKey = PartKey::new("missing"); -const WARNING_ICON: &str = "warning"; +const WARNING_ICON: &str = "warning_filled"; /// The popup the chevron and Alt+Down toggle. const POPUP: &str = "list"; /// The Show Similar part at the end of a family row, in the `Chips` layout. diff --git a/crates/font-manager/tests/it/picker.rs b/crates/font-manager/tests/it/picker.rs index 5b1f60c26..583d16830 100644 --- a/crates/font-manager/tests/it/picker.rs +++ b/crates/font-manager/tests/it/picker.rs @@ -798,6 +798,64 @@ fn the_missing_font_warning_icon_paints_in_status_warn_fg_and_dims_when_disabled ); } +/// Texture ids of textured meshes whose centre falls inside `rect`. +fn mesh_textures(shapes: &[egui::Shape], rect: egui::Rect, out: &mut Vec) { + for shape in shapes { + match shape { + egui::Shape::Vec(inner) => mesh_textures(inner, rect, out), + egui::Shape::Mesh(mesh) if rect.contains(mesh.calc_bounds().center()) => { + out.push(mesh.texture_id); + } + _ => {} + } + } +} + +#[trial] +fn the_missing_font_warning_icon_is_a_filled_triangle() { + use std::cell::Cell; + + let catalog = catalog_of(&[INTER_REGULAR]); + let seen = Rc::new(Cell::new(None)); + let held = Rc::clone(&seen); + let mut family = "Gotham".to_owned(); + let mut fx = Fixture::new(move |ui| { + let out = FontPicker::new("Font family", Bind::bound(&mut family), &catalog).kind(FontPickerKind::Plain).shown_as("Inter").show(ui); + held.set(Some(out.edit.response.id)); + }); + fx.pixels_per_point(2.0); + fx.record_paint(); + fx.in_room(Room::Window); + fx.settle(); + let picker = seen.get().expect("the picker"); + let mark = fx.part_rect(picker, PartKey::new("missing")).expect("the field carries a mark while the family is not installed"); + let mut paint = fx.take_paint().expect("recorded paint output"); + let mut textures = Vec::new(); + for clipped in &paint.shapes { + mesh_textures(std::slice::from_ref(&clipped.shape), mark, &mut textures); + } + let texture = *textures.first().expect("the missing-font warning icon paints a texture"); + let image = paint + .textures_delta + .set + .get(&texture) + .and_then(|deltas| deltas.last()) + .map(|delta| match &delta.image { + egui::ImageData::Color(color) => color, + }) + .expect("the warning icon texture was uploaded"); + let [w, h] = image.size; + let alpha = |fx: f32, fy: f32| { + let x = ((w as f32 * fx) as usize).min(w - 1); + let y = ((h as f32 * fy) as usize).min(h - 1); + image.pixels[y * w + x].a() + }; + let (left, right, center) = (alpha(0.34, 0.69), alpha(0.66, 0.69), alpha(0.50, 0.48)); + paint.textures_delta.clear(); + assert!(left > 128 && right > 128, "the triangle interior is filled, not an outline (left={left}, right={right}, size={w}x{h})"); + assert!(center < 128, "the exclamation stem stays knocked out inside the filled triangle (center={center})"); +} + /// The library picker's family and settings, as the last pass left them. struct Library { family: String, diff --git a/crates/ui-contract/icons/ATTRIBUTION.md b/crates/ui-contract/icons/ATTRIBUTION.md index 4579d05c9..7baac2bd3 100644 --- a/crates/ui-contract/icons/ATTRIBUTION.md +++ b/crates/ui-contract/icons/ATTRIBUTION.md @@ -11,7 +11,7 @@ Each folder holds only the files `icons.toml` lists, unchanged from the pinned s Carbon's licence file is the repository's root `LICENSE` (the icons package has none of its own). -Every set folder's files come from the npm package of the version in the table (`@phosphor-icons/core` 2.0.8, `lucide-static` 1.63.0, `@carbon/icons` 11.91.0, `@tabler/icons` 3.50.0), the same releases as the tags above. Phosphor files are `regular` weight, except `star-filled.svg` and `circle-filled.svg`, which are Phosphor's `fill` weight (`star-fill.svg`, `circle-fill.svg`). `panel-left.svg` is Phosphor's `sidebar-simple` unchanged, and `panel-right.svg` is the same glyph mirrored. +Every set folder's files come from the npm package of the version in the table (`@phosphor-icons/core` 2.0.8, `lucide-static` 1.63.0, `@carbon/icons` 11.91.0, `@tabler/icons` 3.50.0), the same releases as the tags above. Phosphor files are `regular` weight, except `star-filled.svg`, `circle-filled.svg` and `warning-filled.svg`, which are Phosphor's `fill` weight (`star-fill.svg`, `circle-fill.svg`, `warning-fill.svg`). `panel-left.svg` is Phosphor's `sidebar-simple` unchanged, and `panel-right.svg` is the same glyph mirrored. `phosphor/` also holds drawings made for the suite, for glyphs the pinned Phosphor release lacks. They follow Phosphor's regular style (256 view box, 16-unit round-capped strokes, some converted to filled outlines), take their shapes from PhotoCraft's glyphs, and carry the suite's own licence: diff --git a/crates/ui-contract/icons/icons.toml b/crates/ui-contract/icons/icons.toml index 2a324cd10..7fdd9233c 100644 --- a/crates/ui-contract/icons/icons.toml +++ b/crates/ui-contract/icons/icons.toml @@ -454,6 +454,11 @@ phosphor = "warning" carbon = "warning--alt" tabler = "alert-triangle" +[[icon]] +name = "warning_filled" +directional = false +phosphor = "warning-filled" + [[icon]] name = "web_colors" directional = false diff --git a/crates/ui-contract/icons/phosphor/warning-filled.svg b/crates/ui-contract/icons/phosphor/warning-filled.svg new file mode 100644 index 000000000..f8ada0ad2 --- /dev/null +++ b/crates/ui-contract/icons/phosphor/warning-filled.svg @@ -0,0 +1 @@ + \ No newline at end of file From e7e8785fff8ba5aebd8e349bff6806639fde64a2 Mon Sep 17 00:00:00 2001 From: mocenigo Date: Tue, 24 Nov 2026 12:33:11 +0100 Subject: [PATCH 03/21] ui-canvas: a held horizontal thumb keeps its bar until the press ends With vertical_only set while the thumb drags (the page view's pages came to fit the width mid-drag), the bar went and its release never reached it: the drag's edit stayed open and the held extent stayed in the press slot. --- crates/pages/tests/it/views.rs | 25 +++++++++++++++++++ crates/ui-canvas/src/canvas/scrollbars/mod.rs | 4 ++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/crates/pages/tests/it/views.rs b/crates/pages/tests/it/views.rs index 3028d4fd7..0042c2793 100644 --- a/crates/pages/tests/it/views.rs +++ b/crates/pages/tests/it/views.rs @@ -433,6 +433,31 @@ fn assert_centre_kept(out: &Out, before: (usize, kurbo::Point), what: &str) { /// A written zoom keeps the point at the centre; a new room (a panel opened beside the view) refits and keeps the /// current page's top where it was, as production did. +/// The horizontal scroll bar the fixture shows, if any. +fn horizontal_bar(fixture: &Fixture) -> Option { + fixture.by_role(Role::SCROLL_BAR).iter().map(|bar| bar.rect).find(|rect| rect.width() > rect.height()) +} + +#[trial] +fn a_horizontal_thumb_held_while_the_pages_come_to_fit_keeps_its_bar_until_the_release() { + let (mut fixture, state, _) = layout_rig( + 3, + state_with(|s| { + s.fit = Fit::None; + s.zoom = 3.0; + }), + ); + let bar = horizontal_bar(&fixture).expect("pages wider than the view have a horizontal bar"); + // The view starts at the left edge, so the thumb is at the start of the track. + let from = pos2(bar.left() + 4.0, bar.center().y); + fixture.drag_hold_at(from, vec2(20.0, 0.0)); + state.borrow_mut().zoom = 0.5; + fixture.idle(3); + assert!(horizontal_bar(&fixture).is_some(), "the held thumb keeps its bar, so its release reaches it"); + fixture.release_at(from + vec2(20.0, 0.0)).idle(2); + assert!(horizontal_bar(&fixture).is_none(), "after the release, pages that fit have no horizontal bar"); +} + #[trial] fn a_changed_zoom_keeps_the_point_at_the_centre_and_a_new_room_the_current_pages_top() { // The app's zoom. diff --git a/crates/ui-canvas/src/canvas/scrollbars/mod.rs b/crates/ui-canvas/src/canvas/scrollbars/mod.rs index f0d190d33..d8a0f97d2 100644 --- a/crates/ui-canvas/src/canvas/scrollbars/mod.rs +++ b/crates/ui-canvas/src/canvas/scrollbars/mod.rs @@ -477,7 +477,9 @@ impl<'a> CanvasScrollbars<'a> { } fn bars(&self, view: &CanvasView, rect: Rect, style: &ScrollbarsStyle, held: Option<&HeldThumb>) -> Bars { - Bars::of(view, self.document, self.overscroll, !self.vertical_only, rect, style, held) + // A horizontal thumb held keeps its bar until the press ends, so its release closes the drag. + let horizontal = !self.vertical_only || held.is_some_and(|held| held.on(Axis::X)); + Bars::of(view, self.document, self.overscroll, horizontal, rect, style, held) } } From 1d8dc6c2b3f0689b168a294b70a413e52601f2cf Mon Sep 17 00:00:00 2001 From: batistalucasv Date: Tue, 24 Nov 2026 11:42:10 -0300 Subject: [PATCH 04/21] ci: retest flaky automation test From ed1da0da5e7aa77ef299c98ef4d5a97c6bec17ef Mon Sep 17 00:00:00 2001 From: mocenigo Date: Tue, 24 Nov 2026 23:44:09 +0100 Subject: [PATCH 05/21] pages, ui-canvas: drop a held thumb's extent once its press ended unseen A full-screen view drops the bars, so a thumb released there never reached them and the extent stayed in the press slot; with the held-thumb guard, it would keep the horizontal bar up over pages that fit. The bars drop it as soon as they see the thumb idle again. Also moves the new test helper off the doc comment of the zoom test it had split, and has_horizontal_bar uses it. --- crates/pages/tests/it/views.rs | 85 +++++++++++++------ crates/ui-canvas/src/canvas/scrollbars/mod.rs | 10 +++ 2 files changed, 69 insertions(+), 26 deletions(-) diff --git a/crates/pages/tests/it/views.rs b/crates/pages/tests/it/views.rs index 0042c2793..f0ec0c2e8 100644 --- a/crates/pages/tests/it/views.rs +++ b/crates/pages/tests/it/views.rs @@ -116,7 +116,7 @@ fn has_horizontal_bar(zoom: f64) -> bool { s.zoom = zoom; }), ); - fixture.by_role(Role::SCROLL_BAR).iter().any(|bar| bar.rect.width() > bar.rect.height()) + horizontal_bar(&fixture).is_some() } #[trial] @@ -125,6 +125,64 @@ fn the_horizontal_bar_shows_only_when_the_pages_are_wider_than_the_view() { assert!(has_horizontal_bar(3.0), "pages wider than the view scroll sideways"); } +/// The horizontal scroll bar the fixture shows, if any. +fn horizontal_bar(fixture: &Fixture) -> Option { + fixture.by_role(Role::SCROLL_BAR).iter().map(|bar| bar.rect).find(|rect| rect.width() > rect.height()) +} + +#[trial] +fn a_horizontal_thumb_held_while_the_pages_come_to_fit_keeps_its_bar_until_the_release() { + let (mut fixture, state, _) = layout_rig( + 3, + state_with(|s| { + s.fit = Fit::None; + s.zoom = 3.0; + }), + ); + let bar = horizontal_bar(&fixture).expect("pages wider than the view have a horizontal bar"); + // The view starts at the left edge, so the thumb is at the start of the track. + let from = pos2(bar.left() + 4.0, bar.center().y); + fixture.drag_hold_at(from, vec2(20.0, 0.0)); + state.borrow_mut().zoom = 0.5; + fixture.idle(3); + assert!(horizontal_bar(&fixture).is_some(), "the held thumb keeps its bar, so its release reaches it"); + fixture.release_at(from + vec2(20.0, 0.0)).idle(2); + assert!(horizontal_bar(&fixture).is_none(), "after the release, pages that fit have no horizontal bar"); +} + +#[trial] +fn a_horizontal_thumb_released_while_the_bars_are_not_shown_leaves_no_bar_behind() { + let state = Rc::new(RefCell::new(state_with(|s| { + s.fit = Fit::None; + s.zoom = 3.0; + }))); + let full_screen = Rc::new(Cell::new(false)); + let (kept, edge_to_edge) = (Rc::clone(&state), Rc::clone(&full_screen)); + let pages = DemoPages::new(3); + let mut fixture = Fixture::new(move |ui| { + let mut now = kept.borrow().clone(); + PageView::new("Pages", &pages, &mut now, PAPER).options(LayoutOptions::ACROBAT).fill_screen(edge_to_edge.get()).show(ui, |_, _| ()); + *kept.borrow_mut() = now; + }); + fixture.room(vec2(900.0, 600.0)); + fixture.settle(); + let bar = horizontal_bar(&fixture).expect("pages wider than the view have a horizontal bar"); + let from = pos2(bar.left() + 4.0, bar.center().y); + fixture.drag_hold_at(from, vec2(20.0, 0.0)); + // Full screen mid-drag: the bars go, and the release can't reach them. + full_screen.set(true); + fixture.idle(2); + fixture.release_at(from + vec2(20.0, 0.0)).idle(2); + full_screen.set(false); + { + let mut state = state.borrow_mut(); + state.fit = Fit::None; + state.zoom = 0.5; + } + fixture.idle(3); + assert!(horizontal_bar(&fixture).is_none(), "a press that ended unseen leaves no horizontal bar over pages that fit"); +} + #[trial] fn go_to_a_narrow_page_brings_it_back_into_horizontal_view() { let Rig { mut fixture, state, out, .. } = rig_over( @@ -433,31 +491,6 @@ fn assert_centre_kept(out: &Out, before: (usize, kurbo::Point), what: &str) { /// A written zoom keeps the point at the centre; a new room (a panel opened beside the view) refits and keeps the /// current page's top where it was, as production did. -/// The horizontal scroll bar the fixture shows, if any. -fn horizontal_bar(fixture: &Fixture) -> Option { - fixture.by_role(Role::SCROLL_BAR).iter().map(|bar| bar.rect).find(|rect| rect.width() > rect.height()) -} - -#[trial] -fn a_horizontal_thumb_held_while_the_pages_come_to_fit_keeps_its_bar_until_the_release() { - let (mut fixture, state, _) = layout_rig( - 3, - state_with(|s| { - s.fit = Fit::None; - s.zoom = 3.0; - }), - ); - let bar = horizontal_bar(&fixture).expect("pages wider than the view have a horizontal bar"); - // The view starts at the left edge, so the thumb is at the start of the track. - let from = pos2(bar.left() + 4.0, bar.center().y); - fixture.drag_hold_at(from, vec2(20.0, 0.0)); - state.borrow_mut().zoom = 0.5; - fixture.idle(3); - assert!(horizontal_bar(&fixture).is_some(), "the held thumb keeps its bar, so its release reaches it"); - fixture.release_at(from + vec2(20.0, 0.0)).idle(2); - assert!(horizontal_bar(&fixture).is_none(), "after the release, pages that fit have no horizontal bar"); -} - #[trial] fn a_changed_zoom_keeps_the_point_at_the_centre_and_a_new_room_the_current_pages_top() { // The app's zoom. diff --git a/crates/ui-canvas/src/canvas/scrollbars/mod.rs b/crates/ui-canvas/src/canvas/scrollbars/mod.rs index d8a0f97d2..f4e30e5e3 100644 --- a/crates/ui-canvas/src/canvas/scrollbars/mod.rs +++ b/crates/ui-canvas/src/canvas/scrollbars/mod.rs @@ -549,6 +549,16 @@ impl Component for CanvasScrollbars<'_> { } let Some(view) = cx.value().copied() else { return }; let mut held = cx.press_slot::().clone(); + // A press that ended while the bars weren't shown (a full-screen view drops them) never reached them: its thumb + // is idle again, and the extent kept for it is stale. + let stale = held.as_ref().is_some_and(|held| { + let thumb = thumb_of(if held.horizontal { HORIZONTAL } else { VERTICAL }); + matches!(cx.part(thumb).press.phase, PressPhase::Idle | PressPhase::Hover) + }); + if stale { + *cx.press_slot::() = None; + held = None; + } let bars = self.bars(&view, cx.rect, cx.style, held.as_ref()); let mut ended = false; let rtl = cx.flow.is_rtl(); From 189716c2e81271f25f75f3a9b1c564d1d566c059 Mon Sep 17 00:00:00 2001 From: skylartaylor Date: Wed, 25 Nov 2026 07:01:05 +0100 Subject: [PATCH 06/21] ui-shell: the Column start stories use catalog icons for their links message-circle and git-branch are not catalog names, so the icon_ids test failed on next. The community link takes "note" (a chat bubble) and the source link "open". --- crates/ui-shell/src/shell/start/stories.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/ui-shell/src/shell/start/stories.rs b/crates/ui-shell/src/shell/start/stories.rs index 7c7eea8b3..7d5036201 100644 --- a/crates/ui-shell/src/shell/start/stories.rs +++ b/crates/ui-shell/src/shell/start/stories.rs @@ -211,9 +211,9 @@ fn page_templates() -> Vec