charming_fork_zephyr/component/
geo.rs1use serde::Serialize;
2
3use crate::{
4 datatype::CompositeValue,
5 element::{Blur, Emphasis, ItemStyle, Label, Select},
6};
7
8#[derive(Serialize)]
9#[serde(rename_all = "camelCase")]
10pub struct Geo {
11 #[serde(skip_serializing_if = "Option::is_none")]
12 show: Option<bool>,
13
14 #[serde(skip_serializing_if = "Option::is_none")]
15 map: Option<String>,
16
17 #[serde(skip_serializing_if = "Option::is_none")]
18 roam: Option<bool>,
19
20 #[serde(skip_serializing_if = "Option::is_none")]
21 center: Option<(String, String)>,
22
23 #[serde(skip_serializing_if = "Option::is_none")]
24 aspect_scale: Option<i64>,
25
26 #[serde(skip_serializing_if = "Option::is_none")]
27 bounding_coords: Option<((String, String), (String, String))>,
28
29 #[serde(skip_serializing_if = "Option::is_none")]
30 zoom: Option<i64>,
31
32 #[serde(skip_serializing_if = "Option::is_none")]
33 scale_limit: Option<(i64, i64)>,
34
35 #[serde(skip_serializing_if = "Option::is_none")]
36 name_map: Option<(String, String)>,
37
38 #[serde(skip_serializing_if = "Option::is_none")]
39 name_property: Option<String>,
40
41 #[serde(skip_serializing_if = "Option::is_none")]
42 selected_mode: Option<bool>,
43
44 #[serde(skip_serializing_if = "Option::is_none")]
45 label: Option<Label>,
46
47 #[serde(skip_serializing_if = "Option::is_none")]
48 item_style: Option<ItemStyle>,
49
50 #[serde(skip_serializing_if = "Option::is_none")]
51 emphasis: Option<Emphasis>,
52
53 #[serde(skip_serializing_if = "Option::is_none")]
54 select: Option<Select>,
55
56 #[serde(skip_serializing_if = "Option::is_none")]
57 blur: Option<Blur>,
58
59 #[serde(skip_serializing_if = "Option::is_none")]
61 zlevel: Option<i64>,
62
63 #[serde(skip_serializing_if = "Option::is_none")]
65 z: Option<i64>,
66
67 #[serde(skip_serializing_if = "Option::is_none")]
68 left: Option<CompositeValue>,
69
70 #[serde(skip_serializing_if = "Option::is_none")]
71 top: Option<CompositeValue>,
72
73 #[serde(skip_serializing_if = "Option::is_none")]
74 right: Option<CompositeValue>,
75
76 #[serde(skip_serializing_if = "Option::is_none")]
77 bottom: Option<CompositeValue>,
78
79 #[serde(skip_serializing_if = "Option::is_none")]
80 layout_center: Option<(String, String)>,
81
82 #[serde(skip_serializing_if = "Option::is_none")]
83 layout_size: Option<String>,
84
85 #[serde(skip_serializing_if = "Option::is_none")]
86 silent: Option<bool>,
87}
88
89impl Geo {
90 pub fn new() -> Self {
91 Self {
92 show: None,
93 map: None,
94 roam: None,
95 center: None,
96 aspect_scale: None,
97 bounding_coords: None,
98 zoom: None,
99 scale_limit: None,
100 name_map: None,
101 name_property: None,
102 selected_mode: None,
103 label: None,
104 item_style: None,
105 emphasis: None,
106 select: None,
107 blur: None,
108 zlevel: None,
109 z: None,
110 left: None,
111 top: None,
112 right: None,
113 bottom: None,
114 layout_center: None,
115 layout_size: None,
116 silent: None,
117 }
118 }
119
120 pub fn show(mut self, show: bool) -> Self {
121 self.show = Some(show);
122 self
123 }
124
125 pub fn map<S: Into<String>>(mut self, map: S) -> Self {
126 self.map = Some(map.into());
127 self
128 }
129
130 pub fn roam(mut self, roam: bool) -> Self {
131 self.roam = Some(roam);
132 self
133 }
134
135 pub fn center<S: Into<String>>(mut self, center: (S, S)) -> Self {
136 self.center = Some((center.0.into(), center.1.into()));
137 self
138 }
139
140 pub fn aspect_scale<F: Into<i64>>(mut self, aspect_scale: F) -> Self {
141 self.aspect_scale = Some(aspect_scale.into());
142 self
143 }
144
145 pub fn bounding_coords<S: Into<String>>(mut self, bounding_coords: ((S, S), (S, S))) -> Self {
146 self.bounding_coords = Some((
147 ((bounding_coords.0).0.into(), (bounding_coords.0).1.into()),
148 ((bounding_coords.1).0.into(), (bounding_coords.1).1.into()),
149 ));
150 self
151 }
152
153 pub fn zoom<F: Into<i64>>(mut self, zoom: F) -> Self {
154 self.zoom = Some(zoom.into());
155 self
156 }
157
158 pub fn scale_limit<F: Into<i64>>(mut self, scale_limit: (F, F)) -> Self {
159 self.scale_limit = Some((scale_limit.0.into(), scale_limit.1.into()));
160 self
161 }
162
163 pub fn name_map<S: Into<String>>(mut self, name_map: (S, S)) -> Self {
164 self.name_map = Some((name_map.0.into(), name_map.1.into()));
165 self
166 }
167
168 pub fn name_property<S: Into<String>>(mut self, name_property: S) -> Self {
169 self.name_property = Some(name_property.into());
170 self
171 }
172
173 pub fn selected_mode(mut self, selected_mode: bool) -> Self {
174 self.selected_mode = Some(selected_mode);
175 self
176 }
177
178 pub fn label<L: Into<Label>>(mut self, label: L) -> Self {
179 self.label = Some(label.into());
180 self
181 }
182
183 pub fn item_style<S: Into<ItemStyle>>(mut self, item_style: S) -> Self {
184 self.item_style = Some(item_style.into());
185 self
186 }
187
188 pub fn emphasis<E: Into<Emphasis>>(mut self, emphasis: E) -> Self {
189 self.emphasis = Some(emphasis.into());
190 self
191 }
192
193 pub fn select<S: Into<Select>>(mut self, select: S) -> Self {
194 self.select = Some(select.into());
195 self
196 }
197
198 pub fn blur<B: Into<Blur>>(mut self, blur: B) -> Self {
199 self.blur = Some(blur.into());
200 self
201 }
202
203 pub fn zlevel<F: Into<i64>>(mut self, zlevel: F) -> Self {
204 self.zlevel = Some(zlevel.into());
205 self
206 }
207
208 pub fn z<F: Into<i64>>(mut self, z: F) -> Self {
209 self.z = Some(z.into());
210 self
211 }
212
213 pub fn left<C: Into<CompositeValue>>(mut self, left: C) -> Self {
214 self.left = Some(left.into());
215 self
216 }
217
218 pub fn top<C: Into<CompositeValue>>(mut self, top: C) -> Self {
219 self.top = Some(top.into());
220 self
221 }
222
223 pub fn right<C: Into<CompositeValue>>(mut self, right: C) -> Self {
224 self.right = Some(right.into());
225 self
226 }
227
228 pub fn bottom<C: Into<CompositeValue>>(mut self, bottom: C) -> Self {
229 self.bottom = Some(bottom.into());
230 self
231 }
232
233 pub fn layout_center<S: Into<String>>(mut self, layout_center: (S, S)) -> Self {
234 self.layout_center = Some((layout_center.0.into(), layout_center.1.into()));
235 self
236 }
237
238 pub fn layout_size<S: Into<String>>(mut self, layout_size: S) -> Self {
239 self.layout_size = Some(layout_size.into());
240 self
241 }
242
243 pub fn silent(mut self, silent: bool) -> Self {
244 self.silent = Some(silent);
245 self
246 }
247}