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:
@@ -4,6 +4,7 @@
|
||||
// Copyright (c) 2026 Joshua Parmenter / realizedsound
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#if canImport(SwiftUI)
|
||||
import SwiftUI
|
||||
import LyrebirdSynth
|
||||
|
||||
@@ -124,3 +125,117 @@ public struct LyrebirdMessageBanner: View {
|
||||
return Array(all[start..<all.count])
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
// Linux/GTK4 counterpart to `LyrebirdUI.LyrebirdMessageBanner`: a compact banner
|
||||
// showing the most recent few messages from a `LyrebirdMessageCenter`, with a
|
||||
// tier-coloured left stripe, that runs `onOpenFull` on tap. Live updates come
|
||||
// from `@Bindable` on the `@Observable` center (reads inside the body are
|
||||
// observation-tracked, same as the Apple side — no polling). SF-Symbol art and
|
||||
// `RoundedRectangle` chrome are dropped; the layout is `HStack`/`VStack` + `Text`.
|
||||
//
|
||||
// SwiftOpenUI is always present in this target (see Package.swift).
|
||||
import SwiftOpenUI
|
||||
import LyrebirdSynth
|
||||
|
||||
/// A compact recent-messages banner for the Linux/GTK4 UI. Mirrors
|
||||
/// `LyrebirdUI.LyrebirdMessageBanner`: up to ``lineCount`` recent messages with
|
||||
/// a tier-coloured stripe; tapping invokes ``onOpenFull``.
|
||||
public struct LyrebirdMessageBanner: View {
|
||||
|
||||
@Bindable private var center: LyrebirdMessageCenter
|
||||
|
||||
/// Number of recent messages shown when present. Defaults to `3`.
|
||||
public let lineCount: Int
|
||||
|
||||
/// Tap action. `nil` makes the banner non-interactive.
|
||||
public let onOpenFull: (() -> Void)?
|
||||
|
||||
// Presentation constants (points).
|
||||
private let stripeWidth: Double = 3
|
||||
private let stripeHeight: Double = 11
|
||||
private let cornerRadiusPoints: Double = 4
|
||||
|
||||
/// Creates a banner bound to `LyrebirdMessageCenter.shared`.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - lineCount: How many recent messages to show. Defaults to `3`.
|
||||
/// - onOpenFull: Tap action. Defaults to `nil`.
|
||||
@MainActor
|
||||
public init(
|
||||
lineCount: Int = 3,
|
||||
onOpenFull: (() -> Void)? = nil
|
||||
) {
|
||||
self.center = LyrebirdMessageCenter.shared
|
||||
self.lineCount = lineCount
|
||||
self.onOpenFull = onOpenFull
|
||||
}
|
||||
|
||||
/// Creates a banner bound to the given center.
|
||||
///
|
||||
/// - Parameters:
|
||||
/// - center: Center to observe.
|
||||
/// - lineCount: How many recent messages to show. Defaults to `3`.
|
||||
/// - onOpenFull: Tap action. Defaults to `nil`.
|
||||
public init(
|
||||
center: LyrebirdMessageCenter,
|
||||
lineCount: Int = 3,
|
||||
onOpenFull: (() -> Void)? = nil
|
||||
) {
|
||||
self.center = center
|
||||
self.lineCount = lineCount
|
||||
self.onOpenFull = onOpenFull
|
||||
}
|
||||
|
||||
public var body: some View {
|
||||
// A single static Button keeps state changes on the backend's narrow
|
||||
// in-place mutation path (see ParameterButton's Linux body for the
|
||||
// rationale). The empty state and the populated rows both live inside
|
||||
// the one button; `press()` re-reads at click time.
|
||||
Button(action: { onOpenFull?() }) {
|
||||
VStack(alignment: .leading, spacing: 3) {
|
||||
let recent: [LyrebirdMessage] = recentMessages
|
||||
if recent.isEmpty {
|
||||
Text("No messages")
|
||||
.font(.caption)
|
||||
.foregroundStyle(.secondary)
|
||||
} else {
|
||||
ForEach(recent) { msg in
|
||||
bannerRow(msg)
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding(6)
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
.background(Color.lyrebirdControlBackground)
|
||||
.cornerRadius(cornerRadiusPoints)
|
||||
.disabled(onOpenFull == nil)
|
||||
}
|
||||
|
||||
private func bannerRow(_ msg: LyrebirdMessage) -> some View {
|
||||
HStack(spacing: 6) {
|
||||
Capsule()
|
||||
.fill(LyrebirdMessageTierStyle.color(for: msg.tier))
|
||||
.frame(width: stripeWidth, height: stripeHeight)
|
||||
Text(msg.text)
|
||||
.font(.caption)
|
||||
.lineLimit(1)
|
||||
.truncationMode(.tail)
|
||||
Spacer(minLength: 0)
|
||||
}
|
||||
}
|
||||
|
||||
private var recentMessages: [LyrebirdMessage] {
|
||||
// `LyrebirdMessageCenter` is @MainActor; the SwiftOpenUI body runs on the
|
||||
// GTK main thread, so `assumeIsolated` reaches `messages` safely. Bind the
|
||||
// center to a local first so the `@MainActor` closure captures the
|
||||
// (Sendable) center, not `self` (the non-Sendable View).
|
||||
let c: LyrebirdMessageCenter = center
|
||||
let all: [LyrebirdMessage] = MainActor.assumeIsolated { c.messages }
|
||||
guard all.count > lineCount else { return all }
|
||||
let start: Int = all.count - lineCount
|
||||
return Array(all[start..<all.count])
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user