]> git.lizzy.rs Git - nothing.git/blob - src/ui/grid.h
90f6b0c268ff91c27e2e84443f48259c761318ef
[nothing.git] / src / ui / grid.h
1 #ifndef GRID_H_
2 #define GRID_H_
3
4 #include <assert.h>
5
6 #include "system/nth_alloc.h"
7 #include "math/rect.h"
8
9 typedef struct {
10     Rect boundary;
11 } Widget;
12
13 typedef struct {
14     size_t rows;
15     size_t columns;
16     Widget *cells[];
17 } Grid;
18
19 static inline
20 void grid_put_widget(Grid *grid, Widget *widget,
21                      size_t row, size_t column)
22 {
23     assert(grid);
24     assert(widget);
25     assert(row < grid->rows);
26     assert(column < grid->columns);
27     grid->cells[row * grid->columns + column] = widget;
28 }
29
30 void grid_relayout(Grid *grid, Rect boundary);
31
32 #endif  // GRID_H_