add sourcecode links, document slow growing

This commit is contained in:
René Rössler 2022-02-09 12:02:19 +01:00
parent 10c51364c5
commit ae71f91f8c
4 changed files with 70 additions and 48 deletions

View file

@ -32,6 +32,7 @@ impl super::View for GridDemo {
relative: 0.5,
minimum: 60.0,
})
.size(Size::Absolute(14.0))
.vertical(|mut grid| {
grid.cell(|ui| {
ui.painter()
@ -99,6 +100,11 @@ impl super::View for GridDemo {
});
});
});
grid.cell(|ui| {
ui.vertical_centered(|ui| {
ui.add(crate::__egui_github_link_file!());
});
});
});
}
}

View file

@ -1,5 +1,5 @@
use egui::{Label, RichText};
use egui_extras::{Padding, Size, TableBuilder};
use egui_extras::{GridBuilder, Padding, Size, TableBuilder};
/// Shows off a table with dynamic layout
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
@ -29,6 +29,12 @@ impl super::View for TableDemo {
fn ui(&mut self, ui: &mut egui::Ui) {
ui.checkbox(&mut self.virtual_scrool, "Virtual scroll demo");
// The table is inside a grid as its container would otherwise grow slowly as it takes all available height
GridBuilder::new(ui, Padding::new(0.0, 0.0))
.size(Size::Remainder)
.size(Size::Absolute(14.0))
.vertical(|mut grid| {
grid.cell(|ui| {
// TODO: Fix table as a padding smaller than 16 grows the window
TableBuilder::new(ui, Padding::new(3.0, 16.0))
.striped(true)
@ -88,5 +94,12 @@ impl super::View for TableDemo {
}
}
});
});
grid.cell(|ui| {
ui.vertical_centered(|ui| {
ui.add(crate::__egui_github_link_file!());
});
});
});
}
}

View file

@ -44,6 +44,7 @@ impl<'a> GridBuilder<'a> {
}
/// Build horizontal grid
/// Takes the available horizontal width, so there can't be anything right of the grid or the container will grow slowly!
pub fn horizontal<F>(self, grid: F)
where
F: for<'b> FnOnce(Grid<'a, 'b>),
@ -62,6 +63,7 @@ impl<'a> GridBuilder<'a> {
}
/// Build vertical grid
/// Takes the full available vertical height, so there can't be anything below of the grid or the container will grow slowly!
pub fn vertical<F>(self, grid: F)
where
F: for<'b> FnOnce(Grid<'a, 'b>),

View file

@ -1,6 +1,7 @@
/// Table view with (optional) fixed header and scrolling body.
/// Cell widths are precalculated with given size hints so we can have tables like this:
/// | fixed size | all available space/minimum | 30% of available width | fixed size |
/// Takes all available height, so if you want something below the table, put it in a grid.
use crate::{
layout::{CellSize, LineDirection},
sizing::Sizing,