Fix ScrollArea::show_rows (#2258)
This commit is contained in:
parent
3805a3282f
commit
75a825e9a1
1 changed files with 7 additions and 3 deletions
|
@ -499,9 +499,13 @@ impl ScrollArea {
|
||||||
self.show_viewport(ui, |ui, viewport| {
|
self.show_viewport(ui, |ui, viewport| {
|
||||||
ui.set_height((row_height_with_spacing * total_rows as f32 - spacing.y).at_least(0.0));
|
ui.set_height((row_height_with_spacing * total_rows as f32 - spacing.y).at_least(0.0));
|
||||||
|
|
||||||
let min_row = (viewport.min.y / row_height_with_spacing).floor() as usize;
|
let mut min_row = (viewport.min.y / row_height_with_spacing).floor() as usize;
|
||||||
let max_row = (viewport.max.y / row_height_with_spacing).ceil() as usize + 1;
|
let mut max_row = (viewport.max.y / row_height_with_spacing).ceil() as usize + 1;
|
||||||
let max_row = max_row.at_most(total_rows);
|
if max_row > total_rows {
|
||||||
|
let diff = max_row.saturating_sub(min_row);
|
||||||
|
max_row = total_rows;
|
||||||
|
min_row = total_rows.saturating_sub(diff);
|
||||||
|
}
|
||||||
|
|
||||||
let y_min = ui.max_rect().top() + min_row as f32 * row_height_with_spacing;
|
let y_min = ui.max_rect().top() + min_row as f32 * row_height_with_spacing;
|
||||||
let y_max = ui.max_rect().top() + max_row as f32 * row_height_with_spacing;
|
let y_max = ui.max_rect().top() + max_row as f32 * row_height_with_spacing;
|
||||||
|
|
Loading…
Reference in a new issue