From dfd258d3144b99a94fcc2dda04e18fff4cc39f04 Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Sat, 20 Aug 2022 07:04:32 +0800 Subject: [PATCH] PrefUI // Windows Aero support. --- .../Modules/UIModules/PrefUI/ctlPrefUI.swift | 23 +++++++++++++++++++ .../UIModules/PrefUI/suiPrefPaneDevZone.swift | 4 +++- .../PrefUI/suiPrefPaneDictionary.swift | 4 +++- .../PrefUI/suiPrefPaneExperience.swift | 4 +++- .../UIModules/PrefUI/suiPrefPaneGeneral.swift | 4 +++- .../PrefUI/suiPrefPaneKeyboard.swift | 4 +++- 6 files changed, 38 insertions(+), 5 deletions(-) diff --git a/Source/Modules/UIModules/PrefUI/ctlPrefUI.swift b/Source/Modules/UIModules/PrefUI/ctlPrefUI.swift index d9fbda91..e7a325ec 100644 --- a/Source/Modules/UIModules/PrefUI/ctlPrefUI.swift +++ b/Source/Modules/UIModules/PrefUI/ctlPrefUI.swift @@ -149,3 +149,26 @@ extension View { overlay(Tooltip(tooltip: tooltip)) } } + +// MARK: - Windows Aero in Swift UI + +// Ref: https://stackoverflow.com/questions/62461957 + +@available(macOS 10.15, *) +struct VisualEffectView: NSViewRepresentable { + let material: NSVisualEffectView.Material + let blendingMode: NSVisualEffectView.BlendingMode + + func makeNSView(context _: Context) -> NSVisualEffectView { + let visualEffectView = NSVisualEffectView() + visualEffectView.material = material + visualEffectView.blendingMode = blendingMode + visualEffectView.state = NSVisualEffectView.State.active + return visualEffectView + } + + func updateNSView(_ visualEffectView: NSVisualEffectView, context _: Context) { + visualEffectView.material = material + visualEffectView.blendingMode = blendingMode + } +} diff --git a/Source/Modules/UIModules/PrefUI/suiPrefPaneDevZone.swift b/Source/Modules/UIModules/PrefUI/suiPrefPaneDevZone.swift index ec1b3092..50809c62 100644 --- a/Source/Modules/UIModules/PrefUI/suiPrefPaneDevZone.swift +++ b/Source/Modules/UIModules/PrefUI/suiPrefPaneDevZone.swift @@ -90,7 +90,9 @@ struct suiPrefPaneDevZone: View { .preferenceDescription().fixedSize(horizontal: false, vertical: true) } } - }.frame(maxHeight: contentMaxHeight).fixedSize(horizontal: false, vertical: true) + } + .frame(maxHeight: contentMaxHeight).fixedSize(horizontal: false, vertical: true) + .background(VisualEffectView(material: .sidebar, blendingMode: .behindWindow)) } } diff --git a/Source/Modules/UIModules/PrefUI/suiPrefPaneDictionary.swift b/Source/Modules/UIModules/PrefUI/suiPrefPaneDictionary.swift index 6c4845a1..7725263d 100644 --- a/Source/Modules/UIModules/PrefUI/suiPrefPaneDictionary.swift +++ b/Source/Modules/UIModules/PrefUI/suiPrefPaneDictionary.swift @@ -145,7 +145,9 @@ struct suiPrefPaneDictionary: View { ) } } - }.frame(maxHeight: contentMaxHeight).fixedSize(horizontal: false, vertical: true) + } + .frame(maxHeight: contentMaxHeight).fixedSize(horizontal: false, vertical: true) + .background(VisualEffectView(material: .sidebar, blendingMode: .behindWindow)) } } diff --git a/Source/Modules/UIModules/PrefUI/suiPrefPaneExperience.swift b/Source/Modules/UIModules/PrefUI/suiPrefPaneExperience.swift index 5de501d2..d05d78d5 100644 --- a/Source/Modules/UIModules/PrefUI/suiPrefPaneExperience.swift +++ b/Source/Modules/UIModules/PrefUI/suiPrefPaneExperience.swift @@ -177,7 +177,9 @@ struct suiPrefPaneExperience: View { .preferenceDescription() } } - }.frame(maxHeight: contentMaxHeight).fixedSize(horizontal: false, vertical: true) + } + .frame(maxHeight: contentMaxHeight).fixedSize(horizontal: false, vertical: true) + .background(VisualEffectView(material: .sidebar, blendingMode: .behindWindow)) } } diff --git a/Source/Modules/UIModules/PrefUI/suiPrefPaneGeneral.swift b/Source/Modules/UIModules/PrefUI/suiPrefPaneGeneral.swift index a3ffb6d7..2f0b8ed7 100644 --- a/Source/Modules/UIModules/PrefUI/suiPrefPaneGeneral.swift +++ b/Source/Modules/UIModules/PrefUI/suiPrefPaneGeneral.swift @@ -185,7 +185,9 @@ struct suiPrefPaneGeneral: View { .controlSize(.small) } } - }.frame(maxHeight: contentMaxHeight).fixedSize(horizontal: false, vertical: true) + } + .frame(maxHeight: contentMaxHeight).fixedSize(horizontal: false, vertical: true) + .background(VisualEffectView(material: .sidebar, blendingMode: .behindWindow)) } } diff --git a/Source/Modules/UIModules/PrefUI/suiPrefPaneKeyboard.swift b/Source/Modules/UIModules/PrefUI/suiPrefPaneKeyboard.swift index aa74965e..e020e91c 100644 --- a/Source/Modules/UIModules/PrefUI/suiPrefPaneKeyboard.swift +++ b/Source/Modules/UIModules/PrefUI/suiPrefPaneKeyboard.swift @@ -235,7 +235,9 @@ struct suiPrefPaneKeyboard: View { ) } } - }.frame(maxHeight: contentMaxHeight).fixedSize(horizontal: false, vertical: true) + } + .frame(maxHeight: contentMaxHeight).fixedSize(horizontal: false, vertical: true) + .background(VisualEffectView(material: .sidebar, blendingMode: .behindWindow)) } }