summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--DOCS/man/options.rst6
-rw-r--r--osdep/macOS_mpv_helper.swift1
-rw-r--r--osdep/macOS_swift_extensions.swift13
-rw-r--r--osdep/macosx_application.h2
-rw-r--r--osdep/macosx_application.m2
-rw-r--r--video/out/cocoa-cb/title_bar.swift16
-rw-r--r--video/out/cocoa_cb_common.swift4
7 files changed, 44 insertions, 0 deletions
diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst
index 33fbc96a8d..8975625704 100644
--- a/DOCS/man/options.rst
+++ b/DOCS/man/options.rst
@@ -4905,6 +4905,12 @@ The following video options are currently all specific to ``--vo=gpu`` and
:ultraDark: The standard macOS ultraDark material.
(macOS 10.11+ deprecated in macOS 10.14+)
+``--macos-title-bar-color=<color>``
+ Sets the color of the title bar (default: completely transparent). Is
+ influenced by ``--macos-title-bar-appearance`` and
+ ``--macos-title-bar-material``.
+ See ``--sub-color`` for color syntax.
+
``--macos-fs-animation-duration=<default|0-1000>``
Sets the fullscreen resize animation duration in ms (default: default).
The default value is slightly less than the system's animation duration
diff --git a/osdep/macOS_mpv_helper.swift b/osdep/macOS_mpv_helper.swift
index b456c8d59e..fe747db08c 100644
--- a/osdep/macOS_mpv_helper.swift
+++ b/osdep/macOS_mpv_helper.swift
@@ -59,6 +59,7 @@ class MPVHelper: NSObject {
mpv_observe_property(mpvHandle, 0, "macos-title-bar-style", MPV_FORMAT_STRING)
mpv_observe_property(mpvHandle, 0, "macos-title-bar-appearance", MPV_FORMAT_STRING)
mpv_observe_property(mpvHandle, 0, "macos-title-bar-material", MPV_FORMAT_STRING)
+ mpv_observe_property(mpvHandle, 0, "macos-title-bar-color", MPV_FORMAT_STRING)
}
func initRender() {
diff --git a/osdep/macOS_swift_extensions.swift b/osdep/macOS_swift_extensions.swift
index 14d217f589..cc7438fd8c 100644
--- a/osdep/macOS_swift_extensions.swift
+++ b/osdep/macOS_swift_extensions.swift
@@ -56,3 +56,16 @@ extension NSScreen {
}
}
}
+
+extension NSColor {
+
+ convenience init(hex: String) {
+ let int = Int(hex.dropFirst(), radix: 16)
+ let alpha = CGFloat((int! >> 24) & 0x000000FF)/255
+ let red = CGFloat((int! >> 16) & 0x000000FF)/255
+ let green = CGFloat((int! >> 8) & 0x000000FF)/255
+ let blue = CGFloat((int!) & 0x000000FF)/255
+
+ self.init(calibratedRed: red, green: green, blue: blue, alpha: alpha)
+ }
+}
diff --git a/osdep/macosx_application.h b/osdep/macosx_application.h
index 5f33a384f2..7c22abaf84 100644
--- a/osdep/macosx_application.h
+++ b/osdep/macosx_application.h
@@ -19,11 +19,13 @@
#define MPV_MACOSX_APPLICATION
#include "osdep/macosx_menubar.h"
+#include "options/m_option.h"
struct macos_opts {
int macos_title_bar_style;
int macos_title_bar_appearance;
int macos_title_bar_material;
+ struct m_color macos_title_bar_color;
int macos_fs_animation_duration;
int cocoa_cb_sw_renderer;
};
diff --git a/osdep/macosx_application.m b/osdep/macosx_application.m
index 4653b7177d..08b3fce901 100644
--- a/osdep/macosx_application.m
+++ b/osdep/macosx_application.m
@@ -57,6 +57,7 @@ const struct m_sub_options macos_conf = {
{"underWindowBackground", 12}, {"underPageBackground", 13},
{"dark", 14}, {"light", 15}, {"mediumLight", 16},
{"ultraDark", 17})),
+ OPT_COLOR("macos-title-bar-color", macos_title_bar_color, 0),
OPT_CHOICE_OR_INT("macos-fs-animation-duration",
macos_fs_animation_duration, 0, 0, 1000,
({"default", -1})),
@@ -68,6 +69,7 @@ const struct m_sub_options macos_conf = {
},
.size = sizeof(struct macos_opts),
.defaults = &(const struct macos_opts){
+ .macos_title_bar_color = {0, 0, 0, 0},
.macos_fs_animation_duration = -1,
.cocoa_cb_sw_renderer = -1,
},
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
}