diff options
| author | 3gg <3gg@shellblade.net> | 2025-05-24 17:01:01 -0700 |
|---|---|---|
| committer | 3gg <3gg@shellblade.net> | 2025-05-24 17:01:01 -0700 |
| commit | 0ffd63fed9dcfb60be7378b6f53f0f1d011fd26c (patch) | |
| tree | 4a3b0f541b91349955b5b58f24b47c8b38f287f0 /src | |
| parent | 68a3532728b55b73d8bcadb8ccfc1d9396346cd2 (diff) | |
Tweaks
Diffstat (limited to 'src')
| -rw-r--r-- | src/input.c | 2 | ||||
| -rw-r--r-- | src/layout.c | 5 |
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 | |||
| 9 | static void ResizeTable(uiTable* table, int width, int height) { | 11 | static 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 |
