diff options
author | 3gg <3gg@shellblade.net> | 2024-07-13 11:44:32 -0700 |
---|---|---|
committer | 3gg <3gg@shellblade.net> | 2024-07-13 11:44:32 -0700 |
commit | 68a3532728b55b73d8bcadb8ccfc1d9396346cd2 (patch) | |
tree | c87a636a36f21024032fc5cb5900982957491f95 /src/input.c | |
parent | a4294e4a94189dffb1fdf99c9a60d87d77272926 (diff) |
Basic table scrollbar rendering.main
Diffstat (limited to 'src/input.c')
-rw-r--r-- | src/input.c | 5 |
1 files changed, 4 insertions, 1 deletions
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 @@ | |||
6 | 6 | ||
7 | #include <cassert.h> | 7 | #include <cassert.h> |
8 | 8 | ||
9 | #define Min(a, b) ((a) < (b) ? (a) : (b)) | ||
9 | #define Max(a, b) ((a) > (b) ? (a) : (b)) | 10 | #define Max(a, b) ((a) > (b) ? (a) : (b)) |
10 | 11 | ||
11 | /// Return true if the rectangle contains the point. | 12 | /// Return true if the rectangle contains the point. |
@@ -85,7 +86,9 @@ static void ClickTable(uiTable* table, const uiMouseClickEvent* event) { | |||
85 | static void ScrollTable(uiTable* table, const uiMouseScrollEvent* event) { | 86 | static void ScrollTable(uiTable* table, const uiMouseScrollEvent* event) { |
86 | assert(table); | 87 | assert(table); |
87 | assert(event); | 88 | assert(event); |
88 | table->offset = Max(0, table->offset - event->scroll_offset); | 89 | table->offset = |
90 | Min(table->rows - table->num_visible_rows, | ||
91 | Max(0, table->offset - event->scroll_offset)); | ||
89 | } | 92 | } |
90 | 93 | ||
91 | /// Process a scroll event. | 94 | /// Process a scroll event. |