Lyrebird 2.0.0 — Linux support
Consolidated release: the cross-platform Linux port (engine, generators, CLI, REPL, NRT, portable DSP), live ALSA audio + ALSA MIDI + POSIX OSC + portable WAV codec, the GTK4 GUI (LyrebirdUI on the SwiftOpenUI backend), and the Linux live-coding scratchpad (LiveCompile). Apple platforms unchanged; all additive. See RELEASES.md and LINUX_README.md. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -9,8 +9,8 @@ The core `Lyrebird` module has **no UI dependency** — `LyrebirdUI` is imported
|
||||
targets that need GUI windows.
|
||||
|
||||
```swift
|
||||
import LyrebirdSynth // engine, protocols, generators — no UI
|
||||
import LyrebirdUI // LyrebirdWindow, @UIParam, ParameterSlider, etc.
|
||||
import LyrebirdSynth // engine, protocols, generators, @UIParam — no UI
|
||||
import LyrebirdUI // LyrebirdWindow, ParameterSlider, etc.
|
||||
```
|
||||
|
||||
---
|
||||
@@ -21,7 +21,7 @@ Lyrebird provides two property wrappers for RT-safe parameters:
|
||||
|
||||
| | `@LiveParam` | `@UIParam` |
|
||||
|---|---|---|
|
||||
| Module | `Lyrebird` (no UI) | `LyrebirdUI` |
|
||||
| Module | `Lyrebird` (no UI) | `Lyrebird` (UI-observable) |
|
||||
| Projected value | `ParameterNode` | `UIParamNode` |
|
||||
| IS a `Generator`? | Yes (`AudioGenerator`) | No (`ValidGeneratorInput` only) |
|
||||
| RT delivery to oscillators/filters | Per-sample linear ramp | Block-constant (atomic read) |
|
||||
|
||||
@@ -0,0 +1,212 @@
|
||||
<!--
|
||||
linux-parity-plan.md
|
||||
Lyrebird
|
||||
Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
SPDX-License-Identifier: MIT
|
||||
-->
|
||||
|
||||
# Linux parity plan — the two must-dos + the scratch window
|
||||
|
||||
Where Lyrebird's Linux GUI stands and what closes the gap to a defensible
|
||||
"parity with macOS" claim. The interactive widget layer is done and validated:
|
||||
every control/view is ported to a GTK4 `#else` body, and the SwiftOpenUI fork's
|
||||
narrow-mutation path (Patches A–F) makes them behave like real SwiftUI, not a
|
||||
degraded port. What remains are two functional gaps and one follow-on.
|
||||
|
||||
Prereq context: `docs/ui/linux-view-port-plan.md` (the view ports),
|
||||
`spikes/SwiftOpenUIKnob/FORK_PATCH_PLAN.md` + `NARROW_PATH_GENERALIZATION_PLAN.md`
|
||||
(the fork), and the `linux-gui-swiftopenui` memory. The fork is pinned by
|
||||
revision in `Package.swift`; this Mac cannot build the GTK4 backend, so every
|
||||
change is prepare-diff → push fork → bump pin → validate on the Linux VM.
|
||||
|
||||
Ordering: **(1) LyrebirdWindow → (2) MouseTracker → (3) scratch window.**
|
||||
The scratch window depends on (1). (1) and (2) are independent of each other.
|
||||
|
||||
---
|
||||
|
||||
## Must-do 1 — `LyrebirdWindow` (host-window abstraction) — ✅ DONE
|
||||
|
||||
**Status (branch `parity/linux-window-mousetracker`).** Shipped. A `#elseif
|
||||
os(Linux)` body backs `LyrebirdWindow` with a runtime-opened
|
||||
`GtkApplicationWindow` via a new fork API `GTK4Backend.openStandaloneWindow`
|
||||
(+ `gtk_swift_get_default_gtk_application`); `presentInWindow` is ported on all
|
||||
six views and the EngineStatus "Open Window" buttons are re-enabled. VM-runtime
|
||||
confirmed. **Design note that DIVERGES from the original plan below:** the Linux
|
||||
`LyrebirdWindow` / `presentInWindow` are **nonisolated**, NOT `@MainActor` — the
|
||||
whole Linux/GTK4 UI is confined to the GTK main loop (not the Swift main actor),
|
||||
and keeping `@MainActor` forced an `assumeIsolated` hop that captured
|
||||
task-isolated `self` → a "sending self risks data races" error. Only the
|
||||
`@MainActor` `LyrebirdMessageCenter.shared` access needs a self-less
|
||||
`assumeIsolated`. The original recommendation below to "Keep it `@MainActor`" is
|
||||
therefore superseded — do not follow it.
|
||||
|
||||
**Why it was a must-do.** There was no first-class way to open/manage a window on
|
||||
Linux. `LyrebirdWindow` was Apple-only (`NSWindow` + `NSHostingController`);
|
||||
every view's `presentInWindow(...)` convenience, and the EngineStatus "Open
|
||||
Window" buttons, were therefore macOS-only. The demo hand-rolls a single GTK
|
||||
window via SwiftOpenUI's `App`/`Scene`/`WindowGroup` scene model — there's no
|
||||
imperative "open another window hosting this view" equivalent.
|
||||
|
||||
**Current Apple surface** (`Sources/LyrebirdUI/LyrebirdWindow.swift`):
|
||||
`@MainActor final class LyrebirdWindow` — `init(title:width:height:)`,
|
||||
`open<Content: View>(@ViewBuilder content:)` (wraps `NSHostingController`),
|
||||
`close()`, `nsWindow`, and an `NSWindowDelegate` that nils the reference on user
|
||||
close. Consumed by `presentInWindow` on EngineStatus / NodeTree / Message /
|
||||
EventList / Process / RunningProcesses views.
|
||||
|
||||
**Linux approach.** Add a GTK4 `#else` body with the same public API, backed by a
|
||||
`GtkWindow`:
|
||||
- `open(content:)` → create a `GtkApplicationWindow` (or `GtkWindow`), set title +
|
||||
default size, `gtkRenderView(content())` (BackendGTK4) as the child, `present`.
|
||||
- `close()` → destroy the window; wire the `close-request` / destroy signal to nil
|
||||
the reference (parity with the `NSWindowDelegate`).
|
||||
- Keep it `@MainActor`.
|
||||
|
||||
**Key unknown to resolve first (spike).** GTK needs a running `GtkApplication` +
|
||||
main loop before a window can present. Two questions:
|
||||
1. Does SwiftOpenUI already expose a way to open a standalone window at runtime
|
||||
outside the `App`/`WindowGroup` scene (an imperative `GTK4Backend`
|
||||
window API)? If yes, build on it. If not, `LyrebirdWindow` must own the
|
||||
`gtk_init` + application + main-loop lifecycle itself.
|
||||
2. **App entry point.** On macOS `LyrebirdWindow` works standalone (implicit
|
||||
`NSApp`). On Linux, opening a window from a CLI/REPL with no scene needs an
|
||||
owned GTK app + loop. Decide: does `LyrebirdWindow` bootstrap GTK if none is
|
||||
running (so `presentInWindow` works headless-of-a-scene), or is it only valid
|
||||
inside a `GTK4Backend().run(App)` context? Recommendation: make it work in an
|
||||
existing loop first (covers the in-app "Open Window" buttons), then add a
|
||||
bootstrap path for standalone use.
|
||||
|
||||
**Effort:** moderate–substantial. The view hosting is straightforward
|
||||
(`gtkRenderView`); the GTK app/main-loop lifecycle + multi-window management is
|
||||
the real work, sized by what SwiftOpenUI already gives us (the spike answers it).
|
||||
|
||||
**Validation:** `presentInWindow` on EngineStatus/NodeTree/Message from the demo
|
||||
opens a second GTK window that renders + tracks; closing it (button + WM close)
|
||||
nils cleanly; no leak/crash on repeated open/close.
|
||||
|
||||
**Fork implication:** if SwiftOpenUI lacks a standalone-window API, that's a fork
|
||||
addition (a `GTK4Backend.openWindow(title:size:content:)`), upstreamable.
|
||||
|
||||
---
|
||||
|
||||
## Must-do 2 — `MouseTracker` / `MouseInput` (Linux pointer source) — ✅ DONE
|
||||
|
||||
**Status (branch `parity/linux-window-mousetracker`).** Shipped the window-local
|
||||
baseline. A `#elseif os(Linux)` `MouseTracker` (`MouseInputBridge` subclass,
|
||||
`Atomic<Double>` x/y/button, nonisolated) is fed by a new fork API
|
||||
`GTK4PointerTracking` — a `GtkEventControllerMotion` + window-level
|
||||
`GtkGestureClick` attached to every window the backend opens, forwarding
|
||||
normalized (y-flipped) coordinates to a process-wide sink. `installShared()`
|
||||
registers both `MouseInput.install(self)` and the sink; install timing is not
|
||||
sensitive (controllers read the sink at event time). x/y fully covered, button
|
||||
best-effort. Validated by `LYREBIRD_DEMO=mouse`. The X11-global enhancement below
|
||||
remains an optional future add.
|
||||
|
||||
**Why it was a must-do.** The `Mouse.X` / `Mouse.Y` / `Mouse.Click` *generators*
|
||||
(core, `Sources/Lyrebird/Generators/UI/`) read from `MouseInput`, which is fed by
|
||||
a `MouseInputBridge`. The only bridge is `MouseTracker` (AppKit `NSEvent` global
|
||||
monitors) — Apple-only. On Linux the generators silently read the default
|
||||
`0.5/0.5/0` — any patch using mouse control does nothing.
|
||||
|
||||
**Current seam (already platform-neutral — this is the good news):**
|
||||
- `open class MouseInputBridge` (`x`/`y`/`button`, default 0.5/0.5/0) — core.
|
||||
- `enum MouseInput` with `install(_ bridge:)` / `currentX/Y/Button` — core seam.
|
||||
- `MouseTracker: MouseInputBridge` (AppKit) installs `NSEvent` global monitors and
|
||||
overrides `x/y/button` from atomics — Apple-only, in `LyrebirdUI`.
|
||||
|
||||
So the port is a **new `MouseInputBridge` conformer for Linux** + installing it at
|
||||
startup via `MouseInput.install`. No core changes.
|
||||
|
||||
**Linux approach — pick the pointer source (design decision):**
|
||||
- **Window-local (recommended baseline, portable):** a `GtkEventControllerMotion`
|
||||
on the app window updates x/y (normalized to the window), plus a click gesture
|
||||
for `button`. Works on both X11 and Wayland. Limitation: only tracks while the
|
||||
pointer is over a Lyrebird window (not truly global) — acceptable for a synth
|
||||
control surface, and matches how you'd actually perform with it.
|
||||
- **Global (X11-only enhancement):** poll `XQueryPointer` (or XInput2) on a
|
||||
timer/thread for screen-global position. True parity with the macOS global
|
||||
monitor, but **X11 only** — Wayland forbids global pointer access (needs a
|
||||
portal). Gate behind an availability check; fall back to window-local.
|
||||
|
||||
Recommendation: ship window-local first (covers the real use case, no display-
|
||||
server dependency), add X11-global as an optional path if global is wanted.
|
||||
|
||||
**Effort:** moderate. The bridge + install is small; the pointer plumbing
|
||||
(GTK motion controller, or X11 polling) is the work. Live values are read on the
|
||||
RT-adjacent path via atomics exactly as the AppKit tracker does — mirror that.
|
||||
|
||||
**Validation:** a patch with `Mouse.X.Control()` driving a parameter responds to
|
||||
pointer motion over the window on the VM; `MouseInput.currentX/Y/Button` update.
|
||||
|
||||
**Placement:** the Linux bridge lives in `LyrebirdUI` (like `MouseTracker`),
|
||||
conforms to the core `MouseInputBridge`, installed via `MouseInput.install` at app
|
||||
startup — same contract as macOS.
|
||||
|
||||
---
|
||||
|
||||
## Follow-on — the LiveCompile scratch window (after 1 & 2)
|
||||
|
||||
The live-coding scratchpad (`LiveCompile/` sub-package) is macOS-only. It has two
|
||||
layers with very different portability; full detail lives with the engine spike,
|
||||
summarized here for sequencing.
|
||||
|
||||
- **Engine (`LyrebirdLiveCompile`, ~3.3k LOC) — moderate, independent of 1 & 2.**
|
||||
`LiveCompiler` shells `swiftc -emit-library` → dylib, `dlopen`/`dlsym`;
|
||||
`SourceKitLSPClient` drives `sourcekit-lsp`. All portable (Linux toolchain ships
|
||||
`swiftc`, `dlopen`, `sourcekit-lsp`). Adapt: `.dylib`→`.so`, drop `xcrun`
|
||||
(PATH), Linux `-target`/SDK + module paths, dynamic-link the snippet against one
|
||||
`libLyrebird.so` (Linux analog of the `libLyrebirdDynamic.dylib` design), and a
|
||||
Linux `SwiftToolchainStatus`.
|
||||
- **Spike first (½ day, do before committing):** prove a `swiftc → .so → dlopen`
|
||||
snippet resolves Lyrebird's symbols on the VM against the shared
|
||||
`libLyrebird.so`. Swift-on-Linux cross-`.so` symbol/metadata resolution is the
|
||||
one real unknown; go/no-go for the whole path.
|
||||
|
||||
- **Editor UI (`LyrebirdLiveCompileUI`, ~3.1k LOC) — depends on Must-do 1.**
|
||||
Built on `NSTextView` (`ScratchTextView`, `NSViewRepresentable`, AppKit menus) +
|
||||
hand-rolled highlighter/gutter/LSP-completion/position-mapping. Two landings:
|
||||
- **Minimal (modest):** a `LyrebirdWindow` hosting SwiftOpenUI `TextEditor` +
|
||||
Run/Stop + console + the ported `LyrebirdScopeView`. No highlighting/completion.
|
||||
- **Full parity (large, fork work):** wrap **GtkSourceView** (GTK's code editor —
|
||||
syntax highlighting, gutter, completion, UTF-8) as a new SwiftOpenUI widget,
|
||||
rewire `ScratchModel`, feed it the LSP completions. GtkSourceView gives the
|
||||
highlighting/gutter/completion for *less* custom code than the AppKit version,
|
||||
but wrapping it in SwiftOpenUI is a genuine new-backend-widget project.
|
||||
|
||||
**Scratch-window sequencing:** engine spike → engine port (anytime) → Must-do 1 →
|
||||
minimal scratch window → (optional) full GtkSourceView editor.
|
||||
|
||||
---
|
||||
|
||||
## Cross-cutting (applies to all three)
|
||||
|
||||
- **Fork discipline.** Any SwiftOpenUI gap (standalone window API, GtkSourceView
|
||||
widget) is a fork commit: push `joshpar/SwiftOpenUI` `develop`, bump the
|
||||
`Package.swift` revision, validate on the VM. Keep each a clean upstreamable
|
||||
delta (see `FORK_PATCH_PLAN.md`).
|
||||
- **No Linux UI CI.** Core CI skips the UI (needs GTK). Before calling any of this
|
||||
"done", add at least a Linux **build** job for the UI + demo so regressions
|
||||
surface (a compile-only GTK4 job via the `swift:6.x` + `libgtk-4-dev` container
|
||||
noted in `linux-ci-x86-verification`).
|
||||
- **Validate on display, not just compile.** The Process/EventList/Message-family
|
||||
views compile but aren't exercised on the VM yet; fold them into the demo while
|
||||
doing Must-do 1 (they're what `presentInWindow` opens).
|
||||
|
||||
## Definition of "Linux at parity" (the checklist this plan satisfies)
|
||||
|
||||
1. ✅ `LyrebirdWindow` opens/manages GTK windows; `presentInWindow` works for
|
||||
every view; the EngineStatus "Open Window" buttons return.
|
||||
2. ✅ `Mouse.X/Y/Click` generators respond to the pointer on Linux
|
||||
(window-local baseline).
|
||||
3. ◐ Fork on a tagged release + UI has a Linux build job. The Linux CI job is in
|
||||
(`bitbucket-pipelines.yml` — one GTK-enabled build+test step compiles the UI
|
||||
graph). The fork is pinned to its first tagged release, `joshpar/SwiftOpenUI`
|
||||
`0.1.0`, instead of a bare commit. Still open: upstreaming the GTK4 patches to
|
||||
`codelynx/SwiftOpenUI` (externally gated — one maintainer, a prior PR went
|
||||
stale), after which the pin can move to an upstream version.
|
||||
4. ✅ Ported views exercised on display (VM-confirmed): EngineStatus (+ node-tree
|
||||
/ messages detached windows), the mouse demo, and — via `LYREBIRD_DEMO=events`
|
||||
— the Process/EventList family (`LyrebirdEventListPerformanceView` inline,
|
||||
hosting `LyrebirdEventListView` + per-process `LyrebirdProcessView` strips,
|
||||
plus `presentInWindow` for EventListPerformance / EventList / RunningProcesses).
|
||||
5. (Stretch) live-coding scratchpad usable on Linux — not started.
|
||||
@@ -0,0 +1,168 @@
|
||||
<!--
|
||||
linux-view-port-plan.md
|
||||
Lyrebird
|
||||
Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
SPDX-License-Identifier: MIT
|
||||
-->
|
||||
|
||||
# Linux view-port hand-off
|
||||
|
||||
Instructions for porting the remaining **Apple-only** `LyrebirdUI` views to the
|
||||
Linux/GTK4 backend, so a fresh agent can pick this up cold. Prereq context:
|
||||
`spikes/SwiftOpenUIKnob/FORK_PATCH_PLAN.md` (the SwiftOpenUI fork + drag fix) and
|
||||
the `linux-gui-swiftopenui` memory.
|
||||
|
||||
## Where things stand
|
||||
|
||||
`LyrebirdUI` is now **one cross-platform module** (parity steps B + C, done and
|
||||
VM-validated). Every control/view switches its body by backend:
|
||||
|
||||
```swift
|
||||
#if canImport(SwiftUI)
|
||||
import SwiftUI
|
||||
import LyrebirdSynth
|
||||
public struct Foo: View { /* real SwiftUI body */ }
|
||||
#else
|
||||
import SwiftOpenUI
|
||||
import BackendGTK4 // Cairo DrawingContext drawing methods
|
||||
import LyrebirdSynth
|
||||
public struct Foo: View { /* SwiftOpenUI/GTK4 body — same public API */ }
|
||||
#endif
|
||||
```
|
||||
|
||||
The 8 stock controls/views are already dual-body and are your **templates**:
|
||||
- Canvas + drag: `Controls/ParameterKnob.swift`, `Controls/ParameterXY.swift`,
|
||||
`Controls/ParameterSlider.swift`
|
||||
- Canvas + a polled `@Observable` model: `LyrebirdScopeView.swift` +
|
||||
`LyrebirdScopeModel.swift`
|
||||
- Layout + `ForEach` + action: `LyrebirdStatusView.swift`,
|
||||
`Controls/ParameterButton.swift`, `Controls/ParameterLabel.swift`
|
||||
|
||||
The Apple-only views are currently wrapped whole in `#if canImport(SwiftUI)` (so
|
||||
they compile to nothing on Linux). **Porting one = add its `#else` body** in the
|
||||
same file and drop the outer guard (or convert the guard to `#if/#else`).
|
||||
|
||||
## Backend capabilities (SwiftOpenUI/GTK4) — what you have and don't
|
||||
|
||||
Confirmed present (`~/Documents/src/SwiftOpenUI/Sources/SwiftOpenUI/Views/`):
|
||||
`VStack`/`HStack`/`LazyVStack`, `ScrollView`, `List`, `ForEach`, `Text`,
|
||||
`Canvas`, `.onDrag`, `@State`/`@Binding`/`@Observable`. **Missing:** `Table`
|
||||
(use `ScrollView` + `ForEach` rows), `GeometryReader` (unverified — check; a
|
||||
`Canvas` renderer gets its `size` directly, prefer that).
|
||||
|
||||
Hard gaps to design around:
|
||||
- **`DrawingContext` has NO text primitive.** A Canvas body cannot draw text
|
||||
labels (axis ticks, value readouts). Either overlay real `Text` widgets on top
|
||||
of the Canvas (compose in a `ZStack`/stack), or leave labels off on Linux (as
|
||||
`LyrebirdEnvelopeView`'s "L"/"R" markers already do). Adding a text primitive
|
||||
to SwiftOpenUI's `DrawingContext` is the proper upstream fix.
|
||||
- **`DrawingContext` API is imperative Cairo**, not SwiftUI `GraphicsContext`:
|
||||
`setColor(r:g:b:)` / `setLineWidth(_:)` / `moveTo(x:y:)` / `lineTo(x:y:)` /
|
||||
`rectangle(x:y:width:height:)` / `arc(centerX:centerY:radius:startAngle:endAngle:)`
|
||||
/ `stroke()` / `fill()`. A `GraphicsContext`+`Path` body must be rewritten to
|
||||
these calls (see `ParameterKnob`/`ParameterSlider` `#else` bodies).
|
||||
- **`@Observable` needs an explicit `import Observation`** on Linux (SwiftOpenUI
|
||||
does not re-export it the way SwiftUI does).
|
||||
- **`.task` runs OFF the main thread** on SwiftOpenUI (unlike SwiftUI). For
|
||||
periodic polling use a Foundation `Timer` on `RunLoop.main` — see
|
||||
`LyrebirdScopeModel` / the `LinuxStatusModel` inside `LyrebirdStatusView.swift`.
|
||||
- **`Color`** is a SwiftOpenUI type on Linux, not SwiftUI's; `PlatformColors`
|
||||
(AppKit/UIKit) is Apple-only. Use raw colors in the `#else` body.
|
||||
- **Live cross-control redraw already works** in the fork (global interaction
|
||||
deferral + per-drag subtree redraw); Canvas bodies that read a shared value
|
||||
will track during a drag with no extra work. Native widgets (e.g. `GtkScale`)
|
||||
do not — that's why the slider was made Canvas-drawn. Draw with `Canvas` if the
|
||||
control must live-link.
|
||||
|
||||
## The views to port
|
||||
|
||||
**Status: all view ports below are DONE** — each has a `#else` SwiftOpenUI/GTK4
|
||||
body added in-place, same public API/init as the Apple side, and the macOS side
|
||||
stays green (`swift build --target LyrebirdUI`). Every SwiftOpenUI symbol used was
|
||||
checked against the fork source. **Still needs Linux/VM validation** per the
|
||||
workflow below (compile + eyeball) — no Linux build has run yet.
|
||||
|
||||
| View | ~LOC | Kind | Status | Linux notes |
|
||||
|---|---|---|---|---|
|
||||
| **LyrebirdSynthView** | 177 | layout | ✅ done | Adaptive `LazyVGrid(columns:data:)` (SwiftOpenUI's data-based form) of `ParameterKnob`s. |
|
||||
| **LyrebirdSpectrumView** | 234 | Canvas | ✅ done | `DrawingContext` rewrite; FFT polled by `Timer`+`@Observable` model. No axis text (Apple draws none either). |
|
||||
| **LyrebirdScatterView** | 121 | Canvas | ✅ done | `DrawingContext` `arc`+`fill` dots; reuses `_linuxEnvelopeYBounds`. |
|
||||
| **MultiSlider** | 137 | Canvas+drag | ✅ done | Fixed `columnWidth`; Canvas + `.onDrag`, pointer-x→column, pointer-y→value. |
|
||||
| **LyrebirdEngineStatusView** | 603 | layout | ✅ done | `Timer`+`@Observable` model; CPU bars are `Canvas` (not GeometryReader); Picker/Stepper/Toggle/FocusState all exist in the fork. "Open Window" buttons work on Linux too (node-tree / messages open detached windows) now that `LyrebirdWindow` has a GTK4 body; sections also still expand inline. |
|
||||
| **LyrebirdMessageBanner** / **LyrebirdMessageView** / **LyrebirdMessageHelpers** | 128 / 277 / 33 | layout | ✅ done | `@Bindable center` — the GTK4 view host evaluates bodies under `withObservationTracking`, so plain `@Observable` reads live-update (no polling needed). MessageView **dropped** auto-scroll + text selection. |
|
||||
| **LyrebirdNodeTreeView** | 266 | layout | ✅ done | Indented `ForEach` rows; SF chevrons → text glyphs (▼/▶/•). Live via `mirror.snapshot` observation. |
|
||||
| **LyrebirdEventListView** | 335 | layout | ✅ done | `Timer`+`@Observable` model; native `Slider` + `TextField`. (Did not need `List`.) |
|
||||
| **LyrebirdEventListPerformanceView** / **LyrebirdRunningProcessesView** / **LyrebirdProcessView** | 167 / 197 / 224 | layout | ✅ done | `Timer`+`@Observable` models; identity-stable child reassignment preserved; `DbSliderConversion` reused; native `Slider`. |
|
||||
|
||||
Also added a **Linux branch to `PlatformColors`** (`Color.lyrebirdControlBackground`
|
||||
/ `lyrebirdSeparator` as fixed neutral SwiftOpenUI tones) — the Apple file had
|
||||
no `#else`, which blocked every layout port that used those colours.
|
||||
|
||||
Cross-cutting decisions worth knowing for the next port/review:
|
||||
- Every periodic-poll view uses the `LyrebirdScopeModel` pattern (`@Observable`
|
||||
`@unchecked Sendable` model + Foundation `Timer` on `RunLoop.main`), **not**
|
||||
`.task` (off-main on SwiftOpenUI).
|
||||
- SF Symbols don't resolve on GTK4 → text glyphs.
|
||||
- `Font.monospaced()` is not a `Font` method on SwiftOpenUI (it's a separate
|
||||
case) → use the `.monospacedDigit()` **view** modifier instead.
|
||||
- SwiftOpenUI `Color` exposes `.red/.green/.blue/.alpha`, so a `Color` parameter
|
||||
(e.g. Scatter's `pointColor`) feeds `DrawingContext.setColor` directly.
|
||||
|
||||
### Separate subsystems (not simple view ports — scope carefully) — STILL TODO
|
||||
|
||||
- **LyrebirdWindow** (163 L, `NSWindow`). No portable equivalent. Needs a new
|
||||
cross-platform host-window abstraction backed by GTK4 on Linux (the demo,
|
||||
`Sources/LyrebirdUILinuxDemo/main.swift`, stands up a GTK window ad hoc today —
|
||||
start from that). Design work, not a mechanical port. Do this before shipping a
|
||||
first-class Linux app entry point.
|
||||
- **MouseTracker** (165 L, `NSEvent`) + `MouseInput` / `MouseInputBridge`. This
|
||||
feeds the `Mouse.X` / `Mouse.Y` / `Mouse.Click` **generators** (core, in
|
||||
`Sources/Lyrebird/Generators/UI/`), not a view. The core protocol
|
||||
(`MouseInputBridge`) is platform-neutral; nothing conforms to it on GTK4. Needs
|
||||
a GTK global-pointer (or X11/evdev) source installed via `MouseInput.install`.
|
||||
Separate from the view work; do it if the mouse generators are wanted on Linux.
|
||||
|
||||
## Validation workflow (important)
|
||||
|
||||
**You cannot build the GTK4 backend on macOS** — `LyrebirdUI`'s `#else` bodies
|
||||
compile only on Linux. Two rules:
|
||||
|
||||
1. Verify the **Apple** side here after any edit: `swift build --target LyrebirdUI`
|
||||
(must stay green — you are only adding `#else` branches, so it should).
|
||||
2. Verify the **Linux** side on the Linux box / VM. Push to the branch, then on
|
||||
the VM:
|
||||
```bash
|
||||
git pull
|
||||
swift build # builds LyrebirdUI (needs libgtk-4-dev + the fork)
|
||||
LYREBIRD_DEMO=full swift run LyrebirdUILinuxDemo
|
||||
```
|
||||
The ported views are wired into the demo under a new `monitors` mode —
|
||||
`LYREBIRD_DEMO=monitors swift run LyrebirdUILinuxDemo` shows the `LyrebirdSynthView`
|
||||
parameter grid, `LyrebirdScatterView`, a `MultiSlider`, and `LyrebirdEngineStatusView`
|
||||
(which embeds the node-tree + message sections). The Process/EventList family
|
||||
is not yet in the demo (needs a `LyrebirdEventList` + running processes to
|
||||
scaffold). For headless-core-only checks (no GTK) use
|
||||
`swift build --target LyrebirdSynth`, or the emulated x86 route in the
|
||||
`linux-ci-x86-verification` memory.
|
||||
|
||||
If you have Docker, an arm64 `swift:6.3.3` container with `libgtk-4-dev` installed
|
||||
can compile-check the Linux bodies without a display (build only, no run).
|
||||
|
||||
## Gotchas already paid for (don't rediscover)
|
||||
|
||||
- GTK4 reuses a child's cached render node — `queue_draw` must walk the subtree
|
||||
(`gtkQueueDrawSubtree` in the fork). Live redraw during drag already handled.
|
||||
- Drag gesture survival + linked live-update are solved in the fork
|
||||
(`FORK_PATCH_PLAN.md`); Canvas bodies get it for free.
|
||||
- Keep `#if canImport(SwiftUI)` as the discriminator (Linux's SwiftOpenUI does
|
||||
not vend a `SwiftUI` module). Not `#if os(...)`.
|
||||
- SPDX header stays first-5-lines; put `#if` after it, before imports.
|
||||
|
||||
## Definition of done (per view)
|
||||
|
||||
1. `#else` body added, same public API/init as the Apple side.
|
||||
2. `swift build --target LyrebirdUI` green on macOS.
|
||||
3. `swift build` + demo green on the Linux VM; the view renders and (if
|
||||
interactive) tracks.
|
||||
4. If it drops a feature on Linux (e.g. text labels), document it in the file
|
||||
header the way `LyrebirdEnvelopeView` does.
|
||||
Reference in New Issue
Block a user