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
use cranpose_ui_graphics::Color;
/// A set of lines drawn on text: none, an underline, a line through, or both.
/// Combine values with [`TextDecoration::combine`]. Compose's `TextDecoration`.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub struct TextDecoration(u32);
impl TextDecoration {
/// No line is drawn.
pub const NONE: Self = Self(0);
/// A line drawn below the text.
pub const UNDERLINE: Self = Self(1);
/// A line drawn through the middle of the text.
pub const LINE_THROUGH: Self = Self(2);
/// Returns true when every line set in `other` is also set in this value.
pub fn contains(&self, other: Self) -> bool {
(self.0 | other.0) == self.0
}
/// Returns a decoration that draws the lines of both `self` and `other`.
pub fn combine(self, other: Self) -> Self {
Self(self.0 | other.0)
}
}
impl Default for TextDecoration {
fn default() -> Self {
Self::NONE
}
}
#[cfg(test)]
#[path = "tests/decoration_tests.rs"]
mod tests;
/// A shadow drawn behind text. Compose's `Shadow`.
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct Shadow {
/// Color of the shadow, including its alpha.
pub color: Color,
/// Offset of the shadow from the text, in logical pixels.
pub offset: cranpose_ui_graphics::Point,
/// Blur radius of the shadow, in logical pixels. Zero gives a hard-edged shadow.
pub blur_radius: f32,
}
impl Default for Shadow {
fn default() -> Self {
Self {
color: Color(0.0, 0.0, 0.0, 1.0),
offset: cranpose_ui_graphics::Point::new(0.0, 0.0),
blur_radius: 0.0,
}
}
}