pub struct Grid(/* private fields */);Expand description
Builder for a Grid container
Implementations§
Source§impl Grid
impl Grid
Sourcepub fn new(columns: i64) -> Self
pub fn new(columns: i64) -> Self
Create a new grid with columns
Examples found in repository?
examples/simple_plugin.rs (line 206)
193fn build_dashboard() -> PluginValue {
194 Panel::new()
195 .padding(20)
196 .child(
197 "dashboard",
198 Stack::vertical()
199 .spacing(16)
200 .child(
201 "header",
202 Label::new("System Dashboard").size("xl").weight("bold"),
203 )
204 .child(
205 "metrics",
206 Grid::new(2)
207 .gap(16)
208 // Metric card 1
209 .child(
210 "cpu",
211 Panel::new().padding(16).border(1).child(
212 "content",
213 Stack::vertical()
214 .spacing(8)
215 .child("label", Label::new("CPU Usage"))
216 .child(
217 "value",
218 Label::new("--%")
219 .size("xl")
220 .weight("bold")
221 .bind_text("metrics.cpu.display"),
222 )
223 .child(
224 "bar",
225 Slider::new()
226 .min(0.0)
227 .max(100.0)
228 .bind_value("metrics.cpu.value"),
229 ),
230 ),
231 )
232 // Metric card 2
233 .child(
234 "memory",
235 Panel::new().padding(16).border(1).child(
236 "content",
237 Stack::vertical()
238 .spacing(8)
239 .child("label", Label::new("Memory Usage"))
240 .child(
241 "value",
242 Label::new("--%")
243 .size("xl")
244 .weight("bold")
245 .bind_text("metrics.memory.display"),
246 )
247 .child(
248 "bar",
249 Slider::new()
250 .min(0.0)
251 .max(100.0)
252 .bind_value("metrics.memory.value"),
253 ),
254 ),
255 )
256 // Metric card 3
257 .child(
258 "disk",
259 Panel::new().padding(16).border(1).child(
260 "content",
261 Stack::vertical()
262 .spacing(8)
263 .child("label", Label::new("Disk Usage"))
264 .child(
265 "value",
266 Label::new("--%")
267 .size("xl")
268 .weight("bold")
269 .bind_text("metrics.disk.display"),
270 )
271 .child(
272 "bar",
273 Slider::new()
274 .min(0.0)
275 .max(100.0)
276 .bind_value("metrics.disk.value"),
277 ),
278 ),
279 )
280 // Metric card 4
281 .child(
282 "network",
283 Panel::new().padding(16).border(1).child(
284 "content",
285 Stack::vertical()
286 .spacing(8)
287 .child("label", Label::new("Network"))
288 .child(
289 "value",
290 Label::new("-- MB/s")
291 .size("xl")
292 .weight("bold")
293 .bind_text("metrics.network.display"),
294 ),
295 ),
296 ),
297 ),
298 )
299 .build()
300}Sourcepub fn gap(self, gap: i64) -> Self
pub fn gap(self, gap: i64) -> Self
Set the gap between cells
Examples found in repository?
examples/simple_plugin.rs (line 207)
193fn build_dashboard() -> PluginValue {
194 Panel::new()
195 .padding(20)
196 .child(
197 "dashboard",
198 Stack::vertical()
199 .spacing(16)
200 .child(
201 "header",
202 Label::new("System Dashboard").size("xl").weight("bold"),
203 )
204 .child(
205 "metrics",
206 Grid::new(2)
207 .gap(16)
208 // Metric card 1
209 .child(
210 "cpu",
211 Panel::new().padding(16).border(1).child(
212 "content",
213 Stack::vertical()
214 .spacing(8)
215 .child("label", Label::new("CPU Usage"))
216 .child(
217 "value",
218 Label::new("--%")
219 .size("xl")
220 .weight("bold")
221 .bind_text("metrics.cpu.display"),
222 )
223 .child(
224 "bar",
225 Slider::new()
226 .min(0.0)
227 .max(100.0)
228 .bind_value("metrics.cpu.value"),
229 ),
230 ),
231 )
232 // Metric card 2
233 .child(
234 "memory",
235 Panel::new().padding(16).border(1).child(
236 "content",
237 Stack::vertical()
238 .spacing(8)
239 .child("label", Label::new("Memory Usage"))
240 .child(
241 "value",
242 Label::new("--%")
243 .size("xl")
244 .weight("bold")
245 .bind_text("metrics.memory.display"),
246 )
247 .child(
248 "bar",
249 Slider::new()
250 .min(0.0)
251 .max(100.0)
252 .bind_value("metrics.memory.value"),
253 ),
254 ),
255 )
256 // Metric card 3
257 .child(
258 "disk",
259 Panel::new().padding(16).border(1).child(
260 "content",
261 Stack::vertical()
262 .spacing(8)
263 .child("label", Label::new("Disk Usage"))
264 .child(
265 "value",
266 Label::new("--%")
267 .size("xl")
268 .weight("bold")
269 .bind_text("metrics.disk.display"),
270 )
271 .child(
272 "bar",
273 Slider::new()
274 .min(0.0)
275 .max(100.0)
276 .bind_value("metrics.disk.value"),
277 ),
278 ),
279 )
280 // Metric card 4
281 .child(
282 "network",
283 Panel::new().padding(16).border(1).child(
284 "content",
285 Stack::vertical()
286 .spacing(8)
287 .child("label", Label::new("Network"))
288 .child(
289 "value",
290 Label::new("-- MB/s")
291 .size("xl")
292 .weight("bold")
293 .bind_text("metrics.network.display"),
294 ),
295 ),
296 ),
297 ),
298 )
299 .build()
300}Sourcepub fn child(self, id: impl Into<String>, child: impl Builder) -> Self
pub fn child(self, id: impl Into<String>, child: impl Builder) -> Self
Add a child component
Examples found in repository?
examples/simple_plugin.rs (lines 209-231)
193fn build_dashboard() -> PluginValue {
194 Panel::new()
195 .padding(20)
196 .child(
197 "dashboard",
198 Stack::vertical()
199 .spacing(16)
200 .child(
201 "header",
202 Label::new("System Dashboard").size("xl").weight("bold"),
203 )
204 .child(
205 "metrics",
206 Grid::new(2)
207 .gap(16)
208 // Metric card 1
209 .child(
210 "cpu",
211 Panel::new().padding(16).border(1).child(
212 "content",
213 Stack::vertical()
214 .spacing(8)
215 .child("label", Label::new("CPU Usage"))
216 .child(
217 "value",
218 Label::new("--%")
219 .size("xl")
220 .weight("bold")
221 .bind_text("metrics.cpu.display"),
222 )
223 .child(
224 "bar",
225 Slider::new()
226 .min(0.0)
227 .max(100.0)
228 .bind_value("metrics.cpu.value"),
229 ),
230 ),
231 )
232 // Metric card 2
233 .child(
234 "memory",
235 Panel::new().padding(16).border(1).child(
236 "content",
237 Stack::vertical()
238 .spacing(8)
239 .child("label", Label::new("Memory Usage"))
240 .child(
241 "value",
242 Label::new("--%")
243 .size("xl")
244 .weight("bold")
245 .bind_text("metrics.memory.display"),
246 )
247 .child(
248 "bar",
249 Slider::new()
250 .min(0.0)
251 .max(100.0)
252 .bind_value("metrics.memory.value"),
253 ),
254 ),
255 )
256 // Metric card 3
257 .child(
258 "disk",
259 Panel::new().padding(16).border(1).child(
260 "content",
261 Stack::vertical()
262 .spacing(8)
263 .child("label", Label::new("Disk Usage"))
264 .child(
265 "value",
266 Label::new("--%")
267 .size("xl")
268 .weight("bold")
269 .bind_text("metrics.disk.display"),
270 )
271 .child(
272 "bar",
273 Slider::new()
274 .min(0.0)
275 .max(100.0)
276 .bind_value("metrics.disk.value"),
277 ),
278 ),
279 )
280 // Metric card 4
281 .child(
282 "network",
283 Panel::new().padding(16).border(1).child(
284 "content",
285 Stack::vertical()
286 .spacing(8)
287 .child("label", Label::new("Network"))
288 .child(
289 "value",
290 Label::new("-- MB/s")
291 .size("xl")
292 .weight("bold")
293 .bind_text("metrics.network.display"),
294 ),
295 ),
296 ),
297 ),
298 )
299 .build()
300}Sourcepub fn children(
self,
children: impl IntoIterator<Item = (String, PluginValue)>,
) -> Self
pub fn children( self, children: impl IntoIterator<Item = (String, PluginValue)>, ) -> Self
Add multiple children
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Grid
impl RefUnwindSafe for Grid
impl Send for Grid
impl Sync for Grid
impl Unpin for Grid
impl UnsafeUnpin for Grid
impl UnwindSafe for Grid
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more