Files
horizon-airdef/launcher/src/theme.rs
T
Ludovic Marie 86149f7da6 Restyle the launcher in the new design language
A top bar (the mark, Horizon, the pages as text) replaces the sidebar; a mono footer carries
the launcher's version, its update and the community links. Every page is a display title, a
short muted line, then an index list: Play's resources and folders, the versions with their
names large and their size and state in mono, the patch notes, the settings. Buttons are pills,
the main action is the one violet thing on the screen, selection is an ink pill, the console,
notices and the crash report sit on soft plates without borders. The Play page ends with the
faint wordmark, half set below the window's edge.

The sunset photograph and its veils are gone (and the `image` dependency with them): the
window is the page colour, light or dark with the system. The opening draws the wordmark
letter by letter, then the launcher rises into place. HORIZON_LAUNCHER_APPEARANCE=light|dark
overrides the system's appearance, for screenshots and tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-15 00:08:40 +02:00

86 lines
2.6 KiB
Rust

//! The launcher's view of Horizon's design tokens (`crates/horizon-theme`, described in
//! `docs/design-system.md`), which the game's menus and the website share: cool neutrals in two
//! appearances and one violet accent, Geist and Geist Mono (bundled, SIL Open Font License).
use gpui::{rgb, Hsla, WindowAppearance};
use horizon_theme as tokens;
use std::time::Duration;
pub use tokens::{Step, BODY, CAPTION, DISPLAY, HEADING, LABEL, MICRO, TITLE, UI, WORDMARK};
pub const FONT: &str = tokens::FONT;
pub const MONO: &str = tokens::MONO;
/// Shapes and controls, shared with the game's menus and the website.
pub use tokens::{
CONTROL, CONTROL_LARGE, DISABLED, FIELD, GUTTER, INDEX, PLATE_BLEED, PRESSED, RADIUS,
RADIUS_PILL, RADIUS_PLATE, RISE, ROW, SEGMENT,
};
/// Motion: short and eased out, never bouncy.
pub const QUICK: Duration = tokens::QUICK.duration();
pub const MOVE: Duration = tokens::MOVE.duration();
pub const ENTER: Duration = tokens::ENTER.duration();
pub const STAGGER: Duration = tokens::STAGGER;
#[derive(Clone, Copy)]
pub struct Theme {
pub page: Hsla,
pub plate_soft: Hsla,
pub plate: Hsla,
pub surface: Hsla,
pub rule: Hsla,
pub ink: Hsla,
pub ink_soft: Hsla,
pub muted: Hsla,
pub accent: Hsla,
pub on_accent: Hsla,
pub danger: Hsla,
pub success: Hsla,
pub dark: bool,
}
fn c(hex: u32) -> Hsla {
rgb(hex).into()
}
impl Theme {
/// The system's appearance; `HORIZON_LAUNCHER_APPEARANCE=light` or `dark` overrides it (for
/// screenshots and tests).
pub fn for_appearance(appearance: WindowAppearance) -> Self {
match std::env::var("HORIZON_LAUNCHER_APPEARANCE").as_deref() {
Ok("light") => return Self::light(),
Ok("dark") => return Self::dark(),
_ => {}
}
match appearance {
WindowAppearance::Light | WindowAppearance::VibrantLight => Self::light(),
_ => Self::dark(),
}
}
pub fn dark() -> Self {
Self::from(tokens::DARK)
}
pub fn light() -> Self {
Self::from(tokens::LIGHT)
}
fn from(p: tokens::Palette) -> Self {
Self {
page: c(p.page),
plate_soft: c(p.plate_soft),
plate: c(p.plate),
surface: c(p.surface),
rule: c(p.rule),
ink: c(p.ink),
ink_soft: c(p.ink_soft),
muted: c(p.muted),
accent: c(p.accent),
on_accent: c(p.on_accent),
danger: c(p.danger),
success: c(p.success),
dark: p.dark,
}
}
}