commit current state

This commit is contained in:
2026-06-22 15:40:23 -07:00
parent e36dc3a527
commit c6f567535b
14 changed files with 431 additions and 101 deletions
+11 -26
View File
@@ -68,6 +68,7 @@ public struct ShoeGazeView: View {
// MARK: - Properties
private let shoeGaze: ShoeGaze
private let hardwareSampleRate: () -> Double?
/// Bumped on each transport button press to force a re-read of the engine's
/// running state. The button labels/enabled-state read `shoeGaze.engine.isRunning`
@@ -87,11 +88,16 @@ public struct ShoeGazeView: View {
/// Creates a top-level ShoeGaze view.
///
/// - Parameter shoeGaze: The `ShoeGaze` manager whose boards and engine will
/// be displayed. The caller is responsible for engine lifecycle; this view
/// provides Start and Stop transport buttons as a convenience.
public init(shoeGaze: ShoeGaze) {
/// - Parameters:
/// - shoeGaze: The `ShoeGaze` manager whose boards and engine will be displayed.
/// - hardwareSampleRate: Returns the actual hardware/session sample rate (or `nil`), used by
/// the engine-config Start to warn on a mismatch. Defaults to `nil`.
public init(
shoeGaze: ShoeGaze,
hardwareSampleRate: @escaping () -> Double? = { nil }
) {
self.shoeGaze = shoeGaze
self.hardwareSampleRate = hardwareSampleRate
}
// MARK: - Body
@@ -153,7 +159,6 @@ public struct ShoeGazeView: View {
// Referencing `transportTick` makes a press (which toggles it) re-evaluate this
// view so `engine.isRunning` is re-read; toggling any @State invalidates the view.
_ = transportTick
let isRunning: Bool = shoeGaze.engine.isRunning
return HStack(spacing: ShoeGazeView.transportSpacing) {
Text("ShoeGaze")
.font(.title2)
@@ -166,27 +171,7 @@ public struct ShoeGazeView: View {
.buttonStyle(.bordered)
.tint(.orange)
Button("Start") {
do {
try shoeGaze.engine.start()
} catch {
// Surface start errors to the console; the UI remains in the
// non-running state so the user can retry.
print("[ShoeGazeView] engine.start() failed: \(error)")
}
transportTick.toggle()
}
.buttonStyle(.borderedProminent)
.tint(.green)
.disabled(isRunning)
Button("Stop") {
shoeGaze.engine.stop()
transportTick.toggle()
}
.buttonStyle(.bordered)
.tint(.red)
.disabled(!isRunning)
EngineConfigView(shoeGaze: shoeGaze, hardwareSampleRate: hardwareSampleRate)
}
}