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