Clean up demo code
This commit is contained in:
parent
d9eac765dc
commit
b2124f4cd1
1 changed files with 63 additions and 61 deletions
|
@ -1,4 +1,3 @@
|
||||||
use egui::{Label, Vec2};
|
|
||||||
use egui_extras::{Size, StripBuilder, TableBuilder};
|
use egui_extras::{Size, StripBuilder, TableBuilder};
|
||||||
|
|
||||||
/// Shows off a table with dynamic layout
|
/// Shows off a table with dynamic layout
|
||||||
|
@ -29,15 +28,25 @@ impl super::View for TableDemo {
|
||||||
fn ui(&mut self, ui: &mut egui::Ui) {
|
fn ui(&mut self, ui: &mut egui::Ui) {
|
||||||
ui.checkbox(&mut self.virtual_scroll, "Virtual scroll demo");
|
ui.checkbox(&mut self.virtual_scroll, "Virtual scroll demo");
|
||||||
|
|
||||||
// The table is inside a grid as its container would otherwise grow slowly as it takes all available height
|
// Leave room for the source code link after the table demo:
|
||||||
ui.spacing_mut().item_spacing = Vec2::splat(4.0);
|
|
||||||
StripBuilder::new(ui)
|
StripBuilder::new(ui)
|
||||||
.size(Size::Remainder)
|
.size(Size::Remainder) // for the table
|
||||||
.size(Size::Absolute(10.0))
|
.size(Size::Absolute(10.0)) // for the source code link
|
||||||
.vertical(|mut grid| {
|
.vertical(|mut strip| {
|
||||||
grid.cell_clip(|ui| {
|
strip.cell_clip(|ui| {
|
||||||
ui.spacing_mut().item_spacing = Vec2::splat(3.0);
|
self.table_ui(ui);
|
||||||
|
});
|
||||||
|
strip.cell(|ui| {
|
||||||
|
ui.vertical_centered(|ui| {
|
||||||
|
ui.add(crate::__egui_github_link_file!());
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl TableDemo {
|
||||||
|
fn table_ui(&mut self, ui: &mut egui::Ui) {
|
||||||
TableBuilder::new(ui)
|
TableBuilder::new(ui)
|
||||||
.striped(true)
|
.striped(true)
|
||||||
.column(Size::Absolute(120.0))
|
.column(Size::Absolute(120.0))
|
||||||
|
@ -62,7 +71,7 @@ impl super::View for TableDemo {
|
||||||
});
|
});
|
||||||
row.col_clip(|ui| {
|
row.col_clip(|ui| {
|
||||||
ui.add(
|
ui.add(
|
||||||
Label::new("virtual scroll, easily with thousands of rows!")
|
egui::Label::new("virtual scroll, easily with thousands of rows!")
|
||||||
.wrap(false),
|
.wrap(false),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -83,7 +92,7 @@ impl super::View for TableDemo {
|
||||||
});
|
});
|
||||||
row.col_clip(|ui| {
|
row.col_clip(|ui| {
|
||||||
ui.add(
|
ui.add(
|
||||||
Label::new(
|
egui::Label::new(
|
||||||
format!("Normal scroll, each row can have a different height. Height: {}", height),
|
format!("Normal scroll, each row can have a different height. Height: {}", height),
|
||||||
)
|
)
|
||||||
.wrap(false),
|
.wrap(false),
|
||||||
|
@ -96,12 +105,5 @@ impl super::View for TableDemo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
|
||||||
grid.cell(|ui| {
|
|
||||||
ui.vertical_centered(|ui| {
|
|
||||||
ui.add(crate::__egui_github_link_file!());
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue