ADR-0006 — The plugin GUI is written with egui, embedded through baseview

Status: accepted

Context: The GUI is Rust (ADR-0001). A plugin GUI owns neither its window nor its event loop: the host hands over a parent window (X11 window id, HWND or NSView) through CLAP’s gui extension and keeps its own event loop. The GUI must draw into that window, take input from it, and run several instances in one process.

Decision: The GUI uses egui through egui-baseview: baseview opens a child window in the host’s parent on X11, Windows and macOS and drives egui’s frames and input; the plugin crate wires it to CLAP’s gui extension (clack-extensions). The GUI talks to the audio thread only through lock-free structures (atomics for parameter values, ring buffers for meters). GUI code sits behind a small Editor trait in the plugin crate.

Rejected alternative: Rune (GPU-rendered Rust UI with headless testing). At rev 7e4730f0559b (Nov 2026) it can draw into a caller-owned surface only on Apple (rune::embed::LayerHost with a CAMetalLayer) and Android; there is no way to draw into an X11 window or HWND the host owns, so Linux and Windows would need new embedding code in or around a pre-release framework that takes no pull requests. vizia and iced (also baseview-based; vizia is the other common plugin GUI, worth revisiting if egui’s immediate-mode style limits the look).

Consequences: A proven path into hosts on all three desktop platforms. egui repaints immediate-mode: request repaints only while something changes (meters, drags), so an idle GUI costs little CPU. Custom widgets (knobs, keyboards, envelope editors) are drawn with egui’s painter. If Rune gains embedding for raw window handles, it can be revisited behind the Editor trait. The phone/browser remote of the standalone instrument is a separate UI (Dioxus web, ADR-0008); both read the same parameter description.