remove method transferred to set with null
This commit is contained in:
parent
16253fe708
commit
2cf30c0d63
7 changed files with 35 additions and 33 deletions
|
@ -786,12 +786,16 @@ bool Window::IsVisibleOnAllWorkspaces() {
|
|||
return window_->IsVisibleOnAllWorkspaces();
|
||||
}
|
||||
|
||||
void Window::SetVibrancy(const std::string& type) {
|
||||
window_->SetVibrancy(type);
|
||||
}
|
||||
void Window::SetVibrancy(v8::Local<v8::Value> value, mate::Arguments* args) {
|
||||
std::string type;
|
||||
|
||||
void Window::RemoveVibrancy() {
|
||||
window_->RemoveVibrancy();
|
||||
if (value->IsNull()) {
|
||||
window_->SetVibrancy(std::string());
|
||||
} else if (mate::ConvertFromV8(isolate(), value, &type)) {
|
||||
window_->SetVibrancy(type);
|
||||
} else {
|
||||
args->ThrowError("Must pass a string or null");
|
||||
}
|
||||
}
|
||||
|
||||
int32_t Window::ID() const {
|
||||
|
@ -910,7 +914,6 @@ void Window::BuildPrototype(v8::Isolate* isolate,
|
|||
.SetMethod("isVisibleOnAllWorkspaces",
|
||||
&Window::IsVisibleOnAllWorkspaces)
|
||||
.SetMethod("setVibrancy", &Window::SetVibrancy)
|
||||
.SetMethod("removeVibrancy", &Window::RemoveVibrancy)
|
||||
#if defined(OS_WIN)
|
||||
.SetMethod("hookWindowMessage", &Window::HookWindowMessage)
|
||||
.SetMethod("isWindowMessageHooked", &Window::IsWindowMessageHooked)
|
||||
|
|
|
@ -196,8 +196,7 @@ class Window : public mate::TrackableObject<Window>,
|
|||
void SetVisibleOnAllWorkspaces(bool visible);
|
||||
bool IsVisibleOnAllWorkspaces();
|
||||
|
||||
void SetVibrancy(const std::string& type);
|
||||
void RemoveVibrancy();
|
||||
void SetVibrancy(v8::Local<v8::Value> value, mate::Arguments* args);
|
||||
|
||||
int32_t ID() const;
|
||||
v8::Local<v8::Value> WebContents(v8::Isolate* isolate);
|
||||
|
|
|
@ -340,6 +340,9 @@ void NativeWindow::SetParentWindow(NativeWindow* parent) {
|
|||
parent_ = parent;
|
||||
}
|
||||
|
||||
void NativeWindow::SetVibrancy(const std::string& filename) {
|
||||
}
|
||||
|
||||
void NativeWindow::FocusOnWebView() {
|
||||
web_contents()->GetRenderViewHost()->GetWidget()->Focus();
|
||||
}
|
||||
|
|
|
@ -162,8 +162,7 @@ class NativeWindow : public base::SupportsUserData,
|
|||
virtual bool IsVisibleOnAllWorkspaces() = 0;
|
||||
|
||||
// Vibrancy API
|
||||
virtual void SetVibrancy(const std::string& type) = 0;
|
||||
virtual void RemoveVibrancy() = 0;
|
||||
virtual void SetVibrancy(const std::string& type);
|
||||
|
||||
// Webview APIs.
|
||||
virtual void FocusOnWebView();
|
||||
|
|
|
@ -93,7 +93,6 @@ class NativeWindowMac : public NativeWindow,
|
|||
void SetVisibleOnAllWorkspaces(bool visible) override;
|
||||
bool IsVisibleOnAllWorkspaces() override;
|
||||
void SetVibrancy(const std::string& type) override;
|
||||
void RemoveVibrancy() override;
|
||||
|
||||
// content::RenderWidgetHost::InputEventObserver:
|
||||
void OnInputEvent(const blink::WebInputEvent& event) override;
|
||||
|
|
|
@ -1208,18 +1208,27 @@ bool NativeWindowMac::IsVisibleOnAllWorkspaces() {
|
|||
void NativeWindowMac::SetVibrancy(const std::string& type) {
|
||||
if (!(base::mac::IsOSMavericks() || base::mac::IsOSYosemiteOrLater())) return;
|
||||
|
||||
NSVisualEffectView *vview = (NSVisualEffectView *)vibrant_view_;
|
||||
if (vview == nil) {
|
||||
vview = [[NSVisualEffectView alloc] initWithFrame:
|
||||
[[window_ contentView] bounds]];
|
||||
vibrant_view_ = (NSView *)vview;
|
||||
if (type.empty()) {
|
||||
if (vibrant_view_ == nil) return;
|
||||
|
||||
[vview setAutoresizingMask:
|
||||
[vibrant_view_ removeFromSuperview];
|
||||
vibrant_view_ = nil;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
NSVisualEffectView* effect_view = (NSVisualEffectView*)vibrant_view_;
|
||||
if (effect_view == nil) {
|
||||
effect_view = [[NSVisualEffectView alloc] initWithFrame:
|
||||
[[window_ contentView] bounds]];
|
||||
vibrant_view_ = (NSView*)effect_view;
|
||||
|
||||
[effect_view setAutoresizingMask:
|
||||
NSViewWidthSizable | NSViewHeightSizable];
|
||||
|
||||
[vview setBlendingMode:NSVisualEffectBlendingModeBehindWindow];
|
||||
[vview setState:NSVisualEffectStateActive];
|
||||
[[window_ contentView] addSubview:vview
|
||||
[effect_view setBlendingMode:NSVisualEffectBlendingModeBehindWindow];
|
||||
[effect_view setState:NSVisualEffectStateActive];
|
||||
[[window_ contentView] addSubview:effect_view
|
||||
positioned:NSWindowBelow
|
||||
relativeTo:nil];
|
||||
}
|
||||
|
@ -1252,14 +1261,7 @@ void NativeWindowMac::SetVibrancy(const std::string& type) {
|
|||
}
|
||||
}
|
||||
|
||||
[vview setMaterial:vibrancyType];
|
||||
}
|
||||
|
||||
void NativeWindowMac::RemoveVibrancy() {
|
||||
if (vibrant_view_ == nil) return;
|
||||
|
||||
[vibrant_view_ removeFromSuperview];
|
||||
vibrant_view_ = nil;
|
||||
[effect_view setMaterial:vibrancyType];
|
||||
}
|
||||
|
||||
void NativeWindowMac::OnInputEvent(const blink::WebInputEvent& event) {
|
||||
|
|
|
@ -1198,10 +1198,7 @@ Returns `BrowserWindow[]` - All child windows.
|
|||
`selection`, `menu`, `popover`, `sidebar`, `medium-light` or `ultra-dark`. See
|
||||
the [macOS documentation][vibrancy-docs] for more details.
|
||||
|
||||
Adds a vibrancy effect to the browser window.
|
||||
Adds a vibrancy effect to the browser window. Passing `null` or an empty string
|
||||
will remove the vibrancy effect on the window.
|
||||
|
||||
[vibrancy-docs]: https://developer.apple.com/reference/appkit/nsvisualeffectview?language=objc
|
||||
|
||||
#### `win.removeVibrancy()` _macOS_
|
||||
|
||||
Removes the vibrancy effect on the window.
|
||||
|
|
Loading…
Reference in a new issue