mirror of
https://github.com/storytold/deckcraft.git
synced 2026-12-01 10:47:56 +01:00
ui: production's type scale and surface rounding through the app's sizes.json; the title bar shows the title and production's item order
DeckCraft's sizes.json sets body, strong body and control labels to 13 px, captions to 11 px and headings to 18 px, as production's theme did, and popups and the ribbon card to production's 8 px rounding. The title bar under the OS frame still centres the document title, and its end reads theme, comments, Present, search. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
929f445453
commit
7714f32234
5 files changed
+42
-8
No files matched your search
@@ -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) {
|
||||
|
||||
@@ -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(),
|
||||
|
||||
@@ -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);
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -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<craft::theme::AppSizes> {
|
||||
static SIZES: std::sync::LazyLock<std::sync::Arc<craft::theme::AppSizes>> =
|
||||
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());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user