Skip to main content

Crate densa_grid

Crate densa_grid 

Source
Expand description

A data grid over your own data, drawn onto a densa_draw::Canvas.

Domain-agnostic: an application describes its Columns and implements GridSource (one call per visible cell, formatting into a stack buffer); GridPainter lays the columns out from font metrics, aligns text, fills overflowing numbers with # like a spreadsheet, and draws cell styles and glyphs. No GPU dependency: hand the canvas’s instances to densa-render (or any other backend) to show them.

A widget showing a grid asks its data through GridModel instead: the same cells, plus the rows to scroll through and sorting by column.

Painting allocates nothing once the frame’s characters are cached.

Structs§

CellStyle
How one cell is drawn: CellStyle::new(color), with with_background for a fill.
Color
A color in linear RGB with straight (not premultiplied) alpha: the space densa blends in.
Column
A grid column: header title, width in characters, alignment. Made with Column::new.
GridLayout
Pixel geometry of a grid, derived from its columns and the font’s metrics.
GridPainter
Draws a GridSource onto a Canvas.
Palette
Grid colors: Palette::new is the dark default; change its fields for others.
Point
A position in pixels, y down.
Rect
An axis-aligned rectangle in pixels, y down, stored as its four edges.

Enums§

Align
Horizontal alignment of text within a column.
SortOrder
Which way a column sorts.

Constants§

CELL_BYTES
Bytes a cell’s text may take. FmtBuf appends are all-or-nothing, so a write that does not fit leaves the cell as it was (blank if nothing was written yet), not truncated.

Traits§

GridModel
The data of a grid widget: its columns, its rows, and each cell’s text and style, plus what the widget asks of it as the user works with it.
GridSource
The data a GridPainter draws: one call per visible cell, every frame.

Type Aliases§

CellText
The stack buffer a GridSource writes one cell’s text into.