NewsCrawler.org

blit: an immediate mode UI library with deferred layout

blit: an immediate mode UI library with deferred layout
Image: Reddit

blit is an experimental UI library for Rust, and its author started working on it 5 months ago. It has a zero-dependency core, a terminal and GPU backend, and a very fast software renderer. The author describes it as immediate mode[1] with deferred layout.

The work began on a device at Foundation that runs KeyOS, an OS built on a microkernel[2], on a single-core 500 MHz Cortex-A5 with 128 MB of RAM and no GPU. The team had picked Slint, which topped out at 30 fps on its 480×800 LCD, and the author wanted to get more out of the hardware.

The article contrasts retained mode[3], where the framework stores the UI as a tree of objects, with immediate mode, where the UI is rebuilt every frame. blit runs three passes each frame: build, layout and paint. Layout is solved in two passes over the node array: fit walks up from the leaves, and distribute walks down from the root. Layouts are ordinary code that implements the Layout trait.

Read the original pasttheboonies.comDiscussion

Discussion

Commenters mostly welcome the approach. One asks how layout that depends on child size is handled and how stable ids keep focus and IME working when lists reorder, and no answer to these questions is given in the thread. Another commenter calls immediate mode with layout caching where it makes sense the sweet spot for UIs.

Sources

Published: First seen: Читать по-русски

Open as a page