| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ash/common/wm/panels/panel_layout_manager.h" | 5 #include "ash/common/wm/panels/panel_layout_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| 11 #include "ash/common/shelf/wm_shelf.h" | 11 #include "ash/common/shelf/wm_shelf.h" |
| 12 #include "ash/common/shelf/wm_shelf_util.h" | 12 #include "ash/common/shelf/wm_shelf_util.h" |
| 13 #include "ash/common/wm/overview/window_selector_controller.h" | 13 #include "ash/common/wm/overview/window_selector_controller.h" |
| 14 #include "ash/common/wm/window_animation_types.h" | 14 #include "ash/common/wm/window_animation_types.h" |
| 15 #include "ash/common/wm/window_parenting_utils.h" | 15 #include "ash/common/wm/window_parenting_utils.h" |
| 16 #include "ash/common/wm/window_state.h" | 16 #include "ash/common/wm/window_state.h" |
| 17 #include "ash/common/wm_shell.h" | 17 #include "ash/common/wm_shell.h" |
| 18 #include "ash/common/wm_window.h" | 18 #include "ash/common/wm_window.h" |
| 19 #include "ash/public/cpp/shell_window_ids.h" | 19 #include "ash/public/cpp/shell_window_ids.h" |
| 20 #include "ash/public/cpp/window_properties.h" | 20 #include "ash/public/cpp/window_properties.h" |
| 21 #include "ash/root_window_controller.h" | 21 #include "ash/root_window_controller.h" |
| 22 #include "ash/shell.h" |
| 22 #include "ash/wm/window_properties.h" | 23 #include "ash/wm/window_properties.h" |
| 23 #include "base/auto_reset.h" | 24 #include "base/auto_reset.h" |
| 24 #include "third_party/skia/include/core/SkColor.h" | 25 #include "third_party/skia/include/core/SkColor.h" |
| 25 #include "third_party/skia/include/core/SkPath.h" | 26 #include "third_party/skia/include/core/SkPath.h" |
| 26 #include "ui/compositor/scoped_layer_animation_settings.h" | 27 #include "ui/compositor/scoped_layer_animation_settings.h" |
| 27 #include "ui/gfx/canvas.h" | 28 #include "ui/gfx/canvas.h" |
| 28 #include "ui/gfx/geometry/rect.h" | 29 #include "ui/gfx/geometry/rect.h" |
| 29 #include "ui/gfx/geometry/vector2d.h" | 30 #include "ui/gfx/geometry/vector2d.h" |
| 30 #include "ui/views/background.h" | 31 #include "ui/views/background.h" |
| 31 #include "ui/views/widget/widget.h" | 32 #include "ui/views/widget/widget.h" |
| 33 #include "ui/wm/public/activation_client.h" |
| 32 | 34 |
| 33 namespace ash { | 35 namespace ash { |
| 34 namespace { | 36 namespace { |
| 35 | 37 |
| 36 const int kPanelIdealSpacing = 4; | 38 const int kPanelIdealSpacing = 4; |
| 37 | 39 |
| 38 const float kMaxHeightFactor = .80f; | 40 const float kMaxHeightFactor = .80f; |
| 39 const float kMaxWidthFactor = .50f; | 41 const float kMaxWidthFactor = .50f; |
| 40 | 42 |
| 41 // Duration for panel animations. | 43 // Duration for panel animations. |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 root_window_controller_(panel_container->GetRootWindowController()), | 244 root_window_controller_(panel_container->GetRootWindowController()), |
| 243 in_add_window_(false), | 245 in_add_window_(false), |
| 244 in_layout_(false), | 246 in_layout_(false), |
| 245 show_callout_widgets_(true), | 247 show_callout_widgets_(true), |
| 246 dragged_panel_(NULL), | 248 dragged_panel_(NULL), |
| 247 shelf_(nullptr), | 249 shelf_(nullptr), |
| 248 last_active_panel_(NULL), | 250 last_active_panel_(NULL), |
| 249 weak_factory_(this) { | 251 weak_factory_(this) { |
| 250 DCHECK(panel_container); | 252 DCHECK(panel_container); |
| 251 WmShell* shell = panel_container->GetShell(); | 253 WmShell* shell = panel_container->GetShell(); |
| 252 shell->AddActivationObserver(this); | 254 Shell::GetInstance()->activation_client()->AddObserver(this); |
| 253 shell->AddDisplayObserver(this); | 255 shell->AddDisplayObserver(this); |
| 254 shell->AddShellObserver(this); | 256 shell->AddShellObserver(this); |
| 255 } | 257 } |
| 256 | 258 |
| 257 PanelLayoutManager::~PanelLayoutManager() { | 259 PanelLayoutManager::~PanelLayoutManager() { |
| 258 Shutdown(); | 260 Shutdown(); |
| 259 } | 261 } |
| 260 | 262 |
| 261 // static | 263 // static |
| 262 PanelLayoutManager* PanelLayoutManager::Get(WmWindow* window) { | 264 PanelLayoutManager* PanelLayoutManager::Get(WmWindow* window) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 273 if (shelf_) { | 275 if (shelf_) { |
| 274 shelf_->RemoveObserver(this); | 276 shelf_->RemoveObserver(this); |
| 275 shelf_ = nullptr; | 277 shelf_ = nullptr; |
| 276 } | 278 } |
| 277 for (PanelList::iterator iter = panel_windows_.begin(); | 279 for (PanelList::iterator iter = panel_windows_.begin(); |
| 278 iter != panel_windows_.end(); ++iter) { | 280 iter != panel_windows_.end(); ++iter) { |
| 279 delete iter->callout_widget; | 281 delete iter->callout_widget; |
| 280 } | 282 } |
| 281 panel_windows_.clear(); | 283 panel_windows_.clear(); |
| 282 WmShell* shell = panel_container_->GetShell(); | 284 WmShell* shell = panel_container_->GetShell(); |
| 283 shell->RemoveActivationObserver(this); | 285 Shell::GetInstance()->activation_client()->RemoveObserver(this); |
| 284 shell->RemoveDisplayObserver(this); | 286 shell->RemoveDisplayObserver(this); |
| 285 shell->RemoveShellObserver(this); | 287 shell->RemoveShellObserver(this); |
| 286 } | 288 } |
| 287 | 289 |
| 288 void PanelLayoutManager::StartDragging(WmWindow* panel) { | 290 void PanelLayoutManager::StartDragging(WmWindow* panel) { |
| 289 DCHECK(!dragged_panel_); | 291 DCHECK(!dragged_panel_); |
| 290 dragged_panel_ = panel; | 292 dragged_panel_ = panel; |
| 291 Relayout(); | 293 Relayout(); |
| 292 } | 294 } |
| 293 | 295 |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 return; | 483 return; |
| 482 } | 484 } |
| 483 | 485 |
| 484 if (window_state->IsMinimized()) | 486 if (window_state->IsMinimized()) |
| 485 MinimizePanel(window_state->window()); | 487 MinimizePanel(window_state->window()); |
| 486 else | 488 else |
| 487 RestorePanel(window_state->window()); | 489 RestorePanel(window_state->window()); |
| 488 } | 490 } |
| 489 | 491 |
| 490 //////////////////////////////////////////////////////////////////////////////// | 492 //////////////////////////////////////////////////////////////////////////////// |
| 491 // PanelLayoutManager, WmActivationObserver implementation: | 493 // PanelLayoutManager, aura::client::ActivationChangeObserver implementation: |
| 492 | 494 |
| 493 void PanelLayoutManager::OnWindowActivated(WmWindow* gained_active, | 495 void PanelLayoutManager::OnWindowActivated(ActivationReason reason, |
| 494 WmWindow* lost_active) { | 496 aura::Window* gained_active, |
| 497 aura::Window* lost_active) { |
| 498 WmWindow* wm_gained_active = WmWindow::Get(gained_active); |
| 495 // Ignore if the panel that is not managed by this was activated. | 499 // Ignore if the panel that is not managed by this was activated. |
| 496 if (gained_active && gained_active->GetType() == ui::wm::WINDOW_TYPE_PANEL && | 500 if (wm_gained_active && |
| 497 gained_active->GetParent() == panel_container_) { | 501 wm_gained_active->GetType() == ui::wm::WINDOW_TYPE_PANEL && |
| 498 UpdateStacking(gained_active); | 502 wm_gained_active->GetParent() == panel_container_) { |
| 503 UpdateStacking(wm_gained_active); |
| 499 UpdateCallouts(); | 504 UpdateCallouts(); |
| 500 } | 505 } |
| 501 } | 506 } |
| 502 | 507 |
| 503 //////////////////////////////////////////////////////////////////////////////// | 508 //////////////////////////////////////////////////////////////////////////////// |
| 504 // PanelLayoutManager, WmDisplayObserver::Observer implementation: | 509 // PanelLayoutManager, WmDisplayObserver::Observer implementation: |
| 505 | 510 |
| 506 void PanelLayoutManager::OnDisplayConfigurationChanged() { | 511 void PanelLayoutManager::OnDisplayConfigurationChanged() { |
| 507 Relayout(); | 512 Relayout(); |
| 508 } | 513 } |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 920 } | 925 } |
| 921 } | 926 } |
| 922 // This bounds change will have caused a change to the Shelf which does not | 927 // This bounds change will have caused a change to the Shelf which does not |
| 923 // propogate automatically to this class, so manually recalculate bounds. | 928 // propogate automatically to this class, so manually recalculate bounds. |
| 924 OnWindowResized(); | 929 OnWindowResized(); |
| 925 } | 930 } |
| 926 | 931 |
| 927 void PanelLayoutManager::OnKeyboardClosed() {} | 932 void PanelLayoutManager::OnKeyboardClosed() {} |
| 928 | 933 |
| 929 } // namespace ash | 934 } // namespace ash |
| OLD | NEW |