From 7c00f46917383ffaf735a81d71c50c68168f945c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jaakko=20Kera=CC=88nen?= jaakko.keranen@iki.fi
Date: Wed, 25 May 2022 14:06:52 +0300
Subject: [PATCH 1/1] Widget: Clamp overflow scroll indicator
src/ui/widget.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/src/ui/widget.c b/src/ui/widget.c
index 04295497..addab9f0 100644
--- a/src/ui/widget.c
+++ b/src/ui/widget.c
@@ -1236,6 +1236,7 @@ iBool dispatchEvent_Widget(iWidget *d, const SDL_Event *ev) {
void scrollInfo_Widget(const iWidget *d, iWidgetScrollInfo *info) {
iRect bounds = boundsWithoutVisualOffset_Widget(d);
const iRect winRect = adjusted_Rect(safeRect_Root(d->root),
zero_I2(),
init_I2(0, -get_MainWindow()->keyboardHeight));
@@ -1252,6 +1253,16 @@ void scrollInfo_Widget(const iWidget *d, iWidgetScrollInfo *info) {
info->normScroll = iClamp(info->normScroll, 0.0f, 1.0f);
info->thumbHeight = iMin(info->avail / 2, info->avail * info->avail / info->height);
info->thumbY = top_Rect(winRect) + (info->avail - info->thumbHeight) * info->normScroll;
/* Clamp it. */
const iRangei ySpan = ySpan_Rect(visBounds);
if (info->thumbY < ySpan.start) {
info->thumbHeight += info->thumbY - ySpan.start;
info->thumbY = ySpan.start;
info->thumbHeight = iMax(7 * gap_UI, info->thumbHeight);
}
else if (info->thumbY + info->thumbHeight > ySpan.end) {
info->thumbHeight = ySpan.end - info->thumbY;
}
}
}
--
2.25.1
text/plain
This content has been proxied by September (3851b).