Chromium Code Reviews| Index: chrome/browser/ui/panels/panel_manager.cc |
| =================================================================== |
| --- chrome/browser/ui/panels/panel_manager.cc (revision 96619) |
| +++ chrome/browser/ui/panels/panel_manager.cc (working copy) |
| @@ -9,6 +9,7 @@ |
| #include "base/logging.h" |
| #include "base/memory/scoped_ptr.h" |
| #include "chrome/browser/ui/browser.h" |
| +#include "chrome/browser/ui/panels/bottom_bar.h" |
| #include "chrome/browser/ui/window_sizer.h" |
| namespace { |
| @@ -31,6 +32,10 @@ |
| // Horizontal spacing between two panels. |
| const int kPanelsHorizontalSpacing = 4; |
| +// The polling interval to check if auto-hide bottom bar becomes visible or |
| +// hidden so that we can bring up/down panels' titlebar. |
| +const int kBottomBarCheckPollingIntervalMs = 50; |
| + |
| // Single instance of PanelManager. |
| scoped_ptr<PanelManager> panel_instance; |
| } // namespace |
| @@ -44,13 +49,13 @@ |
| } |
| PanelManager::PanelManager() |
| - : max_width_(0), |
| + : auto_hide_bottom_bar_height_(0), |
| + max_width_(0), |
| max_height_(0), |
| - min_x_(0), |
| current_x_(0), |
| - bottom_edge_y_(0), |
| dragging_panel_index_(kInvalidPanelIndex), |
| - dragging_panel_original_x_(0) { |
| + dragging_panel_original_x_(0), |
| + should_check_auto_hide_bottom_bar_on_titlebar_change_(true) { |
| OnDisplayChanged(); |
| } |
| @@ -62,17 +67,23 @@ |
| void PanelManager::OnDisplayChanged() { |
| scoped_ptr<WindowSizer::MonitorInfoProvider> info_provider( |
| WindowSizer::CreateDefaultMonitorInfoProvider()); |
| - SetWorkArea(info_provider->GetPrimaryMonitorWorkArea()); |
| + gfx::Rect work_area = info_provider->GetPrimaryMonitorWorkArea(); |
| + |
| + int auto_hide_bottom_bar_height = |
| + IsBottomBarInAutoHideMode() ? GetBottomBarHeight() : 0; |
| + |
| + SetWorkArea(work_area, auto_hide_bottom_bar_height); |
| } |
| -void PanelManager::SetWorkArea(const gfx::Rect& work_area) { |
| - if (work_area == work_area_) |
| +void PanelManager::SetWorkArea(const gfx::Rect& work_area, |
| + int auto_hide_bottom_bar_height) { |
| + if (work_area == work_area_ && |
| + auto_hide_bottom_bar_height == auto_hide_bottom_bar_height_) |
| return; |
| work_area_ = work_area; |
| + auto_hide_bottom_bar_height_ = auto_hide_bottom_bar_height; |
| - min_x_ = work_area.x(); |
| current_x_ = work_area.right(); |
| - bottom_edge_y_ = work_area.bottom(); |
| max_width_ = static_cast<int>(work_area.width() * kPanelMaxWidthFactor); |
| max_height_ = static_cast<int>(work_area.height() * kPanelMaxHeightFactor); |
| @@ -273,6 +284,13 @@ |
| bool PanelManager::ShouldBringUpTitleBarForAllMinimizedPanels( |
| int mouse_x, int mouse_y) const { |
| + // We should always bring up the title-bar if the mouse is over the auto-hide |
| + // task-bar that becomes visible. |
| + if (auto_hide_bottom_bar_height_ && |
| + mouse_y >= work_area_.bottom() - auto_hide_bottom_bar_height_ && |
| + IsBottomBarFullyVisible()) |
| + return true; |
| + |
| for (Panels::const_iterator iter = panels_.begin(); |
| iter != panels_.end(); ++iter) { |
| if ((*iter)->ShouldBringUpTitleBar(mouse_x, mouse_y)) |
| @@ -281,7 +299,49 @@ |
| return false; |
| } |
| -void PanelManager::BringUpOrDownTitleBarForAllMinimizedPanels(bool bring_up) { |
| +void PanelManager::BringUpTitleBar() { |
| + // If the bottom-bar is in auto-hide mode, delay the bring-up action until |
| + // it is fully visible. We do not want both bottom bar and panel titlebar |
| + // to pop up at the same time but with different speed. |
| + if (!auto_hide_bottom_bar_height_ || |
| + !should_check_auto_hide_bottom_bar_on_titlebar_change_ || |
| + IsBottomBarFullyVisible()) { |
| + bring_up_or_down_titlebar_timer_.Stop(); |
|
Dmitry Titov
2011/08/17 22:56:38
It seems that this code actually wants to receive
jianli
2011/08/22 20:44:42
Done.
|
| + DoBringUpOrDownTitleBar(true); |
| + return; |
| + } |
| + |
| + // Start the timer if not yet. |
| + if (!bring_up_or_down_titlebar_timer_.IsRunning()) { |
| + bring_up_or_down_titlebar_timer_.Start( |
| + base::TimeDelta::FromMilliseconds(kBottomBarCheckPollingIntervalMs), |
| + this, |
| + &PanelManager::BringUpTitleBar); |
| + } |
| +} |
| + |
| +void PanelManager::BringDownTitleBar() { |
| + // If the bottom-bar is in auto-hide mode, delay the bring-down action until |
| + // it is completely hidden. We do not want both bottom bar and panel titlebar |
| + // to pop up at the same time but with different speed. |
| + if (!auto_hide_bottom_bar_height_ || |
| + !should_check_auto_hide_bottom_bar_on_titlebar_change_ || |
| + IsBottomBarHidden()) { |
| + bring_up_or_down_titlebar_timer_.Stop(); |
| + DoBringUpOrDownTitleBar(false); |
| + return; |
| + } |
| + |
| + // Start the timer if not yet. |
| + if (!bring_up_or_down_titlebar_timer_.IsRunning()) { |
| + bring_up_or_down_titlebar_timer_.Start( |
| + base::TimeDelta::FromMilliseconds(kBottomBarCheckPollingIntervalMs), |
| + this, |
| + &PanelManager::BringDownTitleBar); |
| + } |
| +} |
| + |
| +void PanelManager::DoBringUpOrDownTitleBar(bool bring_up) { |
| for (Panels::const_iterator iter = panels_.begin(); |
| iter != panels_.end(); ++iter) { |
| Panel* panel = *iter; |
| @@ -300,6 +360,14 @@ |
| } |
| } |
| +int PanelManager::GetBottomPositionPerExpansionState( |
| + Panel::ExpansionState expansion_state) const { |
| + int bottom = work_area_.bottom(); |
| + if (expansion_state != Panel::MINIMIZED) |
| + bottom -= auto_hide_bottom_bar_height_; |
| + return bottom; |
| +} |
| + |
| void PanelManager::Rearrange(Panels::iterator iter_to_start) { |
| if (iter_to_start == panels_.end()) |
| return; |
| @@ -336,9 +404,9 @@ |
| } |
| int x = current_x_ - width; |
| - int y = bottom_edge_y_ - height; |
| + int y = work_area_.bottom() - auto_hide_bottom_bar_height_ - height; |
| - if (x < min_x_) |
| + if (x < work_area_.x()) |
| return false; |
| current_x_ -= width + kPanelsHorizontalSpacing; |