qthree
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
7 additions and
3 deletions
-
crates/egui/src/containers/scroll_area.rs
|
|
@ -499,9 +499,13 @@ impl ScrollArea { |
|
|
|
self.show_viewport(ui, |ui, viewport| { |
|
|
|
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 max_row = (viewport.max.y / row_height_with_spacing).ceil() as usize + 1; |
|
|
|
let max_row = max_row.at_most(total_rows); |
|
|
|
let mut min_row = (viewport.min.y / row_height_with_spacing).floor() as usize; |
|
|
|
let mut max_row = (viewport.max.y / row_height_with_spacing).ceil() as usize + 1; |
|
|
|
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_max = ui.max_rect().top() + max_row as f32 * row_height_with_spacing; |
|
|
|