From b5928a182e41c14cc2d212ed7a2946d7c693b0cf Mon Sep 17 00:00:00 2001 From: Harrison Booth <73434116+Harrison-Booth@users.noreply.github.com> Date: Tue, 27 Oct 2026 19:50:52 -0500 Subject: [PATCH] Keep the File > New tiles inside the right margin in a narrow window (#1421) set_max_width(CONTENT_W) widened the page past the margin whenever the window was narrower than CONTENT_W, so the last tile in each row ran off the screen edge. --- crates/ui-egui/src/backstage.rs | 4 +++- crates/ui-egui/src/backstage/tests.rs | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/backstage.rs b/crates/ui-egui/src/backstage.rs index 8d91d121..1278e7d8 100644 --- a/crates/ui-egui/src/backstage.rs +++ b/crates/ui-egui/src/backstage.rs @@ -389,7 +389,9 @@ pub fn show(app: &mut SlideApp, ui: &mut Ui) { w.active.bg_stroke = Stroke::new(1.0, t.accent); egui::ScrollArea::vertical().auto_shrink([false, false]).show(ui, |ui| { egui::Frame::NONE.inner_margin(egui::Margin { left: 48, right: 36, top: 22, bottom: 32 }).show(ui, |ui| { - ui.set_max_width(CONTENT_W); + // set_max_width can also widen: in a window narrower than CONTENT_W it would push the + // page past the right margin and clip the tiles (#1421). + ui.set_max_width(ui.available_width().min(CONTENT_W)); if bs.page != Page::Home { ui.label(RichText::new(bs.page.label()).font(theme::bold(22.0)).color(t.text)); ui.add_space(16.0); diff --git a/crates/ui-egui/src/backstage/tests.rs b/crates/ui-egui/src/backstage/tests.rs index 78330b1b..00a4aec6 100644 --- a/crates/ui-egui/src/backstage/tests.rs +++ b/crates/ui-egui/src/backstage/tests.rs @@ -179,6 +179,25 @@ fn every_page_renders() { assert!(h.state_mut().run("app.backstage", json!({"page": "share"})).is_err(), "Share (cloud) isn't offered"); } +/// In a window narrower than the page's maximum width the New tiles stay inside the right margin (#1421). +#[test] +fn new_tiles_keep_the_right_margin_in_a_narrow_window() { + let mut h = Harness::builder().with_size(egui::vec2(1000.0, 900.0)).build_ui_state( + |ui, app: &mut SlideApp| { + app.logic(ui.ctx()); + app.ui(ui); + }, + new_app(), + ); + h.state_mut().run("app.backstage", json!({"page": "new"})).unwrap(); + h.run_steps(3); + let tiles = ["DeckCraft", "Harbor", "Ember", "Meadow", "Nocturne", "Paper", "Briefing"]; + for label in tiles { + let r = h.get_by_label(label).rect(); + assert!(r.right() <= 1000.0 - 36.0, "{label} ends at {}, inside the 36pt right margin", r.right()); + } +} + /// A starter template from File › New opens its deck and leaves the File tab. #[test] fn new_template_opens_a_starter_deck() {