summaryrefslogtreecommitdiffstats
path: root/video/out
diff options
context:
space:
mode:
authorder richter <der.richter@gmx.de>2019-03-29 20:39:42 +0100
committerJan Ekström <jeebjp@gmail.com>2019-04-02 02:09:01 +0300
commit90e44d3ff2182749da8d7d255bef15fd99c18eee (patch)
treea20a2aa8bb26e8b9340aecb96cc9085b1475a2f9 /video/out
parent837e5058ff110247229057f7ab182a041d1c98b8 (diff)
downloadmpv-90e44d3ff2182749da8d7d255bef15fd99c18eee.tar.bz2
mpv-90e44d3ff2182749da8d7d255bef15fd99c18eee.tar.xz
cocoa-cb: add support for custom colored title bar
Diffstat (limited to 'video/out')
-rw-r--r--video/out/cocoa-cb/title_bar.swift16
-rw-r--r--video/out/cocoa_cb_common.swift4
2 files changed, 20 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)
diff --git a/video/out/cocoa_cb_common.swift b/video/out/cocoa_cb_common.swift
index a3fabd0324..f545e72a3d 100644
--- a/video/out/cocoa_cb_common.swift
+++ b/video/out/cocoa_cb_common.swift
@@ -521,6 +521,10 @@ class CocoaCB: NSObject {
if let data = MPVHelper.mpvStringArrayToString(property.data) {
titleBar.set(material: data)
}
+ case "macos-title-bar-color":
+ if let data = MPVHelper.mpvStringArrayToString(property.data) {
+ titleBar.set(color: data)
+ }
default:
break
}