Skip to main content

sequoia_style/
drag_value_style.rs

1use sequoia_core::Color;
2
3#[derive(Clone, Copy, Debug, Default, PartialEq)]
4pub struct DragValueStyle {
5    pub text: Option<Color>,
6    pub line: Option<Color>,
7    pub line_width: Option<f32>,
8    pub font_size: Option<f32>,
9    pub font_weight: Option<u16>,
10}
11
12impl DragValueStyle {
13    pub const fn new() -> Self {
14        Self {
15            text: None,
16            line: None,
17            line_width: None,
18            font_size: None,
19            font_weight: None,
20        }
21    }
22
23    pub const fn text(mut self, color: Color) -> Self {
24        self.text = Some(color);
25        self
26    }
27
28    pub const fn line(mut self, color: Color) -> Self {
29        self.line = Some(color);
30        self
31    }
32
33    pub const fn line_width(mut self, width: f32) -> Self {
34        self.line_width = Some(width);
35        self
36    }
37
38    pub const fn font_size(mut self, size: f32) -> Self {
39        self.font_size = Some(size);
40        self
41    }
42
43    pub const fn font_weight(mut self, weight: u16) -> Self {
44        self.font_weight = Some(weight);
45        self
46    }
47}
48
49#[cfg(test)]
50mod tests {
51    use super::*;
52
53    #[test]
54    fn const_composition_keeps_base() {
55        const CUSTOM: DragValueStyle = DragValueStyle::new().font_size(12.0);
56        assert_eq!(CUSTOM.font_size, Some(12.0));
57        assert_eq!(CUSTOM.text, None);
58    }
59}