Add BrowserWindow::setContentSize.
This commit is contained in:
parent
511a49f6fb
commit
5150fd6946
9 changed files with 33 additions and 1 deletions
|
@ -181,6 +181,10 @@ std::vector<int> Window::GetSize() {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Window::SetContentSize(int width, int height) {
|
||||||
|
window_->SetContentSize(gfx::Size(width, height));
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<int> Window::GetContentSize() {
|
std::vector<int> Window::GetContentSize() {
|
||||||
std::vector<int> result(2);
|
std::vector<int> result(2);
|
||||||
gfx::Size size = window_->GetContentSize();
|
gfx::Size size = window_->GetContentSize();
|
||||||
|
@ -339,8 +343,9 @@ void Window::BuildPrototype(v8::Isolate* isolate,
|
||||||
.SetMethod("setFullScreen", &Window::SetFullscreen)
|
.SetMethod("setFullScreen", &Window::SetFullscreen)
|
||||||
.SetMethod("isFullScreen", &Window::IsFullscreen)
|
.SetMethod("isFullScreen", &Window::IsFullscreen)
|
||||||
.SetMethod("getSize", &Window::GetSize)
|
.SetMethod("getSize", &Window::GetSize)
|
||||||
.SetMethod("getContentSize", &Window::GetContentSize)
|
|
||||||
.SetMethod("setSize", &Window::SetSize)
|
.SetMethod("setSize", &Window::SetSize)
|
||||||
|
.SetMethod("getContentSize", &Window::GetContentSize)
|
||||||
|
.SetMethod("setContentSize", &Window::SetContentSize)
|
||||||
.SetMethod("setMinimumSize", &Window::SetMinimumSize)
|
.SetMethod("setMinimumSize", &Window::SetMinimumSize)
|
||||||
.SetMethod("getMinimumSize", &Window::GetMinimumSize)
|
.SetMethod("getMinimumSize", &Window::GetMinimumSize)
|
||||||
.SetMethod("setMaximumSize", &Window::SetMaximumSize)
|
.SetMethod("setMaximumSize", &Window::SetMaximumSize)
|
||||||
|
|
|
@ -73,6 +73,7 @@ class Window : public mate::EventEmitter,
|
||||||
bool IsFullscreen();
|
bool IsFullscreen();
|
||||||
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);
|
||||||
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();
|
||||||
|
|
|
@ -111,6 +111,7 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
|
||||||
virtual bool IsFullscreen() = 0;
|
virtual bool IsFullscreen() = 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 gfx::Size GetContentSize() = 0;
|
virtual gfx::Size GetContentSize() = 0;
|
||||||
virtual void SetMinimumSize(const gfx::Size& size) = 0;
|
virtual void SetMinimumSize(const gfx::Size& size) = 0;
|
||||||
virtual gfx::Size GetMinimumSize() = 0;
|
virtual gfx::Size GetMinimumSize() = 0;
|
||||||
|
|
|
@ -262,6 +262,11 @@ gfx::Size NativeWindowGtk::GetSize() {
|
||||||
return gfx::Size(frame_extents.width, frame_extents.height);
|
return gfx::Size(frame_extents.width, frame_extents.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NativeWindowGtk::SetContentSize(const gfx::Size& size) {
|
||||||
|
GtkAllocation size = { 0, 0, size.width(), size.height() };
|
||||||
|
gtk_widget_size_allocate(GetWebContents()->GetView()->GetNativeView(), &size);
|
||||||
|
}
|
||||||
|
|
||||||
gfx::Size NativeWindowGtk::GetContentSize() {
|
gfx::Size NativeWindowGtk::GetContentSize() {
|
||||||
gint width, height;
|
gint width, height;
|
||||||
gtk_window_get_size(window_, &width, &height);
|
gtk_window_get_size(window_, &width, &height);
|
||||||
|
|
|
@ -46,6 +46,7 @@ class NativeWindowGtk : public NativeWindow,
|
||||||
virtual bool IsFullscreen() OVERRIDE;
|
virtual bool IsFullscreen() OVERRIDE;
|
||||||
virtual void SetSize(const gfx::Size& size) OVERRIDE;
|
virtual void SetSize(const gfx::Size& size) OVERRIDE;
|
||||||
virtual gfx::Size GetSize() OVERRIDE;
|
virtual gfx::Size GetSize() OVERRIDE;
|
||||||
|
virtual void SetContentSize(const gfx::Size& size) OVERRIDE;
|
||||||
virtual gfx::Size GetContentSize() OVERRIDE;
|
virtual gfx::Size GetContentSize() OVERRIDE;
|
||||||
virtual void SetMinimumSize(const gfx::Size& size) OVERRIDE;
|
virtual void SetMinimumSize(const gfx::Size& size) OVERRIDE;
|
||||||
virtual gfx::Size GetMinimumSize() OVERRIDE;
|
virtual gfx::Size GetMinimumSize() OVERRIDE;
|
||||||
|
|
|
@ -38,6 +38,7 @@ class NativeWindowMac : public NativeWindow {
|
||||||
virtual bool IsFullscreen() OVERRIDE;
|
virtual bool IsFullscreen() OVERRIDE;
|
||||||
virtual void SetSize(const gfx::Size& size) OVERRIDE;
|
virtual void SetSize(const gfx::Size& size) OVERRIDE;
|
||||||
virtual gfx::Size GetSize() OVERRIDE;
|
virtual gfx::Size GetSize() OVERRIDE;
|
||||||
|
virtual void SetContentSize(const gfx::Size& size) OVERRIDE;
|
||||||
virtual gfx::Size GetContentSize() OVERRIDE;
|
virtual gfx::Size GetContentSize() OVERRIDE;
|
||||||
virtual void SetMinimumSize(const gfx::Size& size) OVERRIDE;
|
virtual void SetMinimumSize(const gfx::Size& size) OVERRIDE;
|
||||||
virtual gfx::Size GetMinimumSize() OVERRIDE;
|
virtual gfx::Size GetMinimumSize() OVERRIDE;
|
||||||
|
|
|
@ -305,6 +305,19 @@ gfx::Size NativeWindowMac::GetSize() {
|
||||||
return gfx::Size(frame.size.width, frame.size.height);
|
return gfx::Size(frame.size.width, frame.size.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NativeWindowMac::SetContentSize(const gfx::Size& size) {
|
||||||
|
NSRect frame_nsrect = [window_ frame];
|
||||||
|
NSSize frame = frame_nsrect.size;
|
||||||
|
NSSize content = [window_ contentRectForFrameRect:frame_nsrect].size;
|
||||||
|
|
||||||
|
int width = size.width() + frame.width - content.width;
|
||||||
|
int height = size.height() + frame.height - content.height;
|
||||||
|
frame_nsrect.origin.y -= height - frame_nsrect.size.height;
|
||||||
|
frame_nsrect.size.width = width;
|
||||||
|
frame_nsrect.size.height = height;
|
||||||
|
[window_ setFrame:frame_nsrect display:YES];
|
||||||
|
}
|
||||||
|
|
||||||
gfx::Size NativeWindowMac::GetContentSize() {
|
gfx::Size NativeWindowMac::GetContentSize() {
|
||||||
NSRect bounds = [[window_ contentView] bounds];
|
NSRect bounds = [[window_ contentView] bounds];
|
||||||
return gfx::Size(bounds.size.width, bounds.size.height);
|
return gfx::Size(bounds.size.width, bounds.size.height);
|
||||||
|
|
|
@ -295,6 +295,10 @@ gfx::Size NativeWindowWin::GetSize() {
|
||||||
return window_->GetWindowBoundsInScreen().size();
|
return window_->GetWindowBoundsInScreen().size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NativeWindowWin::SetContentSize(const gfx::Size& size) {
|
||||||
|
// FIXME
|
||||||
|
}
|
||||||
|
|
||||||
gfx::Size NativeWindowWin::GetContentSize() {
|
gfx::Size NativeWindowWin::GetContentSize() {
|
||||||
return window_->GetClientAreaBoundsInScreen().size();
|
return window_->GetClientAreaBoundsInScreen().size();
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,6 +53,7 @@ class NativeWindowWin : public NativeWindow,
|
||||||
virtual bool IsFullscreen() OVERRIDE;
|
virtual bool IsFullscreen() OVERRIDE;
|
||||||
virtual void SetSize(const gfx::Size& size) OVERRIDE;
|
virtual void SetSize(const gfx::Size& size) OVERRIDE;
|
||||||
virtual gfx::Size GetSize() OVERRIDE;
|
virtual gfx::Size GetSize() OVERRIDE;
|
||||||
|
virtual void SetContentSize(const gfx::Size& size) OVERRIDE;
|
||||||
virtual gfx::Size GetContentSize() OVERRIDE;
|
virtual gfx::Size GetContentSize() OVERRIDE;
|
||||||
virtual void SetMinimumSize(const gfx::Size& size) OVERRIDE;
|
virtual void SetMinimumSize(const gfx::Size& size) OVERRIDE;
|
||||||
virtual gfx::Size GetMinimumSize() OVERRIDE;
|
virtual gfx::Size GetMinimumSize() OVERRIDE;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue