tawasuyu

tawasuyu/llimphi

Sovereign retained-mode GPU UI framework in Rust (wgpu+vello+taffy+parley), Elm loop, 40+ widgets.

Rust 660Markdown 302TOML 157RON 312382 Definitions

⎇ main widgets/grid/README.md Markdown · 46 lines · 1.8 KB History raw

chore: refresco desde el monorepo — 27 crates nuevos (anim, lottie, svg, mesh, image, layer, test, wire-view, widgets rag-sidebar/router/lazy-list/rive-button) y sync de los 95 existentes 93253cc22 · Sergio ·

1# llimphi-widget-grid
2
32D virtualized grid for Llimphi.
4
5Sibling of `llimphi-widget-list`, but tiled: clickable cells laid out in `cols`
6columns × rows, with selection, optional caption/hint and overflow clipping.
7Designed as the base for thumbnail galleries in the gThumb / FastStone vein —
8able to list thousands of files without mounting them all: the caller renders
9**only the visible window**.
10
11Like `list`, the widget does **not** scroll by itself. Virtualization belongs to
12the caller, which keeps `scroll_row` (the first visible row of cells) in its
13state and updates it with the wheel. The difference from `list` is that in 2D
14computing the window is not trivial — how many columns fit depends on the
15viewport width — so this crate provides it as a pure, testable function:
16`ventana_visible`.
17
18The widget is **content-agnostic**: each `GridCell` carries a `View<Msg>` the
19caller builds (a `peniko::Image` thumbnail, a skeleton while decoding, an
20icon…). That way the thumbnail pipeline (async queue + cache) lives outside and
21merely fills the cell with an image or a placeholder.
22
23Typical caller flow:
24
25```ignore
26let v = ventana_visible(total, viewport_w, viewport_h, scroll_row, &metrics);
27let cells: Vec<GridCell<Msg>> = (v.first..v.first + v.count)
28    .map(|i| GridCell {
29        content: thumb_or_placeholder(i),    // the caller decides
30        label: Some(name(i)),
31        selected: i == selected,
32        on_click: Msg::Select(i),
33    })
34    .collect();
35let grid = grid_view(GridSpec {
36    cells, cols: v.cols, metrics,
37    caption: Some(format!("{total} images")),
38    truncated_hint: (v.first + v.count < total)
39        .then(|| format!("… and {} more", total - (v.first + v.count))),
40    palette: GridPalette::default(),
41});
42```
43
44---
45
46Part of **llimphi** — see [llimphi](../../README.md).

README.md

llimphi-widget-grid

2D virtualized grid for Llimphi.

Sibling of llimphi-widget-list, but tiled: clickable cells laid out in cols columns × rows, with selection, optional caption/hint and overflow clipping. Designed as the base for thumbnail galleries in the gThumb / FastStone vein — able to list thousands of files without mounting them all: the caller renders only the visible window.

Like list, the widget does not scroll by itself. Virtualization belongs to the caller, which keeps scroll_row (the first visible row of cells) in its state and updates it with the wheel. The difference from list is that in 2D computing the window is not trivial — how many columns fit depends on the viewport width — so this crate provides it as a pure, testable function: ventana_visible.

The widget is content-agnostic: each GridCell carries a View<Msg> the caller builds (a peniko::Image thumbnail, a skeleton while decoding, an icon…). That way the thumbnail pipeline (async queue + cache) lives outside and merely fills the cell with an image or a placeholder.

Typical caller flow:

let v = ventana_visible(total, viewport_w, viewport_h, scroll_row, &metrics);
let cells: Vec<GridCell<Msg>> = (v.first..v.first + v.count)
    .map(|i| GridCell {
        content: thumb_or_placeholder(i),    // the caller decides
        label: Some(name(i)),
        selected: i == selected,
        on_click: Msg::Select(i),
    })
    .collect();
let grid = grid_view(GridSpec {
    cells, cols: v.cols, metrics,
    caption: Some(format!("{total} images")),
    truncated_hint: (v.first + v.count < total)
        .then(|| format!("… and {} more", total - (v.first + v.count))),
    palette: GridPalette::default(),
});

Part of llimphi — see llimphi.