Add initial setContentBounds method
This commit is contained in:
parent
5681ee5220
commit
52199a008d
5 changed files with 21 additions and 3 deletions
|
@ -366,6 +366,12 @@ gfx::Rect Window::GetBounds() {
|
||||||
return window_->GetBounds();
|
return window_->GetBounds();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Window::SetContentBounds(const gfx::Rect& bounds, mate::Arguments* args) {
|
||||||
|
bool animate = false;
|
||||||
|
args->GetNext(&animate);
|
||||||
|
window_->SetContentBounds(bounds, animate);
|
||||||
|
}
|
||||||
|
|
||||||
gfx::Rect Window::GetContentBounds() {
|
gfx::Rect Window::GetContentBounds() {
|
||||||
return window_->GetContentBounds();
|
return window_->GetContentBounds();
|
||||||
}
|
}
|
||||||
|
@ -790,6 +796,7 @@ void Window::BuildPrototype(v8::Isolate* isolate,
|
||||||
.SetMethod("getSize", &Window::GetSize)
|
.SetMethod("getSize", &Window::GetSize)
|
||||||
.SetMethod("setSize", &Window::SetSize)
|
.SetMethod("setSize", &Window::SetSize)
|
||||||
.SetMethod("getContentBounds", &Window::GetContentBounds)
|
.SetMethod("getContentBounds", &Window::GetContentBounds)
|
||||||
|
.SetMethod("setContentBounds", &Window::SetContentBounds)
|
||||||
.SetMethod("getContentSize", &Window::GetContentSize)
|
.SetMethod("getContentSize", &Window::GetContentSize)
|
||||||
.SetMethod("setContentSize", &Window::SetContentSize)
|
.SetMethod("setContentSize", &Window::SetContentSize)
|
||||||
.SetMethod("setMinimumSize", &Window::SetMinimumSize)
|
.SetMethod("setMinimumSize", &Window::SetMinimumSize)
|
||||||
|
|
|
@ -112,6 +112,7 @@ class Window : public mate::TrackableObject<Window>,
|
||||||
std::vector<int> GetSize();
|
std::vector<int> GetSize();
|
||||||
void SetContentSize(int width, int height, mate::Arguments* args);
|
void SetContentSize(int width, int height, mate::Arguments* args);
|
||||||
std::vector<int> GetContentSize();
|
std::vector<int> GetContentSize();
|
||||||
|
void SetContentBounds(const gfx::Rect& bounds, mate::Arguments* args);
|
||||||
gfx::Rect GetContentBounds();
|
gfx::Rect GetContentBounds();
|
||||||
void SetMinimumSize(int width, int height);
|
void SetMinimumSize(int width, int height);
|
||||||
std::vector<int> GetMinimumSize();
|
std::vector<int> GetMinimumSize();
|
||||||
|
|
|
@ -228,6 +228,10 @@ gfx::Size NativeWindow::GetContentSize() {
|
||||||
return GetContentBounds().size();
|
return GetContentBounds().size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NativeWindow::SetContentBounds(const gfx::Rect& bounds, bool animate) {
|
||||||
|
SetBounds(ContentBoundsToWindowBounds(bounds), animate);
|
||||||
|
}
|
||||||
|
|
||||||
gfx::Rect NativeWindow::GetContentBounds() {
|
gfx::Rect NativeWindow::GetContentBounds() {
|
||||||
return WindowBoundsToContentBounds(GetBounds());
|
return WindowBoundsToContentBounds(GetBounds());
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,6 +91,7 @@ class NativeWindow : public base::SupportsUserData,
|
||||||
virtual gfx::Point GetPosition();
|
virtual gfx::Point GetPosition();
|
||||||
virtual void SetContentSize(const gfx::Size& size, bool animate = false);
|
virtual void SetContentSize(const gfx::Size& size, bool animate = false);
|
||||||
virtual gfx::Size GetContentSize();
|
virtual gfx::Size GetContentSize();
|
||||||
|
virtual void SetContentBounds(const gfx::Rect& bounds, bool animate = false);
|
||||||
virtual gfx::Rect GetContentBounds();
|
virtual gfx::Rect GetContentBounds();
|
||||||
virtual void SetSizeConstraints(
|
virtual void SetSizeConstraints(
|
||||||
const extensions::SizeConstraints& size_constraints);
|
const extensions::SizeConstraints& size_constraints);
|
||||||
|
|
|
@ -1045,10 +1045,15 @@ std::vector<gfx::Rect> NativeWindowMac::CalculateNonDraggableRegions(
|
||||||
|
|
||||||
gfx::Rect NativeWindowMac::ContentBoundsToWindowBounds(
|
gfx::Rect NativeWindowMac::ContentBoundsToWindowBounds(
|
||||||
const gfx::Rect& bounds) {
|
const gfx::Rect& bounds) {
|
||||||
if (has_frame())
|
if (has_frame()) {
|
||||||
return gfx::Rect([window_ frameRectForContentRect:bounds.ToCGRect()]);
|
gfx::Rect window_bounds(
|
||||||
else
|
[window_ frameRectForContentRect:bounds.ToCGRect()]);
|
||||||
|
int frame_height = window_bounds.height() - bounds.height();
|
||||||
|
window_bounds.set_y(window_bounds.y() - frame_height);
|
||||||
|
return window_bounds;
|
||||||
|
} else {
|
||||||
return bounds;
|
return bounds;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::Rect NativeWindowMac::WindowBoundsToContentBounds(
|
gfx::Rect NativeWindowMac::WindowBoundsToContentBounds(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue