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 #ifndef ASH_SHELF_BACKGROUND_ANIMATOR_H_
6 #define ASH_SHELF_BACKGROUND_ANIMATOR_H_
8 #include "ash/ash_export.h"
9 #include "base/basictypes.h"
10 #include "ui/gfx/animation/animation_delegate.h"
11 #include "ui/gfx/animation/slide_animation.h"
15 // How the background can be changed.
16 enum BackgroundAnimatorChangeType
{
17 BACKGROUND_CHANGE_ANIMATE
,
18 BACKGROUND_CHANGE_IMMEDIATE
21 // Delegate is notified any time the background changes.
22 class ASH_EXPORT BackgroundAnimatorDelegate
{
24 virtual void UpdateBackground(int alpha
) = 0;
27 virtual ~BackgroundAnimatorDelegate() {}
30 // BackgroundAnimator is used by the shelf to animate the background (alpha).
31 class ASH_EXPORT BackgroundAnimator
: public gfx::AnimationDelegate
{
33 BackgroundAnimator(BackgroundAnimatorDelegate
* delegate
,
36 virtual ~BackgroundAnimator();
38 // Sets the transition time in ms.
39 void SetDuration(int time_in_ms
);
41 // Sets whether a background is rendered. Initial value is false. If |type|
42 // is |CHANGE_IMMEDIATE| and an animation is not in progress this notifies
43 // the delegate immediately (synchronously from this method).
44 void SetPaintsBackground(bool value
, BackgroundAnimatorChangeType type
);
45 bool paints_background() const { return paints_background_
; }
48 int alpha() const { return alpha_
; }
50 // gfx::AnimationDelegate overrides:
51 virtual void AnimationProgressed(const gfx::Animation
* animation
) OVERRIDE
;
54 BackgroundAnimatorDelegate
* delegate_
;
59 gfx::SlideAnimation animation_
;
61 // Whether the background is painted.
62 bool paints_background_
;
64 // Current alpha value of the background.
67 DISALLOW_COPY_AND_ASSIGN(BackgroundAnimator
);
72 #endif // ASH_SHELF_BACKGROUND_ANIMATOR_H_