Skip to main content

Module grid_view

Module grid_view 

Source
Expand description

Virtualized 2D tile grid bound to a ListModel<T> / ListDataSource.

GridView is the photo-gallery / icon-view / file-manager-grid / collection-view widget — the 2D sibling of ListView and TableView. It realizes only the tiles currently visible (plus a buffer), reflows on resize, supports single / multi selection with 2D keyboard navigation, and is fully accessible (Role::GridRole::GridCell).

The layout is pluggable via GridLayoutStrategy; the stock UniformGrid gives fixed tile size / fixed column count / adaptive min-width grids. (Variable-row-height and waterfall strategies, plus marquee selection, drag-reorder, sections and sticky headers, are layered on in later phases.)

GridView::new(model, |tc| {
    Box::new(Card::new().child(TextWidget::new(lit!(&tc.item.name))))
})
.sizing(GridSizing::Adaptive { min_width: 120.0, max_width: None, height: 140.0 })
.spacing(8.0)
.selection(selection_model)

Re-exports§

pub use sections::GroupingSections;
pub use sections::SectionProvider as GridSectionProvider;
pub use sections::grouping_sections;
pub use layout::GridSizing;
pub use layout::ScrollAnchor;

Modules§

layout
Layout strategies for GridView.
sections
Section grouping for GridView.

Structs§

GridView
A virtualized 2D tile grid backed by a ListModel<T>.
TileContext
Context passed to the tile delegate for each realized tile.

Enums§

GridTabTraversal
How Tab moves out of (or within) the grid.