maycoon_theme/theme/
celeste.rs1use peniko::{Color, color::palette};
2
3use crate::globals::Globals;
4use crate::id::WidgetId;
5use crate::style::{
6 DefaultContainerStyles, DefaultInteractiveStyles, DefaultStyles, DefaultTextStyles, Style,
7};
8use crate::theme::Theme;
9
10#[derive(Debug, Clone)]
12pub enum CelesteTheme {
13 Light(Globals),
15}
16
17impl CelesteTheme {
18 pub fn light() -> Self {
20 Self::Light(Globals::default())
21 }
22}
23
24impl Default for CelesteTheme {
25 fn default() -> Self {
26 Self::light()
27 }
28}
29
30impl Theme for CelesteTheme {
31 fn of(&self, id: WidgetId) -> Option<Style> {
32 match id.namespace() {
33 "maycoon-widgets" => match id.id() {
34 "Text" => Some(Style::from_values(light::TEXT)),
35 "Button" => Some(Style::from_values(light::BUTTON)),
36 "Checkbox" => Some(Style::from_values(light::CHECKBOX)),
37 "Slider" => Some(Style::from_values(light::SLIDER)),
38 _ => None,
39 },
40 _ => None,
41 }
42 }
43
44 #[inline(always)]
45 fn defaults(&self) -> DefaultStyles {
46 DefaultStyles::new(
47 DefaultTextStyles::new(palette::css::BLACK, palette::css::WHITE_SMOKE),
48 DefaultContainerStyles::new(palette::css::ANTIQUE_WHITE, palette::css::WHITE),
49 DefaultInteractiveStyles::new(
50 Color::from_rgb8(130, 150, 230),
51 Color::from_rgb8(150, 170, 250),
52 Color::from_rgb8(140, 160, 240),
53 Color::from_rgb8(110, 110, 110),
54 ),
55 )
56 }
57
58 #[inline(always)]
59 fn window_background(&self) -> Color {
60 Color::WHITE
61 }
62
63 #[inline(always)]
64 fn globals(&self) -> &Globals {
65 match &self {
66 CelesteTheme::Light(globals) => globals,
67 }
68 }
69
70 #[inline(always)]
71 fn globals_mut(&mut self) -> &mut Globals {
72 match self {
73 CelesteTheme::Light(globals) => globals,
74 }
75 }
76}
77
78mod light {
79 use crate::style::StyleVal;
80 use peniko::Color;
81 use peniko::color::palette;
82
83 pub const TEXT: [(&str, StyleVal); 2] = [
84 ("color", StyleVal::Color(palette::css::BLACK)),
85 ("color_invert", StyleVal::Color(palette::css::WHITE)),
86 ];
87
88 pub const BUTTON: [(&str, StyleVal); 3] = [
89 (
90 "color_idle",
91 StyleVal::Color(Color::from_rgb8(150, 170, 250)),
92 ),
93 (
94 "color_pressed",
95 StyleVal::Color(Color::from_rgb8(130, 150, 230)),
96 ),
97 (
98 "color_hovered",
99 StyleVal::Color(Color::from_rgb8(140, 160, 240)),
100 ),
101 ];
102
103 pub const CHECKBOX: [(&str, StyleVal); 2] = [
104 (
105 "color_checked",
106 StyleVal::Color(Color::from_rgb8(130, 130, 230)),
107 ),
108 (
109 "color_unchecked",
110 StyleVal::Color(Color::from_rgb8(170, 170, 250)),
111 ),
112 ];
113
114 pub const SLIDER: [(&str, StyleVal); 2] = [
115 ("color", StyleVal::Color(Color::from_rgb8(130, 130, 230))),
116 (
117 "color_ball",
118 StyleVal::Color(Color::from_rgb8(170, 170, 250)),
119 ),
120 ];
121}