Struct egui::Grid

source ·
pub struct Grid { /* private fields */ }
Expand description

A simple grid layout.

The cells are always layed out left to right, top-down. The contents of each cell will be aligned to the left and center.

If you want to add multiple widgets to a cell you need to group them with Ui::horizontal, Ui::vertical etc.

egui::Grid::new("some_unique_id").show(ui, |ui| {
    ui.label("First row, first column");
    ui.label("First row, second column");
    ui.end_row();

    ui.label("Second row, first column");
    ui.label("Second row, second column");
    ui.label("Second row, third column");
    ui.end_row();

    ui.horizontal(|ui| { ui.label("Same"); ui.label("cell"); });
    ui.label("Third row, second column");
    ui.end_row();
});

Implementations§

Create a new Grid with a locally unique identifier.

Setting this will allow the last column to expand to take up the rest of the space of the parent Ui.

If true, add a subtle background color to every other row.

This can make a table easier to read. Default: false.

Set minimum width of each column. Default: crate::style::Spacing::interact_size.x.

Set minimum height of each row. Default: crate::style::Spacing::interact_size.y.

Set soft maximum width (wrapping width) of each column.

Set spacing between columns/rows. Default: crate::style::Spacing::item_spacing.

Change which row number the grid starts on. This can be useful when you have a large Grid inside of ScrollArea::show_rows.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

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

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more