diff --git a/egui/src/grid.rs b/egui/src/grid.rs index 3b4c224d..3f54a4fd 100644 --- a/egui/src/grid.rs +++ b/egui/src/grid.rs @@ -67,7 +67,7 @@ impl GridLayout { spacing: ui.style().spacing.item_spacing, striped: false, initial_x: ui.cursor().x, - min_row_height: 0.0, + min_row_height: ui.style().spacing.interact_size.y, col: 0, row: 0, } @@ -173,7 +173,7 @@ impl GridLayout { pub struct Grid { id_source: Id, striped: bool, - min_row_height: f32, + min_row_height: Option, } impl Grid { @@ -181,7 +181,7 @@ impl Grid { Self { id_source: Id::new(id_source), striped: false, - min_row_height: 0.0, + min_row_height: None, } } @@ -194,9 +194,9 @@ impl Grid { self } - /// Set minimum height of each row. Default: 0. + /// Set minimum height of each row. Default: [`Spacing::interact_size.y`]. pub fn min_row_height(mut self, min_row_height: f32) -> Self { - self.min_row_height = min_row_height; + self.min_row_height = Some(min_row_height); self } } @@ -208,6 +208,7 @@ impl Grid { striped, min_row_height, } = self; + let min_row_height = min_row_height.unwrap_or_else(|| ui.style().spacing.interact_size.y); // Each grid cell is aligned LEFT_CENTER. // If somebody wants to wrap more things inside a cell, diff --git a/egui_demo_lib/src/apps/demo/widget_gallery.rs b/egui_demo_lib/src/apps/demo/widget_gallery.rs index b3ab79ac..32cd6bc2 100644 --- a/egui_demo_lib/src/apps/demo/widget_gallery.rs +++ b/egui_demo_lib/src/apps/demo/widget_gallery.rs @@ -54,9 +54,7 @@ impl super::View for WidgetGallery { color, } = self; - let grid = egui::Grid::new("my_grid") - .striped(true) - .min_row_height(ui.style().spacing.interact_size.y); + let grid = egui::Grid::new("my_grid").striped(true); grid.show(ui, |ui| { ui.label("Label:"); ui.label("Welcome to the widget gallery!");