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
23 // Delegate is notified any time the background changes.
24 class ASH_EXPORT BackgroundAnimatorDelegate
{
26 virtual void UpdateBackground(int alpha
) = 0;
29 virtual ~BackgroundAnimatorDelegate() {}
32 // BackgroundAnimator is used by the shelf to animate the background (alpha).
33 class ASH_EXPORT BackgroundAnimator
: public gfx::AnimationDelegate
{
35 BackgroundAnimator(BackgroundAnimatorDelegate
* delegate
,
38 virtual ~BackgroundAnimator();
40 // Sets the transition time in ms.
41 void SetDuration(int time_in_ms
);
43 // Sets whether a background is rendered. Initial value is false. If |type|
44 // is |CHANGE_IMMEDIATE| and an animation is not in progress this notifies
45 // the delegate immediately (synchronously from this method).
46 void SetPaintsBackground(bool value
, BackgroundAnimatorChangeType type
);
47 bool paints_background() const { return paints_background_
; }
50 int alpha() const { return alpha_
; }
52 // gfx::AnimationDelegate overrides:
53 virtual void AnimationProgressed(const gfx::Animation
* animation
) OVERRIDE
;
56 BackgroundAnimatorDelegate
* delegate_
;
61 gfx::SlideAnimation animation_
;
63 // Whether the background is painted.
64 bool paints_background_
;
66 // Current alpha value of the background.
69 DISALLOW_COPY_AND_ASSIGN(BackgroundAnimator
);
72 } // namespace internal
75 #endif // ASH_SHELF_BACKGROUND_ANIMATOR_H_