Chromium Code Reviews| Index: ash/wm/panel_layout_manager.cc |
| diff --git a/ash/wm/panel_layout_manager.cc b/ash/wm/panel_layout_manager.cc |
| index d793428d12e41b278e119e66eaea1f9dc6ce21d2..b4d951c4ba79e7d6ee916e0b3eef12d7deaf1f80 100644 |
| --- a/ash/wm/panel_layout_manager.cc |
| +++ b/ash/wm/panel_layout_manager.cc |
| @@ -7,6 +7,7 @@ |
| #include <algorithm> |
| #include "ash/launcher/launcher.h" |
| +#include "ash/launcher/launcher_model.h" |
| #include "ash/shell.h" |
| #include "ash/wm/property_util.h" |
| #include "base/auto_reset.h" |
| @@ -36,11 +37,15 @@ namespace internal { |
| PanelLayoutManager::PanelLayoutManager(aura::Window* panel_container) |
| : panel_container_(panel_container), |
| in_layout_(false), |
| - dragged_panel_(NULL) { |
| + dragged_panel_(NULL), |
| + ALLOW_THIS_IN_INITIALIZER_LIST(launcher_icons_observer_(this)){ |
| DCHECK(panel_container); |
| } |
| PanelLayoutManager::~PanelLayoutManager() { |
| + ash::Launcher* launcher = ash::Shell::GetInstance()->launcher(); |
|
sky
2012/03/23 21:41:14
Did you make sure this is deleted before the launc
Dmitry Lomov (no reviews)
2012/03/23 22:34:38
Hopefully the getter will return null?
|
| + if (launcher != NULL) |
| + launcher->RemoveIconsObserver(&launcher_icons_observer_); |
| } |
| void PanelLayoutManager::StartDragging(aura::Window* panel) { |
| @@ -55,6 +60,10 @@ void PanelLayoutManager::FinishDragging() { |
| Relayout(); |
| } |
| +void PanelLayoutManager::SetLauncher(ash::Launcher* launcher) { |
| + launcher->AddIconsObserver(&launcher_icons_observer_); |
| +} |
| + |
| void PanelLayoutManager::ToggleMinimize(aura::Window* panel) { |
| DCHECK(panel->parent() == panel_container_); |
| if (panel->GetProperty(aura::client::kShowStateKey) == |
| @@ -154,38 +163,31 @@ void PanelLayoutManager::Relayout() { |
| return; |
| AutoReset<bool> auto_reset_in_layout(&in_layout_, true); |
| - // Panels are currently laid out just above the launcher (if it exists), |
| - // otherwise at the bottom of the root window. |
| - int right, bottom; |
| ash::Shell* shell = ash::Shell::GetInstance(); |
| - if (shell->launcher() && shell->launcher()->widget()->IsVisible()) { |
| - const gfx::Rect& bounds = |
| - shell->launcher()->widget()->GetWindowScreenBounds(); |
| - right = bounds.width() - 1 - kPanelMarginEdge; |
| - bottom = bounds.y() - 1; |
| - } else { |
| - const gfx::Rect& bounds = panel_container_->GetRootWindow()->bounds(); |
| - right = bounds.width() - 1 - kPanelMarginEdge; |
| - bottom = bounds.bottom() - 1; |
| - } |
| - // Layout the panel windows right to left. |
| for (PanelList::iterator iter = panel_windows_.begin(); |
| iter != panel_windows_.end(); ++iter) { |
| aura::Window* panel_win = *iter; |
| + gfx::Rect icon_rect = |
| + shell->launcher()->GetScreenBoundsOfItemIconForWindow(panel_win); |
|
sky
2012/03/23 21:41:14
This may be empty.
Dmitry Lomov (no reviews)
2012/03/23 22:34:38
True. The layout manager has no idea what to do in
|
| + gfx::Point icon_origin = icon_rect.origin(); |
| + aura::Window::ConvertPointToWindow(panel_container_->GetRootWindow(), |
| + panel_container_, &icon_origin); |
| + |
| if (!panel_win->IsVisible()) |
| continue; |
| - int x = right - panel_win->bounds().width(); |
| - int y = bottom - panel_win->bounds().height(); |
| // Do not relayout dragged panel, but pretend it is in place |
| if (panel_win != dragged_panel_) { |
| - gfx::Rect bounds(x, y, |
| - panel_win->bounds().width(), |
| - panel_win->bounds().height()); |
| + gfx::Rect current_bounds = panel_win->bounds(); |
| + |
| + gfx::Rect bounds( |
| + icon_origin.x() + icon_rect.width()/2 - current_bounds.width()/2, |
| + icon_origin.y() - current_bounds.height(), |
| + current_bounds.width(), |
| + current_bounds.height()); |
| SetChildBoundsDirect(panel_win, bounds); |
| } |
| - right = x - kPanelMarginMiddle; |
| } |
| } |