| 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/resize_shadow_controller.h" | 5 #include "ash/wm/resize_shadow_controller.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "ash/wm/resize_shadow.h" | 9 #include "ash/wm/resize_shadow.h" |
| 10 #include "ui/aura/window.h" | 10 #include "ui/aura/window.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 aura::Window* window, | 44 aura::Window* window, |
| 45 const gfx::Rect& old_bounds, | 45 const gfx::Rect& old_bounds, |
| 46 const gfx::Rect& new_bounds) { | 46 const gfx::Rect& new_bounds) { |
| 47 ResizeShadow* shadow = GetShadowForWindow(window); | 47 ResizeShadow* shadow = GetShadowForWindow(window); |
| 48 if (shadow) | 48 if (shadow) |
| 49 shadow->Layout(new_bounds); | 49 shadow->Layout(new_bounds); |
| 50 } | 50 } |
| 51 | 51 |
| 52 void ResizeShadowController::OnWindowDestroyed(aura::Window* window) { | 52 void ResizeShadowController::OnWindowDestroyed(aura::Window* window) { |
| 53 window_shadows_.erase(window); | 53 window_shadows_.erase(window); |
| 54 aura::WindowObserver::OnWindowDestroyed(window); |
| 54 } | 55 } |
| 55 | 56 |
| 56 ResizeShadow* ResizeShadowController::CreateShadow(aura::Window* window) { | 57 ResizeShadow* ResizeShadowController::CreateShadow(aura::Window* window) { |
| 57 linked_ptr<ResizeShadow> shadow(new ResizeShadow()); | 58 linked_ptr<ResizeShadow> shadow(new ResizeShadow()); |
| 58 window_shadows_.insert(std::make_pair(window, shadow)); | 59 window_shadows_.insert(std::make_pair(window, shadow)); |
| 59 // Attach the layers to this window. | 60 // Attach the layers to this window. |
| 60 shadow->Init(window); | 61 shadow->Init(window); |
| 61 // Ensure initial bounds are correct. | 62 // Ensure initial bounds are correct. |
| 62 shadow->Layout(window->bounds()); | 63 shadow->Layout(window->bounds()); |
| 63 // Watch for bounds changes. | 64 // Watch for bounds changes. |
| 64 window->AddObserver(this); | 65 window->AddObserver(this); |
| 65 return shadow.get(); | 66 return shadow.get(); |
| 66 } | 67 } |
| 67 | 68 |
| 68 ResizeShadow* ResizeShadowController::GetShadowForWindow(aura::Window* window) { | 69 ResizeShadow* ResizeShadowController::GetShadowForWindow(aura::Window* window) { |
| 69 WindowShadowMap::const_iterator it = window_shadows_.find(window); | 70 WindowShadowMap::const_iterator it = window_shadows_.find(window); |
| 70 return it != window_shadows_.end() ? it->second.get() : NULL; | 71 return it != window_shadows_.end() ? it->second.get() : NULL; |
| 71 } | 72 } |
| 72 | 73 |
| 73 } // namespace internal | 74 } // namespace internal |
| 74 } // namespace ash | 75 } // namespace ash |
| OLD | NEW |