use std::sync::atomic::{AtomicU32, Ordering};
use crate::theme::Theme;
static BASE: AtomicU32 = AtomicU32::new(Theme::BASE_RADIUS.to_bits());
static FROST: AtomicU32 = AtomicU32::new(Theme::GLASS_ALPHA.to_bits());
static BEVEL: AtomicU32 = AtomicU32::new(0.225f32.to_bits());
static MAGNIFY: AtomicU32 = AtomicU32::new(0.34f32.to_bits());
pub(crate) fn set_base_radius(radius: f32) {
BASE.store(radius.to_bits(), Ordering::Relaxed);
}
pub(crate) fn set_frost(alpha: f32) {
FROST.store(alpha.to_bits(), Ordering::Relaxed);
}
pub fn set_glass_bevel(share: f32) {
BEVEL.store(share.to_bits(), Ordering::Relaxed);
}
pub fn set_glass_magnify(amount: f32) {
MAGNIFY.store(amount.to_bits(), Ordering::Relaxed);
}
pub(crate) fn magnify() -> f32 {
f32::from_bits(MAGNIFY.load(Ordering::Relaxed))
}
pub(crate) fn bevel() -> f32 {
f32::from_bits(BEVEL.load(Ordering::Relaxed))
}
pub(crate) fn frost() -> f32 {
f32::from_bits(FROST.load(Ordering::Relaxed))
}
impl Theme {
pub const GLASS_ALPHA: f32 =
if cfg!(any(target_os = "macos", target_family = "wasm")) { 0.80 } else { 1.0 };
pub const HEADER_HEIGHT: f32 = 44.0;
pub const TITLEBAR_HEIGHT: f32 = 38.0;
pub const TITLEBAR_TOP_PAD: f32 = 2.0;
pub const TRAFFIC_LIGHT_INSET: f32 = if cfg!(target_os = "macos") { 78.0 } else { 0.0 };
pub const STATUS_STRIP_HEIGHT: f32 = 24.0;
pub const TRANSCRIPT_FADE_BAND: f32 = 24.0;
pub const BASE_RADIUS: f32 = 8.0;
pub fn bubble_radius() -> f32 {
Self::radius(2.0)
}
pub fn surface_radius() -> f32 {
Self::radius(1.5)
}
pub fn panel_radius() -> f32 {
Self::radius(1.25)
}
pub fn button_radius() -> f32 {
Self::radius(1.0)
}
pub fn control_radius() -> f32 {
Self::radius(0.75)
}
fn radius(ratio: f32) -> f32 {
f32::from_bits(BASE.load(Ordering::Relaxed)) * ratio
}
pub const fn inset_radius(outer: f32, inset: f32) -> f32 {
if outer > inset { outer - inset } else { 0.0 }
}
pub const SPACE_XS: f32 = 4.0;
pub const SPACE_SM: f32 = 8.0;
pub const SPACE_MD: f32 = 12.0;
pub const SPACE_LG: f32 = 16.0;
}