Fix plist copyright; move macOS Save/Load to the menu bar
- Info.plists: "Realized Sound" -> "realizedsound" in the copyright string (all four demo apps). - macOS: Save/Load now live in a File menu (Save Rig… ⌘S, Load Rig… ⌘O) and a Board menu (Add Board ⌘B, Start ⌘R, Stop ⌘.) in the app shell's AppDelegate; the in-view Save…/Load… buttons and their NSPanel code are now iOS-only (#if !os(macOS)), with iOS keeping fileExporter/Importer. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#if os(macOS)
|
#if os(macOS)
|
||||||
import AppKit
|
import AppKit
|
||||||
|
import UniformTypeIdentifiers
|
||||||
import LyrebirdSynth
|
import LyrebirdSynth
|
||||||
import LyrebirdUI
|
import LyrebirdUI
|
||||||
import LyrebirdShoeGaze
|
import LyrebirdShoeGaze
|
||||||
@@ -50,6 +51,13 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
|
|||||||
private let shoeGaze: ShoeGaze
|
private let shoeGaze: ShoeGaze
|
||||||
private let window: LyrebirdWindow
|
private let window: LyrebirdWindow
|
||||||
|
|
||||||
|
/// Transport menu items, retained so `validateMenuItem(_:)` can enable/disable them.
|
||||||
|
private var startMenuItem: NSMenuItem?
|
||||||
|
private var stopMenuItem: NSMenuItem?
|
||||||
|
|
||||||
|
/// Default file name offered by the Save panel.
|
||||||
|
private static let defaultRigFileName: String = "ShoeGazeRig"
|
||||||
|
|
||||||
// MARK: - Init
|
// MARK: - Init
|
||||||
|
|
||||||
override init() {
|
override init() {
|
||||||
@@ -152,7 +160,99 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
|
|||||||
keyEquivalent: "q"
|
keyEquivalent: "q"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// File menu — rig save / load.
|
||||||
|
let fileMenuItem: NSMenuItem = NSMenuItem()
|
||||||
|
mainMenu.addItem(fileMenuItem)
|
||||||
|
let fileMenu: NSMenu = NSMenu(title: "File")
|
||||||
|
fileMenuItem.submenu = fileMenu
|
||||||
|
addItem(to: fileMenu, title: "Save Rig…", action: #selector(saveRigAction(_:)), key: "s")
|
||||||
|
addItem(to: fileMenu, title: "Load Rig…", action: #selector(loadRigAction(_:)), key: "o")
|
||||||
|
|
||||||
|
// Board menu — add board + transport.
|
||||||
|
let boardMenuItem: NSMenuItem = NSMenuItem()
|
||||||
|
mainMenu.addItem(boardMenuItem)
|
||||||
|
let boardMenu: NSMenu = NSMenu(title: "Board")
|
||||||
|
boardMenuItem.submenu = boardMenu
|
||||||
|
addItem(to: boardMenu, title: "Add Board", action: #selector(addBoardAction(_:)), key: "b")
|
||||||
|
boardMenu.addItem(NSMenuItem.separator())
|
||||||
|
startMenuItem = addItem(to: boardMenu, title: "Start", action: #selector(startAction(_:)), key: "r")
|
||||||
|
stopMenuItem = addItem(to: boardMenu, title: "Stop", action: #selector(stopAction(_:)), key: ".")
|
||||||
|
|
||||||
NSApplication.shared.mainMenu = mainMenu
|
NSApplication.shared.mainMenu = mainMenu
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Adds a menu item targeting this delegate and returns it.
|
||||||
|
@discardableResult
|
||||||
|
private func addItem(
|
||||||
|
to menu: NSMenu,
|
||||||
|
title: String,
|
||||||
|
action: Selector,
|
||||||
|
key: String
|
||||||
|
) -> NSMenuItem {
|
||||||
|
let item: NSMenuItem = NSMenuItem(title: title, action: action, keyEquivalent: key)
|
||||||
|
item.target = self
|
||||||
|
menu.addItem(item)
|
||||||
|
return item
|
||||||
|
}
|
||||||
|
|
||||||
|
// MARK: - Menu actions
|
||||||
|
|
||||||
|
@objc private func saveRigAction(_ sender: Any?) {
|
||||||
|
let panel: NSSavePanel = NSSavePanel()
|
||||||
|
panel.allowedContentTypes = [.json]
|
||||||
|
panel.nameFieldStringValue = "\(AppDelegate.defaultRigFileName).json"
|
||||||
|
panel.canCreateDirectories = true
|
||||||
|
let session: ShoeGaze = shoeGaze
|
||||||
|
panel.begin { response in
|
||||||
|
guard response == .OK, let url: URL = panel.url else { return }
|
||||||
|
do { try session.saveRig(to: url) }
|
||||||
|
catch { print("[ShoeGazeBuilder] saveRig failed: \(error)") }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc private func loadRigAction(_ sender: Any?) {
|
||||||
|
let panel: NSOpenPanel = NSOpenPanel()
|
||||||
|
panel.allowedContentTypes = [.json]
|
||||||
|
panel.canChooseDirectories = false
|
||||||
|
panel.allowsMultipleSelection = false
|
||||||
|
let session: ShoeGaze = shoeGaze
|
||||||
|
let activeEngine: SynthesisEngine = engine
|
||||||
|
panel.begin { response in
|
||||||
|
guard response == .OK, let url: URL = panel.url else { return }
|
||||||
|
// loadRig rebuilds the graph; stop the engine around it and restart if it was running.
|
||||||
|
let wasRunning: Bool = activeEngine.isRunning
|
||||||
|
if wasRunning { activeEngine.stop() }
|
||||||
|
do { try session.loadRig(from: url) }
|
||||||
|
catch { print("[ShoeGazeBuilder] loadRig failed: \(error)") }
|
||||||
|
if wasRunning { try? activeEngine.start() }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc private func addBoardAction(_ sender: Any?) {
|
||||||
|
var created: PedalBoard?
|
||||||
|
do {
|
||||||
|
let board: PedalBoard = try shoeGaze.addBoard()
|
||||||
|
created = board
|
||||||
|
try shoeGaze.finalizeBoard(board)
|
||||||
|
} catch {
|
||||||
|
if let board: PedalBoard = created { shoeGaze.removeBoard(board) }
|
||||||
|
print("[ShoeGazeBuilder] addBoard failed: \(error)")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc private func startAction(_ sender: Any?) {
|
||||||
|
do { try engine.start() }
|
||||||
|
catch { print("[ShoeGazeBuilder] engine.start() failed: \(error)") }
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc private func stopAction(_ sender: Any?) {
|
||||||
|
engine.stop()
|
||||||
|
}
|
||||||
|
|
||||||
|
func validateMenuItem(_ menuItem: NSMenuItem) -> Bool {
|
||||||
|
if menuItem == startMenuItem { return !engine.isRunning }
|
||||||
|
if menuItem == stopMenuItem { return engine.isRunning }
|
||||||
|
return true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
<key>NSHighResolutionCapable</key>
|
<key>NSHighResolutionCapable</key>
|
||||||
<true/>
|
<true/>
|
||||||
<key>NSHumanReadableCopyright</key>
|
<key>NSHumanReadableCopyright</key>
|
||||||
<string>Copyright © 2026 Realized Sound. All rights reserved.</string>
|
<string>Copyright © 2026 realizedsound. All rights reserved.</string>
|
||||||
<key>NSMicrophoneUsageDescription</key>
|
<key>NSMicrophoneUsageDescription</key>
|
||||||
<string>ShoeGaze Builder can route a hardware input channel through your pedalboard. Enable microphone access to use Live Input mode.</string>
|
<string>ShoeGaze Builder can route a hardware input channel through your pedalboard. Enable microphone access to use Live Input mode.</string>
|
||||||
<key>NSPrincipalClass</key>
|
<key>NSPrincipalClass</key>
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
<key>LSRequiresIPhoneOS</key>
|
<key>LSRequiresIPhoneOS</key>
|
||||||
<true/>
|
<true/>
|
||||||
<key>NSHumanReadableCopyright</key>
|
<key>NSHumanReadableCopyright</key>
|
||||||
<string>Copyright © 2026 Realized Sound. All rights reserved.</string>
|
<string>Copyright © 2026 realizedsound. All rights reserved.</string>
|
||||||
<key>NSMicrophoneUsageDescription</key>
|
<key>NSMicrophoneUsageDescription</key>
|
||||||
<string>ShoeGaze Builder can route a hardware input channel through your pedalboard. Enable microphone access to use Live Input mode.</string>
|
<string>ShoeGaze Builder can route a hardware input channel through your pedalboard. Enable microphone access to use Live Input mode.</string>
|
||||||
<key>UIApplicationSceneManifest</key>
|
<key>UIApplicationSceneManifest</key>
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
<key>NSHighResolutionCapable</key>
|
<key>NSHighResolutionCapable</key>
|
||||||
<true/>
|
<true/>
|
||||||
<key>NSHumanReadableCopyright</key>
|
<key>NSHumanReadableCopyright</key>
|
||||||
<string>Copyright © 2026 Realized Sound. All rights reserved.</string>
|
<string>Copyright © 2026 realizedsound. All rights reserved.</string>
|
||||||
<key>NSMicrophoneUsageDescription</key>
|
<key>NSMicrophoneUsageDescription</key>
|
||||||
<string>ShoeGazeDemo can route a hardware input channel through your pedalboard. Enable microphone access to use Live Input mode.</string>
|
<string>ShoeGazeDemo can route a hardware input channel through your pedalboard. Enable microphone access to use Live Input mode.</string>
|
||||||
<key>NSPrincipalClass</key>
|
<key>NSPrincipalClass</key>
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
<key>LSRequiresIPhoneOS</key>
|
<key>LSRequiresIPhoneOS</key>
|
||||||
<true/>
|
<true/>
|
||||||
<key>NSHumanReadableCopyright</key>
|
<key>NSHumanReadableCopyright</key>
|
||||||
<string>Copyright © 2026 Realized Sound. All rights reserved.</string>
|
<string>Copyright © 2026 realizedsound. All rights reserved.</string>
|
||||||
<key>NSMicrophoneUsageDescription</key>
|
<key>NSMicrophoneUsageDescription</key>
|
||||||
<string>ShoeGazeiOSDemo can route a hardware input channel through your pedalboard. Enable microphone access to use Live Input mode.</string>
|
<string>ShoeGazeiOSDemo can route a hardware input channel through your pedalboard. Enable microphone access to use Live Input mode.</string>
|
||||||
<key>UIApplicationSceneManifest</key>
|
<key>UIApplicationSceneManifest</key>
|
||||||
|
|||||||
@@ -60,10 +60,12 @@ public struct ShoeGazeBuilderView: View {
|
|||||||
/// Bumped on transport/edit actions to force a re-read of `engine.isRunning`.
|
/// Bumped on transport/edit actions to force a re-read of `engine.isRunning`.
|
||||||
@State private var transportTick: Bool = false
|
@State private var transportTick: Bool = false
|
||||||
|
|
||||||
/// iOS file-dialog presentation flags + the document to export.
|
#if !os(macOS)
|
||||||
|
/// iOS file-dialog presentation flags + the document to export. (macOS uses the File menu.)
|
||||||
@State private var showImporter: Bool = false
|
@State private var showImporter: Bool = false
|
||||||
@State private var showExporter: Bool = false
|
@State private var showExporter: Bool = false
|
||||||
@State private var exportDocument: RigFileDocument = RigFileDocument(data: Data())
|
@State private var exportDocument: RigFileDocument = RigFileDocument(data: Data())
|
||||||
|
#endif
|
||||||
|
|
||||||
// MARK: - Init
|
// MARK: - Init
|
||||||
|
|
||||||
@@ -176,10 +178,14 @@ public struct ShoeGazeBuilderView: View {
|
|||||||
|
|
||||||
Spacer()
|
Spacer()
|
||||||
|
|
||||||
|
// On macOS, Save/Load live in the app's File menu (see the app shell's AppDelegate);
|
||||||
|
// on iOS they stay in-view, driven by fileExporter/fileImporter.
|
||||||
|
#if !os(macOS)
|
||||||
Button("Save…") { saveAction() }
|
Button("Save…") { saveAction() }
|
||||||
.buttonStyle(.bordered).tint(.blue)
|
.buttonStyle(.bordered).tint(.blue)
|
||||||
Button("Load…") { loadAction() }
|
Button("Load…") { loadAction() }
|
||||||
.buttonStyle(.bordered).tint(.blue)
|
.buttonStyle(.bordered).tint(.blue)
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -290,42 +296,23 @@ public struct ShoeGazeBuilderView: View {
|
|||||||
transportTick.toggle()
|
transportTick.toggle()
|
||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Save / Load
|
// MARK: - Save / Load (iOS)
|
||||||
|
|
||||||
|
// On macOS, Save/Load are driven from the app's File menu (the app shell owns the
|
||||||
|
// NSSavePanel/NSOpenPanel and calls `shoeGaze.saveRig`/`loadRig` directly). On iOS they are
|
||||||
|
// in-view, presenting `fileExporter`/`fileImporter`.
|
||||||
|
#if !os(macOS)
|
||||||
private func saveAction() {
|
private func saveAction() {
|
||||||
#if os(macOS)
|
|
||||||
let panel: NSSavePanel = NSSavePanel()
|
|
||||||
panel.allowedContentTypes = [.json]
|
|
||||||
panel.nameFieldStringValue = "\(ShoeGazeBuilderView.defaultRigFileName).json"
|
|
||||||
panel.canCreateDirectories = true
|
|
||||||
panel.begin { response in
|
|
||||||
guard response == .OK, let url: URL = panel.url else { return }
|
|
||||||
do { try shoeGaze.saveRig(to: url) }
|
|
||||||
catch { print("[ShoeGazeBuilderView] saveRig failed: \(error)") }
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
do {
|
do {
|
||||||
exportDocument = RigFileDocument(data: try shoeGaze.rigData())
|
exportDocument = RigFileDocument(data: try shoeGaze.rigData())
|
||||||
showExporter = true
|
showExporter = true
|
||||||
} catch {
|
} catch {
|
||||||
print("[ShoeGazeBuilderView] rigData failed: \(error)")
|
print("[ShoeGazeBuilderView] rigData failed: \(error)")
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private func loadAction() {
|
private func loadAction() {
|
||||||
#if os(macOS)
|
|
||||||
let panel: NSOpenPanel = NSOpenPanel()
|
|
||||||
panel.allowedContentTypes = [.json]
|
|
||||||
panel.canChooseDirectories = false
|
|
||||||
panel.allowsMultipleSelection = false
|
|
||||||
panel.begin { response in
|
|
||||||
guard response == .OK, let url: URL = panel.url else { return }
|
|
||||||
loadRig(from: url)
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
showImporter = true
|
showImporter = true
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Loads a rig from a URL, stopping/restarting the engine around the rebuild and resetting the
|
/// Loads a rig from a URL, stopping/restarting the engine around the rebuild and resetting the
|
||||||
@@ -343,7 +330,6 @@ public struct ShoeGazeBuilderView: View {
|
|||||||
transportTick.toggle()
|
transportTick.toggle()
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !os(macOS)
|
|
||||||
private func handleImport(_ result: Result<URL, Error>) {
|
private func handleImport(_ result: Result<URL, Error>) {
|
||||||
switch result {
|
switch result {
|
||||||
case .success(let url):
|
case .success(let url):
|
||||||
|
|||||||
Reference in New Issue
Block a user