sigil-ui 0.1

by David Wilsonannouncement

sigil-ui 0.1.0 is out! It's the UI library behind Vessel's boot screens, splash and graphical installer, and you can now use it in your own Sigil programs.

The part I find interesting is where those screens run. A boot menu needs to draw before the kernel has started. A splash needs to show what's happening while the system comes up. An installer needs forms, lists and progress before you've entered a desktop session. Vessel uses the same drawing library for all three, with the views and layout written in plain Sigil and a small C core doing the pixel work.

Vessel's graphical installer at scale 2 on a virtual display matching its 2880 by 1920 built-in panel, with a welcome screen, language choice, and Try Vessel and Install Vessel options

That's an actual capture of Vessel's installer running in a virtual machine at the built-in panel's native resolution. Its virtual monitor reports the panel's high-density physical dimensions, so Tessera selects scale 2 automatically. The wordmark, text, selection rule and option cards are drawn with sigil-ui. This release makes the library available separately from the system it grew out of.

From the boot menu to the installer

There are four Vessel packages using sigil-ui today, and they give a useful picture of what it can do.

vessel-boot-screens defines the palette, layout, text and views for the boot screens. A menu, a progress display and a boot log are functions that produce element trees. They describe rectangles, labels, colored text runs and masks, with positions calculated by the program.

vessel-efi uses those views in the UEFI boot loader. It draws a canvas and hands it to the firmware's graphics output through a platform adapter. The loader still decides which entries to show, which one is selected and what to boot. sigil-ui draws the description it gets.

Vessel's boot-menu view rendered at scale 2 on a 2880 by 1920 display, with its wordmark, generation list, selected entry, countdown and keyboard hints

This is the real boot-menu view rendered offscreen at 2880 by 1920, with the screen library's sample generations and Vessel's font and wordmark assets. The same view can be inspected as a PNG without booting a machine.

After the kernel starts, vessel-splash uses the same screen library from early userspace. It presents the canvas through Linux DRM or fbdev and keeps the screen useful while the rest of the system starts. A rectangle or a line of text has the same meaning to the view whether the finished pixels are going to firmware or a Linux display device.

Vessel's boot-log view rendered at scale 2 on a 2880 by 1920 display, with colored service statuses, an expanded sample failure and a command for inspecting the log

The boot log is another offscreen render, using the screen library's sample failure. This view isn't connected to real service output yet, so a normal Vessel boot doesn't show it today. Colored text runs pick out service status and the suggested command; the program decides which messages to show and when to expand a failure.

Then there's vessel-installer-gui, which draws the installer flow on a Wayland surface. Its buttons, fields, option cards, disk display and focus rules are Sigil code built from those primitives. Keyboard and pointer events go back to the installer's model; the renderer works from the view the model gives it.

The graphical installer runs as a Wayland client, while the firmware menu and early splash present through their platform adapters. So “before the desktop” covers different environments, and each one gets its own way of putting pixels on screen. The views, theme and drawing primitives can still be shared.

That reuse is what I wanted here: I can work on the screens as ordinary functions, render them offscreen to inspect them, and use the same drawing model in the programs that show them during boot.

A view is a function

A sigil-ui view takes application state and returns a tree describing the screen. When your state changes, call the view again and give the result to ui-update!.

sigil-ui is a low-level UI library: you make your own components with plain functions. That's why the example below is mostly rects and labels. In it, row is a component that builds one application row from its state.

Here's a small launcher-style panel inspired by Tessera's layout and Orpiment palette. This is an approximation written with sigil-ui; Tessera's own launcher draws through Cairo. The example draws a filter field, four rows and a footer, then changes the selected row:

