Files
ShoeGaze/Sources/LyrebirdShoeGazeUI/RigFileDocument.swift
T
josh d41ba37093 Add signal-flow pedalboard builder UI
Interactive builder views in LyrebirdShoeGazeUI:

- PedalPaletteView: vertical sidebar listing every pedal (tap to append
  to the main chain, drag "add:<type>" onto a lane) plus routing actions
  (Stereo Split / Parallel Split / Merge to Mono).
- BoardFlowView: left-to-right signal-flow board driven by
  board.orderedSegments. Pedal cards joined by pink connector lines
  (double for stereo width); split regions render as two stacked L/R
  (A/B) lanes you fill independently by dropping pedals; per-card trash,
  drag-to-reorder within a lane, region route/mode controls, and a
  region trash. Reads shoeGaze.boards[index] fresh each body (index is
  the stable anchor across rebuilds).
- ShoeGazeBuilderView: sidebar + vertically-centered flow board, with
  transport, input picker, board picker, and JSON save/load (NSSavePanel
  / NSOpenPanel on macOS, fileExporter/Importer on iOS via
  RigFileDocument).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-22 09:32:09 -07:00

38 lines
1.2 KiB
Swift

// RigFileDocument.swift
// Lyrebird
//
// Copyright (c) 2026 Joshua Parmenter / realizedsound
// SPDX-License-Identifier: MIT
import SwiftUI
import UniformTypeIdentifiers
/// A minimal JSON `FileDocument` wrapping a ShoeGaze rig's encoded bytes.
///
/// Used by ``ShoeGazeBuilderView``'s iOS `.fileExporter` to write the result of
/// `ShoeGaze.rigData()` to a user-chosen location. macOS uses an `NSSavePanel` directly and does
/// not need this type.
struct RigFileDocument: FileDocument {
/// The rig presets are plain JSON.
static var readableContentTypes: [UTType] { [.json] }
/// Encoded rig JSON.
let data: Data
/// Creates a document from already-encoded rig JSON.
init(data: Data) {
self.data = data
}
/// Decodes an existing document's bytes (required by `FileDocument`, unused by the exporter).
init(configuration: ReadConfiguration) throws {
self.data = configuration.file.regularFileContents ?? Data()
}
/// Writes the rig JSON into a file wrapper for export.
func fileWrapper(configuration: WriteConfiguration) throws -> FileWrapper {
FileWrapper(regularFileWithContents: data)
}
}