feat: snap launcher to stippled edge alignment guides
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import Foundation
|
||||
|
||||
public struct LauncherAlignment: Sendable {
|
||||
public let targetFrame: CGRect
|
||||
public let snappedOrigin: CGPoint
|
||||
|
||||
public init(windowFrame: CGRect, visibleFrame: CGRect) {
|
||||
// Whole-point origins keep the guides aligned with AppKit's window positioning.
|
||||
targetFrame = CGRect(
|
||||
x: (visibleFrame.midX - windowFrame.width / 2).rounded(.down),
|
||||
y: (visibleFrame.midY - windowFrame.height / 2).rounded(.down),
|
||||
width: windowFrame.width,
|
||||
height: windowFrame.height
|
||||
)
|
||||
snappedOrigin = CGPoint(
|
||||
x: abs(windowFrame.minX - targetFrame.minX) <= 12 ? targetFrame.minX : windowFrame.minX,
|
||||
y: abs(windowFrame.maxY - targetFrame.maxY) <= 12 ? targetFrame.minY : windowFrame.minY
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user