summaryrefslogtreecommitdiffstats
path: root/views
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-18 17:20:14 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-18 17:20:14 +0000
commit0c36dc12176391d8dbd7793588f766ecac8bd11b (patch)
tree90d0d7a278d66215365e29d77dc30649c73e9337 /views
parent66d8100268972df7034b931a6fa0a9a81b60e17e (diff)
downloadchromium_src-0c36dc12176391d8dbd7793588f766ecac8bd11b.zip
chromium_src-0c36dc12176391d8dbd7793588f766ecac8bd11b.tar.gz
chromium_src-0c36dc12176391d8dbd7793588f766ecac8bd11b.tar.bz2
Makes NativeFrameView implement GetPreferredSize. Without this we
don't correctly return a preferred/minimum size and the options dialog can end up getting clipped (because the cached size is too small). Also, makes the options window always use the minimum size when showing. This way if we happen to remove an option such that the dialog is smaller the dialog won't end up too big. BUG=59122 TEST=With aero enabled bring up the options dialog on M6/M7. Then bring up the options dialog with this fix enabled and make sure you don't get any clipping. Review URL: http://codereview.chromium.org/3825006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@62937 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r--views/window/native_frame_view.cc7
-rw-r--r--views/window/native_frame_view.h3
-rw-r--r--views/window/window_delegate.cc4
-rw-r--r--views/window/window_delegate.h10
-rw-r--r--views/window/window_gtk.cc2
-rw-r--r--views/window/window_win.cc28
6 files changed, 40 insertions, 14 deletions
diff --git a/views/window/native_frame_view.cc b/views/window/native_frame_view.cc
index f0bbdee..5b0d34e 100644
--- a/views/window/native_frame_view.cc
+++ b/views/window/native_frame_view.cc
@@ -51,4 +51,11 @@ void NativeFrameView::ResetWindowControls() {
// Nothing to do.
}
+gfx::Size NativeFrameView::GetPreferredSize() {
+ gfx::Size pref = frame_->GetClientView()->GetPreferredSize();
+ gfx::Rect bounds(0, 0, pref.width(), pref.height());
+ return frame_->GetNonClientView()->GetWindowBoundsForClientBounds(
+ bounds).size();
+}
+
} // namespace views
diff --git a/views/window/native_frame_view.h b/views/window/native_frame_view.h
index b20e328..07c125c 100644
--- a/views/window/native_frame_view.h
+++ b/views/window/native_frame_view.h
@@ -27,6 +27,9 @@ class NativeFrameView : public NonClientFrameView {
virtual void EnableClose(bool enable);
virtual void ResetWindowControls();
+ // View overrides:
+ virtual gfx::Size GetPreferredSize();
+
private:
// Our containing frame.
WindowWin* frame_;
diff --git a/views/window/window_delegate.cc b/views/window/window_delegate.cc
index 012dd38..1701da7 100644
--- a/views/window/window_delegate.cc
+++ b/views/window/window_delegate.cc
@@ -54,6 +54,10 @@ bool WindowDelegate::GetSavedMaximizedState(bool* maximized) const {
window_name, maximized);
}
+bool WindowDelegate::ShouldRestoreWindowSize() const {
+ return true;
+}
+
ClientView* WindowDelegate::CreateClientView(Window* window) {
return new ClientView(window, GetContentsView());
}
diff --git a/views/window/window_delegate.h b/views/window/window_delegate.h
index 826d6b7..04ac6b3 100644
--- a/views/window/window_delegate.h
+++ b/views/window/window_delegate.h
@@ -120,13 +120,19 @@ class WindowDelegate {
virtual bool GetSavedWindowBounds(gfx::Rect* bounds) const;
virtual bool GetSavedMaximizedState(bool* maximized) const;
+ // Returns true if the window's size should be restored. If this is false,
+ // only the window's origin is restored and the window is given its
+ // preferred size.
+ // Default is true.
+ virtual bool ShouldRestoreWindowSize() const;
+
// Called when the window closes.
- virtual void WindowClosing() { }
+ virtual void WindowClosing() {}
// Called when the window is destroyed. No events must be sent or received
// after this point. The delegate can use this opportunity to delete itself at
// this time if necessary.
- virtual void DeleteDelegate() { }
+ virtual void DeleteDelegate() {}
// Returns the View that is contained within this Window.
virtual View* GetContentsView() {
diff --git a/views/window/window_gtk.cc b/views/window/window_gtk.cc
index 785b1bc..3d7f788 100644
--- a/views/window/window_gtk.cc
+++ b/views/window/window_gtk.cc
@@ -455,6 +455,8 @@ void WindowGtk::SetInitialBounds(GtkWindow* parent,
const gfx::Rect& create_bounds) {
gfx::Rect saved_bounds(create_bounds.ToGdkRectangle());
if (window_delegate_->GetSavedWindowBounds(&saved_bounds)) {
+ if (!window_delegate_->ShouldRestoreWindowSize())
+ saved_bounds.set_size(non_client_view_->GetPreferredSize());
WidgetGtk::SetBounds(saved_bounds);
} else {
if (create_bounds.IsEmpty()) {
diff --git a/views/window/window_win.cc b/views/window/window_win.cc
index b9b1c61..03bf75f 100644
--- a/views/window/window_win.cc
+++ b/views/window/window_win.cc
@@ -1271,19 +1271,23 @@ void WindowWin::SetInitialBounds(const gfx::Rect& create_bounds) {
// Restore the window's placement from the controller.
gfx::Rect saved_bounds(create_bounds.ToRECT());
if (window_delegate_->GetSavedWindowBounds(&saved_bounds)) {
- // Make sure the bounds are at least the minimum size.
- if (saved_bounds.width() < minimum_size_.width()) {
- saved_bounds.SetRect(saved_bounds.x(), saved_bounds.y(),
- saved_bounds.right() + minimum_size_.width() -
- saved_bounds.width(),
- saved_bounds.bottom());
- }
+ if (!window_delegate_->ShouldRestoreWindowSize()) {
+ saved_bounds.set_size(non_client_view_->GetPreferredSize());
+ } else {
+ // Make sure the bounds are at least the minimum size.
+ if (saved_bounds.width() < minimum_size_.width()) {
+ saved_bounds.SetRect(saved_bounds.x(), saved_bounds.y(),
+ saved_bounds.right() + minimum_size_.width() -
+ saved_bounds.width(),
+ saved_bounds.bottom());
+ }
- if (saved_bounds.height() < minimum_size_.height()) {
- saved_bounds.SetRect(saved_bounds.x(), saved_bounds.y(),
- saved_bounds.right(),
- saved_bounds.bottom() + minimum_size_.height() -
- saved_bounds.height());
+ if (saved_bounds.height() < minimum_size_.height()) {
+ saved_bounds.SetRect(saved_bounds.x(), saved_bounds.y(),
+ saved_bounds.right(),
+ saved_bounds.bottom() + minimum_size_.height() -
+ saved_bounds.height());
+ }
}
// "Show state" (maximized, minimized, etc) is handled by Show().