1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-31 13:50:04 -04:00

Grid::num_columns: allow the last column to take up the rest of the space

This allows for resizaeable grids, where the last column will be given the remainder of the width.
To demonstrate, the widget gallery window is now resizeable.
This commit is contained in:
Emil Ernerfeldt
2021-07-02 09:55:57 +02:00
parent 9603bb4f85
commit faf104220b
3 changed files with 37 additions and 13 deletions

View File

@@ -42,7 +42,8 @@ impl super::Demo for WidgetGallery {
fn show(&mut self, ctx: &egui::CtxRef, open: &mut bool) {
egui::Window::new(self.name())
.open(open)
.resizable(false)
.resizable(true)
.default_width(300.0)
.show(ctx, |ui| {
use super::View;
self.ui(ui);
@@ -57,8 +58,9 @@ impl super::View for WidgetGallery {
ui.set_enabled(self.enabled);
egui::Grid::new("my_grid")
.striped(true)
.num_columns(2)
.spacing([40.0, 4.0])
.striped(true)
.show(ui, |ui| {
self.gallery_grid_contents(ui);
});