Deleted check for if Aes128Gcm12Encrypter::IsSupported or not beacuse we
[chromium-blink-merge.git] / ash / shelf / background_animator.cc
blob35e5fba3a74e8699fd5e072efb6419c0269ef09f
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.
5 #include "ash/shelf/background_animator.h"
8 namespace ash {
9 namespace internal {
11 namespace {
13 // Duration of the background animation.
14 const int kBackgroundDurationMS = 1000;
18 BackgroundAnimator::BackgroundAnimator(BackgroundAnimatorDelegate* delegate,
19 int min_alpha,
20 int max_alpha)
21 : delegate_(delegate),
22 min_alpha_(min_alpha),
23 max_alpha_(max_alpha),
24 animation_(this),
25 paints_background_(false),
26 alpha_(min_alpha) {
27 animation_.SetSlideDuration(kBackgroundDurationMS);
30 BackgroundAnimator::~BackgroundAnimator() {
33 void BackgroundAnimator::SetDuration(int time_in_ms) {
34 animation_.SetSlideDuration(time_in_ms);
37 void BackgroundAnimator::SetPaintsBackground(bool value, ChangeType type) {
38 if (paints_background_ == value)
39 return;
40 paints_background_ = value;
41 if (type == CHANGE_IMMEDIATE && !animation_.is_animating()) {
42 animation_.Reset(value ? 1.0f : 0.0f);
43 AnimationProgressed(&animation_);
44 return;
46 if (paints_background_)
47 animation_.Show();
48 else
49 animation_.Hide();
52 void BackgroundAnimator::AnimationProgressed(const gfx::Animation* animation) {
53 int alpha = animation->CurrentValueBetween(min_alpha_, max_alpha_);
54 if (alpha_ == alpha)
55 return;
56 alpha_ = alpha;
57 delegate_->UpdateBackground(alpha_);
60 } // namespace internal
61 } // namespace ash