Merge pull request #4202 from evgenyzinoviev/shadow-pr

Added hasShadow option to BrowserWindow on OS X
This commit is contained in:
Cheng Zhao 2016-01-22 23:56:38 -08:00
commit 31624995bc
9 changed files with 54 additions and 0 deletions

View file

@ -502,6 +502,14 @@ void Window::SetBackgroundColor(const std::string& color_name) {
window_->SetBackgroundColor(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() { void Window::FocusOnWebView() {
window_->FocusOnWebView(); window_->FocusOnWebView();
} }
@ -721,6 +729,8 @@ void Window::BuildPrototype(v8::Isolate* isolate,
.SetMethod("setKiosk", &Window::SetKiosk) .SetMethod("setKiosk", &Window::SetKiosk)
.SetMethod("isKiosk", &Window::IsKiosk) .SetMethod("isKiosk", &Window::IsKiosk)
.SetMethod("setBackgroundColor", &Window::SetBackgroundColor) .SetMethod("setBackgroundColor", &Window::SetBackgroundColor)
.SetMethod("setHasShadow", &Window::SetHasShadow)
.SetMethod("hasShadow", &Window::HasShadow)
.SetMethod("setRepresentedFilename", &Window::SetRepresentedFilename) .SetMethod("setRepresentedFilename", &Window::SetRepresentedFilename)
.SetMethod("getRepresentedFilename", &Window::GetRepresentedFilename) .SetMethod("getRepresentedFilename", &Window::GetRepresentedFilename)
.SetMethod("setDocumentEdited", &Window::SetDocumentEdited) .SetMethod("setDocumentEdited", &Window::SetDocumentEdited)

View file

@ -128,6 +128,8 @@ class Window : public mate::TrackableObject<Window>,
void SetKiosk(bool kiosk); void SetKiosk(bool kiosk);
bool IsKiosk(); bool IsKiosk();
void SetBackgroundColor(const std::string& color_name); void SetBackgroundColor(const std::string& color_name);
void SetHasShadow(bool has_shadow);
bool HasShadow();
void FocusOnWebView(); void FocusOnWebView();
void BlurWebView(); void BlurWebView();
bool IsWebViewFocused(); bool IsWebViewFocused();

View file

@ -563,6 +563,13 @@ void NativeWindow::OnCapturePageDone(const CapturePageCallback& callback,
callback.Run(bitmap); callback.Run(bitmap);
} }
void NativeWindow::SetHasShadow(bool has_shadow) {
}
bool NativeWindow::HasShadow() {
return true;
}
SkColor NativeWindow::ParseHexColor(const std::string& name) { SkColor NativeWindow::ParseHexColor(const std::string& name) {
SkColor result = 0xFF000000; SkColor result = 0xFF000000;
unsigned value = 0; unsigned value = 0;

View file

@ -145,6 +145,8 @@ class NativeWindow : public base::SupportsUserData,
virtual void SetKiosk(bool kiosk) = 0; virtual void SetKiosk(bool kiosk) = 0;
virtual bool IsKiosk() = 0; virtual bool IsKiosk() = 0;
virtual void SetBackgroundColor(const std::string& color_name) = 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 void SetRepresentedFilename(const std::string& filename);
virtual std::string GetRepresentedFilename(); virtual std::string GetRepresentedFilename();
virtual void SetDocumentEdited(bool edited); virtual void SetDocumentEdited(bool edited);

View file

@ -68,6 +68,8 @@ class NativeWindowMac : public NativeWindow {
void SetKiosk(bool kiosk) override; void SetKiosk(bool kiosk) override;
bool IsKiosk() override; bool IsKiosk() override;
void SetBackgroundColor(const std::string& color_name) 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; void SetRepresentedFilename(const std::string& filename) override;
std::string GetRepresentedFilename() override; std::string GetRepresentedFilename() override;
void SetDocumentEdited(bool edited) override; void SetDocumentEdited(bool edited) override;

View file

@ -452,6 +452,12 @@ NativeWindowMac::NativeWindowMac(
if (!has_frame()) if (!has_frame())
[window_ setOpaque:NO]; [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. // We will manage window's lifetime ourselves.
[window_ setReleasedWhenClosed:NO]; [window_ setReleasedWhenClosed:NO];
@ -808,6 +814,14 @@ void NativeWindowMac::SetBackgroundColor(const std::string& color_name) {
[window_ setBackgroundColor:color]; [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) { void NativeWindowMac::SetRepresentedFilename(const std::string& filename) {
[window_ setRepresentedFilename:base::SysUTF8ToNSString(filename)]; [window_ setRepresentedFilename:base::SysUTF8ToNSString(filename)];
} }

View file

@ -72,6 +72,9 @@ const char kStandardWindow[] = "standardWindow";
// Default browser window background color. // Default browser window background color.
const char kBackgroundColor[] = "backgroundColor"; const char kBackgroundColor[] = "backgroundColor";
// Whether the window should have a shadow.
const char kHasShadow[] = "hasShadow";
// The WebPreferences. // The WebPreferences.
const char kWebPreferences[] = "webPreferences"; const char kWebPreferences[] = "webPreferences";

View file

@ -43,6 +43,7 @@ extern const char kType[];
extern const char kDisableAutoHideCursor[]; extern const char kDisableAutoHideCursor[];
extern const char kStandardWindow[]; extern const char kStandardWindow[];
extern const char kBackgroundColor[]; extern const char kBackgroundColor[];
extern const char kHasShadow[];
extern const char kWebPreferences[]; extern const char kWebPreferences[];
// WebPreferences. // WebPreferences.

View file

@ -85,6 +85,8 @@ It creates a new `BrowserWindow` with native properties as set by the `options`.
* `backgroundColor` String - Window's background color as Hexadecimal value, * `backgroundColor` String - Window's background color as Hexadecimal value,
like `#66CD00` or `#FFF`. Default is `#000` (black) for Linux and Windows, like `#66CD00` or `#FFF`. Default is `#000` (black) for Linux and Windows,
`#FFF` for Mac (or clear if transparent). `#FFF` for Mac (or clear if transparent).
* `hasShadow` Boolean - Whether window should have a shadow. This is only
implemented on OS X. Default is `true`.
* `darkTheme` Boolean - Forces using dark theme for the window, only works on * `darkTheme` Boolean - Forces using dark theme for the window, only works on
some GTK+3 desktop environments. Default is `false`. some GTK+3 desktop environments. Default is `false`.
* `transparent` Boolean - Makes the window [transparent](frameless-window.md). * `transparent` Boolean - Makes the window [transparent](frameless-window.md).
@ -777,6 +779,17 @@ screen readers
Sets a 16px overlay onto the current taskbar icon, usually used to convey some Sets a 16px overlay onto the current taskbar icon, usually used to convey some
sort of application status or to passively notify the user. 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+_ ### `win.setThumbarButtons(buttons)` _Windows 7+_