macos: titlebar tabs handle hidden traffic buttons
parent
d84c30ce71
commit
9d9c451b0a
|
|
@ -13,7 +13,7 @@ class TerminalWindow: NSWindow {
|
|||
private var viewModel = ViewModel()
|
||||
|
||||
/// The configuration derived from the Ghostty config so we don't need to rely on references.
|
||||
private(set) var derivedConfig: DerivedConfig?
|
||||
private(set) var derivedConfig: DerivedConfig = .init()
|
||||
|
||||
/// Gets the terminal controller from the window controller.
|
||||
var terminalController: TerminalController? {
|
||||
|
|
@ -341,8 +341,8 @@ class TerminalWindow: NSWindow {
|
|||
}
|
||||
}
|
||||
|
||||
let alpha = derivedConfig?.backgroundOpacity.clamped(to: 0.001...1) ?? 1
|
||||
return derivedConfig?.backgroundColor.withAlphaComponent(alpha)
|
||||
let alpha = derivedConfig.backgroundOpacity.clamped(to: 0.001...1)
|
||||
return derivedConfig.backgroundColor.withAlphaComponent(alpha)
|
||||
}
|
||||
|
||||
private func setInitialWindowPosition(x: Int16?, y: Int16?, windowDecorations: Bool) {
|
||||
|
|
@ -379,15 +379,18 @@ class TerminalWindow: NSWindow {
|
|||
struct DerivedConfig {
|
||||
let backgroundColor: NSColor
|
||||
let backgroundOpacity: Double
|
||||
let macosWindowButtons: Ghostty.MacOSWindowButtons
|
||||
|
||||
init() {
|
||||
self.backgroundColor = NSColor.windowBackgroundColor
|
||||
self.backgroundOpacity = 1
|
||||
self.macosWindowButtons = .visible
|
||||
}
|
||||
|
||||
init(_ config: Ghostty.Config) {
|
||||
self.backgroundColor = NSColor(config.backgroundColor)
|
||||
self.backgroundOpacity = config.backgroundOpacity
|
||||
self.macosWindowButtons = config.macosWindowButtons
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,12 +84,19 @@ class TitlebarTabsTahoeTerminalWindow: TransparentTitlebarTerminalWindow, NSTool
|
|||
// The container is the view that we'll constrain our tab bar within.
|
||||
let container = toolbarView
|
||||
|
||||
// The padding for the tab bar. If we're showing window buttons then
|
||||
// we need to offset the window buttons.
|
||||
let leftPadding: CGFloat = switch(self.derivedConfig.macosWindowButtons) {
|
||||
case .hidden: 0
|
||||
case .visible: 70
|
||||
}
|
||||
|
||||
// Constrain the accessory clip view (the parent of the accessory view
|
||||
// usually that clips the children) to the container view.
|
||||
clipView.translatesAutoresizingMaskIntoConstraints = false
|
||||
clipView.leftAnchor.constraint(equalTo: container.leftAnchor, constant: 78).isActive = true
|
||||
clipView.leftAnchor.constraint(equalTo: container.leftAnchor, constant: leftPadding).isActive = true
|
||||
clipView.rightAnchor.constraint(equalTo: container.rightAnchor).isActive = true
|
||||
clipView.topAnchor.constraint(equalTo: container.topAnchor).isActive = true
|
||||
clipView.topAnchor.constraint(equalTo: container.topAnchor, constant: 2).isActive = true
|
||||
clipView.heightAnchor.constraint(equalTo: container.heightAnchor).isActive = true
|
||||
clipView.needsLayout = true
|
||||
|
||||
|
|
|
|||
|
|
@ -40,15 +40,12 @@ class TitlebarTabsVenturaTerminalWindow: TerminalWindow {
|
|||
|
||||
titlebarTabs = true
|
||||
|
||||
// This should always be true since our super sets this up.
|
||||
if let derivedConfig {
|
||||
// Set the background color of the window
|
||||
backgroundColor = derivedConfig.backgroundColor
|
||||
|
||||
// This makes sure our titlebar renders correctly when there is a transparent background
|
||||
titlebarColor = derivedConfig.backgroundColor.withAlphaComponent(derivedConfig.backgroundOpacity)
|
||||
}
|
||||
}
|
||||
|
||||
// We only need to set this once, but need to do it after the window has been created in order
|
||||
// to determine if the theme is using a very dark background, in which case we don't want to
|
||||
|
|
@ -160,7 +157,7 @@ class TitlebarTabsVenturaTerminalWindow: TerminalWindow {
|
|||
// Update our titlebar color
|
||||
if let preferredBackgroundColor {
|
||||
titlebarColor = preferredBackgroundColor
|
||||
} else if let derivedConfig {
|
||||
} else {
|
||||
titlebarColor = derivedConfig.backgroundColor.withAlphaComponent(derivedConfig.backgroundOpacity)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue