feat: expose new vibrancy types (#19073)

This commit is contained in:
Shelley Vohr 2019-07-11 14:10:45 -05:00 committed by GitHub
parent c756b955b3
commit 75a020e0ac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 4 deletions

View file

@ -234,9 +234,8 @@ It creates a new `BrowserWindow` with native properties as set by the `options`.
Windows, which adds standard window frame. Setting it to `false` will remove
window shadow and window animations. Default is `true`.
* `vibrancy` String (optional) - Add a type of vibrancy effect to the window, only on
macOS. Can be `appearance-based`, `light`, `dark`, `titlebar`, `selection`, `menu`,
`popover`, `sidebar`, `medium-light` or `ultra-dark`. Please note that using `frame: false` in combination with a vibrancy value requires that you use a non-default `titleBarStyle` as well.
Also note that `appearance-based`, `light`, `dark`, `medium-light`, and `ultra-dark` have been deprecated and will be removed in an upcoming version of macOS.
macOS. Can be `appearance-based`, `light`, `dark`, `titlebar`, `selection`,
`menu`, `popover`, `sidebar`, `medium-light`, `ultra-dark`, `header`, `sheet`, `window`, `hud`, `fullscreen-ui`, `tooltip`, `content`, `under-window`, or `under-page`. Please note that using `frame: false` in combination with a vibrancy value requires that you use a non-default `titleBarStyle` as well. Also note that `appearance-based`, `light`, `dark`, `medium-light`, and `ultra-dark` have been deprecated and will be removed in an upcoming version of macOS.
* `zoomToPageWidth` Boolean (optional) - Controls the behavior on macOS when
option-clicking the green stoplight button on the toolbar or by clicking the
Window > Zoom menu item. If `true`, the window will grow to the preferred
@ -1620,7 +1619,7 @@ Adds a window as a tab on this window, after the tab for the window instance.
#### `win.setVibrancy(type)` _macOS_
* `type` String | null - Can be `appearance-based`, `light`, `dark`, `titlebar`,
`selection`, `menu`, `popover`, `sidebar`, `medium-light` or `ultra-dark`. See
`selection`, `menu`, `popover`, `sidebar`, `medium-light`, `ultra-dark`, `header`, `sheet`, `window`, `hud`, `fullscreen-ui`, `tooltip`, `content`, `under-window`, or `under-page`. See
the [macOS documentation][vibrancy-docs] for more details.
Adds a vibrancy effect to the browser window. Passing `null` or an empty string

View file

@ -1347,6 +1347,37 @@ void NativeWindowMac::SetVibrancy(const std::string& type) {
}
}
if (@available(macOS 10.14, *)) {
if (type == "header") {
// NSVisualEffectMaterialHeaderView
vibrancyType = static_cast<NSVisualEffectMaterial>(10);
} else if (type == "sheet") {
// NSVisualEffectMaterialSheet
vibrancyType = static_cast<NSVisualEffectMaterial>(11);
} else if (type == "window") {
// NSVisualEffectMaterialWindowBackground
vibrancyType = static_cast<NSVisualEffectMaterial>(12);
} else if (type == "hud") {
// NSVisualEffectMaterialHUDWindow
vibrancyType = static_cast<NSVisualEffectMaterial>(13);
} else if (type == "fullscreen-ui") {
// NSVisualEffectMaterialFullScreenUI
vibrancyType = static_cast<NSVisualEffectMaterial>(16);
} else if (type == "tooltip") {
// NSVisualEffectMaterialToolTip
vibrancyType = static_cast<NSVisualEffectMaterial>(17);
} else if (type == "content") {
// NSVisualEffectMaterialContentBackground
vibrancyType = static_cast<NSVisualEffectMaterial>(18);
} else if (type == "under-window") {
// NSVisualEffectMaterialUnderWindowBackground
vibrancyType = static_cast<NSVisualEffectMaterial>(21);
} else if (type == "under-page") {
// NSVisualEffectMaterialUnderPageBackground
vibrancyType = static_cast<NSVisualEffectMaterial>(22);
}
}
if (vibrancyType)
[effect_view setMaterial:vibrancyType];
}