use crate::Color;
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub struct TitleBar {
pub height: i32,
pub font: String,
pub font_size: i32,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
#[allow(
clippy::exhaustive_structs,
reason = "built by callers with `..Default::default()`, which a new field does not break"
)]
pub struct Colors {
pub panel_top: Color,
pub panel_bottom: Color,
pub rim_focused: Color,
pub rim_blurred: Color,
pub shadow: Color,
pub title_text: Color,
pub title_shadow: Color,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
#[allow(
clippy::exhaustive_structs,
reason = "built by callers with `..Default::default()`, which a new field does not break"
)]
pub struct Button {
pub fill: Color,
pub hover: Color,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
#[allow(
clippy::exhaustive_structs,
reason = "built by callers with `..Default::default()`, which a new field does not break"
)]
pub struct Buttons {
pub close: Button,
pub minimize: Button,
pub maximize: Button,
}
#[derive(Debug, Clone, PartialEq)]
#[allow(
clippy::exhaustive_structs,
reason = "built by callers with `..Default::default()`, which a new field does not break"
)]
pub struct Theme {
pub name: String,
pub corner_radius: i32,
pub title_bar: TitleBar,
pub colors: Colors,
pub buttons: Buttons,
pub noise_amplitude: f64,
pub shadow_extent: i32,
pub animation_duration_ms: i32,
}
impl Default for Theme {
fn default() -> Self {
Self {
name: String::new(),
corner_radius: 0,
title_bar: TitleBar {
height: 0,
font: String::new(),
font_size: 0,
},
colors: Colors::default(),
buttons: Buttons::default(),
noise_amplitude: 0.0,
shadow_extent: 0,
animation_duration_ms: 0,
}
}
}
#[must_use]
pub fn glass_default() -> Theme {
Theme {
name: "glass-default".to_owned(),
corner_radius: 8,
title_bar: TitleBar {
height: 28,
font: "Inter, sans-serif".to_owned(),
font_size: 13,
},
colors: Colors {
panel_top: Color::new(0xFF, 0xFF, 0xFF, 0x73),
panel_bottom: Color::new(0xFF, 0xFF, 0xFF, 0x26),
rim_focused: Color::new(0xFF, 0xFF, 0xFF, 0x99),
rim_blurred: Color::new(0xC8, 0xC8, 0xC8, 0x4C),
shadow: Color::new(0x00, 0x00, 0x00, 0x8C),
title_text: Color::new(0x1E, 0x1E, 0x1E, 0xFF),
title_shadow: Color::new(0xFF, 0xFF, 0xFF, 0x66),
},
buttons: Buttons {
close: Button {
fill: Color::new(0xFF, 0x5F, 0x56, 0xFF),
hover: Color::new(0xFF, 0x8A, 0x82, 0xFF),
},
minimize: Button {
fill: Color::new(0xFF, 0xBD, 0x2E, 0xFF),
hover: Color::new(0xFF, 0xD1, 0x66, 0xFF),
},
maximize: Button {
fill: Color::new(0x28, 0xC9, 0x40, 0xFF),
hover: Color::new(0x5E, 0xE0, 0x71, 0xFF),
},
},
noise_amplitude: 0.04,
shadow_extent: 24,
animation_duration_ms: 180,
}
}
#[must_use]
pub fn glass_lite() -> Theme {
Theme {
name: "glass-lite".to_owned(),
noise_amplitude: 0.02,
shadow_extent: 12,
animation_duration_ms: 120,
..glass_default()
}
}
#[must_use]
pub fn glass_minimal() -> Theme {
let base = glass_default();
Theme {
name: "glass-minimal".to_owned(),
noise_amplitude: 0.0,
shadow_extent: 0,
animation_duration_ms: 0,
colors: Colors {
shadow: Color::default(),
..base.colors
},
..base
}
}