only allow one rows call

This commit is contained in:
René Rössler 2021-12-17 18:18:13 +01:00
parent 84a3c1813f
commit e00c726bff

View file

@ -142,7 +142,7 @@ pub struct TableBody<'b> {
} }
impl<'a> TableBody<'a> { 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 delta = self.layout.current_y() - self.start_y;
let mut start = 0; let mut start = 0;
@ -150,15 +150,14 @@ impl<'a> TableBody<'a> {
start = (-delta / height).floor() as usize; start = (-delta / height).floor() as usize;
let skip_height = start as f32 * height; let skip_height = start as f32 * height;
let mut row = TableRow { TableRow {
layout: &mut self.layout, layout: &mut self.layout,
widths: self.widths.clone(), widths: self.widths.clone(),
striped: self.striped && self.odd, striped: self.striped && self.odd,
height: skip_height, height: skip_height,
clicked: false, clicked: false,
}; }
.col(|_| ()); // advances the cursor
row.col(|_| {});
} }
let max_height = self.end_y - self.start_y; let max_height = self.end_y - self.start_y;
@ -186,15 +185,14 @@ impl<'a> TableBody<'a> {
if rows - end > 0 { if rows - end > 0 {
let skip_height = (rows - end) as f32 * height; let skip_height = (rows - end) as f32 * height;
let mut row = TableRow { TableRow {
layout: &mut self.layout, layout: &mut self.layout,
widths: self.widths.clone(), widths: self.widths.clone(),
striped: self.striped && self.odd, striped: self.striped && self.odd,
height: skip_height, height: skip_height,
clicked: false, clicked: false,
}; }
.col(|_| ()); // advances the cursor
row.col(|_| {});
} }
} }