From e7278ae98fb95e7e2d79caea2321076ba83918bc Mon Sep 17 00:00:00 2001 From: quou Date: Sat, 3 Aug 2024 16:37:08 +1000 Subject: Fix scrollbar clamping --- gui.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'gui.c') 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( -- cgit v1.2.3-54-g00ecf