]> khamidou — GitHub mirrors - electron.git/commitdiff
added hasShadow option to BrowserWindow (osx)
authorevgenyzinoviev <me@ch1p.com>
Sat, 23 Jan 2016 00:15:49 +0000 (01:15 +0100)
committerevgenyzinoviev <me@ch1p.com>
Sat, 23 Jan 2016 00:16:08 +0000 (01:16 +0100)
atom/browser/api/atom_api_window.cc
atom/browser/api/atom_api_window.h
atom/browser/native_window.cc
atom/browser/native_window.h
atom/browser/native_window_mac.h
atom/browser/native_window_mac.mm
atom/common/options_switches.cc
atom/common/options_switches.h
docs/api/browser-window.md

index 09d88edb9b7b1b7b507c0b0aa31df72c2ecc0fb1..e83b828581af8465513df86a7491e5d976f03c3c 100644 (file)
@@ -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)
index d8e25965d89877a8a0e9937e367e59d08db38150..e7d38a60e66c4d7deba77bb8597bb111a334570a 100644 (file)
@@ -118,6 +118,8 @@ class Window : public mate::TrackableObject<Window>,
   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();
index 1f1a98b0658a05896fe29022682f41375cb658f2..d14df92deb6bd4b331a8cd0045ce6acb2c3c26c5 100644 (file)
@@ -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;
index 0a3ce124bd128c596120b9d4d00cd699ad020764..c3615ccb18369fa84931ac8e2b52e451c2abcc6c 100644 (file)
@@ -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);
index ef3ccb150217b02bded8aa252cc53e995b9d83e1..595b6a2d3403d71cfba872199fd69797b67bf8ff 100644 (file)
@@ -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;
index 156017194ecfb6a1329e39a33500edd5386e6c3c..d7499e244a19990d46f32ef3242822e48dddc762 100644 (file)
@@ -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)];
 }
index 477fe6755faffd0b115c2dfc056b83a05c18f4fc..2349368fc1b4bf4a569349bbcea7bd6e3f1c93ec 100644 (file)
@@ -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";
 
index 78de53b825f96ea09bb62e520065b011d16b5278..7ebcedc8740e47e6b5b6677bf16850a101021f0d 100644 (file)
@@ -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.
index 0bb47f17087493f12fa20e4a2b17835e2cc596c7..7cd1818b317be1490548f85c69ab8c10d562bb27 100644 (file)
@@ -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+_