From: evgenyzinoviev Date: Sat, 23 Jan 2016 00:15:49 +0000 (+0100) Subject: added hasShadow option to BrowserWindow (osx) X-Git-Tag: v0.36.6~34^2~1 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=ff41b4a2677a5bcb4e48052e150607b96d8f5236;p=electron.git added hasShadow option to BrowserWindow (osx) --- diff --git a/atom/browser/api/atom_api_window.cc b/atom/browser/api/atom_api_window.cc index 09d88edb..e83b8285 100644 --- a/atom/browser/api/atom_api_window.cc +++ b/atom/browser/api/atom_api_window.cc @@ -462,6 +462,14 @@ void Window::SetBackgroundColor(const std::string& color_name) { window_->SetBackgroundColor(color_name); } +void Window::SetHasShadow(bool has_shadow) { + window_->SetHasShadow(has_shadow); +} + +bool Window::HasShadow() { + return window_->HasShadow(); +} + void Window::FocusOnWebView() { window_->FocusOnWebView(); } @@ -671,6 +679,8 @@ void Window::BuildPrototype(v8::Isolate* isolate, .SetMethod("setKiosk", &Window::SetKiosk) .SetMethod("isKiosk", &Window::IsKiosk) .SetMethod("setBackgroundColor", &Window::SetBackgroundColor) + .SetMethod("setHasShadow", &Window::SetHasShadow) + .SetMethod("hasShadow", &Window::HasShadow) .SetMethod("setRepresentedFilename", &Window::SetRepresentedFilename) .SetMethod("getRepresentedFilename", &Window::GetRepresentedFilename) .SetMethod("setDocumentEdited", &Window::SetDocumentEdited) diff --git a/atom/browser/api/atom_api_window.h b/atom/browser/api/atom_api_window.h index d8e25965..e7d38a60 100644 --- a/atom/browser/api/atom_api_window.h +++ b/atom/browser/api/atom_api_window.h @@ -118,6 +118,8 @@ class Window : public mate::TrackableObject, void SetKiosk(bool kiosk); bool IsKiosk(); void SetBackgroundColor(const std::string& color_name); + void SetHasShadow(bool has_shadow); + bool HasShadow(); void FocusOnWebView(); void BlurWebView(); bool IsWebViewFocused(); diff --git a/atom/browser/native_window.cc b/atom/browser/native_window.cc index 1f1a98b0..d14df92d 100644 --- a/atom/browser/native_window.cc +++ b/atom/browser/native_window.cc @@ -551,6 +551,13 @@ void NativeWindow::OnCapturePageDone(const CapturePageCallback& callback, callback.Run(bitmap); } +void NativeWindow::SetHasShadow(bool has_shadow) { +} + +bool NativeWindow::HasShadow() { + return true; +} + SkColor NativeWindow::ParseHexColor(const std::string& name) { SkColor result = 0xFF000000; unsigned value = 0; diff --git a/atom/browser/native_window.h b/atom/browser/native_window.h index 0a3ce124..c3615ccb 100644 --- a/atom/browser/native_window.h +++ b/atom/browser/native_window.h @@ -135,6 +135,8 @@ class NativeWindow : public base::SupportsUserData, virtual void SetKiosk(bool kiosk) = 0; virtual bool IsKiosk() = 0; virtual void SetBackgroundColor(const std::string& color_name) = 0; + virtual void SetHasShadow(bool has_shadow); + virtual bool HasShadow(); virtual void SetRepresentedFilename(const std::string& filename); virtual std::string GetRepresentedFilename(); virtual void SetDocumentEdited(bool edited); diff --git a/atom/browser/native_window_mac.h b/atom/browser/native_window_mac.h index ef3ccb15..595b6a2d 100644 --- a/atom/browser/native_window_mac.h +++ b/atom/browser/native_window_mac.h @@ -58,6 +58,8 @@ class NativeWindowMac : public NativeWindow { void SetKiosk(bool kiosk) override; bool IsKiosk() override; void SetBackgroundColor(const std::string& color_name) override; + void SetHasShadow(bool has_shadow) override; + bool HasShadow() override; void SetRepresentedFilename(const std::string& filename) override; std::string GetRepresentedFilename() override; void SetDocumentEdited(bool edited) override; diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm index 15601719..d7499e24 100644 --- a/atom/browser/native_window_mac.mm +++ b/atom/browser/native_window_mac.mm @@ -435,6 +435,12 @@ NativeWindowMac::NativeWindowMac( if (!has_frame()) [window_ setOpaque:NO]; + bool has_shadow = true; + options.Get(options::kHasShadow, &has_shadow); + if (!has_shadow) { + SetHasShadow(false); + } + // We will manage window's lifetime ourselves. [window_ setReleasedWhenClosed:NO]; @@ -714,6 +720,14 @@ void NativeWindowMac::SetBackgroundColor(const std::string& color_name) { [window_ setBackgroundColor:color]; } +void NativeWindowMac::SetHasShadow(bool has_shadow) { + [window_ setHasShadow:has_shadow]; +} + +bool NativeWindowMac::HasShadow() { + return [window_ hasShadow]; +} + void NativeWindowMac::SetRepresentedFilename(const std::string& filename) { [window_ setRepresentedFilename:base::SysUTF8ToNSString(filename)]; } diff --git a/atom/common/options_switches.cc b/atom/common/options_switches.cc index 477fe675..2349368f 100644 --- a/atom/common/options_switches.cc +++ b/atom/common/options_switches.cc @@ -68,6 +68,9 @@ const char kStandardWindow[] = "standardWindow"; // Default browser window background color. const char kBackgroundColor[] = "backgroundColor"; +// Whether the window should have a shadow. +const char kHasShadow[] = "hasShadow"; + // The WebPreferences. const char kWebPreferences[] = "webPreferences"; diff --git a/atom/common/options_switches.h b/atom/common/options_switches.h index 78de53b8..7ebcedc8 100644 --- a/atom/common/options_switches.h +++ b/atom/common/options_switches.h @@ -39,6 +39,7 @@ extern const char kType[]; extern const char kDisableAutoHideCursor[]; extern const char kStandardWindow[]; extern const char kBackgroundColor[]; +extern const char kHasShadow[]; extern const char kWebPreferences[]; // WebPreferences. diff --git a/docs/api/browser-window.md b/docs/api/browser-window.md index 0bb47f17..7cd1818b 100644 --- a/docs/api/browser-window.md +++ b/docs/api/browser-window.md @@ -76,6 +76,8 @@ It creates a new `BrowserWindow` with native properties as set by the `options`. * `backgroundColor` String - Window's background color as Hexadecimal value, like `#66CD00` or `#FFF`. Default is `#000` (black) for Linux and Windows, `#FFF` for Mac (or clear if transparent). + * `hasShadow` Boolean - Whether window should have a shadow. This is only + implemented on OS X. * `darkTheme` Boolean - Forces using dark theme for the window, only works on some GTK+3 desktop environments. Default is `false`. * `transparent` Boolean - Makes the window [transparent](frameless-window.md). @@ -710,6 +712,17 @@ screen readers Sets a 16px overlay onto the current taskbar icon, usually used to convey some sort of application status or to passively notify the user. +### `win.setHasShadow(hasShadow)` _OS X_ + +* `hasShadow` (Boolean) + +Sets whether the window should have a shadow. On Windows and Linux does +nothing. + +### `win.hasShadow()` _OS X_ + +Returns whether the window has a shadow. On Windows and Linux always returns +`true`. ### `win.setThumbarButtons(buttons)` _Windows 7+_