SPB Git

Repository Public

DocumentWindowController.swift 1.8 KB 45 lines swift

1// ORIX Docs2// File: App/Sources/Document/DocumentWindowController.swift3// Description: The document window: a unified title bar hosting the SwiftUI workspace.4//5// Author: Simon-Pierre Boucher6// Contact: contact@spboucher.ai7import AppKit8import SwiftUI910final class DocumentWindowController: NSWindowController, NSWindowDelegate {11    let session: DocumentSession1213    init(session: DocumentSession) {14        self.session = session15        let window = NSWindow(contentRect: NSRect(x: 0, y: 0, width: 1360, height: 880),16                              styleMask: [.titled, .closable, .miniaturizable, .resizable, .fullSizeContentView], backing: .buffered, defer: false)17        window.titlebarAppearsTransparent = true18        window.titleVisibility = .visible19        window.toolbarStyle = .unifiedCompact20        window.minSize = NSSize(width: 760, height: 520)21        window.isRestorable = true22        window.tabbingMode = .preferred23        window.backgroundColor = .dynamic(light: 0xF7F7FA, dark: 0x171922)24        let toolbar = NSToolbar(identifier: "ai.spboucher.orix.docs.toolbar")25        toolbar.showsBaselineSeparator = false26        window.toolbar = toolbar27        super.init(window: window)28        let host = NSHostingController(rootView: WorkspaceView(session: session))29        host.sizingOptions = []30        window.contentViewController = host31        window.setContentSize(NSSize(width: 1360, height: 880))32        window.center()33        window.setFrameAutosaveName("ORIXDocsDocumentWindow")34        window.delegate = self35        shouldCascadeWindows = true36    }3738    @available(*, unavailable)39    required init?(coder: NSCoder) { fatalError("not used") }4041    func windowDidBecomeKey(_ notification: Notification) {42        if window?.firstResponder === window { window?.makeFirstResponder(session.canvas) }43    }44}45
Files main
Menu

Theme