new macOS version

This commit is contained in:
2026-04-01 16:10:30 -05:00
parent 56673078f5
commit 483e3c1d00
13 changed files with 2302 additions and 319 deletions

View File

@@ -32,6 +32,11 @@ final class FloatingPanel: NSPanel {
// Don't activate the app when clicked (user keeps focus on their work)
becomesKeyOnlyIfNeeded = true
}
// Allow the panel to become key so buttons inside it can receive clicks.
// Combined with .nonactivatingPanel, this lets buttons work without
// stealing focus from the user's active app.
override var canBecomeKey: Bool { true }
}
// MARK: - Controller
@@ -49,14 +54,20 @@ final class FloatingPanelController {
let p = FloatingPanel()
let hud = FloatingHUDView()
.environment(session)
p.contentView = NSHostingView(rootView: hud)
// Position: top-right of the main screen, just below the menu bar
// NSHostingController gives proper preferredContentSize tracking so the
// panel auto-resizes as SwiftUI content grows or shrinks.
let controller = NSHostingController(rootView: hud)
p.contentViewController = controller
// Position: top-right of the main screen, just below the menu bar.
// Anchor the top edge so the panel grows downward as content expands.
if let screen = NSScreen.main {
let margin: CGFloat = 16
let x = screen.visibleFrame.maxX - 320 - margin
let y = screen.visibleFrame.maxY - 160 - margin
p.setFrameOrigin(NSPoint(x: x, y: y))
// Place top edge just below the menu bar
let topY = screen.visibleFrame.maxY - margin
p.setFrameTopLeftPoint(NSPoint(x: x, y: topY))
} else {
p.center()
}