| 65 grid->max_row = y; |
65 grid->max_row = y; |
| 66 } |
66 } |
| 67 } |
67 } |
| 68 |
68 |
| 69 void ui_grid_layout(UiGridLayout *grid, int width, int height) { |
69 void ui_grid_layout(UiGridLayout *grid, int width, int height) { |
| |
70 if (width == 0 || height == 0) { |
| |
71 return; |
| |
72 } |
| |
73 |
| 70 int ncols = grid->max_column+1; |
74 int ncols = grid->max_column+1; |
| 71 int nrows = grid->max_row+1; |
75 int nrows = grid->max_row+1; |
| 72 |
76 |
| 73 GridDef *cols = calloc(ncols, sizeof(GridDef)); |
77 GridDef *cols = calloc(ncols, sizeof(GridDef)); |
| 74 GridDef *rows = calloc(nrows, sizeof(GridDef)); |
78 GridDef *rows = calloc(nrows, sizeof(GridDef)); |
| 258 } |
262 } |
| 259 child_width = cwidth; |
263 child_width = cwidth; |
| 260 } else { |
264 } else { |
| 261 child_width = col->size; |
265 child_width = col->size; |
| 262 } |
266 } |
| |
267 child_width -= elm->layout.margin.left + elm->layout.margin.right; |
| 263 } else { |
268 } else { |
| 264 child_width = elm->layout.preferred_width; |
269 child_width = elm->layout.preferred_width; |
| 265 } |
270 } |
| 266 child_width -= elm->layout.margin.left + elm->layout.margin.right; |
|
| 267 |
271 |
| 268 if(elm->layout.vfill) { |
272 if(elm->layout.vfill) { |
| 269 if(elm->layout.rowspan > 1) { |
273 if(elm->layout.rowspan > 1) { |
| 270 int rheight = 0; |
274 int rheight = 0; |
| 271 int end_row = elm->gridy + elm->layout.rowspan; |
275 int end_row = elm->gridy + elm->layout.rowspan; |
| 280 if(real_span > 0) { |
284 if(real_span > 0) { |
| 281 rheight += (real_span-1) * rowspacing; |
285 rheight += (real_span-1) * rowspacing; |
| 282 } |
286 } |
| 283 child_height = rheight; |
287 child_height = rheight; |
| 284 } |
288 } |
| 285 child_height = row->size; |
289 child_height = row->size - elm->layout.margin.top - elm->layout.margin.bottom; |
| 286 } else { |
290 } else { |
| 287 child_height = elm->layout.preferred_height; |
291 child_height = elm->layout.preferred_height; |
| 288 } |
292 } |
| 289 |
293 |
| 290 child_x = col->pos + elm->layout.margin.left; |
294 child_x = col->pos + elm->layout.margin.left; |