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 e1f600fb8df4fd8a425346e7cbe9528a56384434..131f72ccb7e21d515b9f25a85321487924026d77 100644 |
| --- a/ash/wm/panel_layout_manager.cc |
| +++ b/ash/wm/panel_layout_manager.cc |
| @@ -11,6 +11,8 @@ |
| #include "ash/shell.h" |
| #include "ash/wm/frame_painter.h" |
| #include "ash/wm/property_util.h" |
| +#include "ash/wm/window_animations.h" |
| +#include "ash/wm/window_util.h" |
| #include "base/auto_reset.h" |
| #include "base/bind.h" |
| #include "base/bind_helpers.h" |
| @@ -19,6 +21,7 @@ |
| #include "third_party/skia/include/core/SkPath.h" |
| #include "ui/aura/client/activation_client.h" |
| #include "ui/aura/client/aura_constants.h" |
| +#include "ui/aura/focus_manager.h" |
| #include "ui/aura/root_window.h" |
| #include "ui/aura/window.h" |
| #include "ui/gfx/canvas.h" |
| @@ -33,8 +36,6 @@ namespace { |
| const int kPanelMarginEdge = 4; |
| const int kPanelMarginMiddle = 8; |
| -const int kMinimizedHeight = 24; |
| - |
| const float kMaxHeightFactor = .80f; |
| const float kMaxWidthFactor = .50f; |
| @@ -107,6 +108,7 @@ void PanelLayoutManager::StartDragging(aura::Window* panel) { |
| DCHECK(!dragged_panel_); |
| DCHECK(panel->parent() == panel_container_); |
| dragged_panel_ = panel; |
| + Relayout(); |
| } |
| void PanelLayoutManager::FinishDragging() { |
| @@ -124,28 +126,10 @@ void PanelLayoutManager::ToggleMinimize(aura::Window* panel) { |
| DCHECK(panel->parent() == panel_container_); |
| if (panel->GetProperty(aura::client::kShowStateKey) == |
| ui::SHOW_STATE_MINIMIZED) { |
| - const gfx::Rect& old_bounds = panel->bounds(); |
| panel->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); |
| - |
| - gfx::Rect new_bounds(old_bounds); |
| - const gfx::Rect* restore_bounds = GetRestoreBoundsInScreen(panel); |
| - if (restore_bounds) { |
| - new_bounds.set_height(restore_bounds->height()); |
| - new_bounds.set_y(old_bounds.bottom() - restore_bounds->height()); |
| - SetChildBounds(panel, new_bounds); |
| - ClearRestoreBounds(panel); |
| - } |
| } else { |
| - const gfx::Rect& old_bounds = panel->bounds(); |
| panel->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MINIMIZED); |
| - SetRestoreBoundsInParent(panel, old_bounds); |
| - SetChildBounds(panel, |
| - gfx::Rect(old_bounds.x(), |
| - old_bounds.bottom() - kMinimizedHeight, |
| - old_bounds.width(), |
| - kMinimizedHeight)); |
| } |
| - Relayout(); |
| } |
| //////////////////////////////////////////////////////////////////////////////// |
| @@ -158,6 +142,7 @@ void PanelLayoutManager::OnWindowAddedToLayout(aura::Window* child) { |
| if (child == callout_widget_->GetNativeWindow()) |
| return; |
| panel_windows_.push_back(child); |
| + child->AddObserver(this); |
| Relayout(); |
| } |
| @@ -166,6 +151,7 @@ void PanelLayoutManager::OnWillRemoveWindowFromLayout(aura::Window* child) { |
| std::find(panel_windows_.begin(), panel_windows_.end(), child); |
| if (found != panel_windows_.end()) |
| panel_windows_.erase(found); |
| + child->RemoveObserver(this); |
| if (dragged_panel_ == child) |
| dragged_panel_ = NULL; |
| @@ -227,6 +213,22 @@ void PanelLayoutManager::OnLauncherIconPositionsChanged() { |
| Relayout(); |
| } |
| +///////////////////////////////////////////////////////////////////////////// |
| +// PanelLayoutManager, WindowObserver implementation: |
| + |
| +void PanelLayoutManager::OnWindowPropertyChanged(aura::Window* window, |
| + const void* key, |
| + intptr_t old) { |
| + if (key != aura::client::kShowStateKey) |
| + return; |
| + ui::WindowShowState new_state = |
| + window->GetProperty(aura::client::kShowStateKey); |
| + if (new_state == ui::SHOW_STATE_MINIMIZED) |
| + MinimizePanel(window); |
| + else |
| + RestorePanel(window); |
| +} |
| + |
| //////////////////////////////////////////////////////////////////////////////// |
| // PanelLayoutManager, aura::client::ActivationChangeObserver implementation: |
| void PanelLayoutManager::OnWindowActivated(aura::Window* active, |
| @@ -242,6 +244,22 @@ void PanelLayoutManager::OnWindowActivated(aura::Window* active, |
| //////////////////////////////////////////////////////////////////////////////// |
| // PanelLayoutManager private implementation: |
| + |
| +void PanelLayoutManager::MinimizePanel(aura::Window* panel) { |
| + SetWindowVisibilityAnimationType( |
| + panel, WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZE); |
|
sky
2012/11/20 02:05:05
I believe WINDOW_VISIBILITY_ANIMATION_TYPE_MINIMIZ
stevenjb
2012/11/20 21:20:58
Ash panels (now aka Utility Windows) do have a lau
|
| + panel->Hide(); |
| + if (wm::IsActiveWindow(panel)) |
| + wm::DeactivateWindow(panel); |
| + Relayout(); |
| +} |
| + |
| +void PanelLayoutManager::RestorePanel(aura::Window* panel) { |
| + panel->Show(); |
| + wm::ActivateWindow(panel); |
|
sky
2012/11/20 02:05:05
Isn't this done else where?
stevenjb
2012/11/20 21:20:58
I did some investigating and determined that this
|
| + Relayout(); |
| +} |
| + |
| void PanelLayoutManager::Relayout() { |
| if (!launcher_ || !launcher_->widget()) |
| return; |
| @@ -268,7 +286,8 @@ void PanelLayoutManager::Relayout() { |
| if (icon_bounds.IsEmpty()) |
| continue; |
| - if (panel->HasFocus()) { |
| + if (panel->HasFocus() || |
| + panel->Contains(panel->GetFocusManager()->GetFocusedWindow())) { |
| DCHECK(!active_panel); |
| active_panel = panel; |
| } |
| @@ -339,8 +358,11 @@ void PanelLayoutManager::UpdateCallout(aura::Window* active_panel) { |
| weak_factory_.InvalidateWeakPtrs(); |
| // TODO(dcheng): This doesn't account for panels in overflow. They should have |
| // a callout as well. |
| - if (!active_panel || |
| - launcher_->GetScreenBoundsOfItemIconForWindow(active_panel).IsEmpty()) { |
| + if (!active_panel) { |
| + callout_widget_->Hide(); |
| + return; |
| + } |
| + if (launcher_->GetScreenBoundsOfItemIconForWindow(active_panel).IsEmpty()) { |
| callout_widget_->Hide(); |
| return; |
| } |