1#[derive(Debug, Clone, Copy, PartialEq, Eq)]
5pub struct Style {
6 pub bg_color: crate::widget::Color,
8 pub border_color: crate::widget::Color,
10 pub border_width: u8,
12 pub alpha: u8,
16 pub radius: u8,
18}
19
20impl Default for Style {
21 fn default() -> Self {
22 Self {
23 bg_color: crate::widget::Color(255, 255, 255, 255),
24 border_color: crate::widget::Color(0, 0, 0, 255),
25 border_width: 0,
26 alpha: 255,
27 radius: 0,
28 }
29 }
30}
31
32pub struct StyleBuilder {
34 style: Style,
35}
36
37impl Default for StyleBuilder {
38 fn default() -> Self {
39 Self::new()
40 }
41}
42
43impl StyleBuilder {
44 pub fn new() -> Self {
46 Self {
47 style: Style::default(),
48 }
49 }
50
51 pub fn bg_color(mut self, color: crate::widget::Color) -> Self {
53 self.style.bg_color = color;
54 self
55 }
56
57 pub fn border_color(mut self, color: crate::widget::Color) -> Self {
59 self.style.border_color = color;
60 self
61 }
62
63 pub fn border_width(mut self, width: u8) -> Self {
65 self.style.border_width = width;
66 self
67 }
68
69 pub fn alpha(mut self, alpha: u8) -> Self {
71 self.style.alpha = alpha;
72 self
73 }
74
75 pub fn radius(mut self, radius: u8) -> Self {
77 self.style.radius = radius;
78 self
79 }
80
81 pub fn build(self) -> Style {
83 self.style
84 }
85}