| 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/wm/panels/panel_layout_manager.h" | 5 #include "ash/wm/panels/panel_layout_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "ash/screen_util.h" | 10 #include "ash/screen_util.h" |
| 11 #include "ash/shelf/shelf.h" | 11 #include "ash/shelf/shelf.h" |
| 12 #include "ash/shelf/shelf_layout_manager.h" | 12 #include "ash/shelf/shelf_layout_manager.h" |
| 13 #include "ash/shelf/shelf_types.h" | 13 #include "ash/shelf/shelf_types.h" |
| 14 #include "ash/shelf/shelf_util.h" | 14 #include "ash/shelf/shelf_util.h" |
| 15 #include "ash/shelf/shelf_widget.h" | 15 #include "ash/shelf/shelf_widget.h" |
| 16 #include "ash/shell.h" | 16 #include "ash/shell.h" |
| 17 #include "ash/shell_window_ids.h" | 17 #include "ash/shell_window_ids.h" |
| 18 #include "ash/wm/overview/window_selector_controller.h" |
| 18 #include "ash/wm/window_animations.h" | 19 #include "ash/wm/window_animations.h" |
| 19 #include "ash/wm/window_state.h" | 20 #include "ash/wm/window_state.h" |
| 20 #include "ash/wm/window_util.h" | 21 #include "ash/wm/window_util.h" |
| 21 #include "base/auto_reset.h" | 22 #include "base/auto_reset.h" |
| 22 #include "base/bind.h" | 23 #include "base/bind.h" |
| 23 #include "base/bind_helpers.h" | 24 #include "base/bind_helpers.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/SkPaint.h" | 26 #include "third_party/skia/include/core/SkPaint.h" |
| 26 #include "third_party/skia/include/core/SkPath.h" | 27 #include "third_party/skia/include/core/SkPath.h" |
| 27 #include "ui/aura/client/focus_client.h" | 28 #include "ui/aura/client/focus_client.h" |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 // PanelLayoutManager public implementation: | 257 // PanelLayoutManager public implementation: |
| 257 PanelLayoutManager::PanelLayoutManager(aura::Window* panel_container) | 258 PanelLayoutManager::PanelLayoutManager(aura::Window* panel_container) |
| 258 : panel_container_(panel_container), | 259 : panel_container_(panel_container), |
| 259 in_add_window_(false), | 260 in_add_window_(false), |
| 260 in_layout_(false), | 261 in_layout_(false), |
| 261 show_callout_widgets_(true), | 262 show_callout_widgets_(true), |
| 262 dragged_panel_(NULL), | 263 dragged_panel_(NULL), |
| 263 shelf_(NULL), | 264 shelf_(NULL), |
| 264 shelf_layout_manager_(NULL), | 265 shelf_layout_manager_(NULL), |
| 265 last_active_panel_(NULL), | 266 last_active_panel_(NULL), |
| 266 weak_factory_(this) { | 267 weak_factory_(this), |
| 268 overview_mode_active_(false) { |
| 267 DCHECK(panel_container); | 269 DCHECK(panel_container); |
| 268 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())-> | 270 aura::client::GetActivationClient(Shell::GetPrimaryRootWindow())-> |
| 269 AddObserver(this); | 271 AddObserver(this); |
| 270 Shell::GetInstance()->display_controller()->AddObserver(this); | 272 Shell::GetInstance()->display_controller()->AddObserver(this); |
| 271 Shell::GetInstance()->AddShellObserver(this); | 273 Shell::GetInstance()->AddShellObserver(this); |
| 272 } | 274 } |
| 273 | 275 |
| 274 PanelLayoutManager::~PanelLayoutManager() { | 276 PanelLayoutManager::~PanelLayoutManager() { |
| 275 Shutdown(); | 277 Shutdown(); |
| 276 } | 278 } |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 void PanelLayoutManager::OnShelfIconPositionsChanged() { | 459 void PanelLayoutManager::OnShelfIconPositionsChanged() { |
| 458 // TODO: As this is called for every animation step now. Relayout needs to be | 460 // TODO: As this is called for every animation step now. Relayout needs to be |
| 459 // updated to use current icon position instead of use the ideal bounds so | 461 // updated to use current icon position instead of use the ideal bounds so |
| 460 // that the panels slide with their icons instead of jumping. | 462 // that the panels slide with their icons instead of jumping. |
| 461 Relayout(); | 463 Relayout(); |
| 462 } | 464 } |
| 463 | 465 |
| 464 //////////////////////////////////////////////////////////////////////////////// | 466 //////////////////////////////////////////////////////////////////////////////// |
| 465 // PanelLayoutManager, ash::ShellObserver implementation: | 467 // PanelLayoutManager, ash::ShellObserver implementation: |
| 466 | 468 |
| 469 void PanelLayoutManager::OnOverviewModeStarting() { |
| 470 overview_mode_active_ = true; |
| 471 } |
| 472 |
| 473 void PanelLayoutManager::OnOverviewModeEnding() { |
| 474 overview_mode_active_ = false; |
| 475 Relayout(); |
| 476 } |
| 477 |
| 467 void PanelLayoutManager::OnShelfAlignmentChanged(aura::Window* root_window) { | 478 void PanelLayoutManager::OnShelfAlignmentChanged(aura::Window* root_window) { |
| 468 if (panel_container_->GetRootWindow() == root_window) | 479 if (panel_container_->GetRootWindow() == root_window) |
| 469 Relayout(); | 480 Relayout(); |
| 470 } | 481 } |
| 471 | 482 |
| 472 ///////////////////////////////////////////////////////////////////////////// | 483 ///////////////////////////////////////////////////////////////////////////// |
| 473 // PanelLayoutManager, WindowObserver implementation: | 484 // PanelLayoutManager, WindowObserver implementation: |
| 474 | 485 |
| 475 void PanelLayoutManager::OnWindowPropertyChanged(aura::Window* window, | 486 void PanelLayoutManager::OnWindowPropertyChanged(aura::Window* window, |
| 476 const void* key, | 487 const void* key, |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 592 std::find(panel_windows_.begin(), panel_windows_.end(), panel); | 603 std::find(panel_windows_.begin(), panel_windows_.end(), panel); |
| 593 DCHECK(found != panel_windows_.end()); | 604 DCHECK(found != panel_windows_.end()); |
| 594 found->slide_in = true; | 605 found->slide_in = true; |
| 595 Relayout(); | 606 Relayout(); |
| 596 } | 607 } |
| 597 | 608 |
| 598 void PanelLayoutManager::Relayout() { | 609 void PanelLayoutManager::Relayout() { |
| 599 if (!shelf_ || !shelf_->shelf_widget()) | 610 if (!shelf_ || !shelf_->shelf_widget()) |
| 600 return; | 611 return; |
| 601 | 612 |
| 602 if (in_layout_) | 613 // Suppress layouts during overview mode because changing window bounds |
| 614 // interfered with overview mode animations. However, layouts need to be done |
| 615 // when the WindowSelectorController is restoring minimized windows so that |
| 616 // they actually become visible. |
| 617 if (in_layout_ || (overview_mode_active_ && !Shell::GetInstance()-> |
| 618 window_selector_controller()->IsRestoringMinimizedWindows())) |
| 603 return; | 619 return; |
| 604 base::AutoReset<bool> auto_reset_in_layout(&in_layout_, true); | 620 base::AutoReset<bool> auto_reset_in_layout(&in_layout_, true); |
| 605 | 621 |
| 606 ShelfAlignment alignment = shelf_->shelf_widget()->GetAlignment(); | 622 ShelfAlignment alignment = shelf_->shelf_widget()->GetAlignment(); |
| 607 bool horizontal = alignment == SHELF_ALIGNMENT_TOP || | 623 bool horizontal = alignment == SHELF_ALIGNMENT_TOP || |
| 608 alignment == SHELF_ALIGNMENT_BOTTOM; | 624 alignment == SHELF_ALIGNMENT_BOTTOM; |
| 609 gfx::Rect shelf_bounds = ash::ScreenUtil::ConvertRectFromScreen( | 625 gfx::Rect shelf_bounds = ash::ScreenUtil::ConvertRectFromScreen( |
| 610 panel_container_, shelf_->shelf_widget()->GetWindowBoundsInScreen()); | 626 panel_container_, shelf_->shelf_widget()->GetWindowBoundsInScreen()); |
| 611 int panel_start_bounds = kPanelIdealSpacing; | 627 int panel_start_bounds = kPanelIdealSpacing; |
| 612 int panel_end_bounds = horizontal ? | 628 int panel_end_bounds = horizontal ? |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 936 // Keyboard hidden, restore original bounds if they exist. | 952 // Keyboard hidden, restore original bounds if they exist. |
| 937 SetChildBounds(panel, panel_state->GetRestoreBoundsInScreen()); | 953 SetChildBounds(panel, panel_state->GetRestoreBoundsInScreen()); |
| 938 } | 954 } |
| 939 } | 955 } |
| 940 // This bounds change will have caused a change to the Shelf which does not | 956 // This bounds change will have caused a change to the Shelf which does not |
| 941 // propogate automatically to this class, so manually recalculate bounds. | 957 // propogate automatically to this class, so manually recalculate bounds. |
| 942 OnWindowResized(); | 958 OnWindowResized(); |
| 943 } | 959 } |
| 944 | 960 |
| 945 } // namespace ash | 961 } // namespace ash |
| OLD | NEW |