Files
ReactorcoremeltdownandClaude Opus 5.5 b6589ee792 iOS 0.3.0: card editors like Android's for every plugin (knobs, switches, tabs, drawings)
Layouts exported from Android's DeviceLayouts (DeviceLayouts.json), iOS layouts
for the devices with hand-built Android editors, SwiftUI editor shared by the
extension and the app, Mac snapshot tool for the editors.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 22:41:33 +01:00

58 lines
2.1 KiB
Swift

// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
// SPDX-License-Identifier: GPL-3.0-or-later
import Foundation
/// A device editor's tabs and cards, as Android's DeviceLayouts describes them
/// (exported to DeviceLayouts.json by IosGoldenExport) or, for devices whose
/// Android editor is hand-built, as BespokeLayouts.swift lays them out.
struct LayoutPage: Decodable, Identifiable {
let title: String
let panels: [LayoutPanel]
var id: String { title }
}
struct LayoutPanel: Decodable, Identifiable {
enum Tone: String, Decodable { case SOURCE, FILTER, ENV, MOD, OUT }
struct Viz: Decodable {
let kind: String // envelope | filter | lfo | wavetable
var a: String? = nil, d: String? = nil, s: String? = nil, r: String? = nil
var type: String? = nil, cutoff: String? = nil, reso: String? = nil
var wave: String? = nil
var osc: Int? = nil
}
let title: String
let tone: Tone
let keys: [String]
var viz: Viz? = nil
var labels: [String: String]? = nil
var faders: [String]? = nil
var faderScale: Float? = nil
var action: String? = nil
var id: String { title }
}
struct DeviceLayoutsFile: Decodable {
let devices: [String: [LayoutPage]]
let timeDivisions: [String]
let delayDivisions: [String]
}
enum Layouts {
/// Bundled with both the extension and the app (each finds its own copy).
static let file: DeviceLayoutsFile? = {
let bundle = Bundle(for: SizzleDeviceAU.self)
guard let url = bundle.url(forResource: "DeviceLayouts", withExtension: "json"),
let data = try? Data(contentsOf: url) else { return nil }
return try? JSONDecoder().decode(DeviceLayoutsFile.self, from: data)
}()
static func pages(for type: String, allKeys: [String]) -> [LayoutPage] {
if let bespoke = BespokeLayouts.pages[type] { return bespoke }
if let pages = file?.devices[type], !pages.isEmpty { return pages }
return [LayoutPage(title: type, panels: [LayoutPanel(title: type, tone: .SOURCE, keys: allKeys)])]
}
}