BlyxDocumentation
Browse chapters
Documentation / Framework projects

Weaver · Render a file chooser as SVG

Lay out equal-width tiles on small or large viewports, distribute leftover pixels and map pointer coordinates back to an item.

The developer problem

A grid can draw a tile in one place and dispatch a click to its neighbor if painting and input code round dimensions differently. CSS Grid describes how tracks and gaps form a layout. Weaver uses one integer track calculation for both drawing and input.

Run the project locally

The example draws five file tiles in three columns. The final row has two items. Use the same geometry for touch or mouse hit testing when embedding the layout in a UI host. Install Blyx 0.2.1, Rust and a host linker, then run these commands.

git clone --depth 1 --branch v0.1.0 https://github.com/Rahulchaube1/blyx-weaver.git
cd blyx-weaver
blyxc native-run project.blyx

Use the API

Use integer logical pixels. Width, inset, gap, minimum width and row height support values up to 1,000,000. The column limit is 1–10,000, and a grid can address 1,000,000 items. Invalid geometry produces an empty rectangle or a missed hit. Right and bottom edges are exclusive. A narrow positive content area uses one column.

FunctionBehavior
we_columns(width, inset, gap, minimum, limit)Choose a responsive column count; zero indicates an empty or invalid content area.
we_rect(width, inset, gap, columns, rowHeight, index)Return [x, y, width, height] in logical pixels.
we_hit(width, inset, gap, columns, rowHeight, count, x, y)Find the item under a pointer. Gutters, empty cells and outside positions return −1.

Verify a change

Run the package checks from its release directory. Compare the browser example with its expected output, then change the input in the exercise below.

blyxc native-run tests.blyx

Try the program

Output Ready
Expected output
3
112
1
Open in the full playground →

Practice

Move the pointer four pixels left into the gutter. Which item receives it?

Hint

Change only the worked example’s input. The API table describes the output.

Worked solution

The coordinates fall between tracks, so the result is −1.

Find

5, 113, 19

Replace with

5, 109, 19

Output after the change

3
112
-1