mirror of
https://github.com/storytold/deckcraft.git
synced 2026-10-30 21:47:00 -06:00
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.
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user