egui_extras: rename TableBody::delta to TableBody::y_progress

This commit is contained in:
Wayne Warren 2022-04-03 20:26:50 -06:00
parent 51a98d586b
commit b82fc89462

View file

@ -352,7 +352,7 @@ pub struct TableBody<'a> {
} }
impl<'a> TableBody<'a> { impl<'a> TableBody<'a> {
fn delta(&self) -> f32 { fn y_progress(&self) -> f32 {
self.start_y - self.layout.current_y() self.start_y - self.layout.current_y()
} }
@ -424,7 +424,7 @@ impl<'a> TableBody<'a> {
.map(|(index, height)| (index, index % 2 == 0, height)); .map(|(index, height)| (index, index % 2 == 0, height));
let max_height = self.end_y - self.start_y + VIRTUAL_EXTENSION; let max_height = self.end_y - self.start_y + VIRTUAL_EXTENSION;
let delta = self.delta() - VIRTUAL_EXTENSION; let y_progress = self.y_progress() - VIRTUAL_EXTENSION;
// cumulative height of all rows above those being displayed // cumulative height of all rows above those being displayed
let mut height_above_visible: f64 = 0.0; let mut height_above_visible: f64 = 0.0;
@ -433,9 +433,9 @@ impl<'a> TableBody<'a> {
// calculate height above visible table range // calculate height above visible table range
while let Some((_, _, height)) = striped_heights.next() { while let Some((_, _, height)) = striped_heights.next() {
// when delta is greater than height above 0, we need to increment the row index and // when y_progress is greater than height above 0, we need to increment the row index
// update the height above visble with the current height then continue // and update the height above visble with the current height then continue
if height_above_visible >= delta as f64 { if height_above_visible >= y_progress as f64 {
break; break;
} }
height_above_visible += height as f64; height_above_visible += height as f64;
@ -480,13 +480,13 @@ impl<'a> TableBody<'a> {
/// ///
/// Is a lot more performant than adding each individual row as non visible rows must not be rendered /// Is a lot more performant than adding each individual row as non visible rows must not be rendered
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.delta(); let y_progress = self.y_progress();
let mut start = 0; let mut start = 0;
if delta < 0.0 { if y_progress > 0.0 {
start = (delta / height).floor() as usize; start = (y_progress / height).floor() as usize;
self.buffer(delta); self.buffer(y_progress);
} }
let max_height = self.end_y - self.start_y; let max_height = self.end_y - self.start_y;