Repository Public
1// ORIX Sonata2// File: Apps/ORIXSonata/Sources/ORIXSonataApp.swift3// Description: Application entry point: document windows, menus and settings. All behaviour lives in the SonataUI package.4//5// Author: Simon-Pierre Boucher6// Contact: contact@spboucher.ai7import AppKit8import SonataBridge9import SonataUI10import SwiftUI1112/// Launch options for tests and screenshots: `-SonataNewDocument YES` opens an untitled project13/// instead of the open panel, `-SonataAppearance dark|light` forces an appearance.14final class AppDelegate: NSObject, NSApplicationDelegate {15 func applicationDidFinishLaunching(_ notification: Notification) {16 let defaults = UserDefaults.standard17 switch defaults.string(forKey: "SonataAppearance") {18 case "dark": NSApp.appearance = NSAppearance(named: .darkAqua)19 case "light": NSApp.appearance = NSAppearance(named: .aqua)20 default: break21 }22 if defaults.bool(forKey: "SonataNewDocument") {23 DispatchQueue.main.async { NSDocumentController.shared.newDocument(nil) }24 }25 }2627 func applicationShouldOpenUntitledFile(_ sender: NSApplication) -> Bool {28 !UserDefaults.standard.bool(forKey: "SonataNewDocument")29 }30}3132@main33struct ORIXSonataApp: App {34 @NSApplicationDelegateAdaptor(AppDelegate.self) private var delegate3536 init() {37 do {38 try SonataLibrary.checkABI()39 } catch {40 fatalError("ORIX Sonata was built against a different Sonata library: \(error.localizedDescription)")41 }42 }4344 var body: some Scene {45 DocumentGroup(newDocument: { SonataDocument() }) { configuration in46 RootView(document: configuration.document, fileURL: configuration.fileURL)47 }48 .defaultSize(width: 1280, height: 820)49 .commands {50 SonataCommands()51 ExamplesCommands()52 }5354 Settings { SettingsView() }55 }56}57