window_vibrancy/macos/
mod.rs

1// Copyright 2019-2022 Tauri Programme within The Commons Conservancy
2// SPDX-License-Identifier: Apache-2.0
3// SPDX-License-Identifier: MIT
4
5// The use of NSVisualEffectView comes from https://github.com/joboet/winit/tree/macos_blurred_background
6// with a bit of rewrite by @youngsing to make it more like cocoa::appkit style.
7/// <https://developer.apple.com/documentation/appkit/nsvisualeffectview/material>
8#[repr(u64)]
9#[derive(Clone, Copy, Debug, PartialEq)]
10pub enum NSVisualEffectMaterial {
11    #[deprecated(
12        since = "macOS 10.14",
13        note = "A default material appropriate for the view's effectiveAppearance.  You should instead choose an appropriate semantic material."
14    )]
15    AppearanceBased = 0,
16    #[deprecated(since = "macOS 10.14", note = "Use a semantic material instead.")]
17    Light = 1,
18    #[deprecated(since = "macOS 10.14", note = "Use a semantic material instead.")]
19    Dark = 2,
20    #[deprecated(since = "macOS 10.14", note = "Use a semantic material instead.")]
21    MediumLight = 8,
22    #[deprecated(since = "macOS 10.14", note = "Use a semantic material instead.")]
23    UltraDark = 9,
24
25    /// macOS 10.10+
26    Titlebar = 3,
27    /// macOS 10.10+
28    Selection = 4,
29
30    /// macOS 10.11+
31    Menu = 5,
32    /// macOS 10.11+
33    Popover = 6,
34    /// macOS 10.11+
35    Sidebar = 7,
36
37    /// macOS 10.14+
38    HeaderView = 10,
39    /// macOS 10.14+
40    Sheet = 11,
41    /// macOS 10.14+
42    WindowBackground = 12,
43    /// macOS 10.14+
44    HudWindow = 13,
45    /// macOS 10.14+
46    FullScreenUI = 15,
47    /// macOS 10.14+
48    Tooltip = 17,
49    /// macOS 10.14+
50    ContentBackground = 18,
51    /// macOS 10.14+
52    UnderWindowBackground = 21,
53    /// macOS 10.14+
54    UnderPageBackground = 22,
55}
56
57/// <https://developer.apple.com/documentation/appkit/nsvisualeffectview/state>
58#[allow(dead_code)]
59#[repr(u64)]
60#[derive(Clone, Copy, Debug, PartialEq)]
61pub enum NSVisualEffectState {
62    /// Make window vibrancy state follow the window's active state
63    FollowsWindowActiveState = 0,
64    /// Make window vibrancy state always active
65    Active = 1,
66    /// Make window vibrancy state always inactive
67    Inactive = 2,
68}
69
70// TODO: Find references for styles other than 0 and 1
71/// Note that only the first two variants Regular (0) and Clear (1) are officially supported,
72/// see <https://developer.apple.com/documentation/appkit/nsglasseffectview/style-swift.enum>.
73///
74/// All other variants use private macOS APIs and may change or break at any time.
75#[repr(u64)]
76#[derive(Clone, Copy, Debug, PartialEq)]
77pub enum NSGlassEffectViewStyle {
78    /// macOS 26.0+
79    Regular = 0,
80    /// macOS 26.0+
81    Clear = 1,
82    /// macOS 26.0+
83    Dock = 2,
84    /// macOS 26.0+
85    AppIcons = 3,
86    /// macOS 26.0+
87    Widgets = 4,
88    /// macOS 26.0+
89    Text = 5,
90    /// macOS 26.0+
91    AvPlayer = 6,
92    /// macOS 26.0+
93    FaceTime = 7,
94    /// macOS 26.0+
95    ControlCenter = 8,
96    /// macOS 26.0+
97    NotificationCenter = 9,
98    /// macOS 26.0+
99    Monogram = 10,
100    /// macOS 26.0+
101    Bubbles = 11,
102    /// macOS 26.0+
103    Identity = 12,
104    /// macOS 26.0+
105    FocusBorder = 13,
106    /// macOS 26.0+
107    FocusPlatter = 14,
108    /// macOS 26.0+
109    Keyboard = 15,
110    /// macOS 26.0+
111    Sidebar = 16,
112    /// macOS 26.0+
113    AbuttedSidebar = 17,
114    /// macOS 26.0+
115    Inspector = 18,
116    /// macOS 26.0+
117    Control = 19,
118    /// macOS 26.0+
119    Loupe = 20,
120    /// macOS 26.0+
121    Slider = 21,
122    /// macOS 26.0+
123    Camera = 22,
124    /// macOS 26.0+
125    CartouchePopover = 23,
126}
127
128#[cfg(target_os = "macos")]
129mod vibrancy;
130
131#[cfg(target_os = "macos")]
132pub use vibrancy::{apply_vibrancy, clear_vibrancy};
133
134#[cfg(target_os = "macos")]
135mod ns_visual_effect_view_tagged;
136
137#[cfg(target_os = "macos")]
138pub use ns_visual_effect_view_tagged::NSVisualEffectViewTagged;
139
140// Liquid Glass support (macOS 26.0+)
141#[cfg(target_os = "macos")]
142mod liquid_glass;
143
144#[cfg(target_os = "macos")]
145pub use liquid_glass::{apply_liquid_glass, clear_liquid_glass};
146
147#[cfg(target_os = "macos")]
148mod ns_glass_effect_view_tagged;
149
150#[cfg(target_os = "macos")]
151pub use ns_glass_effect_view_tagged::NSGlassEffectViewTagged;