DEVELOPMENT ENVIRONMENT

~liljamo/gandalf

ref: 77593c596da165658f645945a0bfecb16f037165 gandalf/src/theme.rs -rw-r--r-- 3.3 KiB
77593c59Jonni Liljamo feat: musl compatibility 1 year, 8 months ago
                                                                                
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
use iced::{
    application, color,
    widget::{container, text, text_input},
    Background, Color,
};

use once_cell::sync::Lazy;

static GANDALF_COLOR_NONE: Lazy<Color> = Lazy::new(|| color!(0x000000, 0.));
static GANDALF_COLOR_BG: Lazy<Color> = Lazy::new(|| color!(0x292831, 0.8));
static GANDALF_COLOR_TEXT: Lazy<Color> = Lazy::new(|| color!(0x4a7a96, 1.));
static GANDALF_COLOR_PLACEHOLDER: Lazy<Color> = Lazy::new(|| color!(0x333f58, 1.));
static GANDALF_COLOR_PROMPT: Lazy<Color> = Lazy::new(|| color!(0xfbbbad, 1.));
static GANDALF_COLOR_SELECTED: Lazy<Color> = Lazy::new(|| color!(0xee8695, 1.));

#[derive(Debug, Default, Clone, Copy, PartialEq)]
pub enum GTheme {
    #[default]
    Light,
}

/// The style of an application.
#[derive(Default)]
pub enum Application {
    /// The default style.
    #[default]
    Default,
}

impl application::StyleSheet for GTheme {
    type Style = Application;

    fn appearance(&self, style: &Self::Style) -> application::Appearance {
        match style {
            Application::Default => application::Appearance {
                background_color: *GANDALF_COLOR_BG,
                text_color: *GANDALF_COLOR_TEXT,
            },
        }
    }
}

/// The style of a container.
#[derive(Default)]
pub enum Container {
    #[default]
    Transparent,
}

impl container::StyleSheet for GTheme {
    type Style = Container;

    fn appearance(&self, style: &Self::Style) -> container::Appearance {
        match style {
            Container::Transparent => Default::default(),
        }
    }
}

/// The style of text.
#[derive(Clone, Copy, Default)]
pub enum Text {
    #[default]
    Default,
    Selected,
}

impl text::StyleSheet for GTheme {
    type Style = Text;

    fn appearance(&self, style: Self::Style) -> text::Appearance {
        match style {
            Text::Default => text::Appearance {
                color: Some(*GANDALF_COLOR_TEXT),
            },
            Text::Selected => text::Appearance {
                color: Some(*GANDALF_COLOR_SELECTED),
            },
        }
    }
}

/// The style of a text input.
#[derive(Default)]
pub enum TextInput {
    #[default]
    Default,
}

impl text_input::StyleSheet for GTheme {
    type Style = TextInput;

    fn active(&self, _style: &Self::Style) -> text_input::Appearance {
        text_input::Appearance {
            background: Background::Color(*GANDALF_COLOR_NONE),
            border_radius: 0.,
            border_width: 0.,
            border_color: *GANDALF_COLOR_NONE,
        }
    }

    fn hovered(&self, _style: &Self::Style) -> text_input::Appearance {
        text_input::Appearance {
            background: Background::Color(*GANDALF_COLOR_NONE),
            border_radius: 0.,
            border_width: 0.,
            border_color: *GANDALF_COLOR_NONE,
        }
    }

    fn focused(&self, _style: &Self::Style) -> text_input::Appearance {
        text_input::Appearance {
            background: Background::Color(*GANDALF_COLOR_NONE),
            border_radius: 0.,
            border_width: 0.,
            border_color: *GANDALF_COLOR_NONE,
        }
    }

    fn placeholder_color(&self, _style: &Self::Style) -> Color {
        *GANDALF_COLOR_PLACEHOLDER
    }

    fn value_color(&self, _style: &Self::Style) -> Color {
        *GANDALF_COLOR_PROMPT
    }

    fn selection_color(&self, _style: &Self::Style) -> Color {
        *GANDALF_COLOR_NONE
    }
}