pub struct Grid {
id_salt: Id,
num_columns: Option<usize>,
min_col_width: Option<f32>,
min_row_height: Option<f32>,
max_cell_size: Vec2,
spacing: Option<Vec2>,
start_row: usize,
color_picker: Option<Box<dyn Fn(usize, &Style) -> Option<Color32> + Sync + Send>>,
}
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();
});
Fields§
§id_salt: Id
§num_columns: Option<usize>
§min_col_width: Option<f32>
§min_row_height: Option<f32>
§max_cell_size: Vec2
§spacing: Option<Vec2>
§start_row: usize
§color_picker: Option<Box<dyn Fn(usize, &Style) -> Option<Color32> + Sync + Send>>
Implementations§
§impl Grid
impl Grid
pub fn with_row_color<F>(self, color_picker: F) -> Grid
pub fn with_row_color<F>(self, color_picker: F) -> Grid
Setting this will allow for dynamic coloring of rows of the grid object
pub fn num_columns(self, num_columns: usize) -> Grid
pub fn num_columns(self, num_columns: usize) -> Grid
Setting this will allow the last column to expand to take up the rest of the space of the parent Ui
.
pub fn striped(self, striped: bool) -> Grid
pub fn striped(self, striped: bool) -> Grid
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
.
pub fn min_col_width(self, min_col_width: f32) -> Grid
pub fn min_col_width(self, min_col_width: f32) -> Grid
Set minimum width of each column.
Default: crate::style::Spacing::interact_size
.x
.
pub fn min_row_height(self, min_row_height: f32) -> Grid
pub fn min_row_height(self, min_row_height: f32) -> Grid
Set minimum height of each row.
Default: crate::style::Spacing::interact_size
.y
.
pub fn max_col_width(self, max_col_width: f32) -> Grid
pub fn max_col_width(self, max_col_width: f32) -> Grid
Set soft maximum width (wrapping width) of each column.
pub fn spacing(self, spacing: impl Into<Vec2>) -> Grid
pub fn spacing(self, spacing: impl Into<Vec2>) -> Grid
Set spacing between columns/rows.
Default: crate::style::Spacing::item_spacing
.
pub fn start_row(self, start_row: usize) -> Grid
pub fn start_row(self, start_row: usize) -> Grid
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 !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> CheckedAs for T
impl<T> CheckedAs for T
source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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 moresource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request