Skip to main content

Grid

Struct Grid 

Source
pub struct Grid(/* private fields */);
Expand description

Builder for a Grid container

Implementations§

Source§

impl Grid

Source

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}
Source

pub fn columns(self, columns: i64) -> Self

Set the number of columns

Source

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}
Source

pub fn padding(self, padding: i64) -> Self

Set the padding

Source

pub fn width(self, width: i64) -> Self

Set the width

Source

pub fn height(self, height: i64) -> Self

Set the height

Source

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}
Source

pub fn children( self, children: impl IntoIterator<Item = (String, PluginValue)>, ) -> Self

Add multiple children

Trait Implementations§

Source§

impl Builder for Grid

Source§

fn build(self) -> PluginValue

Convert this builder to a PluginValue

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.