Chromium Code Reviews| Index: chrome/browser/ui/panels/panel_browser_view.cc |
| =================================================================== |
| --- chrome/browser/ui/panels/panel_browser_view.cc (revision 90291) |
| +++ chrome/browser/ui/panels/panel_browser_view.cc (working copy) |
| @@ -17,12 +17,17 @@ |
| namespace { |
| // This value is experimental and subjective. |
| const int kSetBoundsAnimationMs = 200; |
| + |
| +// The panel can be fully minimized to 3-pixel lines. |
| +const int kFullyMinimizedHeight = 3; |
| } |
| NativePanel* Panel::CreateNativePanel(Browser* browser, Panel* panel, |
| const gfx::Rect& bounds) { |
| PanelBrowserView* view = new PanelBrowserView(browser, panel, bounds); |
| - (new BrowserFrame(view))->InitBrowserFrame(); |
| + BrowserFrame* frame = new BrowserFrame(view); |
| + frame->set_frame_type(views::Widget::FRAME_TYPE_FORCE_CUSTOM); |
|
jennb
2011/06/27 23:18:02
Curious - why did set_frame_type have to be moved
jianli
2011/06/29 01:28:12
Not needed now. Reverted.
|
| + frame->InitBrowserFrame(); |
| return view; |
| } |
| @@ -32,7 +37,7 @@ |
| panel_(panel), |
| bounds_(bounds), |
| original_height_(bounds.height()), |
| - minimized_(false), |
| + expand_state_(FULLY_RESTORED), |
| closed_(false), |
| focused_(false), |
| mouse_pressed_(false), |
| @@ -153,26 +158,26 @@ |
| } |
| void PanelBrowserView::MinimizePanel() { |
| - if (minimized_) |
| + if (expand_state_ == FULLY_MINIMIZED) |
| return; |
| + expand_state_ = FULLY_MINIMIZED; |
| - minimized_ = true; |
| - gfx::Rect bounds = GetPanelBounds(); |
| - original_height_ = bounds.height(); |
| - bounds.set_height(GetFrameView()->NonClientTopBorderHeight()); |
| - bounds.set_y(bounds.y() + original_height_ - bounds.height()); |
| - SetPanelBounds(bounds); |
| + AdjustHeight(kFullyMinimizedHeight); |
| } |
| -void PanelBrowserView::RestorePanel() { |
| - if (!minimized_) |
| - return; |
| - |
| - minimized_ = false; |
| - gfx::Rect bounds = GetPanelBounds(); |
| - bounds.set_y(bounds.y() - original_height_ + bounds.height()); |
| - bounds.set_height(original_height_); |
| - SetPanelBounds(bounds); |
| +void PanelBrowserView::RestorePanel(bool titlebar_only) { |
| + if (titlebar_only) { |
| + // It is not allowed to "restore" from full height to titlebar height. |
| + if (expand_state_ != FULLY_MINIMIZED) |
|
jennb
2011/06/27 23:18:02
Should this be a DCHECK instead?
jianli
2011/06/29 01:28:12
Not needed due to logic change.
|
| + return; |
| + expand_state_ = TITLEBAR_RESTORED; |
| + AdjustHeight(GetFrameView()->NonClientTopBorderHeight()); |
| + } else { |
| + if (expand_state_ == FULLY_RESTORED) |
| + return; |
| + expand_state_ = FULLY_RESTORED; |
| + AdjustHeight(original_height_); |
| + } |
| } |
| void PanelBrowserView::ClosePanel() { |
| @@ -269,8 +274,15 @@ |
| } |
| void PanelBrowserView::MinimizeOrRestore() { |
| - if (minimized_) |
| - panel_->Restore(); |
| + if (expand_state_ != FULLY_RESTORED) |
| + panel_->manager()->Restore(panel_.get(), false); |
| else |
| - panel_->Minimize(); |
| + panel_->manager()->Minimize(panel_.get()); |
| } |
| + |
| +void PanelBrowserView::AdjustHeight(int height) { |
| + gfx::Rect bounds = bounds_; |
| + bounds.set_y(bounds.y() + bounds.height() - height); |
| + bounds.set_height(height); |
| + SetBounds(bounds); |
| +} |