Skip to main content

cranpose_ui/text/
decoration.rs

1use crate::modifier::Color;
2
3#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
4pub struct TextDecoration(u32);
5
6impl TextDecoration {
7    pub const NONE: Self = Self(0);
8    pub const UNDERLINE: Self = Self(1);
9    pub const LINE_THROUGH: Self = Self(2);
10
11    pub fn contains(&self, other: Self) -> bool {
12        (self.0 | other.0) == self.0
13    }
14
15    pub fn combine(self, other: Self) -> Self {
16        Self(self.0 | other.0)
17    }
18}
19
20impl Default for TextDecoration {
21    fn default() -> Self {
22        Self::NONE
23    }
24}
25
26#[cfg(test)]
27#[path = "tests/decoration_tests.rs"]
28mod tests;
29
30#[derive(Clone, Copy, Debug, PartialEq)]
31pub struct Shadow {
32    pub color: Color,
33    pub offset: crate::modifier::Point,
34    pub blur_radius: f32,
35}
36
37impl Default for Shadow {
38    fn default() -> Self {
39        Self {
40            color: Color(0.0, 0.0, 0.0, 1.0),
41            offset: crate::modifier::Point::new(0.0, 0.0),
42            blur_radius: 0.0,
43        }
44    }
45}