Skip to main content

Module masonry

Module masonry 

Source
Expand description

MasonryLayout — a variable-height grid that packs children into the shortest column (Pinterest-style).

Each child is measured at the shared column width and placed into whichever column currently has the lowest accumulated height. Ties between equal-height columns are broken by column index (leftmost wins). All columns share the same width; column and item spacing are independently configurable. RTL layout mirrors the column order so the first logical child still goes to the leading edge.

let _grid = MasonryLayout::new(3)
    .column_spacing(8.0)
    .item_spacing(8.0)
    .child(TextWidget::new(lit!("Tall card")))
    .child(TextWidget::new(lit!("Short card")))
    .child(TextWidget::new(lit!("Another card")));

Structs§

MasonryLayout
A masonry (Pinterest-style) layout that packs children into the shortest column.