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