sequoia_style/
tooltip_style.rs1use sequoia_core::Color;
2
3#[derive(Clone, Copy, Debug, Default, PartialEq)]
4pub struct TooltipStyle {
5 pub background: Option<Color>,
6 pub border: Option<Color>,
7 pub text: Option<Color>,
8 pub font_size: Option<f32>,
9 pub radius: Option<f32>,
10 pub padding: Option<(f32, f32)>,
11}
12
13impl TooltipStyle {
14 pub const fn new() -> Self {
15 Self {
16 background: None,
17 border: None,
18 text: None,
19 font_size: None,
20 radius: None,
21 padding: None,
22 }
23 }
24
25 pub const fn background(mut self, color: Color) -> Self {
26 self.background = Some(color);
27 self
28 }
29
30 pub const fn border(mut self, color: Color) -> Self {
31 self.border = Some(color);
32 self
33 }
34
35 pub const fn text(mut self, color: Color) -> Self {
36 self.text = Some(color);
37 self
38 }
39
40 pub const fn font_size(mut self, size: f32) -> Self {
41 self.font_size = Some(size);
42 self
43 }
44
45 pub const fn radius(mut self, radius: f32) -> Self {
46 self.radius = Some(radius);
47 self
48 }
49
50 pub const fn padding_xy(mut self, pad_x: f32, pad_y: f32) -> Self {
51 self.padding = Some((pad_x, pad_y));
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: TooltipStyle = TooltipStyle::new().radius(8.0);
63 assert_eq!(CUSTOM.radius, Some(8.0));
64 assert_eq!(CUSTOM.text, None);
65 }
66}