rosier 0.3.0

A fast picture and video viewer for large folders
//! Design tokens. Every color, size and radius on screen comes from here.
//!
//! The chrome is graphite glass floating over a soft, blurred wash of
//! whatever is selected, so the color on screen comes from the media. One
//! rose accent (after the name) marks selection and favorites, nothing else.
//! Spacing sits on a 4px grid.

use gpui::{Rgba, rgb, rgba};

/// Whether the desktop blurs what is behind the window (KDE Plasma on
/// Wayland, through the KWin blur protocol). Elsewhere the window stays
/// opaque and the glass floats over rosier's own blurred backdrop.
pub fn glass_window() -> bool {
    use std::sync::OnceLock;
    static G: OnceLock<bool> = OnceLock::new();
    *G.get_or_init(|| {
        std::env::var("XDG_CURRENT_DESKTOP").is_ok_and(|d| d.to_ascii_uppercase().contains("KDE"))
            && std::env::var_os("WAYLAND_DISPLAY").is_some()
    })
}

// ---- Graphite ramp ------------------------------------------------------

/// The window behind everything.
pub fn stage() -> Rgba {
    if glass_window() { rgba(0x0f0f10a8) } else { rgb(0x0f0f10) }
}
/// Darkening laid over the blurred backdrop so glass and text stay legible.
pub fn backdrop_scrim() -> Rgba {
    rgba(0x0c0c0e78)
}
pub fn text() -> Rgba {
    rgb(0xededed)
}
pub fn text_dim() -> Rgba {
    rgb(0xa1a1a6)
}
pub fn text_faint() -> Rgba {
    rgb(0x85858b)
}
/// Hairlines: primary text at ~8%.
pub fn line() -> Rgba {
    rgba(0xededed14)
}

// ---- Glass ---------------------------------------------------------------

/// Fill of a floating glass panel (sidebar, toolbar).
pub fn glass_fill() -> Rgba {
    rgba(0x1c1c216b)
}
/// The pane holding the grid: darker glass, so tiles sit on calm ground.
pub fn glass_deep() -> Rgba {
    rgba(0x111113a6)
}
/// Edge of glass: a bright hairline, like light caught on a rim.
pub fn glass_edge() -> Rgba {
    rgba(0xffffff1f)
}
/// Top-down sheen inside glass.
pub fn glass_sheen() -> Rgba {
    rgba(0xffffff17)
}
/// Controls on glass: buttons, segments, rows.
pub fn raised() -> Rgba {
    rgba(0xffffff0d)
}
pub fn raised_hover() -> Rgba {
    rgba(0xffffff1a)
}
/// The selected segment or row: brighter glass.
pub fn raised_active() -> Rgba {
    rgba(0xffffff24)
}

// ---- Accent and overlays ---------------------------------------------------

/// The one accent: rose, after the app's name. Selection and favorites.
pub fn accent() -> Rgba {
    rgb(0xe8678f)
}
pub fn accent_hover() -> Rgba {
    rgb(0xf283a6)
}
pub fn accent_soft() -> Rgba {
    rgba(0xe8678f2e)
}
/// Primary button on dark glass: off-white with dark text.
pub fn primary() -> Rgba {
    rgb(0xededed)
}
pub fn primary_hover() -> Rgba {
    rgb(0xffffff)
}
pub fn on_primary() -> Rgba {
    rgb(0x141415)
}
pub fn danger() -> Rgba {
    rgb(0xe5484d)
}
/// Scrim under text drawn over media.
pub fn scrim() -> Rgba {
    rgba(0x000000b8)
}
pub fn scrim_light() -> Rgba {
    rgba(0x0000007a)
}

// ---- Sizes (logical pixels, 4px grid) ---------------------------------------

/// Gap between floating panels and the window edge.
pub const GUTTER: f32 = 8.0;
pub const SIDEBAR_W: f32 = 240.0;
pub const TOOLBAR_H: f32 = 52.0;
pub const STATUS_H: f32 = 32.0;
pub const GRID_PAD: f32 = 12.0;
pub const TILE_GAP: f32 = 4.0;
/// Radii: panels, controls, small things.
pub const R_PANEL: f32 = 16.0;
pub const RADIUS: f32 = 8.0;
pub const R_SMALL: f32 = 6.0;
pub const CONTROL_H: f32 = 32.0;
pub const ROW_H: f32 = 32.0;

/// Tile size range for the toolbar slider.
pub const TILE_MIN: f32 = 110.0;
pub const TILE_MAX: f32 = 420.0;
pub const TILE_DEFAULT: f32 = 210.0;