Skip to main content

sequoia_style/
resize_handle_style.rs

1use sequoia_core::Color;
2
3#[derive(Clone, Copy, Debug, Default, PartialEq)]
4pub struct ResizeHandleStyle {
5    pub idle: Option<Color>,
6    pub active: Option<Color>,
7    pub idle_width: Option<f32>,
8    pub active_width: Option<f32>,
9    pub gutter: Option<Color>,
10}
11
12impl ResizeHandleStyle {
13    pub const fn new() -> Self {
14        Self {
15            idle: None,
16            active: None,
17            idle_width: None,
18            active_width: None,
19            gutter: None,
20        }
21    }
22
23    pub const fn idle(mut self, color: Color) -> Self {
24        self.idle = Some(color);
25        self
26    }
27
28    pub const fn active(mut self, color: Color) -> Self {
29        self.active = Some(color);
30        self
31    }
32
33    pub const fn idle_width(mut self, width: f32) -> Self {
34        self.idle_width = Some(width);
35        self
36    }
37
38    pub const fn active_width(mut self, width: f32) -> Self {
39        self.active_width = Some(width);
40        self
41    }
42
43    pub const fn gutter(mut self, color: Color) -> Self {
44        self.gutter = Some(color);
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: ResizeHandleStyle = ResizeHandleStyle::new().idle_width(2.0);
56        assert_eq!(CUSTOM.idle_width, Some(2.0));
57        assert_eq!(CUSTOM.idle, None);
58    }
59}