T-044 — The editor’s Play shell: light and dark theme kept in state, the MathStruct wordmark, monochrome marks, Play/Edit tabs, a pedal dock, model details with font notices, idle repaint
Status: done (maintainer looked at the screenshots and the editor in Reaper, 2026-12-04) · Area: rust · Depends on: T-020
Read for that: Spec 003 (all of it except Edit and Keys played from the editor), T-020 (Decisions, Outcome), T-019 (D1: v4 sections), crates/piano/src/{gui.rs,gui/*,view.rs,params.rs,lib.rs}, crates/params/src/state.rs, scripts/gui-smoke-test.sh.
What: T-020’s editor is a dark, teal-and-gold panel with every control on one page. Spec 003 replaces its frame with the Play shell at the same fixed 720 × 400:
- Theme: light and dark palettes of Spec 003 (Visual identity), applied to egui’s
Visualsand to the custom-painted keyboard and meters; the choice System / Light / Dark in the header, kept in the plugin state (D1); System follows the OS where it can be read (D2), else light. - Header: the
math𝄞tructwordmark with Piano in the top-left corner (D3), the model’s name, Play and Edit tabs, the theme choice and a Details button. - Play: the table-driven controls as today (every group; the group decides, no GUI code per parameter), Sustain renamed String sustain (id 2 stays), controls at ~14 pt; meters labelled L, R, dBFS and Output after Gain, monochrome bar with a distinct peak-hold mark, latched CLIP (the only chromatic mark) cleared by a click.
- Edit: a placeholder naming T-047. Switching tabs keeps scroll positions (stable ids).
- Dock (both tabs): three pedal slots above the keyboard: Sustain Up/Down (engine state, CC64 ≥ 64), Sostenuto and Soft shown as unsupported (T-010 adds them), each distinguishable without colour. Keyboard in monochrome (D4) with a one-line legend.
- Details: a panel (over the middle region) with model name, version, source, fit licence and the attribution (as T-020), plus the font notices: Liberation Serif and Bravura, copyright lines and SIL OFL 1.1, full licence texts scrollable.
- Repaint: ~30 fps while a meter moves, holds a peak or a key sounds; ~4 Hz otherwise (D5).
Decisions (accepted by the maintainer, 2026-12-03)
| Question | Options | Proposal | |
|---|---|---|---|
| D1 | Theme in the state | (a) a v4 section EDIT: [version u8 = 1, theme u8], theme 0 = System, 1 = Light, 2 = Dark; missing section or unknown value → System; written on every save; not part of presets (an editor preference, not sound); a change from the editor calls the host’s state.mark_dirty; held at runtime in an AtomicU8 in PianoShared; (b) a hidden parameter; (c) a file in the user’s config directory, shared by every instance | (a): T-019 D1 reserved EDIT for this; per-project like the spec says (“stored in the plugin state”); a hidden parameter would show up in automation lanes |
| D2 | Reading the OS setting | (a) the dark-light crate (3.x): Linux through the org.freedesktop.appearance color-scheme portal (zbus, pure Rust), macOS and Windows through their settings; called on a short-lived thread when the editor opens, result in an atomic, light until it answers; never on the audio thread; (b) hand-written per OS (zbus call on Linux, objc2 on macOS, registry on Windows); (c) shelling out to gdbus/busctl on Linux | (a): one small call covering the three platforms; zbus adds a moderate pure-Rust dependency tree, no C library. Read once per opening; no live follow while open |
| D3 | Wordmark fonts | (a) subsets of Liberation Serif (math, truct, Piano) and Bravura (U+1D11E) built by a committed script with fonttools from nixpkgs’ liberation_ttf and bravura, a few KiB each, committed under crates/piano/assets/fonts/ with their OFL.txt; drawn as three galleys with the clef scaled and offset by constants local to the logo; (b) full fonts (~1 MB in the binary); (c) a precomposed image at three scales | (a): crisp at every scale (vector glyphs through egui), small, reproducible; the spacing constants are tuned on screenshots at 100/150/200 % |
| D4 | Monochrome key marks | (a) held = key filled with the secondary ink (white keys) or inset light (black keys); sounding = a round dot near the key’s foot; undamped = a thin bar along the foot in ink; pedal Down = filled box, Up = outlined, unsupported = dashed outline with the word; (b) intensity shading for sounding | (a): three marks that coexist on one key and read without colour; intensity needs a level per key the view does not carry |
| D5 | Repaint rate | (a) 33 ms while any meter is above its floor or holds a peak, a key is sounding or held, or the pointer is over the window; 250 ms otherwise; egui’s own input still repaints at once; (b) keep 33 ms always (T-020 D3) | (a): Spec 003’s refinement; the decision is pure (a function of the meters and key bits) and unit-tested |
Changed during implementation (maintainer, 2026-12-03): D2 on Linux and the BSDs reads the portal with gdbus call … org.freedesktop.portal.Settings.ReadOne org.freedesktop.appearance color-scheme (fallback busctl --user) as a child process with a 1 s deadline, killed if late; dark-light stays for macOS and Windows only (built without its default features). Reason: dark-light uses zbus on async-io, and async-io starts a global async-io thread that never ends; its code lives in the plugin library, so a host that unloads the library could crash. D3: both fonts carry OFL Reserved Font Names (Liberation, Bravura), and a subset is a Modified Version, so the subsets are renamed MathStruct Wordmark Serif / Clef and credited as “based on” the originals; Bravura comes from a pinned commit of steinbergmedia/bravura with its SHA-256 (nixpkgs has no Bravura), scripts/subset-wordmark-fonts.sh.
Out of scope: resizing (T-045), playing from the editor (T-046), the inspector (T-047), screen-reader names beyond the labels egui keeps (no AccessKit bridge in egui-baseview 0.9), tabular digits.
Done when
- The gates of AGENTS.md pass, including bundle,
clap-validatorand the GUI smoke test. - Tests:
EDITround-trip; a v4 state withoutEDIT, and v1–v3 states, load as System; an unknown theme byte loads as System; the theme is not in presets; contrast of ink and secondary on each theme’s surfaces ≥ 4.5:1 (WCAG formula); the repaint decision (D5); the pedal slots (Sustain from the view, the two unsupported); the layout still gives every table entry one control in group order; parameter text still Latin-1 (the wordmark’s clef is drawn from its own font, outside that check);no_allocpasses. - Light and dark screenshots of the editor while a pedalled chord sounds (the smoke test’s
GUI_SMOKE_PPM, the theme selected through the state), and the wordmark at 100 %, 150 %, 200 %, attached to this page’s outcome; the maintainer has looked at them. - The default sound is unchanged (golden test); renaming Sustain changes only the parameter’s display name.
Outcome
-
The shell at 720 × 400: header with the wordmark (top left), the model name, Play/Edit tabs, Theme (System/Light/Dark) and Details; Play shows the table-driven controls in two columns above the stereo meters (Output after Gain, dBFS, peak-hold tick, latched CLIP per channel, the only chromatic mark); Edit is a placeholder for T-047; the dock (both tabs) holds the three pedal slots and the monochrome keyboard with its legend. Sustain is now String sustain (id 2). Details replaces the middle region while open: the model line and attribution, then the two font credits with their OFL texts collapsible.
-
The theme lives in the state section
EDIT(crates/params/src/state.rs,Theme), restored on load, never in presets (a preset load keeps the current theme); a change from the editor sets a flag and requests a main-thread callback, which calls the host’sstate.mark_dirty. System asks the OS on a helper thread when the editor opens (crates/piano/src/gui/system_theme.rs), light until it answers; the editor joins that thread on close (at most ~2 s, both queries’ deadlines). -
Wordmark constants (
gui/wordmark.rs): serif 24 pt, clef 0.58 × serif size raised 4 pt, 3.5 pt optical space before it reduced by a 0.08 em pull, 2.5 pt after it, 8 pt before a 12 pt Piano. -
Fixed on the way (pre-existing since T-020): baseview 0.4.2 on X11 sizes a new window by
Xft.dpi(1.0 when unset) and ignores the host’s scale it then draws with, so at a CLAP scale of 2 the window was 720 × 400 whileget_sizesaid 1440 × 800. On X11 the window is now created with the physical size reported to the host (window_sizeingui.rs). The smoke test takesGUI_SMOKE_THEME=light|darkandGUI_SMOKE_SCALE=1|1.5|2and passes at all three scales. -
Gates: fmt, clippy, nextest (154 passed, 1 skipped: the X11 test), bundle,
clap-validator validate(38 passed, 0 failed, 6 skipped), GUI smoke test in light and dark at scale 1 and in light at 1.5 and 2. The non-Linuxdark-lightpath was not compiled here (no Windows/macOS target); its API was checked against the crate’s source. -
Implemented by Codex; the D2 change and the X11 size fix by Claude. Reviewed by Mistral (defects only). Triage: no verified defect. State format (round-trip, legacy v1–v3, malformed
EDIT, 64 KiB boundary, the pre-T-044 decoder reading the new state), contrast, sizes, repaint decision, meter ballistics, key geometry,parse_color_scheme, font subsets probed and passed (as ports: the reviewer’s tool calls to cargo were refused in its session). Its guesses: U+2212 in the meter scale renders (visible in the captures);dark_light::detectandMode::{Dark, Light, Unspecified}exist in 3.0.0 (checked); WindowsLogicalSizematchesget_sizewhen the host’s scale equals the system’s — not changed. -
Follow-up (maintainer, 2026-12-03): the look of the website (mathstruct.org/instruments). Palette from the site’s CSS (paper
#FAFAF9, raised white, ink#0B0B0B; dark#0A0A0A/#F4F4F3), pill buttons with the selected tab solid ink, black sliders (gui/slider.rs: ink track and knob on a light rail, click/drag/arrow keys; egui’s slider paints rail and knob in one colour), group labels as spaced-out monospace capitals, meters with an ink bar. The wordmark is now the website’s own: its SVG path data (Liberation Serif letters, Noto Music clef) rasterized per display scale bygui/outline.rs; this replaces D3’s font subsets, the Bravura font andscripts/subset-wordmark-fonts.sh. The theme choice is a round sun/moon button as on the site: a click switches to the opposite of what is shown (leaving System); System stays the default until the first click. Gates as above (159 tests passed) and the smoke test in light, dark and at scale 2.
Captures from the X11 smoke test (editor embedded in a host window, pedalled chord): light, dark, light at scale 2.


