]> khamidou — GitHub mirrors - electron.git/commitdiff
Make the extraSize of BrowserWindow.setAspectRatio optional
authorCheng Zhao <zcbenz@gmail.com>
Thu, 23 Jul 2015 02:14:02 +0000 (10:14 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Thu, 23 Jul 2015 02:14:02 +0000 (10:14 +0800)
atom/browser/api/atom_api_window.cc
atom/browser/api/atom_api_window.h
docs/api/browser-window.md

index c4e6b06af06f291867cf51e5b9fc8757d0461d26..5f7c2503fced84f5db781e8281e26bc2a18188f2 100644 (file)
@@ -249,10 +249,6 @@ bool Window::IsFullscreen() {
   return window_->IsFullscreen();
 }
 
-void Window::SetAspectRatio(double aspect_ratio, const gfx::Size& extraSize) {
-  window_->SetAspectRatio(aspect_ratio, extraSize);
-}
-
 void Window::SetBounds(const gfx::Rect& bounds) {
   window_->SetBounds(bounds);
 }
@@ -455,6 +451,12 @@ void Window::ShowDefinitionForSelection() {
 }
 #endif
 
+void Window::SetAspectRatio(double aspect_ratio, mate::Arguments* args) {
+  gfx::Size extra_size;
+  args->GetNext(&extra_size);
+  window_->SetAspectRatio(aspect_ratio, extra_size);
+}
+
 void Window::SetVisibleOnAllWorkspaces(bool visible) {
   return window_->SetVisibleOnAllWorkspaces(visible);
 }
index f807ab135f28c2191bb53f8f6821ac4bbe601ccf..cc2b3a64b5e99808bf55f9095d7aa16ab4493842 100644 (file)
@@ -95,7 +95,6 @@ class Window : public mate::TrackableObject<Window>,
   bool IsMinimized();
   void SetFullScreen(bool fullscreen);
   bool IsFullscreen();
-  void SetAspectRatio(double aspect_ratio, const gfx::Size& extraSize);
   void SetBounds(const gfx::Rect& bounds);
   gfx::Rect GetBounds();
   void SetSize(int width, int height);
@@ -135,6 +134,7 @@ class Window : public mate::TrackableObject<Window>,
   bool IsMenuBarAutoHide();
   void SetMenuBarVisibility(bool visible);
   bool IsMenuBarVisible();
+  void SetAspectRatio(double aspect_ratio, mate::Arguments* args);
 
 #if defined(OS_MACOSX)
   void ShowDefinitionForSelection();
index 445265e544712c512cbda28b9a61ce0a47c444ce..c8fc39a53f1ffce0bda20bd1fff3dc8269029b0b 100644 (file)
@@ -361,7 +361,7 @@ Sets whether the window should be in fullscreen mode.
 
 Returns whether the window is in fullscreen mode.
 
-### BrowserWindow.setAspectRatio(aspectRatio, [extraSize])
+### BrowserWindow.setAspectRatio(aspectRatio[, extraSize])
 
 * `aspectRatio` The aspect ratio we want to maintain for some portion of the content view.
 * `rect` Object - The extra size to not be included in the aspect ratio to be maintained.
@@ -372,6 +372,8 @@ This will have a window maintain an aspect ratio. The extra size allows a develo
 
 Consider a normal window with an HD video player and associated controls. Perhaps there are 15 pixels of controls on the left edge, 25 pixels of controls on the right edge and 50 pixels of controls below the player. In order to maintain a 16:9 aspect ratio (standard aspect ratio for HD @1920x1080) within the player itself we would call this function with arguments of 16/9 and [ 40, 50 ]. The second argument doesn't care where the extra width and height are within the content view — only that they exist. Just sum any extra width and height areas you have within the overall content view.
 
+__Note__: This API is only implemented on OS X.
+
 ### BrowserWindow.setBounds(options)
 
 * `options` Object