mirror of
https://github.com/emilk/egui.git
synced 2026-08-31 05:40:03 -04:00
[grid] Set default row height to interact_size.y
It is what we use for horizontal layouts, and makes sense.
This commit is contained in:
@@ -67,7 +67,7 @@ impl GridLayout {
|
|||||||
spacing: ui.style().spacing.item_spacing,
|
spacing: ui.style().spacing.item_spacing,
|
||||||
striped: false,
|
striped: false,
|
||||||
initial_x: ui.cursor().x,
|
initial_x: ui.cursor().x,
|
||||||
min_row_height: 0.0,
|
min_row_height: ui.style().spacing.interact_size.y,
|
||||||
col: 0,
|
col: 0,
|
||||||
row: 0,
|
row: 0,
|
||||||
}
|
}
|
||||||
@@ -173,7 +173,7 @@ impl GridLayout {
|
|||||||
pub struct Grid {
|
pub struct Grid {
|
||||||
id_source: Id,
|
id_source: Id,
|
||||||
striped: bool,
|
striped: bool,
|
||||||
min_row_height: f32,
|
min_row_height: Option<f32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Grid {
|
impl Grid {
|
||||||
@@ -181,7 +181,7 @@ impl Grid {
|
|||||||
Self {
|
Self {
|
||||||
id_source: Id::new(id_source),
|
id_source: Id::new(id_source),
|
||||||
striped: false,
|
striped: false,
|
||||||
min_row_height: 0.0,
|
min_row_height: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,9 +194,9 @@ impl Grid {
|
|||||||
self
|
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 {
|
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
|
self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -208,6 +208,7 @@ impl Grid {
|
|||||||
striped,
|
striped,
|
||||||
min_row_height,
|
min_row_height,
|
||||||
} = self;
|
} = self;
|
||||||
|
let min_row_height = min_row_height.unwrap_or_else(|| ui.style().spacing.interact_size.y);
|
||||||
|
|
||||||
// Each grid cell is aligned LEFT_CENTER.
|
// Each grid cell is aligned LEFT_CENTER.
|
||||||
// If somebody wants to wrap more things inside a cell,
|
// If somebody wants to wrap more things inside a cell,
|
||||||
|
|||||||
@@ -54,9 +54,7 @@ impl super::View for WidgetGallery {
|
|||||||
color,
|
color,
|
||||||
} = self;
|
} = self;
|
||||||
|
|
||||||
let grid = egui::Grid::new("my_grid")
|
let grid = egui::Grid::new("my_grid").striped(true);
|
||||||
.striped(true)
|
|
||||||
.min_row_height(ui.style().spacing.interact_size.y);
|
|
||||||
grid.show(ui, |ui| {
|
grid.show(ui, |ui| {
|
||||||
ui.label("Label:");
|
ui.label("Label:");
|
||||||
ui.label("Welcome to the widget gallery!");
|
ui.label("Welcome to the widget gallery!");
|
||||||
|
|||||||
Reference in New Issue
Block a user