From 90e44d3ff2182749da8d7d255bef15fd99c18eee Mon Sep 17 00:00:00 2001 From: der richter Date: Fri, 29 Mar 2019 20:39:42 +0100 Subject: cocoa-cb: add support for custom colored title bar --- osdep/macOS_mpv_helper.swift | 1 + osdep/macOS_swift_extensions.swift | 13 +++++++++++++ osdep/macosx_application.h | 2 ++ osdep/macosx_application.m | 2 ++ 4 files changed, 18 insertions(+) (limited to 'osdep') 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, }, -- cgit v1.2.3