| 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/wallpaper/wallpaper_widget_controller.h" | 5 #include "ash/common/wallpaper/wallpaper_widget_controller.h" |
| 6 | 6 |
| 7 #include "ash/ash_export.h" | 7 #include "ash/ash_export.h" |
| 8 #include "ash/common/wallpaper/wallpaper_delegate.h" | 8 #include "ash/common/wallpaper/wallpaper_delegate.h" |
| 9 #include "ash/common/wm_shell.h" | |
| 10 #include "ash/common/wm_window.h" | 9 #include "ash/common/wm_window.h" |
| 11 #include "ash/root_window_controller.h" | 10 #include "ash/root_window_controller.h" |
| 11 #include "ash/shell.h" |
| 12 #include "ui/compositor/layer_animation_observer.h" | 12 #include "ui/compositor/layer_animation_observer.h" |
| 13 #include "ui/compositor/scoped_layer_animation_settings.h" | 13 #include "ui/compositor/scoped_layer_animation_settings.h" |
| 14 #include "ui/views/widget/widget.h" | 14 #include "ui/views/widget/widget.h" |
| 15 | 15 |
| 16 namespace ash { | 16 namespace ash { |
| 17 namespace { | 17 namespace { |
| 18 | 18 |
| 19 class ShowWallpaperAnimationObserver : public ui::ImplicitAnimationObserver, | 19 class ShowWallpaperAnimationObserver : public ui::ImplicitAnimationObserver, |
| 20 public views::WidgetObserver { | 20 public views::WidgetObserver { |
| 21 public: | 21 public: |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 SetBounds(new_bounds); | 112 SetBounds(new_bounds); |
| 113 } | 113 } |
| 114 | 114 |
| 115 void WallpaperWidgetController::StartAnimating( | 115 void WallpaperWidgetController::StartAnimating( |
| 116 RootWindowController* root_window_controller) { | 116 RootWindowController* root_window_controller) { |
| 117 if (widget_) { | 117 if (widget_) { |
| 118 ui::ScopedLayerAnimationSettings settings( | 118 ui::ScopedLayerAnimationSettings settings( |
| 119 widget_->GetLayer()->GetAnimator()); | 119 widget_->GetLayer()->GetAnimator()); |
| 120 settings.AddObserver(new ShowWallpaperAnimationObserver( | 120 settings.AddObserver(new ShowWallpaperAnimationObserver( |
| 121 root_window_controller, widget_, | 121 root_window_controller, widget_, |
| 122 WmShell::Get()->wallpaper_delegate()->ShouldShowInitialAnimation())); | 122 Shell::Get()->wallpaper_delegate()->ShouldShowInitialAnimation())); |
| 123 // When |widget_| shows, AnimateShowWindowCommon() is called to do the | 123 // When |widget_| shows, AnimateShowWindowCommon() is called to do the |
| 124 // animation. Sets transition duration to 0 to avoid animating to the | 124 // animation. Sets transition duration to 0 to avoid animating to the |
| 125 // show animation's initial values. | 125 // show animation's initial values. |
| 126 settings.SetTransitionDuration(base::TimeDelta()); | 126 settings.SetTransitionDuration(base::TimeDelta()); |
| 127 widget_->Show(); | 127 widget_->Show(); |
| 128 } | 128 } |
| 129 } | 129 } |
| 130 | 130 |
| 131 AnimatingWallpaperWidgetController::AnimatingWallpaperWidgetController( | 131 AnimatingWallpaperWidgetController::AnimatingWallpaperWidgetController( |
| 132 WallpaperWidgetController* controller) | 132 WallpaperWidgetController* controller) |
| 133 : controller_(controller) {} | 133 : controller_(controller) {} |
| 134 | 134 |
| 135 AnimatingWallpaperWidgetController::~AnimatingWallpaperWidgetController() {} | 135 AnimatingWallpaperWidgetController::~AnimatingWallpaperWidgetController() {} |
| 136 | 136 |
| 137 void AnimatingWallpaperWidgetController::StopAnimating() { | 137 void AnimatingWallpaperWidgetController::StopAnimating() { |
| 138 if (controller_) | 138 if (controller_) |
| 139 controller_->widget()->GetLayer()->GetAnimator()->StopAnimating(); | 139 controller_->widget()->GetLayer()->GetAnimator()->StopAnimating(); |
| 140 } | 140 } |
| 141 | 141 |
| 142 WallpaperWidgetController* AnimatingWallpaperWidgetController::GetController( | 142 WallpaperWidgetController* AnimatingWallpaperWidgetController::GetController( |
| 143 bool pass_ownership) { | 143 bool pass_ownership) { |
| 144 if (pass_ownership) | 144 if (pass_ownership) |
| 145 return controller_.release(); | 145 return controller_.release(); |
| 146 return controller_.get(); | 146 return controller_.get(); |
| 147 } | 147 } |
| 148 | 148 |
| 149 } // namespace ash | 149 } // namespace ash |
| OLD | NEW |