Separate Simple Backend creation from initialization.
[chromium-blink-merge.git] / ash / shelf / background_animator.h
blobdbe495a2bc31ac6332846368098c68e5fd9e591f
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/base/animation/animation_delegate.h"
11 #include "ui/base/animation/slide_animation.h"
13 namespace ash {
14 namespace internal {
16 // Delegate is notified any time the background changes.
17 class ASH_EXPORT BackgroundAnimatorDelegate {
18 public:
19 virtual void UpdateBackground(int alpha) = 0;
21 protected:
22 virtual ~BackgroundAnimatorDelegate() {}
25 // BackgroundAnimator is used by the shelf to animate the background (alpha).
26 class ASH_EXPORT BackgroundAnimator : public ui::AnimationDelegate {
27 public:
28 // How the background can be changed.
29 enum ChangeType {
30 CHANGE_ANIMATE,
31 CHANGE_IMMEDIATE
34 BackgroundAnimator(BackgroundAnimatorDelegate* delegate,
35 int min_alpha,
36 int max_alpha);
37 virtual ~BackgroundAnimator();
39 // Sets the transition time in ms.
40 void SetDuration(int time_in_ms);
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_; }
48 // Current alpha.
49 int alpha() const { return alpha_; }
51 // ui::AnimationDelegate overrides:
52 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE;
54 private:
55 BackgroundAnimatorDelegate* delegate_;
57 const int min_alpha_;
58 const int max_alpha_;
60 ui::SlideAnimation animation_;
62 // Whether the background is painted.
63 bool paints_background_;
65 // Current alpha value of the background.
66 int alpha_;
68 DISALLOW_COPY_AND_ASSIGN(BackgroundAnimator);
71 } // namespace internal
72 } // namespace ash
74 #endif // ASH_SHELF_BACKGROUND_ANIMATOR_H_