| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/shelf/shelf_background_animator.h" | 5 #include "ash/common/shelf/shelf_background_animator.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "ash/animation/animation_change_type.h" | 9 #include "ash/animation/animation_change_type.h" |
| 10 #include "ash/common/shelf/shelf_background_animator_observer.h" | 10 #include "ash/common/shelf/shelf_background_animator_observer.h" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 DCHECK_EQ(animation, animator_.get()); | 91 DCHECK_EQ(animation, animator_.get()); |
| 92 SetAnimationValues(animation->GetCurrentValue()); | 92 SetAnimationValues(animation->GetCurrentValue()); |
| 93 } | 93 } |
| 94 | 94 |
| 95 void ShelfBackgroundAnimator::AnimationEnded(const gfx::Animation* animation) { | 95 void ShelfBackgroundAnimator::AnimationEnded(const gfx::Animation* animation) { |
| 96 DCHECK_EQ(animation, animator_.get()); | 96 DCHECK_EQ(animation, animator_.get()); |
| 97 SetAnimationValues(animation->GetCurrentValue()); | 97 SetAnimationValues(animation->GetCurrentValue()); |
| 98 animator_.reset(); | 98 animator_.reset(); |
| 99 } | 99 } |
| 100 | 100 |
| 101 void ShelfBackgroundAnimator::AnimationCanceled( | |
| 102 const gfx::Animation* animation) { | |
| 103 DCHECK_EQ(animation, animator_.get()); | |
| 104 SetAnimationValues(animator_->IsShowing() ? 1.0 : 0.0); | |
| 105 // Animations are only cancelled when they are being pre-empted so we don't | |
| 106 // destroy the |animator_| because it may be re-used immediately. | |
| 107 } | |
| 108 | |
| 109 void ShelfBackgroundAnimator::OnWallpaperDataChanged() {} | 101 void ShelfBackgroundAnimator::OnWallpaperDataChanged() {} |
| 110 | 102 |
| 111 void ShelfBackgroundAnimator::OnWallpaperColorsChanged() { | 103 void ShelfBackgroundAnimator::OnWallpaperColorsChanged() { |
| 112 AnimateBackground(target_background_type_, AnimationChangeType::ANIMATE); | 104 AnimateBackground(target_background_type_, AnimationChangeType::ANIMATE); |
| 113 } | 105 } |
| 114 | 106 |
| 115 void ShelfBackgroundAnimator::OnBackgroundTypeChanged( | 107 void ShelfBackgroundAnimator::OnBackgroundTypeChanged( |
| 116 ShelfBackgroundType background_type, | 108 ShelfBackgroundType background_type, |
| 117 AnimationChangeType change_type) { | 109 AnimationChangeType change_type) { |
| 118 PaintBackground(background_type, change_type); | 110 PaintBackground(background_type, change_type); |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 | 228 |
| 237 void ShelfBackgroundAnimator::SetAnimationValues(double t) { | 229 void ShelfBackgroundAnimator::SetAnimationValues(double t) { |
| 238 DCHECK_GE(t, 0.0); | 230 DCHECK_GE(t, 0.0); |
| 239 DCHECK_LE(t, 1.0); | 231 DCHECK_LE(t, 1.0); |
| 240 shelf_background_values_.UpdateCurrentValues(t); | 232 shelf_background_values_.UpdateCurrentValues(t); |
| 241 item_background_values_.UpdateCurrentValues(t); | 233 item_background_values_.UpdateCurrentValues(t); |
| 242 NotifyObservers(); | 234 NotifyObservers(); |
| 243 } | 235 } |
| 244 | 236 |
| 245 } // namespace ash | 237 } // namespace ash |
| OLD | NEW |