Aether UI for Aether
Port of the Perry UI framework to Aether.
Declarative widget DSL backed by GTK4 (Linux and FreeBSD), AppKit (macOS),
and a native Win32 backend (Windows) — the three backend implementations
share the same ABI declared in backend/aether_ui_backend.h. Uses Aether's
trailing-block builder pattern.
Credits
This module is a from-scratch Aether + C rewrite of the aether-ui Rust crates
from the Perry project by the Perry
contributors. The Rust implementations (aether-ui-gtk4, aether-ui-macos, and
the core aether-ui crate) were used as reference for architecture, widget
API design, reactive state bindings, and platform-specific GTK4/AppKit
patterns. Based on commit
7f1e3f9
of the main branch.
Portions Copyright (c) 2026 Perry Contributors collectively, and portions Copyright (c) 2026 Aether Contributors collectively. MIT License.
Apps built on other people's ideas
Some apps under apps/ port or borrow from existing projects. Each
carries its own NOTICE (and the upstream licence verbatim) beside its
source; the summary:
- Maerkdown (
apps/maerkdown) — the word-as-widget markdown editor.
Its extended inline syntax (++insertion++, ||spoiler||,
==highlight==, ^superscript^, ~subscript~) is taken from the
Extended Markdown Syntax
plugin for Obsidian by Kotaindah55 (Sheva Ihza),
MIT.
The delimiters and their meanings come from that project's documented
rules; no code was copied, and the parser is an independent
implementation over this editor's own document model.
- Font Picker (
apps/font_picker) — a rule-for-rule port of
Javascript Font Picker, MIT, portions
Copyright (c) 2024-2025 Zygomatic.
- Falling Blocks (
apps/falling_blocks) — derived from
fallingblocks and
therefore GPL-3.0, unlike the rest of this repository. See the
header in that app's source before distributing binaries built from it.
Quick start
Linux (GTK4)
sudo apt install libgtk-4-dev # Debian/Ubuntu
./build.sh examples/counter/counter.ae
./build/counter
The floor is GTK 4.6 / GLib 2.72 (Ubuntu 22.04). On GTK < 4.8 two things
degrade: image_fill can only keep or ignore aspect ratio (original and
cover apply, and report, as contain), and a chrome-drawn toggle keeps its
native face because a 4.6 check button has no child slot.
FreeBSD / GhostBSD (GTK4)
Same GTK4 backend as Linux; build.sh detects FreeBSD and uses clang.
sudo pkg install gtk4 pkgconf # ensure a zlib.pc exists for freetype2 -> zlib
./build.sh examples/counter/counter.ae
./build/counter
tests/spec_matrix.sh needs no display of its own — on FreeBSD it starts a
private Xvfb (pkg install xorg-vfbserver), unprivileged, and any pre-set
$DISPLAY is respected instead.
macOS (AppKit)
./build.sh examples/counter/counter.ae
./build/counter
Windows (native Win32)
Build from an MSYS2 MinGW64 shell (no extra dev libraries — USER32, GDI+
and Common Controls ship with Windows itself):
./build.sh examples/counter/counter.ae
./build/counter.exe
The C-level suites build through the same script (a .c source links against
the platform backend directly), and run headless:
# widget + driver smoke suite for the current backend
./build.sh tests/test_widgets.c test_widgets && AETHER_UI_HEADLESS=1 ./build/test_widgets
# microbenchmarks, CSV to stdout
./build.sh benchmarks/bench_widgets.c bench_widgets && AETHER_UI_HEADLESS=1 ./build/bench_widgets
The whole pipeline, the way CI runs it:
./ci.sh # build everything, smoke-launch, run every driver spec
./tests/spec_matrix.sh # just the AetherUIDriver specs
ci.sh also cross-compiles AND LINKS the Win32 backend when a mingw-w64
compiler is present (brew install mingw-w64, or apt install gcc-mingw-w64-x86-64), and says SKIP when there is none. The link half is not
redundant: a Windows API declared in a header whose import library is missing
compiles perfectly and fails at link, so dropping -lole32 leaves the syntax
check at zero errors while the link reports __imp_CoCreateInstance.
That is not a substitute for running on Windows, which nothing here does; it
is what stops the one backend nobody can execute from being edited blind.
See docs/design/win32-gdiplus-renderer.md
for the Win32 rendering model, and docs/README.md for the
rest of the design notes.
DSL with Scope
Aether UI is a "DSL with Scope" — Matz's own name (he coined it when
asked to name the pattern) for the builder-block style: nested blocks that
describe structure declaratively while keeping full imperative power, with an
implicit receiver so children wire to their parent without explicit
plumbing. It runs in the Smalltalk-blocks / Ruby-Shoes / Groovy-SwingBuilder /
Kotlin-Compose / SwiftUI lineage — and, unlike a markup format, the blocks are
executed code, not parsed into a DOM for some later actioning. See
Paul Hammant's "That Ruby and Groovy Language Feature"
for the full tour, and Aether's own
docs/closures-and-builder-dsl.md
for the mechanism (trailing blocks, the _ctx implicit-receiver convention,
and builder … with "configure then execute").
A UI is opened inside a surface scope. The surface's kind decides its
lifecycle (see Surfaces below):
import ui
main() {
counter = ui.ui_state(0)
ui.window("My App", 400, 200) {
root = ui.vstack(10) {
ui.text("Hello World")
ui.text_bound(counter, "Count: ", "")
ui.hstack(5) {
ui.btn("+1") callback {
ui.ui_set(counter, ui.ui_get(counter) + 1)
}
ui.btn("-1") callback {
ui.ui_set(counter, ui.ui_get(counter) - 1)
}
}
}
_ci = ui.content_inset(root) // the standard 12px window gutter
}
}
The window(…) { … } block builds the tree, then — because it's a builder
function whose body runs after the block — opens the window and runs the
event loop. No trailing app_run(root): the surface is the entry point.
content_inset(root) is the one line that keeps the content off the window's
frame; it is opt-in, because a container's geometry is a contract apps read
(on_layout, pointer mapping), so nothing insets a window behind your back.
Surfaces (window / render_to / record)
A surface is the ambient destination a widget/drawing block populates.
The kind decides lifecycle:
| Surface |
Lifecycle |
What it is |
window(title, w, h) { … } |
lived — runs the event loop, ends on window close |
An on-screen interactive window. Absorbs the old app_run. |
render_to(target, w, h) { … } |
bounded — one render pass, returns |
Draw into a target: pixel buffer, PNG, PDF, paper. No event loop. |
record(w, h) { … } |
bounded — captures, returns |
A test/recording surface — inspect what was built. No event loop. |
window_run(title, w, h, root) |
lived |
Explicit-root variant of window for trees built imperatively (e.g. a root_grid whose cells are grid_place'd in). |
Interactive verbs (onclick, onhover) used inside a bounded surface are
diagnostic-inert: they render but the handler never fires (there's no event
loop to deliver to). The diagnostic is collected on the surface by default
(read it with surface_diagnostics(handle)); routing it to stderr or a hard
fail is an explicit opt-in, never the default — the framework never writes to
a stream you didn't ask it to.
Inside a surface block, use the context-attaching layout verbs (vstack,
hstack, zstack, …) — not the root_* variants (root_vstack,
root_hstack). The root_* verbs are detached: they take no builder context
and so don't attach to the enclosing surface, leaving you with a window that
maps but renders blank. The root_* forms exist only for the explicit-root
window_run(title, w, h, root) path, where you build the tree imperatively and
hand the root in. Inside window {…} / render_to {…} / record {…}, always
vstack (which the compiler auto-parents to the surface via the _ctx
convention).
Why three verbs instead of one app_run? Because app_run welded together
three jobs — create the window, mount the tree, run the loop — and forced that
lived shape onto every program. Most surfaces aren't lived: a render-to-PNG,
a print-to-paper, a headless test needs no loop and ends by reaching }. Only
a live window has "a life of its own" that ends on an external event, so only
window carries the loop.
Widgets available
| Widget |
Aether function |
GTK4 |
AppKit |
Win32 |
| Text |
ui.text("label") |
GtkLabel |
NSTextField (label) |
STATIC |
| Button |
ui.button("label") callback { } |
GtkButton |
NSButton |
BUTTON (BS_PUSHBUTTON) |
| VStack |
ui.vstack(spacing) { children } |
GtkBox vertical |
NSStackView vertical |
AetherUIStack (custom) |
| HStack |
ui.hstack(spacing) { children } |
GtkBox horizontal |
NSStackView horizontal |
AetherUIStack (custom) |
| Spacer |
ui.spacer() |
Expanding GtkBox |
NSView flex filler |
flex placeholder |
| Divider |
ui.divider() |
GtkSeparator |
NSBox separator |
GDI line (custom class) |
| TextField |
ui.textfield("hint") callback |val| { } |
GtkEntry |
NSTextField |
EDIT |
| SecureField |
ui.securefield("hint") callback |val| { } |
GtkPasswordEntry |
NSSecureTextField |
EDIT (ES_PASSWORD) |
| Toggle |
ui.toggle("label") callback |active| { } |
GtkCheckButton |
NSButton (switch) |
BUTTON (BS_AUTOCHECKBOX) |
| Slider |
ui.slider(min, max, init) callback |val| |
GtkScale |
NSSlider |
TRACKBAR (comctl32) |
| Picker |
ui.picker() callback |idx| { } |
GtkDropDown |
NSPopUpButton |
COMBOBOX (CBS_DROPDOWNLIST) |
| TextArea |
ui.textarea("hint") callback |val| { } |
GtkTextView |
NSTextView |
EDIT (ES_MULTILINE) |
| ProgressBar |
ui.progressbar(0.75) |
GtkProgressBar |
NSProgressIndicator |
PROGRESS (comctl32) |
| ScrollView |
ui.scrollview() { children } |
GtkScrolledWindow |
NSScrollView |
AetherUIStack + WS_VSCROLL |
| Grid |
grid(cols, rspace, cspace) { ... } (children fill it row by row; equal_cells() for a keypad), or ui.root_grid(...) + grid_place(...) |
GtkGrid |
NSGridView |
AetherUIGrid (custom) |
| Menu bar |
ui.menu_bar() + menu() + menu_item() |
GMenu / GActionMap |
NSMenu |
HMENU (CreateMenu/SetMenu) |
| GPU view |
ui.gpuview_create(w, h) (#92) |
GtkGLArea |
NSOpenGLView |
not yet (reports 0) |
| Native view |
ui.native_view(w, h) (#193) |
not yet (reports 0) |
not yet (reports 0) |
child HWND, handle handed to the app |
| Tabs |
ui.tabs() { tab("title") { … } } |
GtkStackSwitcher + GtkStack |
NSTabView |
button strip over a page zstack |
| SplitView |
ui.splitview("h") { pane1 pane2 } |
GtkPaned |
NSSplitView |
own divider band, mouse-capture drag |
| ListBox |
ui.listbox(spacing) callback |item, i, row| |
composed from a stack of rows, identical on all backends |
|
|
| Table |
ui.table(cols) callback |item, col| |
composed on a ListBox, identical on all backends |
|
|
| Tree |
ui.tree(roots) |
composed on a ListBox, identical on all backends |
|
|
| VList |
ui.vlist("v", rows, |item, i, parent| { }) |
GtkListView |
NSTableView |
composed window (no native list) |
Native view — an engine presents into a panel
gpuview hands back a GL context the toolkit owns and presents for you.
A native view