| 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/system_modal_container_layout_manager.h" | 5 #include "ash/wm/system_modal_container_layout_manager.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "ash/session/session_state_delegate.h" | 9 #include "ash/session/session_state_delegate.h" |
| 10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 | 39 |
| 40 // The center point of the window can diverge this much from the center point | 40 // The center point of the window can diverge this much from the center point |
| 41 // of the container to be kept centered upon resizing operations. | 41 // of the container to be kept centered upon resizing operations. |
| 42 const int kCenterPixelDelta = 32; | 42 const int kCenterPixelDelta = 32; |
| 43 | 43 |
| 44 //////////////////////////////////////////////////////////////////////////////// | 44 //////////////////////////////////////////////////////////////////////////////// |
| 45 // SystemModalContainerLayoutManager, public: | 45 // SystemModalContainerLayoutManager, public: |
| 46 | 46 |
| 47 SystemModalContainerLayoutManager::SystemModalContainerLayoutManager( | 47 SystemModalContainerLayoutManager::SystemModalContainerLayoutManager( |
| 48 aura::Window* container) | 48 aura::Window* container) |
| 49 : container_(container), | 49 : SnapToPixelLayoutManager(container), |
| 50 container_(container), |
| 50 modal_background_(NULL) { | 51 modal_background_(NULL) { |
| 51 } | 52 } |
| 52 | 53 |
| 53 SystemModalContainerLayoutManager::~SystemModalContainerLayoutManager() { | 54 SystemModalContainerLayoutManager::~SystemModalContainerLayoutManager() { |
| 54 } | 55 } |
| 55 | 56 |
| 56 //////////////////////////////////////////////////////////////////////////////// | 57 //////////////////////////////////////////////////////////////////////////////// |
| 57 // SystemModalContainerLayoutManager, aura::LayoutManager implementation: | 58 // SystemModalContainerLayoutManager, aura::LayoutManager implementation: |
| 58 | 59 |
| 59 void SystemModalContainerLayoutManager::OnWindowResized() { | 60 void SystemModalContainerLayoutManager::OnWindowResized() { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 79 AddModalWindow(child); | 80 AddModalWindow(child); |
| 80 } | 81 } |
| 81 | 82 |
| 82 void SystemModalContainerLayoutManager::OnWillRemoveWindowFromLayout( | 83 void SystemModalContainerLayoutManager::OnWillRemoveWindowFromLayout( |
| 83 aura::Window* child) { | 84 aura::Window* child) { |
| 84 child->RemoveObserver(this); | 85 child->RemoveObserver(this); |
| 85 if (child->GetProperty(aura::client::kModalKey) != ui::MODAL_TYPE_NONE) | 86 if (child->GetProperty(aura::client::kModalKey) != ui::MODAL_TYPE_NONE) |
| 86 RemoveModalWindow(child); | 87 RemoveModalWindow(child); |
| 87 } | 88 } |
| 88 | 89 |
| 89 void SystemModalContainerLayoutManager::OnWindowRemovedFromLayout( | |
| 90 aura::Window* child) { | |
| 91 } | |
| 92 | |
| 93 void SystemModalContainerLayoutManager::OnChildWindowVisibilityChanged( | |
| 94 aura::Window* child, | |
| 95 bool visible) { | |
| 96 } | |
| 97 | |
| 98 void SystemModalContainerLayoutManager::SetChildBounds( | 90 void SystemModalContainerLayoutManager::SetChildBounds( |
| 99 aura::Window* child, | 91 aura::Window* child, |
| 100 const gfx::Rect& requested_bounds) { | 92 const gfx::Rect& requested_bounds) { |
| 101 SetChildBoundsDirect(child, requested_bounds); | 93 SnapToPixelLayoutManager::SetChildBounds(child, requested_bounds); |
| 102 child->SetProperty(kCenteredKey, DialogIsCentered(requested_bounds)); | 94 child->SetProperty(kCenteredKey, DialogIsCentered(requested_bounds)); |
| 103 } | 95 } |
| 104 | 96 |
| 105 //////////////////////////////////////////////////////////////////////////////// | 97 //////////////////////////////////////////////////////////////////////////////// |
| 106 // SystemModalContainerLayoutManager, aura::WindowObserver implementation: | 98 // SystemModalContainerLayoutManager, aura::WindowObserver implementation: |
| 107 | 99 |
| 108 void SystemModalContainerLayoutManager::OnWindowPropertyChanged( | 100 void SystemModalContainerLayoutManager::OnWindowPropertyChanged( |
| 109 aura::Window* window, | 101 aura::Window* window, |
| 110 const void* key, | 102 const void* key, |
| 111 intptr_t old) { | 103 intptr_t old) { |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 bool SystemModalContainerLayoutManager::DialogIsCentered( | 287 bool SystemModalContainerLayoutManager::DialogIsCentered( |
| 296 const gfx::Rect& window_bounds) { | 288 const gfx::Rect& window_bounds) { |
| 297 gfx::Point window_center = window_bounds.CenterPoint(); | 289 gfx::Point window_center = window_bounds.CenterPoint(); |
| 298 gfx::Point container_center = GetUsableDialogArea().CenterPoint(); | 290 gfx::Point container_center = GetUsableDialogArea().CenterPoint(); |
| 299 return | 291 return |
| 300 std::abs(window_center.x() - container_center.x()) < kCenterPixelDelta && | 292 std::abs(window_center.x() - container_center.x()) < kCenterPixelDelta && |
| 301 std::abs(window_center.y() - container_center.y()) < kCenterPixelDelta; | 293 std::abs(window_center.y() - container_center.y()) < kCenterPixelDelta; |
| 302 } | 294 } |
| 303 | 295 |
| 304 } // namespace ash | 296 } // namespace ash |
| OLD | NEW |