feat(macos): hover HUD for activity
This commit is contained in:
@@ -42,6 +42,28 @@ enum WindowPlacement {
|
||||
return NSRect(x: x, y: y, width: clampedWidth, height: clampedHeight)
|
||||
}
|
||||
|
||||
static func anchoredBelowFrame(size: NSSize, anchor: NSRect, padding: CGFloat, in bounds: NSRect) -> NSRect {
|
||||
if bounds == .zero {
|
||||
let x = round(anchor.midX - size.width / 2)
|
||||
let y = round(anchor.minY - size.height - padding)
|
||||
return NSRect(x: x, y: y, width: size.width, height: size.height)
|
||||
}
|
||||
|
||||
let clampedWidth = min(size.width, bounds.width)
|
||||
let clampedHeight = min(size.height, bounds.height)
|
||||
|
||||
let desiredX = round(anchor.midX - clampedWidth / 2)
|
||||
let desiredY = round(anchor.minY - clampedHeight - padding)
|
||||
|
||||
let maxX = bounds.maxX - clampedWidth
|
||||
let maxY = bounds.maxY - clampedHeight
|
||||
|
||||
let x = maxX >= bounds.minX ? min(max(desiredX, bounds.minX), maxX) : bounds.minX
|
||||
let y = maxY >= bounds.minY ? min(max(desiredY, bounds.minY), maxY) : bounds.minY
|
||||
|
||||
return NSRect(x: x, y: y, width: clampedWidth, height: clampedHeight)
|
||||
}
|
||||
|
||||
static func ensureOnScreen(
|
||||
window: NSWindow,
|
||||
defaultSize: NSSize,
|
||||
|
||||
Reference in New Issue
Block a user