window: adding setBounds and getBounds api
This commit is contained in:
parent
4608f5e9cd
commit
ae6a1b409f
8 changed files with 54 additions and 0 deletions
|
@ -15,6 +15,7 @@
|
||||||
#include "native_mate/callback.h"
|
#include "native_mate/callback.h"
|
||||||
#include "native_mate/constructor.h"
|
#include "native_mate/constructor.h"
|
||||||
#include "native_mate/dictionary.h"
|
#include "native_mate/dictionary.h"
|
||||||
|
#include "ui/gfx/geometry/rect.h"
|
||||||
|
|
||||||
#include "atom/common/node_includes.h"
|
#include "atom/common/node_includes.h"
|
||||||
|
|
||||||
|
@ -222,6 +223,14 @@ bool Window::IsFullscreen() {
|
||||||
return window_->IsFullscreen();
|
return window_->IsFullscreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Window::SetBounds(const gfx::Rect& bounds) {
|
||||||
|
window_->SetBounds(bounds);
|
||||||
|
}
|
||||||
|
|
||||||
|
gfx::Rect Window::GetBounds() {
|
||||||
|
return window_->GetBounds();
|
||||||
|
}
|
||||||
|
|
||||||
void Window::SetSize(int width, int height) {
|
void Window::SetSize(int width, int height) {
|
||||||
window_->SetSize(gfx::Size(width, height));
|
window_->SetSize(gfx::Size(width, height));
|
||||||
}
|
}
|
||||||
|
@ -464,6 +473,8 @@ void Window::BuildPrototype(v8::Isolate* isolate,
|
||||||
.SetMethod("isMinimized", &Window::IsMinimized)
|
.SetMethod("isMinimized", &Window::IsMinimized)
|
||||||
.SetMethod("setFullScreen", &Window::SetFullScreen)
|
.SetMethod("setFullScreen", &Window::SetFullScreen)
|
||||||
.SetMethod("isFullScreen", &Window::IsFullscreen)
|
.SetMethod("isFullScreen", &Window::IsFullscreen)
|
||||||
|
.SetMethod("getBounds", &Window::GetBounds)
|
||||||
|
.SetMethod("setBounds", &Window::SetBounds)
|
||||||
.SetMethod("getSize", &Window::GetSize)
|
.SetMethod("getSize", &Window::GetSize)
|
||||||
.SetMethod("setSize", &Window::SetSize)
|
.SetMethod("setSize", &Window::SetSize)
|
||||||
.SetMethod("getContentSize", &Window::GetContentSize)
|
.SetMethod("getContentSize", &Window::GetContentSize)
|
||||||
|
|
|
@ -16,6 +16,10 @@
|
||||||
|
|
||||||
class GURL;
|
class GURL;
|
||||||
|
|
||||||
|
namespace gfx {
|
||||||
|
class Rect;
|
||||||
|
}
|
||||||
|
|
||||||
namespace mate {
|
namespace mate {
|
||||||
class Arguments;
|
class Arguments;
|
||||||
class Dictionary;
|
class Dictionary;
|
||||||
|
@ -85,6 +89,8 @@ class Window : public mate::EventEmitter,
|
||||||
bool IsMinimized();
|
bool IsMinimized();
|
||||||
void SetFullScreen(bool fullscreen);
|
void SetFullScreen(bool fullscreen);
|
||||||
bool IsFullscreen();
|
bool IsFullscreen();
|
||||||
|
void SetBounds(const gfx::Rect& bounds);
|
||||||
|
gfx::Rect GetBounds();
|
||||||
void SetSize(int width, int height);
|
void SetSize(int width, int height);
|
||||||
std::vector<int> GetSize();
|
std::vector<int> GetSize();
|
||||||
void SetContentSize(int width, int height);
|
void SetContentSize(int width, int height);
|
||||||
|
|
|
@ -113,6 +113,8 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
|
||||||
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 gfx::Rect GetBounds() = 0;
|
||||||
virtual void SetSize(const gfx::Size& size) = 0;
|
virtual void SetSize(const gfx::Size& size) = 0;
|
||||||
virtual gfx::Size GetSize() = 0;
|
virtual gfx::Size GetSize() = 0;
|
||||||
virtual void SetContentSize(const gfx::Size& size) = 0;
|
virtual void SetContentSize(const gfx::Size& size) = 0;
|
||||||
|
|
|
@ -45,6 +45,8 @@ 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;
|
||||||
|
gfx::Rect GetBounds() override;
|
||||||
void SetSize(const gfx::Size& size) override;
|
void SetSize(const gfx::Size& size) override;
|
||||||
gfx::Size GetSize() override;
|
gfx::Size GetSize() override;
|
||||||
void SetContentSize(const gfx::Size& size) override;
|
void SetContentSize(const gfx::Size& size) override;
|
||||||
|
|
|
@ -470,6 +470,15 @@ bool NativeWindowMac::IsFullscreen() const {
|
||||||
return [window_ styleMask] & NSFullScreenWindowMask;
|
return [window_ styleMask] & NSFullScreenWindowMask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NativeWindowMac::SetBounds(const gfx::Rect& bounds) {
|
||||||
|
Move(bounds);
|
||||||
|
}
|
||||||
|
|
||||||
|
gfx::Rect NativeWindowMac::GetBounds() {
|
||||||
|
return gfx::Rect(GetPosition(),
|
||||||
|
GetSize());
|
||||||
|
}
|
||||||
|
|
||||||
void NativeWindowMac::SetSize(const gfx::Size& size) {
|
void NativeWindowMac::SetSize(const gfx::Size& size) {
|
||||||
NSRect frame = [window_ frame];
|
NSRect frame = [window_ frame];
|
||||||
frame.origin.y -= size.height() - frame.size.height;
|
frame.origin.y -= size.height() - frame.size.height;
|
||||||
|
|
|
@ -373,6 +373,14 @@ bool NativeWindowViews::IsFullscreen() const {
|
||||||
return window_->IsFullscreen();
|
return window_->IsFullscreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NativeWindowViews::SetBounds(const gfx::Rect& bounds) {
|
||||||
|
window_->SetBoundsConstrained(bounds);
|
||||||
|
}
|
||||||
|
|
||||||
|
gfx::Rect NativeWindowViews::GetBounds() {
|
||||||
|
return window_->GetRestoredBounds();
|
||||||
|
}
|
||||||
|
|
||||||
void NativeWindowViews::SetSize(const gfx::Size& size) {
|
void NativeWindowViews::SetSize(const gfx::Size& size) {
|
||||||
#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
|
||||||
|
|
|
@ -50,6 +50,8 @@ 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;
|
||||||
|
gfx::Rect GetBounds() override;
|
||||||
void SetSize(const gfx::Size& size) override;
|
void SetSize(const gfx::Size& size) override;
|
||||||
gfx::Size GetSize() override;
|
gfx::Size GetSize() override;
|
||||||
void SetContentSize(const gfx::Size& size) override;
|
void SetContentSize(const gfx::Size& size) override;
|
||||||
|
|
|
@ -316,6 +316,20 @@ Sets whether the window should be in fullscreen mode.
|
||||||
|
|
||||||
Returns whether the window is in fullscreen mode.
|
Returns whether the window is in fullscreen mode.
|
||||||
|
|
||||||
|
### BrowserWindow.setBounds(options)
|
||||||
|
|
||||||
|
* `options` Object
|
||||||
|
* `x` Integer
|
||||||
|
* `y` Integer
|
||||||
|
* `width` Integer
|
||||||
|
* `height` Integer
|
||||||
|
|
||||||
|
Resizes and moves the window to `width`, `height`, `x`, `y`.
|
||||||
|
|
||||||
|
### BrowserWindow.getBounds()
|
||||||
|
|
||||||
|
Returns an object that contains window's width, height, x and y values.
|
||||||
|
|
||||||
### BrowserWindow.setSize(width, height)
|
### BrowserWindow.setSize(width, height)
|
||||||
|
|
||||||
* `width` Integer
|
* `width` Integer
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue