From d0c07ee9cdb1101244e3b5b4e5322e46cb735163 Mon Sep 17 00:00:00 2001 From: "pfeldman@chromium.org" Date: Thu, 16 Jul 2009 16:47:32 +0000 Subject: SingleSplitView: survive minimize / restore when resize changes leading bounds. BUG=16855 Review URL: http://codereview.chromium.org/155629 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20872 0039d316-1c4b-4281-b951-d872f2087c98 --- views/controls/single_split_view.cc | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/views/controls/single_split_view.cc b/views/controls/single_split_view.cc index 7915171..30ecc34 100644 --- a/views/controls/single_split_view.cc +++ b/views/controls/single_split_view.cc @@ -35,13 +35,20 @@ SingleSplitView::SingleSplitView(View* leading, void SingleSplitView::DidChangeBounds(const gfx::Rect& previous, const gfx::Rect& current) { if (resize_leading_on_bounds_change_) { - if (is_horizontal_) - divider_offset_ += current.width() - previous.width(); - else - divider_offset_ += current.height() - previous.height(); - - if (divider_offset_ < 0) - divider_offset_ = kDividerSize; + // We do not update divider_offset_ on minimize (to zero) and on restore + // (to largest value). As a result we get back to the original value upon + // window restore. + bool is_minimize_or_restore = + previous.height() == 0 || current.height() == 0; + if (!is_minimize_or_restore) { + if (is_horizontal_) + divider_offset_ += current.width() - previous.width(); + else + divider_offset_ += current.height() - previous.height(); + + if (divider_offset_ < 0) + divider_offset_ = kDividerSize; + } } View::DidChangeBounds(previous, current); } @@ -56,7 +63,10 @@ void SingleSplitView::Layout() { if (!leading->IsVisible() && !trailing->IsVisible()) return; - if (!trailing->IsVisible()) { + if (width() == 0 || height() == 0) { + // We are most likely minimized - do not touch divider offset. + return; + } else if (!trailing->IsVisible()) { leading->SetBounds(0, 0, width(), height()); } else if (!leading->IsVisible()) { trailing->SetBounds(0, 0, width(), height()); -- cgit v1.1