diff options
Diffstat (limited to 'src/layout.c')
| -rw-r--r-- | src/layout.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/src/layout.c b/src/layout.c index 62e1876..2b43ce8 100644 --- a/src/layout.c +++ b/src/layout.c | |||
| @@ -44,22 +44,18 @@ static void ResizeTable(uiTable* table, int width, int height) { | |||
| 44 | int* widths = table->widths; | 44 | int* widths = table->widths; |
| 45 | // Header. | 45 | // Header. |
| 46 | for (int col = 0; col < table->cols; ++col) { | 46 | for (int col = 0; col < table->cols; ++col) { |
| 47 | const uiCell* cell = &table->header[col]; | 47 | const uiCell* cell = &table->header[col]; |
| 48 | const uiLabel* label = (uiLabel*)cell->child; | 48 | const int length = (int)string_length(cell->text); |
| 49 | const int length = (int)string_length(label->text); | ||
| 50 | 49 | ||
| 51 | widths[col] = length; | 50 | widths[col] = length; |
| 52 | } | 51 | } |
| 53 | // Table contents. | 52 | // Table contents. |
| 54 | for (int row = 0; row < table->rows; ++row) { | 53 | for (int row = 0; row < table->rows; ++row) { |
| 55 | for (int col = 0; col < table->cols; ++col) { | 54 | for (int col = 0; col < table->cols; ++col) { |
| 56 | const uiCell* cell = GetCell(table, row, col); | 55 | const uiCell* cell = GetCell(table, row, col); |
| 57 | if (cell->child) { | 56 | const int length = (int)string_length(cell->text); |
| 58 | const uiLabel* label = (uiLabel*)cell->child; | ||
| 59 | const int length = (int)string_length(label->text); | ||
| 60 | 57 | ||
| 61 | widths[col] = length > widths[col] ? length : widths[col]; | 58 | widths[col] = length > widths[col] ? length : widths[col]; |
| 62 | } | ||
| 63 | } | 59 | } |
| 64 | } | 60 | } |
| 65 | // Multiply string lengths times glyph width to compute pixel size. | 61 | // Multiply string lengths times glyph width to compute pixel size. |
