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
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 loading_tips: Text,
    pub btn_solid_dark: ButtonStyle,
    pub btn_outline_dark: ButtonStyle,
    pub btn_solid_light: ButtonStyle,
    pub btn_outline_light: ButtonStyle,
    pub btn_solid_destructive: ButtonStyle,
    pub btn_outline_destructive: ButtonStyle,
}

#[derive(Clone)]
pub struct ButtonStyle {
    pub fg: Color,
    pub fg_disabled: Color,
    pub fg_hotkey: 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,
            loading_tips: Text::new(),

            // Buttons
            btn_solid_dark: ButtonStyle {
                fg: hex("#4C4C4C"),
                fg_disabled: hex("#4C4C4C").alpha(0.3),
                fg_hotkey: hex("#EE702E"),
                bg: Color::WHITE.alpha(0.8),
                bg_hover: Color::WHITE,
                bg_disabled: Color::grey(0.6),
                outline: Color::WHITE.alpha(0.6),
            },
            btn_outline_dark: ButtonStyle {
                fg: hex("#4C4C4C"),
                fg_disabled: hex("#4C4C4C").alpha(0.3),
                fg_hotkey: hex("#EE702E"),
                bg: Color::CLEAR,
                bg_hover: hex("#4C4C4C").alpha(0.1),
                bg_disabled: Color::grey(0.8),
                outline: hex("#4C4C4C"),
            },
            btn_solid_light: ButtonStyle {
                fg: hex("#F2F2F2"),
                fg_disabled: hex("#F2F2F2").alpha(0.3),
                fg_hotkey: Color::GREEN,
                bg: hex("#003046").alpha(0.8),
                bg_hover: hex("#003046"),
                bg_disabled: Color::grey(0.1),
                outline: hex("#003046").alpha(0.6),
            },
            btn_outline_light: ButtonStyle {
                fg: hex("#F2F2F2"),
                fg_disabled: hex("#F2F2F2").alpha(0.3),
                fg_hotkey: Color::GREEN,
                bg: Color::CLEAR,
                bg_hover: hex("#F2F2F2").alpha(0.1),
                bg_disabled: Color::grey(0.5),
                outline: hex("#F2F2F2"),
            },
            btn_solid_destructive: ButtonStyle {
                fg: hex("#F2F2F2"),
                fg_disabled: hex("#F2F2F2").alpha(0.3),
                fg_hotkey: Color::GREEN,
                bg: hex("#FF5E5E").alpha(0.8),
                bg_hover: hex("#FF5E5E"),
                bg_disabled: Color::grey(0.1),
                outline: hex("#FF5E5E").alpha(0.6),
            },
            btn_outline_destructive: ButtonStyle {
                fg: hex("#FF5E5E"),
                fg_disabled: hex("#FF5E5E").alpha(0.3),
                fg_hotkey: Color::GREEN,
                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)
}