From 72eb87a6312316ba595c2709348f12d5c8cd52bc Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 23 Jul 2015 10:14:02 +0800 Subject: [PATCH] Make the extraSize of BrowserWindow.setAspectRatio optional --- atom/browser/api/atom_api_window.cc | 10 ++++++---- atom/browser/api/atom_api_window.h | 2 +- docs/api/browser-window.md | 4 +++- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/atom/browser/api/atom_api_window.cc b/atom/browser/api/atom_api_window.cc index c4e6b06af0..5f7c2503fc 100644 --- a/atom/browser/api/atom_api_window.cc +++ b/atom/browser/api/atom_api_window.cc @@ -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); } diff --git a/atom/browser/api/atom_api_window.h b/atom/browser/api/atom_api_window.h index f807ab135f..cc2b3a64b5 100644 --- a/atom/browser/api/atom_api_window.h +++ b/atom/browser/api/atom_api_window.h @@ -95,7 +95,6 @@ class Window : public mate::TrackableObject, 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, bool IsMenuBarAutoHide(); void SetMenuBarVisibility(bool visible); bool IsMenuBarVisible(); + void SetAspectRatio(double aspect_ratio, mate::Arguments* args); #if defined(OS_MACOSX) void ShowDefinitionForSelection(); diff --git a/docs/api/browser-window.md b/docs/api/browser-window.md index 445265e544..c8fc39a53f 100644 --- a/docs/api/browser-window.md +++ b/docs/api/browser-window.md @@ -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