Skip to main content

Module grid

Module grid 

Source
Expand description

Grid — a 2D layout container with explicit row and column tracks.

Columns and rows are declared as TrackSize slices supporting three sizing modes: Fixed(px) (exact logical pixels), Auto (sized to the largest child in that track), and Fractional(fr) (share of the remaining space after fixed and auto tracks are allocated — the CSS fr unit). Children are placed in row-major order: child 0 occupies cell (row=0, col=0), child 1 (row=0, col=1), and so on. Dormant children are excluded from placement while keeping their siblings at their original cell positions, so toggling a cell visible/dormant does not shift other cells.

Fractional columns fall back to the child’s natural width when the parent provides no width constraint (intrinsic-measurement pass), preventing wrap-aware children from reporting inflated heights.

// Two equal columns with a fixed 40 dp row, separated by an 8 dp gap
let _grid = Grid::new()
    .columns(vec![TrackSize::Fractional(1.0), TrackSize::Fractional(1.0)])
    .rows(vec![TrackSize::Fixed(40.0)])
    .column_gap(8.0)
    .child(RectWidget::new())
    .child(RectWidget::new());

Structs§

Grid
A 2D grid layout container with explicit track declarations.

Enums§

TrackSize
Sizing mode for a single row or column track in a Grid.