mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
macos: ability to interrupt animation, track it in menu
This commit is contained in:
@ -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 }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user