mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 16:56:09 +03:00
Merge pull request #1438 from mitchellh/macos-backdrop
macos: set titlebar tab window button backdrop color based on appearance
This commit is contained in:
@ -177,7 +177,6 @@ class TerminalWindow: NSWindow {
|
|||||||
view.topAnchor.constraint(equalTo: toolbarView.topAnchor).isActive = true
|
view.topAnchor.constraint(equalTo: toolbarView.topAnchor).isActive = true
|
||||||
view.heightAnchor.constraint(equalTo: toolbarView.heightAnchor).isActive = true
|
view.heightAnchor.constraint(equalTo: toolbarView.heightAnchor).isActive = true
|
||||||
view.wantsLayer = true
|
view.wantsLayer = true
|
||||||
view.layer?.backgroundColor = CGColor(genericGrayGamma2_2Gray: 0.0, alpha: 0.45)
|
|
||||||
|
|
||||||
let topBorder = NSView()
|
let topBorder = NSView()
|
||||||
view.addSubview(topBorder)
|
view.addSubview(topBorder)
|
||||||
@ -187,7 +186,17 @@ class TerminalWindow: NSWindow {
|
|||||||
topBorder.topAnchor.constraint(equalTo: view.topAnchor).isActive = true
|
topBorder.topAnchor.constraint(equalTo: view.topAnchor).isActive = true
|
||||||
topBorder.bottomAnchor.constraint(equalTo: view.topAnchor, constant: 1).isActive = true
|
topBorder.bottomAnchor.constraint(equalTo: view.topAnchor, constant: 1).isActive = true
|
||||||
topBorder.wantsLayer = true
|
topBorder.wantsLayer = true
|
||||||
topBorder.layer?.backgroundColor = CGColor(genericGrayGamma2_2Gray: 0.0, alpha: 0.85)
|
|
||||||
|
// This is jank but this makes the background color for light themes on the button
|
||||||
|
// backdrop look MUCH better. I couldn't figure out a perfect color to use that works
|
||||||
|
// for both so we just check the appearance.
|
||||||
|
if effectiveAppearance.name == .aqua {
|
||||||
|
view.layer?.backgroundColor = NSColor.textBackgroundColor.cgColor.copy(alpha: 0.45)
|
||||||
|
topBorder.layer?.backgroundColor = NSColor.textBackgroundColor.cgColor.copy(alpha: 0.85)
|
||||||
|
} else {
|
||||||
|
view.layer?.backgroundColor = CGColor(genericGrayGamma2_2Gray: 0.0, alpha: 0.45)
|
||||||
|
topBorder.layer?.backgroundColor = CGColor(genericGrayGamma2_2Gray: 0.0, alpha: 0.85)
|
||||||
|
}
|
||||||
|
|
||||||
windowButtonsBackdrop = view
|
windowButtonsBackdrop = view
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user