From e00c726bff653f9db2f861b511fe0e24a904cf4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20R=C3=B6ssler?= Date: Fri, 17 Dec 2021 18:18:13 +0100 Subject: [PATCH] only allow one rows call --- egui_dynamic_grid/src/table.rs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/egui_dynamic_grid/src/table.rs b/egui_dynamic_grid/src/table.rs index 3ec1a5b0..dcd3020c 100644 --- a/egui_dynamic_grid/src/table.rs +++ b/egui_dynamic_grid/src/table.rs @@ -142,7 +142,7 @@ pub struct TableBody<'b> { } impl<'a> TableBody<'a> { - pub fn rows(&mut self, height: f32, rows: usize, mut row: impl FnMut(usize, TableRow)) { + pub fn rows(mut self, height: f32, rows: usize, mut row: impl FnMut(usize, TableRow)) { let delta = self.layout.current_y() - self.start_y; let mut start = 0; @@ -150,15 +150,14 @@ impl<'a> TableBody<'a> { start = (-delta / height).floor() as usize; let skip_height = start as f32 * height; - let mut row = TableRow { + TableRow { layout: &mut self.layout, widths: self.widths.clone(), striped: self.striped && self.odd, height: skip_height, clicked: false, - }; - - row.col(|_| {}); + } + .col(|_| ()); // advances the cursor } let max_height = self.end_y - self.start_y; @@ -186,15 +185,14 @@ impl<'a> TableBody<'a> { if rows - end > 0 { let skip_height = (rows - end) as f32 * height; - let mut row = TableRow { + TableRow { layout: &mut self.layout, widths: self.widths.clone(), striped: self.striped && self.odd, height: skip_height, clicked: false, - }; - - row.col(|_| {}); + } + .col(|_| ()); // advances the cursor } }