From 9630b96c1b64e1285c2bda9d2f278a720e3f0d4c Mon Sep 17 00:00:00 2001 From: Stephen Waits Date: Sat, 28 Nov 2026 18:02:00 -0700 Subject: [PATCH] Fix the page growing while scrolled: close panel rows at their own bottom end_row folded the panels' bottoms from 0.0, so a row whose bottom was above the top of the window (negative screen y while scrolled) was closed at y=0. Everything after it was placed from there, the scroll content grew by the scroll offset, and the scroll bar kept shrinking at the bottom. The lowest bottom is now a plain function in fmt with a native test. Co-Authored-By: Claude Sonnet 5.5 --- crates/ui/src/fmt.rs | 16 ++++++++++++++++ crates/ui/src/style.rs | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/crates/ui/src/fmt.rs b/crates/ui/src/fmt.rs index ef2408c..f516131 100644 --- a/crates/ui/src/fmt.rs +++ b/crates/ui/src/fmt.rs @@ -9,6 +9,13 @@ pub fn previous_label(range: Range) -> String { format!("previous {}", label.strip_prefix("last ").unwrap_or(label)) } +/// The lowest edge of a row of panels: the largest of their `bottoms`, or +/// `empty` when there are none. The bottoms are screen positions, so they are +/// negative while the row is scrolled above the top of the window. +pub fn lowest(bottoms: impl IntoIterator, empty: f32) -> f32 { + bottoms.into_iter().reduce(f32::max).unwrap_or(empty) +} + /// Whole-number percentages of `parts` that add up to exactly 100, giving the /// leftovers of rounding to the largest shares. All zero when nothing is counted. pub fn shares(parts: &[u64]) -> Vec { @@ -229,6 +236,15 @@ pub fn hidden_after_all<'a>(ticked: bool, languages: impl Iterator Vec { /// Close a row of panels drawn at `rects`: the cursor moves below the tallest. pub fn end_row(ui: &mut Ui, rects: &[Rect]) { - let bottom = rects.iter().map(|rect| rect.bottom()).fold(0.0, f32::max); + let bottom = crate::fmt::lowest(rects.iter().map(|rect| rect.bottom()), ui.cursor().top()); let left = rects.first().map_or(ui.cursor().left(), |rect| rect.left()); ui.allocate_rect( Rect::from_min_max(Pos2::new(left, ui.cursor().top()), Pos2::new(ui.cursor().right(), bottom)),