summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorquou <quou@disroot.org>2024-08-03 16:37:08 +1000
committerquou <quou@disroot.org>2024-08-03 16:37:08 +1000
commite7278ae98fb95e7e2d79caea2321076ba83918bc (patch)
treeed1f946afe7cb02e1fe0e25fc131b735415e0f21
parentfbf210c76a4c548fe16513a0c07c50532b51d4fb (diff)
Fix scrollbar clamping
-rw-r--r--gui.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/gui.c b/gui.c
index 5efda30..063a644 100644
--- a/gui.c
+++ b/gui.c
@@ -145,14 +145,12 @@ void gui_scrollable(
nx = cs[0] - (r.w - size);
ny = cs[1] - (r.h - size);
}
- if (nx > 0) {
- state->x = clamp(state->x, 0, nx);
+ state->x = clamp(state->x, 0, maxi(0, nx));
+ state->y = clamp(state->y, 0, maxi(0, ny));
+ if (nx > 0)
gui_scrollbar(g, state, srx, nx, 1);
- }
- if (ny > 0) {
- state->y = clamp(state->y, 0, ny);
+ if (ny > 0)
gui_scrollbar(g, state, sry, ny, 0);
- }
}
void gui_scrollbar(