charming_fork_zephyr/component/
aria.rs1use serde::Serialize;
2
3use crate::{
4 datatype::CompositeValue,
5 element::{Color, Label, Symbol},
6};
7
8#[derive(Serialize)]
12#[serde(rename_all = "camelCase")]
13pub struct DecalItem {
14 #[serde(skip_serializing_if = "Option::is_none")]
16 symbol: Option<Symbol>,
17
18 #[serde(skip_serializing_if = "Option::is_none")]
20 symbol_size: Option<i64>,
21
22 #[serde(skip_serializing_if = "Option::is_none")]
24 symbol_keep_aspect: Option<bool>,
25
26 #[serde(skip_serializing_if = "Option::is_none")]
29 color: Option<Color>,
30
31 #[serde(skip_serializing_if = "Option::is_none")]
34 background_color: Option<Color>,
35
36 #[serde(skip_serializing_if = "Option::is_none")]
38 dash_array_x: Option<CompositeValue>,
39
40 #[serde(skip_serializing_if = "Option::is_none")]
42 dash_array_y: Option<CompositeValue>,
43
44 #[serde(skip_serializing_if = "Option::is_none")]
46 rotation: Option<i64>,
47
48 #[serde(skip_serializing_if = "Option::is_none")]
51 max_tile_width: Option<i64>,
52
53 #[serde(skip_serializing_if = "Option::is_none")]
56 max_tile_height: Option<i64>,
57}
58
59impl DecalItem {
60 pub fn new() -> DecalItem {
61 DecalItem {
62 symbol: None,
63 symbol_size: None,
64 symbol_keep_aspect: None,
65 color: None,
66 background_color: None,
67 dash_array_x: None,
68 dash_array_y: None,
69 rotation: None,
70 max_tile_width: None,
71 max_tile_height: None,
72 }
73 }
74
75 pub fn symbol<S: Into<Symbol>>(mut self, symbol: S) -> DecalItem {
76 self.symbol = Some(symbol.into());
77 self
78 }
79
80 pub fn symbol_size<F: Into<i64>>(mut self, symbol_size: F) -> DecalItem {
81 self.symbol_size = Some(symbol_size.into());
82 self
83 }
84
85 pub fn symbol_keep_aspect(mut self, symbol_keep_aspect: bool) -> DecalItem {
86 self.symbol_keep_aspect = Some(symbol_keep_aspect);
87 self
88 }
89
90 pub fn color<C: Into<Color>>(mut self, color: C) -> DecalItem {
91 self.color = Some(color.into());
92 self
93 }
94
95 pub fn background_color<C: Into<Color>>(mut self, background_color: C) -> DecalItem {
96 self.background_color = Some(background_color.into());
97 self
98 }
99
100 pub fn dash_array_x<F: Into<CompositeValue>>(mut self, dash_array_x: F) -> DecalItem {
101 self.dash_array_x = Some(dash_array_x.into());
102 self
103 }
104
105 pub fn dash_array_y<F: Into<CompositeValue>>(mut self, dash_array_y: F) -> DecalItem {
106 self.dash_array_y = Some(dash_array_y.into());
107 self
108 }
109
110 pub fn rotation<F: Into<i64>>(mut self, rotation: F) -> DecalItem {
111 self.rotation = Some(rotation.into());
112 self
113 }
114
115 pub fn max_tile_width<F: Into<i64>>(mut self, max_tile_width: F) -> DecalItem {
116 self.max_tile_width = Some(max_tile_width.into());
117 self
118 }
119
120 pub fn max_tile_height<F: Into<i64>>(mut self, max_tile_height: F) -> DecalItem {
121 self.max_tile_height = Some(max_tile_height.into());
122 self
123 }
124}
125
126#[derive(Serialize)]
130#[serde(rename_all = "camelCase")]
131pub struct Decal {
132 #[serde(skip_serializing_if = "Option::is_none")]
135 show: Option<bool>,
136
137 #[serde(skip_serializing_if = "Vec::is_empty")]
141 decals: Vec<DecalItem>,
142}
143
144impl Decal {
145 pub fn new() -> Decal {
146 Decal {
147 show: None,
148 decals: vec![],
149 }
150 }
151
152 pub fn show(mut self, show: bool) -> Decal {
153 self.show = Some(show);
154 self
155 }
156
157 pub fn decals<D: Into<DecalItem>>(mut self, decals: Vec<D>) -> Decal {
158 self.decals = decals.into_iter().map(|d| d.into()).collect();
159 self
160 }
161}
162
163#[derive(Serialize)]
194#[serde(rename_all = "camelCase")]
195pub struct Aria {
196 #[serde(skip_serializing_if = "Option::is_none")]
198 enabled: Option<bool>,
199
200 #[serde(skip_serializing_if = "Option::is_none")]
205 label: Option<Label>,
206
207 #[serde(skip_serializing_if = "Option::is_none")]
210 decal: Option<Decal>,
211}
212
213impl Aria {
214 pub fn new() -> Aria {
215 Aria {
216 enabled: None,
217 label: None,
218 decal: None,
219 }
220 }
221
222 pub fn enabled(mut self, enabled: bool) -> Aria {
223 self.enabled = Some(enabled);
224 self
225 }
226
227 pub fn label<L: Into<Label>>(mut self, label: L) -> Aria {
228 self.label = Some(label.into());
229 self
230 }
231
232 pub fn decal<D: Into<Decal>>(mut self, decal: D) -> Aria {
233 self.decal = Some(decal.into());
234 self
235 }
236}