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
use crate::{Color, Text};

pub mod buttons;

#[derive(Clone)]
pub struct Style {
    pub outline_thickness: f64,
    pub outline_color: Color,
    pub panel_bg: Color,
    pub hotkey_color: Color,
    pub hovering_color: Color,
    pub loading_tips: Text,
    pub btn_primary_dark: ButtonStyle,
    pub btn_secondary_dark: ButtonStyle,
    pub btn_primary_light: ButtonStyle,
    pub btn_secondary_light: ButtonStyle,
    pub btn_primary_destructive: ButtonStyle,
    pub btn_secondary_destructive: ButtonStyle,
}

#[derive(Clone)]
pub struct ButtonStyle {
    pub fg: Color,
    pub fg_disabled: Color,
    pub outline: Color,
    pub bg: Color,
    pub bg_hover: Color,
    pub bg_disabled: Color,
}

impl Style {
    pub fn standard() -> Style {
        Style {
            outline_thickness: 2.0,
            outline_color: Color::WHITE,
            panel_bg: Color::grey(0.4),
            hotkey_color: Color::GREEN,
            hovering_color: Color::ORANGE,
            loading_tips: Text::new(),

            // Buttons
            btn_primary_dark: ButtonStyle {
                fg: hex("#4C4C4C"),
                fg_disabled: hex("#4C4C4C").alpha(0.3),
                bg: Color::WHITE.alpha(0.8),
                bg_hover: Color::WHITE,
                bg_disabled: Color::grey(0.6),
                outline: Color::WHITE.alpha(0.6),
            },
            btn_secondary_dark: ButtonStyle {
                fg: hex("#4C4C4C"),
                fg_disabled: hex("#4C4C4C").alpha(0.3),
                bg: Color::CLEAR,
                bg_hover: hex("#4C4C4C").alpha(0.1),
                bg_disabled: Color::grey(0.8),
                outline: hex("#4C4C4C"),
            },
            btn_primary_light: ButtonStyle {
                fg: hex("#F2F2F2"),
                fg_disabled: hex("#F2F2F2").alpha(0.3),
                bg: hex("#003046").alpha(0.8),
                bg_hover: hex("#003046"),
                bg_disabled: Color::grey(0.1),
                outline: hex("#003046").alpha(0.6),
            },
            btn_secondary_light: ButtonStyle {
                fg: hex("#F2F2F2"),
                fg_disabled: hex("#F2F2F2").alpha(0.3),
                bg: Color::CLEAR,
                bg_hover: hex("#F2F2F2").alpha(0.1),
                bg_disabled: Color::grey(0.5),
                outline: hex("#F2F2F2"),
            },
            btn_primary_destructive: ButtonStyle {
                fg: hex("#F2F2F2"),
                fg_disabled: hex("#F2F2F2").alpha(0.3),
                bg: hex("#FF5E5E").alpha(0.8),
                bg_hover: hex("#FF5E5E"),
                bg_disabled: Color::grey(0.1),
                outline: hex("#FF5E5E").alpha(0.6),
            },
            btn_secondary_destructive: ButtonStyle {
                fg: hex("#FF5E5E"),
                fg_disabled: hex("#FF5E5E").alpha(0.3),
                bg: Color::CLEAR,
                bg_hover: hex("#FF5E5E").alpha(0.1),
                bg_disabled: Color::grey(0.1),
                outline: hex("#FF5E5E"),
            },
        }
    }
}

// Convenience
fn hex(x: &str) -> Color {
    Color::hex(x)
}