Skip to main content

sequoia_style/
table_tree_style.rs

1use sequoia_core::Color;
2
3#[derive(Clone, Copy, Debug, Default, PartialEq)]
4pub struct TableStyle {
5    pub header_size: Option<f32>,
6
7    pub header_color: Option<Color>,
8
9    pub row_stripe: Option<Color>,
10}
11
12impl TableStyle {
13    pub const fn new() -> Self {
14        Self {
15            header_size: None,
16            header_color: None,
17            row_stripe: None,
18        }
19    }
20
21    pub const fn header_size(mut self, size: f32) -> Self {
22        self.header_size = Some(size);
23        self
24    }
25
26    pub const fn header_color(mut self, color: Color) -> Self {
27        self.header_color = Some(color);
28        self
29    }
30
31    pub const fn row_stripe(mut self, color: Color) -> Self {
32        self.row_stripe = Some(color);
33        self
34    }
35}
36
37#[derive(Clone, Copy, Debug, Default, PartialEq)]
38pub struct TreeStyle {
39    pub arrow_color: Option<Color>,
40
41    pub font_size: Option<f32>,
42}
43
44impl TreeStyle {
45    pub const fn new() -> Self {
46        Self {
47            arrow_color: None,
48            font_size: None,
49        }
50    }
51
52    pub const fn arrow_color(mut self, color: Color) -> Self {
53        self.arrow_color = Some(color);
54        self
55    }
56
57    pub const fn font_size(mut self, size: f32) -> Self {
58        self.font_size = Some(size);
59        self
60    }
61}
62
63#[cfg(test)]
64mod tests {
65    use super::*;
66
67    #[test]
68    fn table_builders_compose() {
69        let s = TableStyle::new().header_size(13.0);
70        assert_eq!(s.header_size, Some(13.0));
71        assert_eq!(s.row_stripe, None);
72    }
73
74    #[test]
75    fn tree_builders_compose() {
76        let s = TreeStyle::new().font_size(14.0);
77        assert_eq!(s.font_size, Some(14.0));
78        assert_eq!(s.arrow_color, None);
79    }
80}