pub struct Grid { /* private fields */ }Expand description
A simple grid layout.
The cells are always laid 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§
Source§impl Grid
impl Grid
Sourcepub fn with_row_color<F>(self, color_picker: F) -> Self
pub fn with_row_color<F>(self, color_picker: F) -> Self
Setting this will allow for dynamic coloring of rows of the grid object
Sourcepub fn num_columns(self, num_columns: usize) -> Self
pub fn num_columns(self, num_columns: usize) -> Self
Setting this will allow the last column to expand to take up the rest of the space of the parent Ui.
Sourcepub fn striped(self, striped: bool) -> Self
pub fn striped(self, striped: bool) -> Self
If true, add a subtle background color to every other row.
This can make a table easier to read.
Default is whatever is in crate::Visuals::striped.
Sourcepub fn min_col_width(self, min_col_width: f32) -> Self
pub fn min_col_width(self, min_col_width: f32) -> Self
Set minimum width of each column.
Default: crate::style::Spacing::interact_size.x.
Sourcepub fn min_row_height(self, min_row_height: f32) -> Self
pub fn min_row_height(self, min_row_height: f32) -> Self
Set minimum height of each row.
Default: crate::style::Spacing::interact_size.y.
Sourcepub fn max_col_width(self, max_col_width: f32) -> Self
pub fn max_col_width(self, max_col_width: f32) -> Self
Set soft maximum width (wrapping width) of each column.
Sourcepub fn spacing(self, spacing: impl Into<Vec2>) -> Self
pub fn spacing(self, spacing: impl Into<Vec2>) -> Self
Set spacing between columns/rows.
Default: crate::style::Spacing::item_spacing.
Sourcepub fn start_row(self, start_row: usize) -> Self
pub fn start_row(self, start_row: usize) -> Self
Change which row number the grid starts on.
This can be useful when you have a large crate::Grid inside of crate::ScrollArea::show_rows.
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more