macos: ability to interrupt animation, track it in menu

This commit is contained in:
Mitchell Hashimoto
2024-09-28 15:29:47 -07:00
parent 1570ef01a7
commit 13eb8ac6e2
2 changed files with 15 additions and 2 deletions

View File

@ -558,5 +558,7 @@ class AppDelegate: NSObject,
guard let quickController = self.quickController else { return }
quickController.toggle()
self.menuQuickTerminal?.state = if (quickController.visible) { .on } else { .off }
}
}

View File

@ -10,6 +10,9 @@ class QuickTerminalController: BaseTerminalController {
/// The position for the quick terminal.
let position: QuickTerminalPosition
/// The current state of the quick terminal
private(set) var visible: Bool = false
init(_ ghostty: Ghostty.App,
position: QuickTerminalPosition = .top,
baseConfig base: Ghostty.SurfaceConfiguration? = nil,
@ -76,8 +79,7 @@ class QuickTerminalController: BaseTerminalController {
// MARK: Methods
func toggle() {
guard let window = self.window else { return }
if (window.alphaValue > 0) {
if (visible) {
animateOut()
} else {
animateIn()
@ -87,6 +89,10 @@ class QuickTerminalController: BaseTerminalController {
func animateIn() {
guard let window = self.window else { return }
// Set our visibility state
guard !visible else { return }
visible = true
// Animate the window in
animateWindowIn(window: window, from: position)
@ -100,6 +106,11 @@ class QuickTerminalController: BaseTerminalController {
func animateOut() {
guard let window = self.window else { return }
// Set our visibility state
guard visible else { return }
visible = false
animateWindowOut(window: window, to: position)
}