fix: use surfaceConfig.backgroundColor to determine if the theme is light or dark
Signed-off-by: Aaron Ruan <i@ar212.com>1.1.x
parent
3a7fb03ef9
commit
602b47ff4e
|
|
@ -218,6 +218,9 @@ class TerminalController: BaseTerminalController {
|
||||||
// Set our explicit appearance if we need to based on the configuration.
|
// Set our explicit appearance if we need to based on the configuration.
|
||||||
window.appearance = surfaceConfig.windowAppearance
|
window.appearance = surfaceConfig.windowAppearance
|
||||||
|
|
||||||
|
// Update our window light/darkness based on our updated background color
|
||||||
|
window.isLightTheme = OSColor(surfaceConfig.backgroundColor).isLightColor
|
||||||
|
|
||||||
// If our window is not visible, then we do nothing. Some things such as blurring
|
// If our window is not visible, then we do nothing. Some things such as blurring
|
||||||
// have no effect if the window is not visible. Ultimately, we'll have this called
|
// have no effect if the window is not visible. Ultimately, we'll have this called
|
||||||
// at some point when a surface becomes focused.
|
// at some point when a surface becomes focused.
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,10 @@ import Cocoa
|
||||||
class TerminalWindow: NSWindow {
|
class TerminalWindow: NSWindow {
|
||||||
@objc dynamic var keyEquivalent: String = ""
|
@objc dynamic var keyEquivalent: String = ""
|
||||||
|
|
||||||
|
/// This is used to determine if certain elements should be drawn light or dark and should
|
||||||
|
/// be updated whenever the window background color or surrounding elements changes.
|
||||||
|
var isLightTheme: Bool = false
|
||||||
|
|
||||||
lazy var titlebarColor: NSColor = backgroundColor {
|
lazy var titlebarColor: NSColor = backgroundColor {
|
||||||
didSet {
|
didSet {
|
||||||
guard let titlebarContainer else { return }
|
guard let titlebarContainer else { return }
|
||||||
|
|
@ -295,7 +299,6 @@ class TerminalWindow: NSWindow {
|
||||||
|
|
||||||
|
|
||||||
if newTabButtonImageLayer == nil {
|
if newTabButtonImageLayer == nil {
|
||||||
let isLightTheme = backgroundColor.isLightColor
|
|
||||||
let fillColor: NSColor = isLightTheme ? .black.withAlphaComponent(0.85) : .white.withAlphaComponent(0.85)
|
let fillColor: NSColor = isLightTheme ? .black.withAlphaComponent(0.85) : .white.withAlphaComponent(0.85)
|
||||||
let newImage = NSImage(size: newTabButtonImage.size, flipped: false) { rect in
|
let newImage = NSImage(size: newTabButtonImage.size, flipped: false) { rect in
|
||||||
newTabButtonImage.draw(in: rect)
|
newTabButtonImage.draw(in: rect)
|
||||||
|
|
@ -714,7 +717,7 @@ fileprivate class WindowButtonsBackdropView: NSView {
|
||||||
|
|
||||||
init(window: TerminalWindow) {
|
init(window: TerminalWindow) {
|
||||||
self.terminalWindow = window
|
self.terminalWindow = window
|
||||||
self.isLightTheme = window.backgroundColor.isLightColor
|
self.isLightTheme = window.isLightTheme
|
||||||
|
|
||||||
super.init(frame: .zero)
|
super.init(frame: .zero)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue