From 68a3532728b55b73d8bcadb8ccfc1d9396346cd2 Mon Sep 17 00:00:00 2001 From: 3gg <3gg@shellblade.net> Date: Sat, 13 Jul 2024 11:44:32 -0700 Subject: Basic table scrollbar rendering. --- src/input.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/input.c') diff --git a/src/input.c b/src/input.c index c4b1be7..20551a6 100644 --- a/src/input.c +++ b/src/input.c @@ -6,6 +6,7 @@ #include +#define Min(a, b) ((a) < (b) ? (a) : (b)) #define Max(a, b) ((a) > (b) ? (a) : (b)) /// Return true if the rectangle contains the point. @@ -85,7 +86,9 @@ static void ClickTable(uiTable* table, const uiMouseClickEvent* event) { static void ScrollTable(uiTable* table, const uiMouseScrollEvent* event) { assert(table); assert(event); - table->offset = Max(0, table->offset - event->scroll_offset); + table->offset = + Min(table->rows - table->num_visible_rows, + Max(0, table->offset - event->scroll_offset)); } /// Process a scroll event. -- cgit v1.2.3