From 4152fbecb6ee8360575aa4c24e9cedf822f159dc Mon Sep 17 00:00:00 2001 From: 3gg <3gg@shellblade.net> Date: Wed, 25 Mar 2026 19:59:14 -0700 Subject: Implement vertical and horizontal layouts. Use widget position properly when rendering. Toolbar, buttons and edit bars WIP --- src/widget/table.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/widget/table.c') diff --git a/src/widget/table.c b/src/widget/table.c index e7d412e..d9a6440 100644 --- a/src/widget/table.c +++ b/src/widget/table.c @@ -3,11 +3,12 @@ #define Min(a, b) ((a) < (b) ? (a) : (b)) #define Max(a, b) ((a) > (b) ? (a) : (b)) -uiTable* uiMakeTable(int rows, int cols, const char** header) { +uiTable* uiMakeTable(uiPtr parent, int rows, int cols, const char** header) { uiTable* table = UI_NEW(uiTable); *table = (uiTable){ - .widget = (uiWidget){.type = uiTypeTable}, + .widget = + (uiWidget){.type = uiTypeTable, .stretch = (uiStretchX | uiStretchY)}, .rows = rows, .cols = cols, .widths = (cols > 0) ? calloc(cols, sizeof(int)) : 0, @@ -15,6 +16,7 @@ uiTable* uiMakeTable(int rows, int cols, const char** header) { .cells = (rows * cols > 0) ? calloc(rows, sizeof(uiCell*)) : 0, .flags = {0}, }; + WidgetSetParent(uiMakeTablePtr(table), parent); if (header) { for (int col = 0; col < cols; ++col) { @@ -91,13 +93,14 @@ void SyncScrollbarToTable(uiTable* table) { assert(table); ScrollbarScroll( &table->scrollbar, (int)((double)table->offset / (double)table->rows * - (double)table->height)); + (double)table->widget.rect.height)); } void SyncTableToScrollbar(uiTable* table) { assert(table); - table->offset = (int)((double)table->scrollbar.handle_y / - (double)table->height * (double)table->rows); + table->offset = + (int)((double)table->scrollbar.handle_y / + (double)table->widget.rect.height * (double)table->rows); } const uiCell* TableGetCell(const uiTable* table, int row, int col) { -- cgit v1.2.3