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::prelude::styles::*;
impl ColorSet {
pub fn new(normal: Option<Color>, hover: Option<Color>) -> Self {
Self { normal, hover }
}
pub fn new_values(normal: Color, hover: Color) -> Self {
Self::new(Some(normal), Some(hover))
}
pub fn new_same(color: Color) -> Self {
Self::new(Some(color), Some(color))
}
pub fn get(&self, hovering: bool) -> Option<Color> {
if hovering {
self.hover
} else {
self.normal
}
}
}
impl FocusColorSet {
pub fn new(normal: Option<Color>, hover: Option<Color>, focused: Option<Color>) -> Self {
Self {
normal,
hover,
focused,
}
}
pub fn new_values(normal: Color, hover: Color, focused: Color) -> Self {
Self::new(Some(normal), Some(hover), Some(focused))
}
pub fn new_same(color: Color) -> Self {
Self::new(Some(color), Some(color), Some(color))
}
pub fn get(&self, hovering: bool, focused: bool) -> Option<Color> {
if focused {
self.focused
} else if hovering {
self.hover
} else {
self.normal
}
}
}
impl ToggleColorSet {
pub fn new(
normal: Option<Color>,
hover: Option<Color>,
toggled: Option<Color>,
hover_toggled: Option<Color>,
) -> Self {
Self {
normal,
hover,
toggled,
hover_toggled,
}
}
pub fn new_values(normal: Color, hover: Color, toggled: Color, hover_toggled: Color) -> Self {
Self::new(
Some(normal),
Some(hover),
Some(toggled),
Some(hover_toggled),
)
}
pub fn new_same_hover(
normal: Option<Color>,
hover: Option<Color>,
toggled: Option<Color>,
) -> Self {
Self::new(normal, hover, toggled, hover)
}
pub fn new_same(color: Color) -> Self {
Self::new(Some(color), Some(color), Some(color), Some(color))
}
pub fn get(&self, hovering: bool, toggled: bool) -> Option<Color> {
match (hovering, toggled) {
(true, true) => self.hover_toggled,
(true, false) => self.hover,
(false, true) => self.toggled,
(false, false) => self.normal,
}
}
}