(define (launcher selected)
  (define (row index name detail)
    (group 16 (+ 68 (* index 44))
      (list
        (rect 0 0 568 40 (if (= index selected) 'selected 'background))
        (rect 0 0 2 40 (if (= index selected) 'accent 'background))
        (label 16 12 name (if (= index selected) 'accent 'text))
        (label 360 12 detail 'muted))))
  (group 0 0
    (list
      (rect 0 0 600 1 'edge)
      (rect 0 319 600 1 'edge)
      (rect 0 0 1 320 'edge)
      (rect 599 0 1 320 'edge)
      (rect 16 12 568 36 'edge)
      (rect 17 13 566 34 'field)
      (label 28 22 ">" 'accent)
      (label 52 22 "Filter applications..." 'muted)
      (row 0 "Terminal" "foot")
      (row 1 "Files" "file manager")
      (row 2 "Web browser" "Firefox")
      (row 3 "Text editor" "Emacs")
      (rect 16 260 568 1 'edge)
      (label 24 282 "Up/Down select   Enter open   Esc close" 'muted))))

(define ui (make-ui theme (make-canvas 1200 640) 2 'background))
(ui-update! ui (launcher 0))
(display "Selection damage: ")
(write (ui-update! ui (launcher 1)))
(newline)
(write-png! "launcher-s2.png" (ui-canvas ui))

That's the view and update code. The complete example adds imports, the color theme and a font set. The runnable package includes those files, a package manifest and the demo's real Spleen 16x32 bitmap glyphs, charset and font license. Extract it, run sigil deps install and sigil build --config dev, then run ./build/dev/bin/launcher-example from the extracted directory.

The canvas is 1200 by 640 physical pixels at scale 2, so the view has 600 by 320 logical pixels. The font advances eight logical pixels per character, using the 16x32 glyph asset at this scale. Running the example writes this image:

The sigil-ui launcher approximation rendered at scale 2, with Files selected, a filter field, four application rows and keyboard hints

The selection change reports ((16 68 568 40) (16 112 568 40)): the old and new rows, in logical coordinates. The filter field, other rows and footer stay unchanged. This example only draws the panel; filtering, keyboard handling and launching an application would belong to the program using it. You can render and inspect it without opening a window or taking control of a display.

sigil-ui keeps the tree from the previous update. It compares the next description with that tree, reuses unchanged display items and repaints the damaged rectangles. ui-update! gives those rectangles back to the program for presentation. A key preserves a child's identity when you reorder a list, and a component can keep its subtree while its function and input stay unchanged.

Your application still owns its state and decides when to update. In the installer, that means the install flow can decide which control is focused or enabled, and the drawing code can show that decision. The UI library doesn't need to know how to partition a disk or start a service to draw the next frame.

Sigil for the screens, C for the pixels

The retained tree, reconciliation, themes and display list are Sigil. C handles pixel loops, PNG encoding and the native surface interfaces. The renderer draws into XRGB8888 buffers on the CPU: solid and blended rectangles, bitmap text, colored text runs and alpha masks.

This makes the drawing path quite direct. A view produces display items, the renderer paints a canvas, and a surface presents the pixels. You can also keep the canvas offscreen and save it to a file, as in the example above.

Fonts and masks can have a separate asset for each integer scale. The view uses logical coordinates, so a scale-2 font can have twice the pixels while keeping the same logical advance. Vessel supplies its own font and wordmark assets through the theme. The library doesn't have to know what those assets represent.

Positions are explicit. If a label should be centered, your layout code calculates its position. If a window gets smaller, your program decides how to tighten the spacing or change the arrangement. That's the approach Vessel's installer takes, and its controls live in Vessel rather than in sigil-ui's public API.

What 0.1 is ready for

You can use this release for offscreen renders, boot and status displays, and Wayland programs where you want to build the controls yourself. It includes offscreen, Linux fbdev and DRM surfaces, plus Wayland windows and fullscreen surfaces with keyboard and pointer input. The Wayland path handles resize and integer-scale changes and presents damage through shared-memory buffers.

The native package currently targets Linux. A Wayland program needs dynamic linking because the surface loads libwayland-client and libxkbcommon at runtime. Offscreen rendering doesn't need those libraries.

This is an early API, and it may change. Layout, widget input handling and animation timing belong to your program. Text uses bitmap fonts; there's no shaping engine, IME or accessibility integration. Fractional-scale outputs are handled by rendering at an integer scale and letting the compositor resample. GPU rendering, clipboard, drag and drop, and a public subsurface or DMA-BUF API are outside 0.1.

Those limits matter if you're choosing it for an application. The release notes and design document go into the model and its limits in more detail.

Try it

With Sigil 0.24 on Linux, add this to your package's dependencies:

(from-pkg name: "sigil/sigil-ui" version: "^0.1")

Run sigil deps install, then build your program as usual. The README has the complete offscreen example, and the repository includes a Wayland demo and benchmarks. sigil-ui is licensed under BSD-3-Clause; the demo's Spleen fonts have their own license.

You can browse the source on Sigil Forge and read the 0.1.0 release notes. If you're building a boot screen, an installer or a small graphical tool in Sigil, I'd love to see what you make with it!