🍎 allow x-axis offset to be set for sheets
This commit is contained in:
parent
f441ba2694
commit
359123458d
5 changed files with 35 additions and 13 deletions
|
@ -371,8 +371,12 @@ std::vector<int> Window::GetMaximumSize() {
|
|||
return result;
|
||||
}
|
||||
|
||||
void Window::SetSheetOffset(double offset) {
|
||||
window_->SetSheetOffset(offset);
|
||||
void Window::SetSheetOffset(double offsetY) {
|
||||
window_->SetSheetOffset(offsetY);
|
||||
}
|
||||
|
||||
void Window::SetSheetOffsets(double offsetX, double offsetY) {
|
||||
window_->SetSheetOffsets(offsetX, offsetY);
|
||||
}
|
||||
|
||||
void Window::SetResizable(bool resizable) {
|
||||
|
@ -682,6 +686,7 @@ void Window::BuildPrototype(v8::Isolate* isolate,
|
|||
.SetMethod("setMaximumSize", &Window::SetMaximumSize)
|
||||
.SetMethod("getMaximumSize", &Window::GetMaximumSize)
|
||||
.SetMethod("setSheetOffset", &Window::SetSheetOffset)
|
||||
.SetMethod("setSheetOffsets", &Window::SetSheetOffsets)
|
||||
.SetMethod("setResizable", &Window::SetResizable)
|
||||
.SetMethod("isResizable", &Window::IsResizable)
|
||||
.SetMethod("setMovable", &Window::SetMovable)
|
||||
|
|
|
@ -110,7 +110,8 @@ class Window : public mate::TrackableObject<Window>,
|
|||
std::vector<int> GetMinimumSize();
|
||||
void SetMaximumSize(int width, int height);
|
||||
std::vector<int> GetMaximumSize();
|
||||
void SetSheetOffset(double offset);
|
||||
void SetSheetOffset(double offsetY);
|
||||
void SetSheetOffsets(double offsetX, double offsetY);
|
||||
void SetResizable(bool resizable);
|
||||
bool IsResizable();
|
||||
void SetMovable(bool movable);
|
||||
|
|
|
@ -53,7 +53,8 @@ NativeWindow::NativeWindow(
|
|||
enable_larger_than_screen_(false),
|
||||
is_closed_(false),
|
||||
has_dialog_attached_(false),
|
||||
sheet_offset_(0.0),
|
||||
sheet_offset_x_(0.0),
|
||||
sheet_offset_y_(0.0),
|
||||
aspect_ratio_(0.0),
|
||||
inspectable_web_contents_(inspectable_web_contents),
|
||||
weak_factory_(this) {
|
||||
|
@ -254,12 +255,21 @@ gfx::Size NativeWindow::GetMaximumSize() {
|
|||
return GetSizeConstraints().GetMaximumSize();
|
||||
}
|
||||
|
||||
void NativeWindow::SetSheetOffset(const double offset) {
|
||||
sheet_offset_ = offset;
|
||||
void NativeWindow::SetSheetOffset(const double offsetY) {
|
||||
sheet_offset_y_ = offsetY;
|
||||
}
|
||||
|
||||
double NativeWindow::GetSheetOffset() {
|
||||
return sheet_offset_;
|
||||
void NativeWindow::SetSheetOffsets(const double offsetX, const double offsetY) {
|
||||
sheet_offset_x_ = offsetX;
|
||||
sheet_offset_y_ = offsetY;
|
||||
}
|
||||
|
||||
double NativeWindow::GetSheetOffsetX() {
|
||||
return sheet_offset_x_;
|
||||
}
|
||||
|
||||
double NativeWindow::GetSheetOffsetY() {
|
||||
return sheet_offset_y_;
|
||||
}
|
||||
|
||||
void NativeWindow::SetRepresentedFilename(const std::string& filename) {
|
||||
|
|
|
@ -123,8 +123,10 @@ class NativeWindow : public base::SupportsUserData,
|
|||
virtual gfx::Size GetMinimumSize();
|
||||
virtual void SetMaximumSize(const gfx::Size& size);
|
||||
virtual gfx::Size GetMaximumSize();
|
||||
virtual void SetSheetOffset(const double offset);
|
||||
virtual double GetSheetOffset();
|
||||
virtual void SetSheetOffset(const double offsetY);
|
||||
virtual void SetSheetOffsets(const double offsetX, const double offsetY);
|
||||
virtual double GetSheetOffsetX();
|
||||
virtual double GetSheetOffsetY();
|
||||
virtual void SetResizable(bool resizable) = 0;
|
||||
virtual bool IsResizable() = 0;
|
||||
virtual void SetMovable(bool movable) = 0;
|
||||
|
@ -320,8 +322,10 @@ class NativeWindow : public base::SupportsUserData,
|
|||
// it should be cancelled when we can prove that the window is responsive.
|
||||
base::CancelableClosure window_unresposive_closure_;
|
||||
|
||||
// Used to display sheets at the appropriate vertical offset
|
||||
double sheet_offset_;
|
||||
// Used to display sheets at the appropriate horizontal and vertical offsets
|
||||
// on OS X.
|
||||
double sheet_offset_x_;
|
||||
double sheet_offset_y_;
|
||||
|
||||
// Used to maintain the aspect ratio of a view which is inside of the
|
||||
// content view.
|
||||
|
|
|
@ -257,7 +257,9 @@ bool ScopedDisableResize::disable_resize_ = false;
|
|||
- (NSRect)window:(NSWindow*)window
|
||||
willPositionSheet:(NSWindow*)sheet usingRect:(NSRect)rect {
|
||||
NSView* view = window.contentView;
|
||||
rect.origin.y = view.frame.size.height - shell_->GetSheetOffset();
|
||||
|
||||
rect.origin.x = shell_->GetSheetOffsetX();
|
||||
rect.origin.y = view.frame.size.height - shell_->GetSheetOffsetY();
|
||||
return rect;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue