Make the extraSize of BrowserWindow.setAspectRatio optional

This commit is contained in:
Cheng Zhao 2015-07-23 10:14:02 +08:00
parent df35700b94
commit 72eb87a631
3 changed files with 10 additions and 6 deletions

View 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);
}

View 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();

View 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