ui/grid.rs#
Source: lib/ui/grid.rs
grid -- a grid box: rows and columns with spans and alignment (a box with its own placing
mode; data.rs's grid_begin is the data table)
gridbox_begin(id, cols, flags, gap) open a grid: one entry per column in DIP, > 0
fixed, 0 its widest child, < 0 a share of the width
left (fill weight); rows grow with their tallest
child. flags: the box decorations and padding of
box_begin (BOX_CARD, BOX_CLIP, pad(n), ...) and the
alignment of the children: GRID_H_START | _CENTER |
_END (default: stretched across the cell),
GRID_V_START | _END | _STRETCH (default: centred);
gap: DIP between cells
gridbox_rows(rows) (after gridbox_begin) row sizes like cols; rows
without an entry are 0 (their tallest child); < 0
share the height left when the grid has a fixed one
gridbox_end()
next_span(cols, rows) the next child covers that many cells
next_cell(col, row) the next child starts there (later cells follow it)
next_align(h, v) the next child's alignment: AL_START, AL_CENTER,
AL_END, AL_STRETCH (AL_DEFAULT: the grid's)
Children fill the cells row by row, skipping cells a row span still covers. next_size
still applies: a fixed size is aligned in the cell, a natural one too, a fill size (< 0)
stretches. Natural column widths and row heights come from the previous pass, as box
sizes do; a change asks for another pass. A spanned child widens the last of its natural
columns (rows) when it does not fit. A TX_WRAP text (and a BOX_WRAP box) wraps at the
width its cell gives it (avail_width), so its row grows with its lines.
impl Ui
fn gridbox_begin(&mut self, id: u32, cols: &[i32], flags: u32, gap: i32)gridbox_begin(id, cols, flags, gap): open a grid (see the module comment)fn gridbox_rows(&mut self, rows: &[i32])gridbox_rows(rows): row sizes of the open grid (DIP; > 0 fixed, 0 natural, < 0 fill)fn next_span(&mut self, cols: u32, rows: u32)next_span(cols, rows): the next grid child covers that many cellsfn next_cell(&mut self, col: u32, row: u32)next_cell(col, row): the next grid child starts in that cellfn next_align(&mut self, h: u32, v: u32)next_align(h, v): the next grid child's alignment (AL_*; AL_DEFAULT: the grid's)fn gridbox_end(&mut self)gridbox_end: store the measured sizes (another pass when they changed), close the box