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"
11 // Duration of the background animation.
12 const int kBackgroundDurationMS
= 1000;
16 BackgroundAnimator::BackgroundAnimator(BackgroundAnimatorDelegate
* delegate
,
19 : delegate_(delegate
),
20 min_alpha_(min_alpha
),
21 max_alpha_(max_alpha
),
23 paints_background_(false),
25 animation_
.SetSlideDuration(kBackgroundDurationMS
);
28 BackgroundAnimator::~BackgroundAnimator() {
31 void BackgroundAnimator::SetDuration(int time_in_ms
) {
32 animation_
.SetSlideDuration(time_in_ms
);
35 void BackgroundAnimator::SetPaintsBackground(
36 bool value
, BackgroundAnimatorChangeType type
) {
37 if (paints_background_
== value
)
39 paints_background_
= value
;
40 if (type
== BACKGROUND_CHANGE_IMMEDIATE
&& !animation_
.is_animating()) {
41 animation_
.Reset(value
? 1.0f
: 0.0f
);
42 AnimationProgressed(&animation_
);
45 if (paints_background_
)
51 void BackgroundAnimator::AnimationProgressed(const gfx::Animation
* animation
) {
52 int alpha
= animation
->CurrentValueBetween(min_alpha_
, max_alpha_
);
56 delegate_
->UpdateBackground(alpha_
);