| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "ash/shelf/background_animator.h" | |
| 6 | |
| 7 namespace ash { | |
| 8 namespace { | |
| 9 | |
| 10 // Duration of the background animation. | |
| 11 const int kBackgroundDurationMS = 1000; | |
| 12 | |
| 13 } | |
| 14 | |
| 15 BackgroundAnimator::BackgroundAnimator(BackgroundAnimatorDelegate* delegate, | |
| 16 int min_alpha, | |
| 17 int max_alpha) | |
| 18 : delegate_(delegate), | |
| 19 min_alpha_(min_alpha), | |
| 20 max_alpha_(max_alpha), | |
| 21 animation_(this), | |
| 22 paints_background_(false), | |
| 23 alpha_(min_alpha) { | |
| 24 animation_.SetSlideDuration(kBackgroundDurationMS); | |
| 25 } | |
| 26 | |
| 27 BackgroundAnimator::~BackgroundAnimator() { | |
| 28 } | |
| 29 | |
| 30 void BackgroundAnimator::SetDuration(int time_in_ms) { | |
| 31 animation_.SetSlideDuration(time_in_ms); | |
| 32 } | |
| 33 | |
| 34 void BackgroundAnimator::SetPaintsBackground( | |
| 35 bool value, BackgroundAnimatorChangeType type) { | |
| 36 if (paints_background_ == value) | |
| 37 return; | |
| 38 paints_background_ = value; | |
| 39 if (type == BACKGROUND_CHANGE_IMMEDIATE && !animation_.is_animating()) { | |
| 40 animation_.Reset(value ? 1.0f : 0.0f); | |
| 41 AnimationProgressed(&animation_); | |
| 42 return; | |
| 43 } | |
| 44 if (paints_background_) | |
| 45 animation_.Show(); | |
| 46 else | |
| 47 animation_.Hide(); | |
| 48 } | |
| 49 | |
| 50 void BackgroundAnimator::AnimationProgressed(const gfx::Animation* animation) { | |
| 51 int alpha = animation->CurrentValueBetween(min_alpha_, max_alpha_); | |
| 52 if (alpha_ == alpha) | |
| 53 return; | |
| 54 alpha_ = alpha; | |
| 55 delegate_->UpdateBackground(alpha_); | |
| 56 } | |
| 57 | |
| 58 } // namespace ash | |
| OLD | NEW |