Merge pull request #4112 from evgenyzinoviev/resize-animate-pr
Animate window resizing on OS X
This commit is contained in:
commit
712f11a9a3
9 changed files with 50 additions and 36 deletions
|
@ -338,16 +338,20 @@ bool Window::IsFullscreen() {
|
||||||
return window_->IsFullscreen();
|
return window_->IsFullscreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::SetBounds(const gfx::Rect& bounds) {
|
void Window::SetBounds(const gfx::Rect& bounds, mate::Arguments* args) {
|
||||||
window_->SetBounds(bounds);
|
bool animate = false;
|
||||||
|
args->GetNext(&animate);
|
||||||
|
window_->SetBounds(bounds, animate);
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::Rect Window::GetBounds() {
|
gfx::Rect Window::GetBounds() {
|
||||||
return window_->GetBounds();
|
return window_->GetBounds();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::SetSize(int width, int height) {
|
void Window::SetSize(int width, int height, mate::Arguments* args) {
|
||||||
window_->SetSize(gfx::Size(width, height));
|
bool animate = false;
|
||||||
|
args->GetNext(&animate);
|
||||||
|
window_->SetSize(gfx::Size(width, height), animate);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<int> Window::GetSize() {
|
std::vector<int> Window::GetSize() {
|
||||||
|
@ -358,8 +362,10 @@ std::vector<int> Window::GetSize() {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::SetContentSize(int width, int height) {
|
void Window::SetContentSize(int width, int height, mate::Arguments* args) {
|
||||||
window_->SetContentSize(gfx::Size(width, height));
|
bool animate = false;
|
||||||
|
args->GetNext(&animate);
|
||||||
|
window_->SetContentSize(gfx::Size(width, height), animate);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<int> Window::GetContentSize() {
|
std::vector<int> Window::GetContentSize() {
|
||||||
|
@ -414,8 +420,10 @@ void Window::Center() {
|
||||||
window_->Center();
|
window_->Center();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::SetPosition(int x, int y) {
|
void Window::SetPosition(int x, int y, mate::Arguments* args) {
|
||||||
window_->SetPosition(gfx::Point(x, y));
|
bool animate = false;
|
||||||
|
args->GetNext(&animate);
|
||||||
|
window_->SetPosition(gfx::Point(x, y), animate);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<int> Window::GetPosition() {
|
std::vector<int> Window::GetPosition() {
|
||||||
|
|
|
@ -94,11 +94,11 @@ class Window : public mate::TrackableObject<Window>,
|
||||||
bool IsMinimized();
|
bool IsMinimized();
|
||||||
void SetFullScreen(bool fullscreen);
|
void SetFullScreen(bool fullscreen);
|
||||||
bool IsFullscreen();
|
bool IsFullscreen();
|
||||||
void SetBounds(const gfx::Rect& bounds);
|
void SetBounds(const gfx::Rect& bounds, mate::Arguments* args);
|
||||||
gfx::Rect GetBounds();
|
gfx::Rect GetBounds();
|
||||||
void SetSize(int width, int height);
|
void SetSize(int width, int height, mate::Arguments* args);
|
||||||
std::vector<int> GetSize();
|
std::vector<int> GetSize();
|
||||||
void SetContentSize(int width, int height);
|
void SetContentSize(int width, int height, mate::Arguments* args);
|
||||||
std::vector<int> GetContentSize();
|
std::vector<int> GetContentSize();
|
||||||
void SetMinimumSize(int width, int height);
|
void SetMinimumSize(int width, int height);
|
||||||
std::vector<int> GetMinimumSize();
|
std::vector<int> GetMinimumSize();
|
||||||
|
@ -109,7 +109,7 @@ class Window : public mate::TrackableObject<Window>,
|
||||||
void SetAlwaysOnTop(bool top);
|
void SetAlwaysOnTop(bool top);
|
||||||
bool IsAlwaysOnTop();
|
bool IsAlwaysOnTop();
|
||||||
void Center();
|
void Center();
|
||||||
void SetPosition(int x, int y);
|
void SetPosition(int x, int y, mate::Arguments* args);
|
||||||
std::vector<int> GetPosition();
|
std::vector<int> GetPosition();
|
||||||
void SetTitle(const std::string& title);
|
void SetTitle(const std::string& title);
|
||||||
std::string GetTitle();
|
std::string GetTitle();
|
||||||
|
|
|
@ -154,24 +154,24 @@ void NativeWindow::InitFromOptions(const mate::Dictionary& options) {
|
||||||
Show();
|
Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindow::SetSize(const gfx::Size& size) {
|
void NativeWindow::SetSize(const gfx::Size& size, bool animate) {
|
||||||
SetBounds(gfx::Rect(GetPosition(), size));
|
SetBounds(gfx::Rect(GetPosition(), size), animate);
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::Size NativeWindow::GetSize() {
|
gfx::Size NativeWindow::GetSize() {
|
||||||
return GetBounds().size();
|
return GetBounds().size();
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindow::SetPosition(const gfx::Point& position) {
|
void NativeWindow::SetPosition(const gfx::Point& position, bool animate) {
|
||||||
SetBounds(gfx::Rect(position, GetSize()));
|
SetBounds(gfx::Rect(position, GetSize()), animate);
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::Point NativeWindow::GetPosition() {
|
gfx::Point NativeWindow::GetPosition() {
|
||||||
return GetBounds().origin();
|
return GetBounds().origin();
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindow::SetContentSize(const gfx::Size& size) {
|
void NativeWindow::SetContentSize(const gfx::Size& size, bool animate) {
|
||||||
SetSize(ContentSizeToWindowSize(size));
|
SetSize(ContentSizeToWindowSize(size), animate);
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::Size NativeWindow::GetContentSize() {
|
gfx::Size NativeWindow::GetContentSize() {
|
||||||
|
|
|
@ -105,13 +105,13 @@ class NativeWindow : public base::SupportsUserData,
|
||||||
virtual bool IsMinimized() = 0;
|
virtual bool IsMinimized() = 0;
|
||||||
virtual void SetFullScreen(bool fullscreen) = 0;
|
virtual void SetFullScreen(bool fullscreen) = 0;
|
||||||
virtual bool IsFullscreen() const = 0;
|
virtual bool IsFullscreen() const = 0;
|
||||||
virtual void SetBounds(const gfx::Rect& bounds) = 0;
|
virtual void SetBounds(const gfx::Rect& bounds, bool animate = false) = 0;
|
||||||
virtual gfx::Rect GetBounds() = 0;
|
virtual gfx::Rect GetBounds() = 0;
|
||||||
virtual void SetSize(const gfx::Size& size);
|
virtual void SetSize(const gfx::Size& size, bool animate = false);
|
||||||
virtual gfx::Size GetSize();
|
virtual gfx::Size GetSize();
|
||||||
virtual void SetPosition(const gfx::Point& position);
|
virtual void SetPosition(const gfx::Point& position, bool animate = false);
|
||||||
virtual gfx::Point GetPosition();
|
virtual gfx::Point GetPosition();
|
||||||
virtual void SetContentSize(const gfx::Size& size);
|
virtual void SetContentSize(const gfx::Size& size, bool animate = false);
|
||||||
virtual gfx::Size GetContentSize();
|
virtual gfx::Size GetContentSize();
|
||||||
virtual void SetSizeConstraints(
|
virtual void SetSizeConstraints(
|
||||||
const extensions::SizeConstraints& size_constraints);
|
const extensions::SizeConstraints& size_constraints);
|
||||||
|
|
|
@ -42,7 +42,7 @@ class NativeWindowMac : public NativeWindow {
|
||||||
bool IsMinimized() override;
|
bool IsMinimized() override;
|
||||||
void SetFullScreen(bool fullscreen) override;
|
void SetFullScreen(bool fullscreen) override;
|
||||||
bool IsFullscreen() const override;
|
bool IsFullscreen() const override;
|
||||||
void SetBounds(const gfx::Rect& bounds) override;
|
void SetBounds(const gfx::Rect& bounds, bool animate = false) override;
|
||||||
gfx::Rect GetBounds() override;
|
gfx::Rect GetBounds() override;
|
||||||
void SetContentSizeConstraints(
|
void SetContentSizeConstraints(
|
||||||
const extensions::SizeConstraints& size_constraints) override;
|
const extensions::SizeConstraints& size_constraints) override;
|
||||||
|
|
|
@ -581,7 +581,7 @@ bool NativeWindowMac::IsFullscreen() const {
|
||||||
return [window_ styleMask] & NSFullScreenWindowMask;
|
return [window_ styleMask] & NSFullScreenWindowMask;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindowMac::SetBounds(const gfx::Rect& bounds) {
|
void NativeWindowMac::SetBounds(const gfx::Rect& bounds, bool animate) {
|
||||||
NSRect cocoa_bounds = NSMakeRect(bounds.x(), 0,
|
NSRect cocoa_bounds = NSMakeRect(bounds.x(), 0,
|
||||||
bounds.width(),
|
bounds.width(),
|
||||||
bounds.height());
|
bounds.height());
|
||||||
|
@ -590,7 +590,7 @@ void NativeWindowMac::SetBounds(const gfx::Rect& bounds) {
|
||||||
cocoa_bounds.origin.y =
|
cocoa_bounds.origin.y =
|
||||||
NSHeight([screen frame]) - bounds.height() - bounds.y();
|
NSHeight([screen frame]) - bounds.height() - bounds.y();
|
||||||
|
|
||||||
[window_ setFrame:cocoa_bounds display:YES];
|
[window_ setFrame:cocoa_bounds display:YES animate:animate];
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::Rect NativeWindowMac::GetBounds() {
|
gfx::Rect NativeWindowMac::GetBounds() {
|
||||||
|
|
|
@ -375,7 +375,8 @@ bool NativeWindowViews::IsFullscreen() const {
|
||||||
return window_->IsFullscreen();
|
return window_->IsFullscreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindowViews::SetBounds(const gfx::Rect& bounds) {
|
void NativeWindowViews::SetBounds(const gfx::Rect& bounds,
|
||||||
|
bool animate = false) {
|
||||||
#if defined(USE_X11)
|
#if defined(USE_X11)
|
||||||
// On Linux the minimum and maximum size should be updated with window size
|
// On Linux the minimum and maximum size should be updated with window size
|
||||||
// when window is not resizable.
|
// when window is not resizable.
|
||||||
|
|
|
@ -61,7 +61,7 @@ class NativeWindowViews : public NativeWindow,
|
||||||
bool IsMinimized() override;
|
bool IsMinimized() override;
|
||||||
void SetFullScreen(bool fullscreen) override;
|
void SetFullScreen(bool fullscreen) override;
|
||||||
bool IsFullscreen() const override;
|
bool IsFullscreen() const override;
|
||||||
void SetBounds(const gfx::Rect& bounds) override;
|
void SetBounds(const gfx::Rect& bounds, bool animate) override;
|
||||||
gfx::Rect GetBounds() override;
|
gfx::Rect GetBounds() override;
|
||||||
gfx::Size GetContentSize() override;
|
gfx::Size GetContentSize() override;
|
||||||
void SetContentSizeConstraints(
|
void SetContentSizeConstraints(
|
||||||
|
|
|
@ -450,14 +450,16 @@ the player itself we would call this function with arguments of 16/9 and
|
||||||
are within the content view--only that they exist. Just sum any extra width and
|
are within the content view--only that they exist. Just sum any extra width and
|
||||||
height areas you have within the overall content view.
|
height areas you have within the overall content view.
|
||||||
|
|
||||||
### `win.setBounds(options)`
|
### `win.setBounds(options[, animate])`
|
||||||
|
|
||||||
`options` Object, properties:
|
* `options` Object, properties:
|
||||||
|
|
||||||
* `x` Integer
|
* `x` Integer
|
||||||
* `y` Integer
|
* `y` Integer
|
||||||
* `width` Integer
|
* `width` Integer
|
||||||
* `height` Integer
|
* `height` Integer
|
||||||
|
|
||||||
|
* `animate` Boolean (optional) _OS X_
|
||||||
|
|
||||||
Resizes and moves the window to `width`, `height`, `x`, `y`.
|
Resizes and moves the window to `width`, `height`, `x`, `y`.
|
||||||
|
|
||||||
|
@ -465,10 +467,11 @@ Resizes and moves the window to `width`, `height`, `x`, `y`.
|
||||||
|
|
||||||
Returns an object that contains window's width, height, x and y values.
|
Returns an object that contains window's width, height, x and y values.
|
||||||
|
|
||||||
### `win.setSize(width, height)`
|
### `win.setSize(width, height[, animate])`
|
||||||
|
|
||||||
* `width` Integer
|
* `width` Integer
|
||||||
* `height` Integer
|
* `height` Integer
|
||||||
|
* `animate` Boolean (optional) _OS X_
|
||||||
|
|
||||||
Resizes the window to `width` and `height`.
|
Resizes the window to `width` and `height`.
|
||||||
|
|
||||||
|
@ -476,10 +479,11 @@ Resizes the window to `width` and `height`.
|
||||||
|
|
||||||
Returns an array that contains window's width and height.
|
Returns an array that contains window's width and height.
|
||||||
|
|
||||||
### `win.setContentSize(width, height)`
|
### `win.setContentSize(width, height[, animate])`
|
||||||
|
|
||||||
* `width` Integer
|
* `width` Integer
|
||||||
* `height` Integer
|
* `height` Integer
|
||||||
|
* `animate` Boolean (optional) _OS X_
|
||||||
|
|
||||||
Resizes the window's client area (e.g. the web page) to `width` and `height`.
|
Resizes the window's client area (e.g. the web page) to `width` and `height`.
|
||||||
|
|
||||||
|
@ -535,10 +539,11 @@ Returns whether the window is always on top of other windows.
|
||||||
|
|
||||||
Moves window to the center of the screen.
|
Moves window to the center of the screen.
|
||||||
|
|
||||||
### `win.setPosition(x, y)`
|
### `win.setPosition(x, y[, animate])`
|
||||||
|
|
||||||
* `x` Integer
|
* `x` Integer
|
||||||
* `y` Integer
|
* `y` Integer
|
||||||
|
* `animate` Boolean (optional) _OS X_
|
||||||
|
|
||||||
Moves window to `x` and `y`.
|
Moves window to `x` and `y`.
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue