Chromium Code Reviews| Index: chrome/browser/ui/panels/panel_strip.cc |
| diff --git a/chrome/browser/ui/panels/panel_strip.cc b/chrome/browser/ui/panels/panel_strip.cc |
| index 03289f1c2a6ba81c00d3936ebec19fbe4017e302..7f5c9073f05ab4e6f9495337c872fa421e28d8f0 100644 |
| --- a/chrome/browser/ui/panels/panel_strip.cc |
| +++ b/chrome/browser/ui/panels/panel_strip.cc |
| @@ -12,6 +12,7 @@ |
| #include "chrome/browser/ui/browser.h" |
| #include "chrome/browser/ui/panels/panel_manager.h" |
| #include "chrome/browser/ui/panels/panel_mouse_watcher.h" |
| +#include "chrome/browser/ui/panels/panel_overflow_strip.h" |
| #include "chrome/common/chrome_notification_types.h" |
| #include "content/public/browser/notification_service.h" |
| #include "content/public/browser/notification_source.h" |
| @@ -131,6 +132,8 @@ void PanelStrip::AddNewPanel(Panel* panel) { |
| // Keep panel visible in the strip even if overlap would occur. |
| // Panel is moved to overflow from the strip after a delay. |
| + // TODO(jianli): Enable overflow area support for other platforms. |
|
jennb
2011/12/02 19:15:00
Could you file a bug and put bug # here so we don'
jianli
2011/12/02 23:23:46
Done.
|
| +#if defined(OS_WIN) |
| if (x < display_area_.x()) { |
| x = display_area_.x(); |
| MessageLoop::current()->PostDelayedTask( |
| @@ -139,12 +142,16 @@ void PanelStrip::AddNewPanel(Panel* panel) { |
| overflow_action_factory_.GetWeakPtr(), |
| panel, |
| true), // new panel |
| - kMoveNewPanelToOverflowDelayMilliseconds); |
| + remove_delays_for_testing_ ? |
| + 0 : kMoveNewPanelToOverflowDelayMilliseconds); |
| } |
| +#endif |
| panel->Initialize(gfx::Rect(x, y, width, height)); |
| } |
| void PanelStrip::AddExistingPanel(Panel* panel) { |
| + DCHECK(panel->expansion_state() == Panel::IN_OVERFLOW); |
| + |
| gfx::Size restored_size = panel->restored_size(); |
| int height = restored_size.height(); |
| int width = restored_size.width(); |
| @@ -155,6 +162,7 @@ void PanelStrip::AddExistingPanel(Panel* panel) { |
| } |
| int y = display_area_.bottom() - height; |
| panel->SetPanelBounds(gfx::Rect(x, y, width, height)); |
| + panel->SetExpansionState(Panel::EXPANDED); |
| } |
| int PanelStrip::GetMaxPanelWidth() const { |
| @@ -205,6 +213,7 @@ bool PanelStrip::DoRemove(Panel* panel) { |
| DecrementMinimizedPanels(); |
| panels_.erase(iter); |
| + panel_manager_->OnPanelRemoved(panel); |
| return true; |
| } |
| @@ -340,20 +349,37 @@ void PanelStrip::EndDragging(bool cancelled) { |
| } |
| void PanelStrip::OnPanelExpansionStateChanged( |
| - Panel::ExpansionState old_state, Panel::ExpansionState new_state) { |
| - DCHECK_NE(new_state, old_state); |
| - switch (new_state) { |
| + Panel* panel, Panel::ExpansionState old_state) { |
| + DCHECK(panel->expansion_state() != Panel::IN_OVERFLOW); |
| + |
| + gfx::Size size = panel->restored_size(); |
|
jennb
2011/12/02 19:15:00
Should only have to modify height. Panels coming f
jianli
2011/12/02 23:23:46
I rather update both width and height since this t
|
| + switch (panel->expansion_state()) { |
| case Panel::EXPANDED: |
| - DecrementMinimizedPanels(); |
| + if (old_state == Panel::TITLE_ONLY || old_state == Panel::MINIMIZED) |
| + DecrementMinimizedPanels(); |
| break; |
| - case Panel::MINIMIZED: |
| case Panel::TITLE_ONLY: |
| + size.set_height(panel->TitleOnlyHeight()); |
| + if (old_state == Panel::EXPANDED) |
| + IncrementMinimizedPanels(); |
| + break; |
| + case Panel::MINIMIZED: |
| + size.set_height(Panel::kMinimizedPanelHeight); |
| if (old_state == Panel::EXPANDED) |
| IncrementMinimizedPanels(); |
| break; |
| default: |
| + NOTREACHED(); |
|
jennb
2011/12/02 19:15:00
nit: Don't need DCHECK up above when we have this
jianli
2011/12/02 23:23:46
Done.
|
| break; |
| } |
| + |
| + int bottom = GetBottomPositionForExpansionState(panel->expansion_state()); |
|
jennb
2011/12/02 19:15:00
nit: Use a local var for panel->expansion_state()
jianli
2011/12/02 23:23:46
Done.
|
| + gfx::Rect bounds = panel->GetBounds(); |
| + panel->SetPanelBounds( |
| + gfx::Rect(bounds.right() - size.width(), |
| + bottom - size.height(), |
| + size.width(), |
| + size.height())); |
| } |
| void PanelStrip::IncrementMinimizedPanels() { |
| @@ -603,20 +629,18 @@ void PanelStrip::MovePanelToOverflow(Panel* panel, bool is_new) { |
| if (!DoRemove(panel)) |
| return; |
| - // TODO(jianli): Replace with the real code using overflow strip. |
| - // panel_manager_->panel_overflow_strip()->AddPanel(panel, is_new); |
| + panel_manager_->panel_overflow_strip()->AddPanel(panel, is_new); |
| } |
| void PanelStrip::MovePanelsFromOverflowIfNeeded() { |
| - // TODO(jianli): Replace with the real code using overflow strip. |
| - // PanelOverflowStrip* overflow = panel_manager_->panel_overflow_strip(); |
| - // Panel* candidate; |
| - // while (candidate = overflow->FirstPanel() && |
| - // GetRightMostAvailablePosition - |
| - // candidate->GetRestoredSize().width() >= display_area_.x()) { |
| - // overflow->Remove(candidate); |
| - // AddPanel(candidate); |
| - // } |
| + PanelOverflowStrip* overflow_strip = panel_manager_->panel_overflow_strip(); |
| + Panel* overflow_panel; |
| + while ((overflow_panel = overflow_strip->first_panel()) && |
| + GetRightMostAvailablePosition() - |
| + overflow_panel->restored_size().width() >= display_area_.x()) { |
| + overflow_strip->Remove(overflow_panel); |
| + AddPanel(overflow_panel); |
| + } |
| } |
| void PanelStrip::RemoveAll() { |