egui_extras: clean up virtual scroll table demo settings a little
This commit is contained in:
parent
1c5f93322d
commit
91d78fa2e9
1 changed files with 37 additions and 24 deletions
|
@ -30,9 +30,15 @@ impl super::Demo for TableDemo {
|
||||||
|
|
||||||
impl super::View for TableDemo {
|
impl super::View for TableDemo {
|
||||||
fn ui(&mut self, ui: &mut egui::Ui) {
|
fn ui(&mut self, ui: &mut egui::Ui) {
|
||||||
|
let mut settings_height = 44.0;
|
||||||
|
if self.virtual_scroll {
|
||||||
|
settings_height = 66.0;
|
||||||
|
} else {
|
||||||
|
self.heterogeneous_rows = false
|
||||||
|
}
|
||||||
// Leave room for the source code link after the table demo:
|
// Leave room for the source code link after the table demo:
|
||||||
StripBuilder::new(ui)
|
StripBuilder::new(ui)
|
||||||
.size(Size::exact(66.0)) // for the settings
|
.size(Size::exact(settings_height)) // for the settings
|
||||||
.size(Size::remainder()) // for the table
|
.size(Size::remainder()) // for the table
|
||||||
.size(Size::exact(10.0)) // for the source code link
|
.size(Size::exact(10.0)) // for the source code link
|
||||||
.vertical(|mut strip| {
|
.vertical(|mut strip| {
|
||||||
|
@ -42,16 +48,20 @@ impl super::View for TableDemo {
|
||||||
.size(Size::remainder())
|
.size(Size::remainder())
|
||||||
.horizontal(|mut strip| {
|
.horizontal(|mut strip| {
|
||||||
strip.cell(|ui| {
|
strip.cell(|ui| {
|
||||||
ui.checkbox(&mut self.heterogeneous_rows, "Heterogeneous rows");
|
|
||||||
ui.checkbox(&mut self.virtual_scroll, "Virtual Scroll");
|
ui.checkbox(&mut self.virtual_scroll, "Virtual Scroll");
|
||||||
|
if self.virtual_scroll {
|
||||||
|
ui.checkbox(&mut self.heterogeneous_rows, "Heterogeneous rows");
|
||||||
|
}
|
||||||
ui.checkbox(&mut self.resizable, "Resizable columns");
|
ui.checkbox(&mut self.resizable, "Resizable columns");
|
||||||
});
|
});
|
||||||
|
if self.virtual_scroll {
|
||||||
strip.cell(|ui| {
|
strip.cell(|ui| {
|
||||||
ui.add(
|
ui.add(
|
||||||
egui::Slider::new(&mut self.num_rows, 0..=300_000)
|
egui::Slider::new(&mut self.num_rows, 0..=300_000)
|
||||||
.text("Num rows"),
|
.text("Num rows"),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
strip.cell(|ui| {
|
strip.cell(|ui| {
|
||||||
|
@ -94,6 +104,7 @@ impl TableDemo {
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.body(|mut body| {
|
.body(|mut body| {
|
||||||
|
if self.virtual_scroll {
|
||||||
if !self.heterogeneous_rows {
|
if !self.heterogeneous_rows {
|
||||||
body.rows(text_height, self.num_rows, |row_index, mut row| {
|
body.rows(text_height, self.num_rows, |row_index, mut row| {
|
||||||
row.col(|ui| {
|
row.col(|ui| {
|
||||||
|
@ -104,13 +115,15 @@ impl TableDemo {
|
||||||
});
|
});
|
||||||
row.col(|ui| {
|
row.col(|ui| {
|
||||||
ui.add(
|
ui.add(
|
||||||
egui::Label::new("Thousands of rows of even height").wrap(false),
|
egui::Label::new("Thousands of rows of even height")
|
||||||
|
.wrap(false),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
} else if self.virtual_scroll {
|
} else {
|
||||||
let rows = DemoRows::new(self.num_rows);
|
let rows = DemoRows::new(self.num_rows);
|
||||||
body.heterogeneous_rows(rows, DemoRows::populate_row);
|
body.heterogeneous_rows(rows, DemoRows::populate_row);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
for row_index in 0..20 {
|
for row_index in 0..20 {
|
||||||
let thick = row_index % 6 == 0;
|
let thick = row_index % 6 == 0;
|
||||||
|
|
Loading…
Reference in a new issue