Macro kas::grid

grid!() { /* proc-macro */ }
Expand description

Make a grid widget

Constructs a table with auto-determined number of rows and columns. Each child is assigned a cell using match-like syntax.

A child may be stretched across multiple cells using range-like syntax: 3..5, 3..=4 and 3..+2 are all equivalent.

Behaviour of overlapping widgets is identical to float!: the first declared item is on top.

Children are navigated in order of declaration.

Items support widget layout syntax.

Example

let my_widget = kas::grid! {
    (0, 0) => "top left",
    (1, 0) => "top right",
    (0..2, 1) => "bottom row (merged)",
};

Syntax

Grid :
   grid! { GridCell* }

GridCell :
   ( CellRange , CellRange ) => ( Layout | { Layout } )

CellRange :
   LitInt ( .. +? LitInt )?

Cells are specified using match-like syntax from (col_spec, row_spec) to a layout, e.g.: (1, 0) => self.foo. Spans are specified via range syntax, e.g. (0..2, 1) => self.bar.