From 0ffd63fed9dcfb60be7378b6f53f0f1d011fd26c Mon Sep 17 00:00:00 2001 From: 3gg <3gg@shellblade.net> Date: Sat, 24 May 2025 17:01:01 -0700 Subject: Tweaks --- src/input.c | 2 +- src/layout.c | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'src') 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( for (col = 0; (col < table->cols) && (x > table->widths[col]); ++col) { x -= table->widths[col]; } - // 0 is the header and we want to map the first row to 0, so -1. + // 0 is the header, and we want to map the first row to 0, so -1. row = table->offset + ((p.y - widget->rect.y) / g_ui.font->header.glyph_height) - 1; // 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 @@ #include +#define Min(a, b) ((a) < (b) ? (a) : (b)) + static void ResizeTable(uiTable* table, int width, int height) { assert(table); @@ -16,7 +18,8 @@ static void ResizeTable(uiTable* table, int width, int height) { table->height = height; // Compute the number of rows that are visible at once. - table->num_visible_rows = height / g_ui.font->header.glyph_height; + table->num_visible_rows = + Min(table->rows, height / g_ui.font->header.glyph_height); assert(table->num_visible_rows <= table->rows); // Determine if there is vertical overflow. This determines whether we need to -- cgit v1.2.3