- add sources.
[platform/framework/web/crosswalk.git] / src / ash / shelf / background_animator.h
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 #ifndef ASH_SHELF_BACKGROUND_ANIMATOR_H_
6 #define ASH_SHELF_BACKGROUND_ANIMATOR_H_
7
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"
12
13 namespace ash {
14 namespace internal {
15
16 // Delegate is notified any time the background changes.
17 class ASH_EXPORT BackgroundAnimatorDelegate {
18  public:
19   virtual void UpdateBackground(int alpha) = 0;
20
21  protected:
22   virtual ~BackgroundAnimatorDelegate() {}
23 };
24
25 // BackgroundAnimator is used by the shelf to animate the background (alpha).
26 class ASH_EXPORT BackgroundAnimator : public gfx::AnimationDelegate {
27  public:
28   // How the background can be changed.
29   enum ChangeType {
30     CHANGE_ANIMATE,
31     CHANGE_IMMEDIATE
32   };
33
34   BackgroundAnimator(BackgroundAnimatorDelegate* delegate,
35                      int min_alpha,
36                      int max_alpha);
37   virtual ~BackgroundAnimator();
38
39   // Sets the transition time in ms.
40   void SetDuration(int time_in_ms);
41
42   // Sets whether a background is rendered. Initial value is false. If |type|
43   // is |CHANGE_IMMEDIATE| and an animation is not in progress this notifies
44   // the delegate immediately (synchronously from this method).
45   void SetPaintsBackground(bool value, ChangeType type);
46   bool paints_background() const { return paints_background_; }
47
48   // Current alpha.
49   int alpha() const { return alpha_; }
50
51   // gfx::AnimationDelegate overrides:
52   virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE;
53
54  private:
55   BackgroundAnimatorDelegate* delegate_;
56
57   const int min_alpha_;
58   const int max_alpha_;
59
60   gfx::SlideAnimation animation_;
61
62   // Whether the background is painted.
63   bool paints_background_;
64
65   // Current alpha value of the background.
66   int alpha_;
67
68   DISALLOW_COPY_AND_ASSIGN(BackgroundAnimator);
69 };
70
71 }  // namespace internal
72 }  // namespace ash
73
74 #endif  // ASH_SHELF_BACKGROUND_ANIMATOR_H_