adds test, adds view to AtomNSWindow and minor fixes
This commit is contained in:
Родитель
2cf30c0d63
Коммит
5e62d28e50
|
@ -786,16 +786,11 @@ bool Window::IsVisibleOnAllWorkspaces() {
|
|||
return window_->IsVisibleOnAllWorkspaces();
|
||||
}
|
||||
|
||||
void Window::SetVibrancy(v8::Local<v8::Value> value, mate::Arguments* args) {
|
||||
void Window::SetVibrancy(mate::Arguments* args) {
|
||||
std::string type;
|
||||
|
||||
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");
|
||||
}
|
||||
args->GetNext(&type);
|
||||
window_->SetVibrancy(type);
|
||||
}
|
||||
|
||||
int32_t Window::ID() const {
|
||||
|
|
|
@ -196,7 +196,7 @@ class Window : public mate::TrackableObject<Window>,
|
|||
void SetVisibleOnAllWorkspaces(bool visible);
|
||||
bool IsVisibleOnAllWorkspaces();
|
||||
|
||||
void SetVibrancy(v8::Local<v8::Value> value, mate::Arguments* args);
|
||||
void SetVibrancy(mate::Arguments* args);
|
||||
|
||||
int32_t ID() const;
|
||||
v8::Local<v8::Value> WebContents(v8::Isolate* isolate);
|
||||
|
|
|
@ -201,13 +201,6 @@ void NativeWindow::InitFromOptions(const mate::Dictionary& options) {
|
|||
options.Get(options::kShow, &show);
|
||||
if (show)
|
||||
Show();
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
std::string type;
|
||||
if (options.Get(options::kVibrancyType, &type)) {
|
||||
SetVibrancy(type);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void NativeWindow::SetSize(const gfx::Size& size, bool animate) {
|
||||
|
|
|
@ -163,9 +163,6 @@ class NativeWindowMac : public NativeWindow,
|
|||
// The "titleBarStyle" option.
|
||||
TitleBarStyle title_bar_style_;
|
||||
|
||||
// Vibrancy view
|
||||
NSView* vibrant_view_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(NativeWindowMac);
|
||||
};
|
||||
|
||||
|
|
|
@ -311,6 +311,7 @@ bool ScopedDisableResize::disable_resize_ = false;
|
|||
@property BOOL disableKeyOrMainWindow;
|
||||
@property NSPoint windowButtonsOffset;
|
||||
@property (nonatomic, retain) AtomPreviewItem* quickLookItem;
|
||||
@property (nonatomic, retain) NSView* vibrantView;
|
||||
|
||||
- (void)setShell:(atom::NativeWindowMac*)shell;
|
||||
- (void)setEnableLargerThanScreen:(bool)enable;
|
||||
|
@ -743,6 +744,11 @@ NativeWindowMac::NativeWindowMac(
|
|||
|
||||
InstallView();
|
||||
|
||||
std::string type;
|
||||
if (options.Get(options::kVibrancyType, &type)) {
|
||||
SetVibrancy(type);
|
||||
}
|
||||
|
||||
// Set maximizable state last to ensure zoom button does not get reset
|
||||
// by calls to other APIs.
|
||||
SetMaximizable(maximizable);
|
||||
|
@ -1208,20 +1214,22 @@ bool NativeWindowMac::IsVisibleOnAllWorkspaces() {
|
|||
void NativeWindowMac::SetVibrancy(const std::string& type) {
|
||||
if (!(base::mac::IsOSMavericks() || base::mac::IsOSYosemiteOrLater())) return;
|
||||
|
||||
if (type.empty()) {
|
||||
if (vibrant_view_ == nil) return;
|
||||
NSView* vibrant_view = [window_ vibrantView];
|
||||
|
||||
[vibrant_view_ removeFromSuperview];
|
||||
vibrant_view_ = nil;
|
||||
if (type.empty()) {
|
||||
if (vibrant_view == nil) return;
|
||||
|
||||
[vibrant_view removeFromSuperview];
|
||||
[window_ setVibrantView:nil];
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
NSVisualEffectView* effect_view = (NSVisualEffectView*)vibrant_view_;
|
||||
NSVisualEffectView* effect_view = (NSVisualEffectView*)vibrant_view;
|
||||
if (effect_view == nil) {
|
||||
effect_view = [[NSVisualEffectView alloc] initWithFrame:
|
||||
[[window_ contentView] bounds]];
|
||||
vibrant_view_ = (NSView*)effect_view;
|
||||
[window_ setVibrantView:(NSView*)effect_view];
|
||||
|
||||
[effect_view setAutoresizingMask:
|
||||
NSViewWidthSizable | NSViewHeightSizable];
|
||||
|
|
|
@ -427,6 +427,18 @@ describe('browser-window module', function () {
|
|||
})
|
||||
})
|
||||
|
||||
describe('BrowserWindow.setVibrancy(type)', function () {
|
||||
it('allows setting, changing, and removing the vibrancy', function () {
|
||||
assert.doesNotThrow(function () {
|
||||
w.setVibrancy('light')
|
||||
w.setVibrancy('dark')
|
||||
w.setVibrancy(null)
|
||||
w.setVibrancy('ultra-dark')
|
||||
w.setVibrancy('')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('BrowserWindow.fromId(id)', function () {
|
||||
it('returns the window with id', function () {
|
||||
assert.equal(w.id, BrowserWindow.fromId(w.id).id)
|
||||
|
|
Загрузка…
Ссылка в новой задаче