Backstage New, Home and Open pages at production's sizes

New and Home tiles at production's 160x90 (blank 200x112) with names in
body text (TileGrid CaptionType::Body); Home's New and Templates headings
are plain page headings with their links, no fold or rule (test). Open:
the Presentations heading is a page section (RecentList::heading_sections)
and the search field keeps one width from LeastWidth::Palette. Home icon
at the medium thumbnail size.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Dylan M. Taylor
2026-11-29 22:47:32 +00:00
co-authored by Claude Opus 5.5
parent 5a3bae4cc0
commit 2fde397a0a
2 changed files with 55 additions and 17 deletions
+38 -17
View File
@@ -6,16 +6,16 @@ use craft::ui::contract::{
ActivateOn, Bind, BodyCx, CollectionEvent, LeastWidth, Props as _, SelectMode, Show as _, ShowCollection as _, ShowContainer as _, Sizing,
clicked,
};
use craft::ui::display::{Divider, Picture, Shade, Text};
use craft::ui::display::{Divider, Picture, PictureSize, Shade, Text};
use craft::ui::layout_components::{Row, Stack};
use craft::ui::list::{List, ListRow, ThumbAspect};
use craft::ui::list::{List, ListRow, ThumbAspect, ThumbSize};
use craft::ui::runtime::env::with_env;
use craft::ui::sections::Section;
use craft::ui::sections::{HeaderStrength, Section};
use craft::ui::shell::{RecentFile, RecentList, RecentRemove, StartAction};
use craft::ui::style::TypeRole;
use craft::ui::text::TextField;
use craft::ui::tile_grid::{CaptionPlace, GridZoom, Tile, TileGrid};
use craft::ui::tile_grid::{CaptionPlace, CaptionType, GridZoom, Tile, TileGrid};
use super::{Backstage, Icon, Outcome, Page, SlideApp, Ui, Value, json};
@@ -78,17 +78,21 @@ fn template_tiles(query: &str, limit: usize) -> Vec<NewTile> {
.collect()
}
/// The blank presentation's picture against a theme's: production's New page shows it larger, 200 wide to 160.
const BLANK_ZOOM: f64 = 1.25;
/// Production's New and Home pages show a theme's picture 160 wide, against the card thumbnail's 128.
const THEME_ZOOM: f64 = 1.25;
/// Shows `tiles` as pictures with their names under them, on two lines before a long name is cut; `zoom` scales the
/// card thumbnail.
/// The blank presentation's picture against the card thumbnail: production's New page shows it 200 wide.
const BLANK_ZOOM: f64 = 1.5625;
/// Shows `tiles` as pictures with their names under them in body text, on two lines before a long name is cut; `zoom`
/// scales the card thumbnail.
fn show_tiles(app: &mut SlideApp, ui: &mut Ui, label: &'static str, tiles: &[NewTile], zoom: f64) {
let source = keyed(tiles, |tile: &NewTile| tile.key.clone()).with_text(|tile| Cow::Borrowed(tile.label.as_str()));
let grid = TileGrid::<NewChoice>::new(label)
.select(SelectMode::Single)
.activate(ActivateOn::Click)
.caption(CaptionPlace::BelowWrapped)
.caption_type(CaptionType::Body)
.zoom(GridZoom::Fixed(zoom))
.aspect(16.0 / 9.0)
.sizing(Sizing::FillWidth)
@@ -184,23 +188,27 @@ fn recent_actions(app: &mut SlideApp, actions: Vec<StartAction>) {
pub(super) fn home(app: &mut SlideApp, ui: &mut Ui, _cx: &mut BodyCx<'_>, bs: &mut Backstage, out: &mut Outcome) {
Row::new().show(ui, |ui, _| {
// PLAN: assumed assets/app-icon/deckcraft-mark.svg (dialogs-w18)
let _ = Picture::svg("DeckCraft", include_bytes!("../../../../assets/app-icon/deckcraft-mark.svg")).show(ui);
let _ = Picture::svg("DeckCraft", include_bytes!("../../../../assets/app-icon/deckcraft-mark.svg"))
.extent(PictureSize::Thumb(ThumbSize::Medium))
.show(ui);
let _ = Text::new("DeckCraft").role(TypeRole::Display).show(ui);
});
Section::new("New")
// Plain page headings, as the New page's, with the link to the rest at their end.
let heading = |title: &'static str| Section::fixed(title).strength(HeaderStrength::Heading).quiet_header();
heading("New")
.controls(|ui, _| {
if clicked(&Link::new("More themes").show(ui)) {
out.page = Some(Page::New);
}
})
.show(ui, |ui, _| show_tiles(app, ui, "New presentations", &theme_tiles("", 5, true), 1.0));
Section::new("Templates")
.show(ui, |ui, _| show_tiles(app, ui, "New presentations", &theme_tiles("", 5, true), THEME_ZOOM));
heading("Templates")
.controls(|ui, _| {
if clicked(&Link::new("More templates").show(ui)) {
out.page = Some(Page::New);
}
})
.show(ui, |ui, _| show_tiles(app, ui, "Starter templates", &template_tiles("", 3), 1.0));
.show(ui, |ui, _| show_tiles(app, ui, "Starter templates", &template_tiles("", 3), THEME_ZOOM));
let files = recent_files(app, &bs.query);
let empty = recent_empty(&bs.query);
let shown = RecentList::new(&files)
@@ -225,10 +233,10 @@ pub(super) fn new_page(app: &mut SlideApp, ui: &mut Ui, _cx: &mut BodyCx<'_>, bs
let _ = TextField::search("Search for themes and templates", Bind::bound(&mut bs.query)).placeholder("Search for themes and templates").show(ui);
let themes = theme_tiles(&bs.query, usize::MAX, false);
let templates = template_tiles(&bs.query, usize::MAX);
show_tiles(app, ui, "Themes", &themes, 1.0);
show_tiles(app, ui, "Themes", &themes, THEME_ZOOM);
if bs.query.trim().is_empty() || !templates.is_empty() {
let _ = Text::new("Templates").role(TypeRole::Heading).show(ui);
show_tiles(app, ui, "Starter templates", &templates, 1.0);
show_tiles(app, ui, "Starter templates", &templates, THEME_ZOOM);
}
if themes.is_empty() && templates.is_empty() {
let _ = Text::new(format!("No themes or templates match “{}”.", bs.query.trim())).shade(Shade::Muted).show(ui);
@@ -287,9 +295,22 @@ pub(super) fn open_page(app: &mut SlideApp, ui: &mut Ui, _cx: &mut BodyCx<'_>, b
});
let _ = Divider::vertical().show(ui);
Stack::new().fill_width().show(ui, |ui, _| {
let _ = TextField::search("Search for a file", Bind::bound(&mut bs.query)).placeholder("Search for a file").show(ui);
// A search box keeps one width while its query changes, as production's does, not its text's.
Row::new().show(ui, |ui, _| {
Stack::new().least_width(LeastWidth::Palette).show(ui, |ui, _| {
let _ = TextField::search("Search for a file", Bind::bound(&mut bs.query))
.placeholder("Search for a file")
.sizing(Sizing::FillWidth)
.show(ui);
});
});
let files = recent_files(app, &bs.query);
let shown = RecentList::new(&files).remove(RecentRemove::Always).heading("Presentations").empty(recent_empty(&bs.query)).show(ui);
let shown = RecentList::new(&files)
.remove(RecentRemove::Always)
.heading("Presentations")
.heading_sections()
.empty(recent_empty(&bs.query))
.show(ui);
recent_actions(app, shown.actions);
});
});
+17
View File
@@ -143,6 +143,23 @@ fn the_new_pages_templates_have_no_fold() {
page_choice(&h, "Briefing");
}
/// Home heads its new presentations and starter templates with plain page headings, as the New page does: neither
/// folds away, and each keeps its link to the New page.
#[test]
fn the_home_pages_headings_have_no_fold() {
let mut h = new_app();
h.state_mut().run("app.backstage", json!({"page": Page::Home.id()})).unwrap();
h.run_steps(3);
let view = h.get_by_role_and_label(Role::Group, "File view");
for heading in ["New", "Templates"] {
let mut nodes = view.query_all_by_label(heading).filter(|node| !in_navigation(node)).peekable();
assert!(nodes.peek().is_some(), "Home has its {heading} heading");
assert!(nodes.all(|node| node.accesskit_node().data().is_expanded().is_none()), "the {heading} heading opens and closes nothing");
}
page_choice(&h, "More themes");
page_choice(&h, "More templates");
}
#[test]
fn open_lists_recent_files_and_opens_one() {
let dir = temp_dir("open");