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
use densa_core::Color;
/// Colors and sizes widgets share, so an application restyles every widget in one place.
/// Sizes are in logical pixels.
#[derive(Debug, Clone, PartialEq)]
#[non_exhaustive]
pub struct Theme {
/// Behind everything: the window.
pub background: Color,
/// Panels and toolbars.
pub surface: Color,
/// Controls: buttons, inputs.
pub raised: Color,
/// A control under the pointer.
pub hover: Color,
/// A control being pressed.
pub pressed: Color,
/// Lines between and around things.
pub border: Color,
/// Text.
pub text: Color,
/// Secondary text: hints, labels of lesser weight.
pub text_dim: Color,
/// The accent: default buttons, selected items.
pub accent: Color,
/// Text on the accent color.
pub on_accent: Color,
/// Selected text's background.
pub selection: Color,
/// The ring around the focused control.
pub focus: Color,
/// Body text size.
pub font_size: f32,
/// The base unit of spacing.
pub spacing: f32,
}
impl Theme {
/// Light text on dark surfaces.
pub fn dark() -> Self {
Self {
background: Color::srgb(0x0B1220),
surface: Color::srgb(0x111A2B),
raised: Color::srgb(0x1A2540),
hover: Color::srgb(0x22304A),
pressed: Color::srgb(0x2A3A5C),
border: Color::srgb(0x22304A),
text: Color::srgb(0xE6EDF7),
text_dim: Color::srgb(0x9AA8BE),
accent: Color::srgb(0x2F5BEA),
on_accent: Color::WHITE,
selection: Color::srgb(0x2F5BEA).with_alpha(0.45),
focus: Color::srgb(0x6B9BFF),
font_size: 13.0,
spacing: 4.0,
}
}
/// Dark text on light surfaces.
pub fn light() -> Self {
Self {
background: Color::srgb(0xF4F6FA),
surface: Color::srgb(0xFFFFFF),
raised: Color::srgb(0xFFFFFF),
hover: Color::srgb(0xEEF2F8),
pressed: Color::srgb(0xE2E8F2),
border: Color::srgb(0xD5DCE6),
text: Color::srgb(0x0B1220),
text_dim: Color::srgb(0x5B6B82),
accent: Color::srgb(0x2F5BEA),
on_accent: Color::WHITE,
selection: Color::srgb(0x2F5BEA).with_alpha(0.25),
focus: Color::srgb(0x2F5BEA),
font_size: 13.0,
spacing: 4.0,
}
}
}
impl Default for Theme {
/// [`Theme::dark`]: data-dense screens are mostly read in dark rooms.
fn default() -> Self {
Self::dark()
}
}