summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/input.c2
-rw-r--r--src/layout.c5
2 files changed, 5 insertions, 2 deletions
diff --git a/src/input.c b/src/input.c
index 20551a6..4461c8b 100644
--- a/src/input.c
+++ b/src/input.c
@@ -52,7 +52,7 @@ static void GetTableRowColAtXy(
52 for (col = 0; (col < table->cols) && (x > table->widths[col]); ++col) { 52 for (col = 0; (col < table->cols) && (x > table->widths[col]); ++col) {
53 x -= table->widths[col]; 53 x -= table->widths[col];
54 } 54 }
55 // 0 is the header and we want to map the first row to 0, so -1. 55 // 0 is the header, and we want to map the first row to 0, so -1.
56 row = table->offset + 56 row = table->offset +
57 ((p.y - widget->rect.y) / g_ui.font->header.glyph_height) - 1; 57 ((p.y - widget->rect.y) / g_ui.font->header.glyph_height) - 1;
58 // Out-of-bounds check. 58 // Out-of-bounds check.
diff --git a/src/layout.c b/src/layout.c
index f83976f..62e1876 100644
--- a/src/layout.c
+++ b/src/layout.c
@@ -6,6 +6,8 @@
6 6
7#include <cassert.h> 7#include <cassert.h>
8 8
9#define Min(a, b) ((a) < (b) ? (a) : (b))
10
9static void ResizeTable(uiTable* table, int width, int height) { 11static void ResizeTable(uiTable* table, int width, int height) {
10 assert(table); 12 assert(table);
11 13
@@ -16,7 +18,8 @@ static void ResizeTable(uiTable* table, int width, int height) {
16 table->height = height; 18 table->height = height;
17 19
18 // Compute the number of rows that are visible at once. 20 // Compute the number of rows that are visible at once.
19 table->num_visible_rows = height / g_ui.font->header.glyph_height; 21 table->num_visible_rows =
22 Min(table->rows, height / g_ui.font->header.glyph_height);
20 assert(table->num_visible_rows <= table->rows); 23 assert(table->num_visible_rows <= table->rows);
21 24
22 // Determine if there is vertical overflow. This determines whether we need to 25 // Determine if there is vertical overflow. This determines whether we need to