diff --git a/apps/deckcraft-web/src/presenter.rs b/apps/deckcraft-web/src/presenter.rs index 3817638d2..6b4c25034 100644 --- a/apps/deckcraft-web/src/presenter.rs +++ b/apps/deckcraft-web/src/presenter.rs @@ -5,7 +5,7 @@ use craft::ui::contract::{Politeness, Props as _, Show as _}; use craft::ui::fonts::{I18nScripts, UiFonts}; use craft::ui::notices::{Notice, NoticeLayout}; use craft::ui::primitives::{CachedTexture, Revision, TextureStore, TextureStoreOptions}; -use craft::ui::runtime::env::{RootEnv, WindowKey}; +use craft::ui::runtime::env::WindowKey; use craft::ui::runtime::frame::FrameInput; use craft::ui::shell::{AppShell, embed}; use craft::web_host::link::{LinkLimits, LinkState, WindowLink}; @@ -167,7 +167,7 @@ impl PopupApp { impl eframe::App for PopupApp { fn raw_input_hook(&mut self, ctx: &egui::Context, _input: &mut egui::RawInput) { - embed::before_input(ctx, |_| FrameInput::new(RootEnv::default())); + embed::before_input(ctx, |_| FrameInput::new(deckcraft_ui_egui::theme::root_env())); } fn logic(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) { diff --git a/crates/ui-egui/src/app.rs b/crates/ui-egui/src/app.rs index dbb5ade81..3e93a1a78 100644 --- a/crates/ui-egui/src/app.rs +++ b/crates/ui-egui/src/app.rs @@ -11,7 +11,7 @@ use super::{ }; use craft::ui::contract::{Bind, CommandSet as _, Tracked}; use craft::ui::runtime::commands::{CommandGate, CommandInput}; -use craft::ui::runtime::env::{RootEnv, Scale, WindowKey}; +use craft::ui::runtime::env::{Scale, WindowKey}; use craft::ui::runtime::frame::FrameInput; use craft::ui::runtime::windows::WindowHost; use craft::ui::shell::{AppShell, PageKind, Slot, SlotSize, embed}; @@ -152,7 +152,7 @@ impl SlideApp { injected_target: None, twist_frame: None, clock: Default::default(), - root: RootEnv::new(), + root: crate::theme::root_env(), #[cfg(not(target_arch = "wasm32"))] opening_jobs, dialogs: Default::default(), diff --git a/crates/ui-egui/src/ribbon/title_bar.rs b/crates/ui-egui/src/ribbon/title_bar.rs index 58e7c6209..ead6b7f5a 100644 --- a/crates/ui-egui/src/ribbon/title_bar.rs +++ b/crates/ui-egui/src/ribbon/title_bar.rs @@ -16,19 +16,20 @@ pub fn title_bar(app: &mut SlideApp, ui: &mut egui::Ui, _cx: &mut BodyCx<'_>) { let dirty = app.session.active().is_some_and(|doc| doc.is_dirty()); let title = if dirty { Title::unsaved(text) } else { Title::new(text) }; let dark = app.ui.brightness == crate::state::Brightness::Dark; - TitleBar::new().show_titled( + // The bar under the OS frame still carries the document's title, centred. + TitleBar::new().title_when_native().show_titled( ui, title, |ui, _| super::qat::bar(app, ui), |ui, _| { - IconButton::command(Icon::Search.id(), "app.palette").label("Search commands").show(ui); - Button::command(CommandRef::new("show.fromCurrent")).label("Present").variant(Variant::PRIMARY).show(ui); + IconButton::command(if dark { Icon::Sparkle } else { Icon::Palette }.id(), "view.dark").label("Light/Dark appearance").show(ui); ToggleButton::command(CommandRef::with_params("view.pane", json!({"pane": "comments", "toggle": true}))) .label("Comments") .icon(Icon::CommentsBubble.id()) .icon_only() .show(ui); - IconButton::command(if dark { Icon::Sparkle } else { Icon::Palette }.id(), "view.dark").label("Light/Dark appearance").show(ui); + Button::command(CommandRef::new("show.fromCurrent")).label("Present").variant(Variant::PRIMARY).show(ui); + IconButton::command(Icon::Search.id(), "app.palette").label("Search commands").show(ui); }, ); } diff --git a/crates/ui-egui/src/sizes.json b/crates/ui-egui/src/sizes.json new file mode 100644 index 000000000..8bd8d12d0 --- /dev/null +++ b/crates/ui-egui/src/sizes.json @@ -0,0 +1,11 @@ +{ + "all": { + "radius.surface": 8, + "typography.body.size": 13, + "typography.body_strong.size": 13, + "typography.caption.size": 11, + "typography.heading.line_height": 24, + "typography.heading.size": 18, + "typography.label.size": 13 + } +} diff --git a/crates/ui-egui/src/theme.rs b/crates/ui-egui/src/theme.rs index 3136cf2db..5589d4d0c 100644 --- a/crates/ui-egui/src/theme.rs +++ b/crates/ui-egui/src/theme.rs @@ -265,6 +265,21 @@ pub fn to_color32(c: deckcraft_color::Rgba) -> Color32 { Color32::from_rgba_unmultiplied(c.r, c.g, c.b, c.a) } +/// DeckCraft's overrides of the suite's size sets (`sizes.json`): its interface type scale and surface rounding. One +/// shared value, so every root that carries it keeps one identity for the token cache. +pub fn app_sizes() -> std::sync::Arc { + static SIZES: std::sync::LazyLock> = + std::sync::LazyLock::new(|| std::sync::Arc::new(craft::theme::AppSizes::parse_or_default(include_bytes!("sizes.json")))); + SIZES.clone() +} + +/// The app's root values before the frame's own: [`RootEnv`](craft::ui::runtime::env::RootEnv) with DeckCraft's sizes. +pub fn root_env() -> craft::ui::runtime::env::RootEnv { + let mut root = craft::ui::runtime::env::RootEnv::new(); + root.sizes = app_sizes(); + root +} + #[cfg(test)] mod tests { use super::*; @@ -482,4 +497,11 @@ mod tests { assert!(ink, "{c:?} ({:04X}) draws nothing at {size} px", c as u32); } } + + /// A path or value the size sets reject would make the app fall back to the suite's sizes with only a log line. + #[test] + fn the_apps_sizes_file_is_accepted() { + let sizes = craft::theme::AppSizes::parse(include_bytes!("sizes.json")).expect("sizes.json is valid"); + assert!(!sizes.is_empty()); + } }