summaryrefslogtreecommitdiffstats
path: root/video/out/cocoa-cb/title_bar.swift
diff options
context:
space:
mode:
Diffstat (limited to 'video/out/cocoa-cb/title_bar.swift')
-rw-r--r--video/out/cocoa-cb/title_bar.swift16
1 files changed, 16 insertions, 0 deletions
diff --git a/video/out/cocoa-cb/title_bar.swift b/video/out/cocoa-cb/title_bar.swift
index e9109d4a2b..8a7bf30f02 100644
--- a/video/out/cocoa-cb/title_bar.swift
+++ b/video/out/cocoa-cb/title_bar.swift
@@ -62,12 +62,14 @@ class TitleBar: NSVisualEffectView {
autoresizingMask = [.viewWidthSizable, .viewMinYMargin]
systemBar.alphaValue = 0
state = .followsWindowActiveState
+ wantsLayer = true
window.contentView!.addSubview(self, positioned: .above, relativeTo: nil)
window.titlebarAppearsTransparent = true
window.styleMask.insert(.fullSizeContentView)
set(appearance: Int(mpv.macOpts!.macos_title_bar_appearance))
set(material: Int(mpv.macOpts!.macos_title_bar_material))
+ set(color: mpv.macOpts!.macos_title_bar_color)
}
// catch these events so they are not propagated to the underlying view
@@ -108,6 +110,20 @@ class TitleBar: NSVisualEffectView {
}
}
+ func set(color: Any) {
+ if color is String {
+ layer?.backgroundColor = NSColor(hex: color as! String).cgColor
+ } else {
+ let col = color as! m_color
+ let red = CGFloat(col.r)/255
+ let green = CGFloat(col.g)/255
+ let blue = CGFloat(col.b)/255
+ let alpha = CGFloat(col.a)/255
+ layer?.backgroundColor = NSColor(calibratedRed: red, green: green,
+ blue: blue, alpha: alpha).cgColor
+ }
+ }
+
func show() {
if (!cocoaCB.window.border && !cocoaCB.window.isInFullscreen) { return }
let loc = cocoaCB.view.convert(cocoaCB.window.mouseLocationOutsideOfEventStream, from: nil)