maycoon_theme/theme/
celeste.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
use peniko::Color;

use crate::globals::Globals;
use crate::id::WidgetId;
use crate::style::{
    DefaultContainerStyles, DefaultInteractiveStyles, DefaultStyles, DefaultTextStyles, Style,
    StyleVal,
};
use crate::theme::Theme;

/// A smooth and minimalistic theme with a cold blue and purple touch.
#[derive(Debug, Clone)]
pub enum CelesteTheme {
    /// Use [CelesteTheme::light] to use the light Celeste theme.
    Light(Globals),
}

impl CelesteTheme {
    /// The Light Celeste Theme.
    pub fn light() -> Self {
        Self::Light(Globals::default())
    }
}

impl Theme for CelesteTheme {
    fn of(&self, id: WidgetId) -> Option<Style> {
        match id.namespace() {
            "maycoon-widgets" => match id.id() {
                "Text" => Some(Style::from_values([
                    ("color".to_string(), StyleVal::Color(Color::BLACK)),
                    ("color_invert".to_string(), StyleVal::Color(Color::WHITE)),
                ])),

                "Button" => Some(Style::from_values([
                    (
                        "color_idle".to_string(),
                        StyleVal::Color(Color::rgb8(150, 170, 250)),
                    ),
                    (
                        "color_pressed".to_string(),
                        StyleVal::Color(Color::rgb8(130, 150, 230)),
                    ),
                    (
                        "color_hovered".to_string(),
                        StyleVal::Color(Color::rgb8(140, 160, 240)),
                    ),
                ])),

                "Checkbox" => Some(Style::from_values([
                    (
                        "color_checked".to_string(),
                        StyleVal::Color(Color::rgb8(130, 130, 230)),
                    ),
                    (
                        "color_unchecked".to_string(),
                        StyleVal::Color(Color::rgb8(170, 170, 250)),
                    ),
                ])),

                "Slider" => Some(Style::from_values([
                    (
                        "color".to_string(),
                        StyleVal::Color(Color::rgb8(130, 130, 230)),
                    ),
                    (
                        "color_ball".to_string(),
                        StyleVal::Color(Color::rgb8(170, 170, 250)),
                    ),
                ])),

                _ => None,
            },
            _ => None,
        }
    }

    fn defaults(&self) -> DefaultStyles {
        DefaultStyles::new(
            DefaultTextStyles::new(Color::BLACK, Color::WHITE_SMOKE),
            DefaultContainerStyles::new(Color::ANTIQUE_WHITE, Color::WHITE),
            DefaultInteractiveStyles::new(
                Color::rgb8(130, 150, 230),
                Color::rgb8(150, 170, 250),
                Color::rgb8(140, 160, 240),
                Color::rgb8(110, 110, 110),
            ),
        )
    }

    fn window_background(&self) -> Color {
        Color::WHITE
    }

    fn globals(&self) -> &Globals {
        match &self {
            CelesteTheme::Light(globals) => globals,
        }
    }

    fn globals_mut(&mut self) -> &mut Globals {
        match self {
            CelesteTheme::Light(globals) => globals,
        }
    }
}