mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-05-14 12:18:36 +03:00
42 lines
1.1 KiB
Swift
42 lines
1.1 KiB
Swift
import Cocoa
|
|
|
|
enum SlideTerminalPosition {
|
|
case top
|
|
|
|
/// Set the initial state for a window for animating out of this position.
|
|
func setInitial(in window: NSWindow, on screen: NSScreen) {
|
|
// We always start invisible
|
|
window.alphaValue = 0
|
|
|
|
// Position depends
|
|
switch (self) {
|
|
case .top:
|
|
window.setFrame(.init(
|
|
origin: .init(
|
|
x: 0,
|
|
y: screen.frame.maxY),
|
|
size: .init(
|
|
width: screen.frame.width,
|
|
height: window.frame.height)
|
|
), display: false)
|
|
}
|
|
}
|
|
|
|
/// Set the final state for a window in this position.
|
|
func setFinal(in window: NSWindow, on screen: NSScreen) {
|
|
// We always end visible
|
|
window.alphaValue = 1
|
|
|
|
// Position depends
|
|
switch (self) {
|
|
case .top:
|
|
window.setFrame(.init(
|
|
origin: .init(
|
|
x: window.frame.origin.x,
|
|
y: screen.visibleFrame.maxY - window.frame.height),
|
|
size: window.frame.size
|
|
), display: true)
|
|
}
|
|
}
|
|
}
|