use lieui_geom::Color;
#[derive(Clone, Copy, PartialEq, Debug)]
pub struct Theme {
pub window_background: Color,
pub text: Color,
pub text_secondary: Color,
pub accent: Color,
pub control: Color,
pub control_hover: Color,
pub control_pressed: Color,
pub control_border: Color,
pub input_background: Color,
pub selection: Color,
pub caret: Color,
pub scrollbar_thumb: Color,
pub scrollbar_thumb_drag: Color,
pub tooltip_background: Color,
pub tooltip_text: Color,
pub control_radius: f32,
}
impl Theme {
pub fn light() -> Self {
Self {
window_background: Color::new(245, 245, 245),
text: Color::new(32, 32, 32),
text_secondary: Color::new(140, 140, 140),
accent: Color::new(90, 120, 220),
control: Color::new(228, 228, 228),
control_hover: Color::new(212, 212, 212),
control_pressed: Color::new(196, 196, 196),
control_border: Color::new(180, 180, 180),
input_background: Color::WHITE,
selection: Color::rgba(90, 140, 240, 90),
caret: Color::new(30, 30, 30),
scrollbar_thumb: Color::rgba(120, 120, 120, 110),
scrollbar_thumb_drag: Color::rgba(90, 90, 90, 170),
tooltip_background: Color::rgba(0x1f, 0x29, 0x37, 0xf2),
tooltip_text: Color::WHITE,
control_radius: 4.0,
}
}
pub fn dark() -> Self {
Self {
window_background: Color::new(32, 32, 36),
text: Color::new(230, 230, 230),
text_secondary: Color::new(140, 140, 148),
accent: Color::new(110, 150, 250),
control: Color::new(58, 58, 64),
control_hover: Color::new(70, 70, 78),
control_pressed: Color::new(48, 48, 54),
control_border: Color::new(90, 90, 98),
input_background: Color::new(48, 48, 54),
selection: Color::rgba(90, 140, 240, 120),
caret: Color::new(230, 230, 230),
scrollbar_thumb: Color::rgba(180, 180, 180, 110),
scrollbar_thumb_drag: Color::rgba(200, 200, 200, 170),
tooltip_background: Color::rgba(0x0b, 0x0f, 0x14, 0xf5),
tooltip_text: Color::new(230, 230, 230),
control_radius: 4.0,
}
}
}
impl Default for Theme {
fn default() -> Self {
Self::light()
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn presets_differ_meaningfully() {
let l = Theme::light();
let d = Theme::dark();
assert_ne!(l.window_background, d.window_background);
assert_ne!(l.text, d.text);
assert_ne!(l.input_background, d.input_background);
assert!(l.selection.a < 255 && d.selection.a < 255);
assert!(l.scrollbar_thumb.a < 255);
}
#[test]
fn default_is_light() {
assert_eq!(Theme::default(), Theme::light());
}
}