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>
40 lines
2.0 KiB
Swift
40 lines
2.0 KiB
Swift
// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
// Renders every device's editor (each tab) to PNG on the Mac, to look at the
|
|
// layouts without a device: `make -C ios editor-snapshots` → build/snapshots/png/.
|
|
|
|
import AppKit
|
|
import AudioToolbox
|
|
import SwiftUI
|
|
|
|
@main
|
|
struct EditorSnapshots {
|
|
@MainActor static func main() {
|
|
DeviceEditor.snapshot = true
|
|
let out = URL(fileURLWithPath: CommandLine.arguments.count > 1 ? CommandLine.arguments[1] : "png")
|
|
try? FileManager.default.createDirectory(at: out, withIntermediateDirectories: true)
|
|
for c in SizzleComponentList.all() {
|
|
let desc = AudioComponentDescription(componentType: c.type, componentSubType: c.subtype,
|
|
componentManufacturer: 0x5473_7973, componentFlags: 0, componentFlagsMask: 0)
|
|
guard let cls = SizzleDeviceAU.class(forComponentType: c.type) as? SizzleDeviceAU.Type,
|
|
let au = try? cls.init(componentDescription: desc, options: []) else { print("FAIL \(c.name)"); continue }
|
|
let model = DeviceModel(au: au)
|
|
let pages = Layouts.pages(for: au.toolboxType, allKeys: model.order)
|
|
for (i, page) in pages.enumerated() {
|
|
let view = DeviceEditor(model: model, page: i)
|
|
.frame(width: 560)
|
|
.fixedSize(horizontal: false, vertical: true)
|
|
.environment(\.colorScheme, .dark)
|
|
let r = ImageRenderer(content: view)
|
|
r.scale = 2
|
|
guard let img = r.cgImage else { print("FAIL render \(c.name)"); continue }
|
|
let rep = NSBitmapImageRep(cgImage: img)
|
|
let name = "\(au.toolboxType)_\(i)_\(page.title.replacingOccurrences(of: " ", with: "_")).png"
|
|
try? rep.representation(using: .png, properties: [:])?.write(to: out.appendingPathComponent(name))
|
|
print("wrote \(name)")
|
|
}
|
|
}
|
|
}
|
|
}
|