From 4dbf81c94c1c60d647330ee84e01dc3b8368165b Mon Sep 17 00:00:00 2001 From: der richter Date: Thu, 26 Dec 2024 17:47:44 +0100 Subject: [PATCH] mac/title: use enum for material values instead of generic integers --- osdep/mac/app_bridge.h | 21 +++++++++++++++++++ osdep/mac/app_bridge.m | 25 ++++++++++++++++------- video/out/mac/title_bar.swift | 38 +++++++++++++++++------------------ 3 files changed, 58 insertions(+), 26 deletions(-) diff --git a/osdep/mac/app_bridge.h b/osdep/mac/app_bridge.h index 0e10c5bc5bdab..961b01ca8b2bb 100644 --- a/osdep/mac/app_bridge.h +++ b/osdep/mac/app_bridge.h @@ -47,6 +47,27 @@ enum { MAC_APPEAR_VIBRANT_DARK_HC, }; +enum { + MAC_MAT_TITLEBAR = 0, + MAC_MAT_SELECTION, + MAC_MAT_MENU, + MAC_MAT_POPOVER, + MAC_MAT_SIDEBAR, + MAC_MAT_HEADER_VIEW, + MAC_MAT_SHEET, + MAC_MAT_WINDOW_BACKGROUND, + MAC_MAT_HUD_WINDOW, + MAC_MAT_FULL_SCREEN, + MAC_MAT_TOOL_TIP, + MAC_MAT_CONTENT_BACKGROUND, + MAC_MAT_UNDER_WINDOW_BACKGROUND, + MAC_MAT_UNDER_PAGE_BACKGROUND, + MAC_MAT_DARK, + MAC_MAT_LIGHT, + MAC_MAT_MEDIUM_LIGHT, + MAC_MAT_ULTRA_DARK, +}; + enum { MAC_CSP_AUTO = -1, MAC_CSP_DISPLAY_P3, diff --git a/osdep/mac/app_bridge.m b/osdep/mac/app_bridge.m index e11b5635f30d4..8f256034e1743 100644 --- a/osdep/mac/app_bridge.m +++ b/osdep/mac/app_bridge.m @@ -37,13 +37,24 @@ {"vibrantLightHighContrast", MAC_APPEAR_VIBRANT_LIGHT_HC}, {"vibrantDarkHighContrast", MAC_APPEAR_VIBRANT_DARK_HC})}, {"macos-title-bar-material", OPT_CHOICE(macos_title_bar_material, - {"titlebar", 0}, {"selection", 1}, {"menu", 2}, - {"popover", 3}, {"sidebar", 4}, {"headerView", 5}, - {"sheet", 6}, {"windowBackground", 7}, {"hudWindow", 8}, - {"fullScreen", 9}, {"toolTip", 10}, {"contentBackground", 11}, - {"underWindowBackground", 12}, {"underPageBackground", 13}, - {"dark", 14}, {"light", 15}, {"mediumLight", 16}, - {"ultraDark", 17})}, + {"titlebar", MAC_MAT_TITLEBAR}, + {"selection", MAC_MAT_SELECTION}, + {"menu", MAC_MAT_MENU}, + {"popover", MAC_MAT_POPOVER}, + {"sidebar", MAC_MAT_SIDEBAR}, + {"headerView", MAC_MAT_HEADER_VIEW}, + {"sheet", MAC_MAT_SHEET}, + {"windowBackground", MAC_MAT_WINDOW_BACKGROUND}, + {"hudWindow", MAC_MAT_HUD_WINDOW}, + {"fullScreen", MAC_MAT_FULL_SCREEN}, + {"toolTip", MAC_MAT_TOOL_TIP}, + {"contentBackground", MAC_MAT_CONTENT_BACKGROUND}, + {"underWindowBackground", MAC_MAT_UNDER_WINDOW_BACKGROUND}, + {"underPageBackground", MAC_MAT_UNDER_PAGE_BACKGROUND}, + {"dark", MAC_MAT_DARK}, + {"light", MAC_MAT_LIGHT}, + {"mediumLight", MAC_MAT_MEDIUM_LIGHT}, + {"ultraDark", MAC_MAT_ULTRA_DARK})}, {"macos-title-bar-color", OPT_COLOR(macos_title_bar_color)}, {"macos-fs-animation-duration", OPT_CHOICE(macos_fs_animation_duration, {"default", -1}), diff --git a/video/out/mac/title_bar.swift b/video/out/mac/title_bar.swift index ff8f86b1c420d..f2408fd1d057e 100644 --- a/video/out/mac/title_bar.swift +++ b/video/out/mac/title_bar.swift @@ -108,25 +108,25 @@ class TitleBar: NSVisualEffectView { } func set(material: Int32) { - self.material = { switch material { - case 0: return .titlebar - case 1: return .selection - case 2: return .menu - case 3: return .popover - case 4: return .sidebar - case 5: return .headerView - case 6: return .sheet - case 7: return .windowBackground - case 8: return .hudWindow - case 9: return .fullScreenUI - case 10: return .toolTip - case 11: return .contentBackground - case 12: return .underWindowBackground - case 13: return .underPageBackground - case 14: return .dark - case 15: return .light - case 16: return .mediumLight - case 17: return .ultraDark + self.material = { switch Int(material) { + case MAC_MAT_TITLEBAR: return .titlebar + case MAC_MAT_SELECTION: return .selection + case MAC_MAT_MENU: return .menu + case MAC_MAT_POPOVER: return .popover + case MAC_MAT_SIDEBAR: return .sidebar + case MAC_MAT_HEADER_VIEW: return .headerView + case MAC_MAT_SHEET: return .sheet + case MAC_MAT_WINDOW_BACKGROUND: return .windowBackground + case MAC_MAT_HUD_WINDOW: return .hudWindow + case MAC_MAT_FULL_SCREEN: return .fullScreenUI + case MAC_MAT_TOOL_TIP: return .toolTip + case MAC_MAT_CONTENT_BACKGROUND: return .contentBackground + case MAC_MAT_UNDER_WINDOW_BACKGROUND: return .underWindowBackground + case MAC_MAT_UNDER_PAGE_BACKGROUND: return .underPageBackground + case MAC_MAT_DARK: return .dark + case MAC_MAT_LIGHT: return .light + case MAC_MAT_MEDIUM_LIGHT: return .mediumLight + case MAC_MAT_ULTRA_DARK: return .ultraDark default: return .titlebar } }()