From 2fde397a0a423c7078f6667fec22d581e379f397 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Sun, 29 Nov 2026 22:47:32 +0000 Subject: [PATCH 1/2] 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 --- crates/ui-egui/src/backstage/files.rs | 55 ++++++++++++++++++--------- crates/ui-egui/src/backstage/tests.rs | 17 +++++++++ 2 files changed, 55 insertions(+), 17 deletions(-) diff --git a/crates/ui-egui/src/backstage/files.rs b/crates/ui-egui/src/backstage/files.rs index f02a6e93d..f02fd036c 100644 --- a/crates/ui-egui/src/backstage/files.rs +++ b/crates/ui-egui/src/backstage/files.rs @@ -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 { .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::::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) { 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); }); }); diff --git a/crates/ui-egui/src/backstage/tests.rs b/crates/ui-egui/src/backstage/tests.rs index 1797a177a..e727d92df 100644 --- a/crates/ui-egui/src/backstage/tests.rs +++ b/crates/ui-egui/src/backstage/tests.rs @@ -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"); From 56935cee34bbed933968b88b89c9f0a4c60fcf84 Mon Sep 17 00:00:00 2001 From: "Dylan M. Taylor" Date: Sun, 29 Nov 2026 22:47:35 +0000 Subject: [PATCH 2/2] Backstage Info page: document name in accent, tiles apart, value column The document name takes the display role in the accent tone, and DeckCraft's display type is production's 28 px (sizes.json). Task tiles stand a section gap from their titles and from each other. The property list sets its values a section gap past the names (LabelGap::Section), so a readout no longer runs into its label. Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/backstage/info.rs | 73 ++++++++++++++++------------ crates/ui-egui/src/sizes.json | 2 + 2 files changed, 44 insertions(+), 31 deletions(-) diff --git a/crates/ui-egui/src/backstage/info.rs b/crates/ui-egui/src/backstage/info.rs index ef2cf1acb..be2b4ae1b 100644 --- a/crates/ui-egui/src/backstage/info.rs +++ b/crates/ui-egui/src/backstage/info.rs @@ -1,8 +1,11 @@ use super::{Backstage, Icon, Outcome, Page, SlideApp, Ui, Value, json}; use crate::app::files::SaveOutcome; use craft::behavior::ColumnWidth; +use craft::theme::variant::Tone; use craft::ui::buttons::{Arrangement, Button, Link}; -use craft::ui::contract::{Bind, BodyCx, Entry, FieldLayout, LabelScheme, Props as _, Show as _, ShowContainer as _, Sizing, WrapWidth}; +use craft::ui::contract::{ + Bind, BodyCx, Entry, FieldLayout, Gap, LabelGap, LabelScheme, Props as _, Show as _, ShowContainer as _, Sizing, WrapWidth, +}; use craft::ui::display::{Picture, Shade, Text}; use craft::ui::form::{Field, FieldGroup}; use craft::ui::layout::CellAlign; @@ -10,6 +13,7 @@ use craft::ui::layout_components::{Grid, Row, Stack}; use craft::ui::pickers::Select; use craft::ui::primitives::Span; use craft::ui::runtime::commands::{ClipItem, ClipboardHandle}; +use craft::ui::runtime::env::{Overrides, with_env}; use craft::ui::runtime::focus; use craft::ui::style::{TypeRole, Variant}; use craft::ui::text::TextField; @@ -41,6 +45,7 @@ pub(super) const PROPERTIES: [(&str, &str, &str); 7] = [ /// A task's action beside its heading and explanation, sized by the controls and content. pub(super) fn task_row(ui: &mut Ui, icon: Icon, label: &'static str, title: &'static str, detail: &'static str, enabled: bool) -> bool { Row::new() + .gap(Gap::Section) .show(ui, |ui, _| { let pressed = Button::new(label).icon(icon.id()).arrangement(Arrangement::Stacked).enabled(enabled).show(ui).clicked(); Stack::new().wrap_width(WrapWidth::Column).show(ui, |ui, _| { @@ -62,7 +67,7 @@ pub(super) fn info(app: &mut SlideApp, ui: &mut Ui, _cx: &mut BodyCx<'_>, bs: &m let path = v.get("path").and_then(Value::as_str).map(str::to_string); let title = v.get("title").and_then(Value::as_str).unwrap_or(""); let dirty = v.get("dirty").and_then(Value::as_bool).unwrap_or(false); - Text::new(title.to_string()).role(TypeRole::Heading).show(ui); + Text::new(title.to_string()).role(TypeRole::Display).tone(Tone::Accent).show(ui); Text::new(path.as_deref().unwrap_or("Not saved yet").to_string()).shade(Shade::Muted).show(ui); if let Some(path) = &path { Row::new().wrap(true).show(ui, |ui, _| { @@ -79,7 +84,7 @@ pub(super) fn info(app: &mut SlideApp, ui: &mut Ui, _cx: &mut BodyCx<'_>, bs: &m }); } Grid::new(&[ColumnWidth::Content, ColumnWidth::Content]).cells(CellAlign::Top).show(ui, |ui, _| { - Stack::new().wrap_width(WrapWidth::Column).show(ui, |ui, _| { + Stack::new().wrap_width(WrapWidth::Column).gap(Gap::Section).show(ui, |ui, _| { if task_row( ui, Icon::Accessibility, @@ -102,34 +107,40 @@ pub(super) fn info(app: &mut SlideApp, ui: &mut Ui, _cx: &mut BodyCx<'_>, bs: &m Stack::new().show(ui, |ui, _| { Text::new("Properties").role(TypeRole::Heading).show(ui); let props = v.get("properties").cloned().unwrap_or_default(); - FieldGroup::new("Properties").labels(LabelScheme::Inspector).show(ui, |ui, _| { - let readout = |ui: &mut Ui, label: &'static str, value: String| { - Field::new(label).layout(FieldLayout::Beside).value(value.clone()).show(ui, |ui, _| { - Text::new(value.clone()).show(ui); - }); - }; - if let Some(size) = v.get("bytes").and_then(Value::as_u64).map(format_bytes) { - readout(ui, "Size", size); - } - readout(ui, "Slides", v.get("slides").and_then(Value::as_u64).unwrap_or(0).to_string()); - readout(ui, "Hidden slides", v.get("hiddenSlides").and_then(Value::as_u64).unwrap_or(0).to_string()); - for (i, (key, label, hint)) in PROPERTIES.iter().enumerate() { - let saved = props.get(*key).and_then(Value::as_str).unwrap_or("").to_string(); - let Some(draft) = bs.props.get_mut(i) else { continue }; - Field::new(*label).id_salt(*key).layout(FieldLayout::Beside).show(ui, |ui, _| { - let response = TextField::new(*label, Bind::bound(draft)).placeholder(*hint).show(ui); - if (response.text_lost_focus || response.submitted) && *draft != saved { - // Losing focus can precede this field's body, so its draft must commit before it is refreshed. - let mut params = serde_json::Map::new(); - params.insert((*key).to_string(), json!(draft.clone())); - let _ = app.run("file.properties", Value::Object(params)); - } else if !focus::is_focused(ui.ctx(), response.response.id) && *draft != saved { - draft.clone_from(&saved); - ui.ctx().request_repaint(); - } - }); - } - readout(ui, "Location", path.clone().unwrap_or_else(|| "Not saved yet".into())); + // The values stand in their own column, apart from the longest name ("Hidden slides"). + let wide = |overrides: &mut Overrides| { + overrides.values.set(LabelGap::Section); + }; + with_env(ui, wide, |ui| { + FieldGroup::new("Properties").labels(LabelScheme::Inspector).show(ui, |ui, _| { + let readout = |ui: &mut Ui, label: &'static str, value: String| { + Field::new(label).layout(FieldLayout::Beside).value(value.clone()).show(ui, |ui, _| { + Text::new(value.clone()).show(ui); + }); + }; + if let Some(size) = v.get("bytes").and_then(Value::as_u64).map(format_bytes) { + readout(ui, "Size", size); + } + readout(ui, "Slides", v.get("slides").and_then(Value::as_u64).unwrap_or(0).to_string()); + readout(ui, "Hidden slides", v.get("hiddenSlides").and_then(Value::as_u64).unwrap_or(0).to_string()); + for (i, (key, label, hint)) in PROPERTIES.iter().enumerate() { + let saved = props.get(*key).and_then(Value::as_str).unwrap_or("").to_string(); + let Some(draft) = bs.props.get_mut(i) else { continue }; + Field::new(*label).id_salt(*key).layout(FieldLayout::Beside).show(ui, |ui, _| { + let response = TextField::new(*label, Bind::bound(draft)).placeholder(*hint).show(ui); + if (response.text_lost_focus || response.submitted) && *draft != saved { + // Losing focus can precede this field's body, so its draft must commit before it is refreshed. + let mut params = serde_json::Map::new(); + params.insert((*key).to_string(), json!(draft.clone())); + let _ = app.run("file.properties", Value::Object(params)); + } else if !focus::is_focused(ui.ctx(), response.response.id) && *draft != saved { + draft.clone_from(&saved); + ui.ctx().request_repaint(); + } + }); + } + readout(ui, "Location", path.clone().unwrap_or_else(|| "Not saved yet".into())); + }) }); }); }); diff --git a/crates/ui-egui/src/sizes.json b/crates/ui-egui/src/sizes.json index ccf7bbba2..8d442338e 100644 --- a/crates/ui-egui/src/sizes.json +++ b/crates/ui-egui/src/sizes.json @@ -9,6 +9,8 @@ "typography.body.size": 13, "typography.body_strong.size": 13, "typography.caption.size": 11, + "typography.display.line_height": 36, + "typography.display.size": 28, "typography.heading.line_height": 24, "typography.heading.size": 18, "typography.label.size": 13,