sequoia_style/
slider_style.rs1use sequoia_core::Color;
2
3#[derive(Clone, Copy, Debug, Default, PartialEq)]
4pub struct SliderStyle {
5 pub track: Option<Color>,
6 pub fill: Option<Color>,
7 pub thumb_center: Option<Color>,
8 pub thumb_outline: Option<Color>,
9 pub track_height: Option<f32>,
10 pub thumb_size: Option<f32>,
11}
12
13impl SliderStyle {
14 pub const fn new() -> Self {
15 Self {
16 track: None,
17 fill: None,
18 thumb_center: None,
19 thumb_outline: None,
20 track_height: None,
21 thumb_size: None,
22 }
23 }
24
25 pub const fn track(mut self, color: Color) -> Self {
26 self.track = Some(color);
27 self
28 }
29
30 pub const fn fill(mut self, color: Color) -> Self {
31 self.fill = Some(color);
32 self
33 }
34
35 pub const fn thumb_center(mut self, color: Color) -> Self {
36 self.thumb_center = Some(color);
37 self
38 }
39
40 pub const fn thumb_outline(mut self, color: Color) -> Self {
41 self.thumb_outline = Some(color);
42 self
43 }
44
45 pub const fn track_height(mut self, height: f32) -> Self {
46 self.track_height = Some(height);
47 self
48 }
49
50 pub const fn thumb_size(mut self, size: f32) -> Self {
51 self.thumb_size = Some(size);
52 self
53 }
54}
55
56#[cfg(test)]
57mod tests {
58 use super::*;
59
60 #[test]
61 fn const_composition_keeps_base() {
62 const CUSTOM: SliderStyle = SliderStyle::new().track_height(6.0);
63 assert_eq!(CUSTOM.track_height, Some(6.0));
64 assert_eq!(CUSTOM.track, None);
65 }
66}