add labels on grid demo

This commit is contained in:
René Rössler 2022-02-09 11:47:34 +01:00
parent 417cb1dd02
commit 10c51364c5

View file

@ -25,7 +25,7 @@ impl super::Demo for GridDemo {
impl super::View for GridDemo {
fn ui(&mut self, ui: &mut egui::Ui) {
GridBuilder::new(ui, Padding::new(0.0, 5.0))
GridBuilder::new(ui, Padding::new(0.0, 0.0))
.size(Size::Absolute(50.0))
.size(Size::Remainder)
.size(Size::RelativeMinimum {
@ -36,6 +36,7 @@ impl super::View for GridDemo {
grid.cell(|ui| {
ui.painter()
.rect_filled(ui.available_rect_before_wrap(), 0.0, Color32::BLUE);
ui.label("Full width and 50px height");
});
grid.grid(|builder| {
builder.sizes(Size::Remainder, 2).horizontal(|mut grid| {
@ -45,6 +46,7 @@ impl super::View for GridDemo {
0.0,
Color32::RED,
);
ui.label("remaining height and 50% of the width");
});
grid.grid(|builder| {
builder.sizes(Size::Remainder, 3).vertical(|mut grid| {
@ -55,6 +57,7 @@ impl super::View for GridDemo {
0.0,
Color32::YELLOW,
);
ui.label("one third of the box left of me but same width");
});
});
});
@ -63,7 +66,7 @@ impl super::View for GridDemo {
grid.grid(|builder| {
builder
.size(Size::Remainder)
.size(Size::Absolute(50.0))
.size(Size::Absolute(60.0))
.size(Size::Remainder)
.size(Size::Absolute(70.0))
.horizontal(|mut grid| {
@ -71,7 +74,7 @@ impl super::View for GridDemo {
grid.grid(|builder| {
builder
.size(Size::Remainder)
.size(Size::Absolute(50.0))
.size(Size::Absolute(60.0))
.size(Size::Remainder)
.vertical(|mut grid| {
grid.empty();
@ -81,6 +84,7 @@ impl super::View for GridDemo {
0.0,
Color32::GOLD,
);
ui.label("60x60");
});
});
});
@ -91,6 +95,7 @@ impl super::View for GridDemo {
0.0,
Color32::GREEN,
);
ui.label("height: half the available - at least 60px, width: 70px");
});
});
});