| 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/common/material_design/material_design_controller.h" | 9 #include "ash/common/material_design/material_design_controller.h" |
| 10 #include "ash/common/shelf/shelf_background_animator_observer.h" | 10 #include "ash/common/shelf/shelf_background_animator_observer.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 ++successful_animator_count_; | 81 ++successful_animator_count_; |
| 82 DCHECK_LE(successful_animator_count_, kNumAnimators); | 82 DCHECK_LE(successful_animator_count_, kNumAnimators); |
| 83 // UpdateBackground() is only called when alpha values change, this ensures | 83 // UpdateBackground() is only called when alpha values change, this ensures |
| 84 // observers are always notified for every background change. | 84 // observers are always notified for every background change. |
| 85 OnAlphaChanged(animator, animator->alpha()); | 85 OnAlphaChanged(animator, animator->alpha()); |
| 86 } | 86 } |
| 87 | 87 |
| 88 void ShelfBackgroundAnimator::OnAlphaChanged(BackgroundAnimator* animator, | 88 void ShelfBackgroundAnimator::OnAlphaChanged(BackgroundAnimator* animator, |
| 89 int alpha) { | 89 int alpha) { |
| 90 if (animator == opaque_background_animator_.get()) { | 90 if (animator == opaque_background_animator_.get()) { |
| 91 FOR_EACH_OBSERVER(ShelfBackgroundAnimatorObserver, observers_, | 91 for (auto& observer : observers_) |
| 92 UpdateShelfOpaqueBackground(alpha)); | 92 observer.UpdateShelfOpaqueBackground(alpha); |
| 93 } else if (animator == asset_background_animator_.get()) { | 93 } else if (animator == asset_background_animator_.get()) { |
| 94 FOR_EACH_OBSERVER(ShelfBackgroundAnimatorObserver, observers_, | 94 for (auto& observer : observers_) |
| 95 UpdateShelfAssetBackground(alpha)); | 95 observer.UpdateShelfAssetBackground(alpha); |
| 96 } else if (animator == item_background_animator_.get()) { | 96 } else if (animator == item_background_animator_.get()) { |
| 97 FOR_EACH_OBSERVER(ShelfBackgroundAnimatorObserver, observers_, | 97 for (auto& observer : observers_) |
| 98 UpdateShelfItemBackground(alpha)); | 98 observer.UpdateShelfItemBackground(alpha); |
| 99 } else { | 99 } else { |
| 100 NOTREACHED(); | 100 NOTREACHED(); |
| 101 } | 101 } |
| 102 } | 102 } |
| 103 | 103 |
| 104 void ShelfBackgroundAnimator::AnimateBackground( | 104 void ShelfBackgroundAnimator::AnimateBackground( |
| 105 ShelfBackgroundType background_type, | 105 ShelfBackgroundType background_type, |
| 106 BackgroundAnimatorChangeType change_type) { | 106 BackgroundAnimatorChangeType change_type) { |
| 107 // Ensure BackgroundAnimationEnded() has been called for all the | 107 // Ensure BackgroundAnimationEnded() has been called for all the |
| 108 // BackgroundAnimators owned by this so that |successful_animator_count_| | 108 // BackgroundAnimators owned by this so that |successful_animator_count_| |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 void ShelfBackgroundAnimator::StopAnimators() { | 197 void ShelfBackgroundAnimator::StopAnimators() { |
| 198 if (opaque_background_animator_) | 198 if (opaque_background_animator_) |
| 199 opaque_background_animator_->Stop(); | 199 opaque_background_animator_->Stop(); |
| 200 if (asset_background_animator_) | 200 if (asset_background_animator_) |
| 201 asset_background_animator_->Stop(); | 201 asset_background_animator_->Stop(); |
| 202 if (item_background_animator_) | 202 if (item_background_animator_) |
| 203 item_background_animator_->Stop(); | 203 item_background_animator_->Stop(); |
| 204 } | 204 } |
| 205 | 205 |
| 206 } // namespace ash | 206 } // namespace ash |
| OLD | NEW |