refactor: use NSVisualEffectMaterial* constants directly (#22121)
This commit is contained in:
parent
b66db2f268
commit
43ca62cad0
1 changed files with 16 additions and 34 deletions
|
@ -1455,8 +1455,7 @@ void NativeWindowMac::SetVibrancy(const std::string& type) {
|
||||||
relativeTo:nil];
|
relativeTo:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string dep_warn =
|
std::string dep_warn = " has been deprecated and removed as of macOS 10.15.";
|
||||||
" has been deprecated and will be removed in a future version of macOS.";
|
|
||||||
node::Environment* env =
|
node::Environment* env =
|
||||||
node::Environment::GetCurrent(v8::Isolate::GetCurrent());
|
node::Environment::GetCurrent(v8::Isolate::GetCurrent());
|
||||||
|
|
||||||
|
@ -1477,61 +1476,44 @@ void NativeWindowMac::SetVibrancy(const std::string& type) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (@available(macOS 10.11, *)) {
|
if (@available(macOS 10.11, *)) {
|
||||||
// TODO(codebytere): Use NSVisualEffectMaterial* constants directly once
|
|
||||||
// they are available in the minimum SDK version
|
|
||||||
if (type == "selection") {
|
if (type == "selection") {
|
||||||
// NSVisualEffectMaterialSelection
|
vibrancyType = NSVisualEffectMaterialSelection;
|
||||||
vibrancyType = static_cast<NSVisualEffectMaterial>(4);
|
|
||||||
} else if (type == "menu") {
|
} else if (type == "menu") {
|
||||||
// NSVisualEffectMaterialMenu
|
vibrancyType = NSVisualEffectMaterialMenu;
|
||||||
vibrancyType = static_cast<NSVisualEffectMaterial>(5);
|
|
||||||
} else if (type == "popover") {
|
} else if (type == "popover") {
|
||||||
// NSVisualEffectMaterialPopover
|
vibrancyType = NSVisualEffectMaterialPopover;
|
||||||
vibrancyType = static_cast<NSVisualEffectMaterial>(6);
|
|
||||||
} else if (type == "sidebar") {
|
} else if (type == "sidebar") {
|
||||||
// NSVisualEffectMaterialSidebar
|
vibrancyType = NSVisualEffectMaterialSidebar;
|
||||||
vibrancyType = static_cast<NSVisualEffectMaterial>(7);
|
|
||||||
} else if (type == "medium-light") {
|
} else if (type == "medium-light") {
|
||||||
// NSVisualEffectMaterialMediumLight
|
|
||||||
EmitWarning(env, "NSVisualEffectMaterialMediumLight" + dep_warn,
|
EmitWarning(env, "NSVisualEffectMaterialMediumLight" + dep_warn,
|
||||||
"electron");
|
"electron");
|
||||||
vibrancyType = static_cast<NSVisualEffectMaterial>(8);
|
vibrancyType = NSVisualEffectMaterialMediumLight;
|
||||||
} else if (type == "ultra-dark") {
|
} else if (type == "ultra-dark") {
|
||||||
// NSVisualEffectMaterialUltraDark
|
|
||||||
EmitWarning(env, "NSVisualEffectMaterialUltraDark" + dep_warn,
|
EmitWarning(env, "NSVisualEffectMaterialUltraDark" + dep_warn,
|
||||||
"electron");
|
"electron");
|
||||||
vibrancyType = static_cast<NSVisualEffectMaterial>(9);
|
vibrancyType = NSVisualEffectMaterialUltraDark;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (@available(macOS 10.14, *)) {
|
if (@available(macOS 10.14, *)) {
|
||||||
if (type == "header") {
|
if (type == "header") {
|
||||||
// NSVisualEffectMaterialHeaderView
|
vibrancyType = NSVisualEffectMaterialHeaderView;
|
||||||
vibrancyType = static_cast<NSVisualEffectMaterial>(10);
|
|
||||||
} else if (type == "sheet") {
|
} else if (type == "sheet") {
|
||||||
// NSVisualEffectMaterialSheet
|
vibrancyType = NSVisualEffectMaterialSheet;
|
||||||
vibrancyType = static_cast<NSVisualEffectMaterial>(11);
|
|
||||||
} else if (type == "window") {
|
} else if (type == "window") {
|
||||||
// NSVisualEffectMaterialWindowBackground
|
vibrancyType = NSVisualEffectMaterialWindowBackground;
|
||||||
vibrancyType = static_cast<NSVisualEffectMaterial>(12);
|
|
||||||
} else if (type == "hud") {
|
} else if (type == "hud") {
|
||||||
// NSVisualEffectMaterialHUDWindow
|
vibrancyType = NSVisualEffectMaterialHUDWindow;
|
||||||
vibrancyType = static_cast<NSVisualEffectMaterial>(13);
|
|
||||||
} else if (type == "fullscreen-ui") {
|
} else if (type == "fullscreen-ui") {
|
||||||
// NSVisualEffectMaterialFullScreenUI
|
vibrancyType = NSVisualEffectMaterialFullScreenUI;
|
||||||
vibrancyType = static_cast<NSVisualEffectMaterial>(16);
|
|
||||||
} else if (type == "tooltip") {
|
} else if (type == "tooltip") {
|
||||||
// NSVisualEffectMaterialToolTip
|
vibrancyType = NSVisualEffectMaterialToolTip;
|
||||||
vibrancyType = static_cast<NSVisualEffectMaterial>(17);
|
|
||||||
} else if (type == "content") {
|
} else if (type == "content") {
|
||||||
// NSVisualEffectMaterialContentBackground
|
vibrancyType = NSVisualEffectMaterialContentBackground;
|
||||||
vibrancyType = static_cast<NSVisualEffectMaterial>(18);
|
|
||||||
} else if (type == "under-window") {
|
} else if (type == "under-window") {
|
||||||
// NSVisualEffectMaterialUnderWindowBackground
|
vibrancyType = NSVisualEffectMaterialUnderWindowBackground;
|
||||||
vibrancyType = static_cast<NSVisualEffectMaterial>(21);
|
|
||||||
} else if (type == "under-page") {
|
} else if (type == "under-page") {
|
||||||
// NSVisualEffectMaterialUnderPageBackground
|
vibrancyType = NSVisualEffectMaterialUnderPageBackground;
|
||||||
vibrancyType = static_cast<NSVisualEffectMaterial>(22);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue