зеркало из https://github.com/electron/electron.git
Add initial setContentBounds method
This commit is contained in:
Родитель
5681ee5220
Коммит
52199a008d
|
@ -366,6 +366,12 @@ gfx::Rect 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() {
|
||||
return window_->GetContentBounds();
|
||||
}
|
||||
|
@ -790,6 +796,7 @@ void Window::BuildPrototype(v8::Isolate* isolate,
|
|||
.SetMethod("getSize", &Window::GetSize)
|
||||
.SetMethod("setSize", &Window::SetSize)
|
||||
.SetMethod("getContentBounds", &Window::GetContentBounds)
|
||||
.SetMethod("setContentBounds", &Window::SetContentBounds)
|
||||
.SetMethod("getContentSize", &Window::GetContentSize)
|
||||
.SetMethod("setContentSize", &Window::SetContentSize)
|
||||
.SetMethod("setMinimumSize", &Window::SetMinimumSize)
|
||||
|
|
|
@ -112,6 +112,7 @@ class Window : public mate::TrackableObject<Window>,
|
|||
std::vector<int> GetSize();
|
||||
void SetContentSize(int width, int height, mate::Arguments* args);
|
||||
std::vector<int> GetContentSize();
|
||||
void SetContentBounds(const gfx::Rect& bounds, mate::Arguments* args);
|
||||
gfx::Rect GetContentBounds();
|
||||
void SetMinimumSize(int width, int height);
|
||||
std::vector<int> GetMinimumSize();
|
||||
|
|
|
@ -228,6 +228,10 @@ gfx::Size NativeWindow::GetContentSize() {
|
|||
return GetContentBounds().size();
|
||||
}
|
||||
|
||||
void NativeWindow::SetContentBounds(const gfx::Rect& bounds, bool animate) {
|
||||
SetBounds(ContentBoundsToWindowBounds(bounds), animate);
|
||||
}
|
||||
|
||||
gfx::Rect NativeWindow::GetContentBounds() {
|
||||
return WindowBoundsToContentBounds(GetBounds());
|
||||
}
|
||||
|
|
|
@ -91,6 +91,7 @@ class NativeWindow : public base::SupportsUserData,
|
|||
virtual gfx::Point GetPosition();
|
||||
virtual void SetContentSize(const gfx::Size& size, bool animate = false);
|
||||
virtual gfx::Size GetContentSize();
|
||||
virtual void SetContentBounds(const gfx::Rect& bounds, bool animate = false);
|
||||
virtual gfx::Rect GetContentBounds();
|
||||
virtual void SetSizeConstraints(
|
||||
const extensions::SizeConstraints& size_constraints);
|
||||
|
|
|
@ -1045,10 +1045,15 @@ std::vector<gfx::Rect> NativeWindowMac::CalculateNonDraggableRegions(
|
|||
|
||||
gfx::Rect NativeWindowMac::ContentBoundsToWindowBounds(
|
||||
const gfx::Rect& bounds) {
|
||||
if (has_frame())
|
||||
return gfx::Rect([window_ frameRectForContentRect:bounds.ToCGRect()]);
|
||||
else
|
||||
if (has_frame()) {
|
||||
gfx::Rect window_bounds(
|
||||
[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;
|
||||
}
|
||||
}
|
||||
|
||||
gfx::Rect NativeWindowMac::WindowBoundsToContentBounds(
|
||||
|
|
Загрузка…
Ссылка в новой задаче