Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef ASH_SHELF_BACKGROUND_ANIMATOR_H_ | 5 #ifndef ASH_SHELF_BACKGROUND_ANIMATOR_H_ |
| 6 #define ASH_SHELF_BACKGROUND_ANIMATOR_H_ | 6 #define ASH_SHELF_BACKGROUND_ANIMATOR_H_ |
| 7 | 7 |
| 8 #include "ash/ash_export.h" | 8 #include "ash/ash_export.h" |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "ui/gfx/animation/animation_delegate.h" | 10 #include "ui/gfx/animation/animation_delegate.h" |
| 11 #include "ui/gfx/animation/slide_animation.h" | 11 #include "ui/gfx/animation/slide_animation.h" |
| 12 | 12 |
| 13 namespace ash { | 13 namespace ash { |
| 14 | |
| 15 // How the background can be changed. | |
| 16 enum BackgroundAnimatorChangeType { | |
| 17 CHANGE_ANIMATE, | |
|
oshima
2013/12/05 22:51:01
BACKGROUND_CHANGE_ANIMATE
BACKGROUND_CHANGE_IMMEDI
varkha
2013/12/05 23:42:05
Done.
| |
| 18 CHANGE_IMMEDIATE | |
| 19 }; | |
| 20 | |
| 14 namespace internal { | 21 namespace internal { |
| 15 | 22 |
| 16 // Delegate is notified any time the background changes. | 23 // Delegate is notified any time the background changes. |
| 17 class ASH_EXPORT BackgroundAnimatorDelegate { | 24 class ASH_EXPORT BackgroundAnimatorDelegate { |
| 18 public: | 25 public: |
| 19 virtual void UpdateBackground(int alpha) = 0; | 26 virtual void UpdateBackground(int alpha) = 0; |
| 20 | 27 |
| 21 protected: | 28 protected: |
| 22 virtual ~BackgroundAnimatorDelegate() {} | 29 virtual ~BackgroundAnimatorDelegate() {} |
| 23 }; | 30 }; |
| 24 | 31 |
| 25 // BackgroundAnimator is used by the shelf to animate the background (alpha). | 32 // BackgroundAnimator is used by the shelf to animate the background (alpha). |
| 26 class ASH_EXPORT BackgroundAnimator : public gfx::AnimationDelegate { | 33 class ASH_EXPORT BackgroundAnimator : public gfx::AnimationDelegate { |
| 27 public: | 34 public: |
| 28 // How the background can be changed. | |
| 29 enum ChangeType { | |
| 30 CHANGE_ANIMATE, | |
| 31 CHANGE_IMMEDIATE | |
| 32 }; | |
| 33 | |
| 34 BackgroundAnimator(BackgroundAnimatorDelegate* delegate, | 35 BackgroundAnimator(BackgroundAnimatorDelegate* delegate, |
| 35 int min_alpha, | 36 int min_alpha, |
| 36 int max_alpha); | 37 int max_alpha); |
| 37 virtual ~BackgroundAnimator(); | 38 virtual ~BackgroundAnimator(); |
| 38 | 39 |
| 39 // Sets the transition time in ms. | 40 // Sets the transition time in ms. |
| 40 void SetDuration(int time_in_ms); | 41 void SetDuration(int time_in_ms); |
| 41 | 42 |
| 42 // Sets whether a background is rendered. Initial value is false. If |type| | 43 // 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 // is |CHANGE_IMMEDIATE| and an animation is not in progress this notifies |
| 44 // the delegate immediately (synchronously from this method). | 45 // the delegate immediately (synchronously from this method). |
| 45 void SetPaintsBackground(bool value, ChangeType type); | 46 void SetPaintsBackground(bool value, BackgroundAnimatorChangeType type); |
| 46 bool paints_background() const { return paints_background_; } | 47 bool paints_background() const { return paints_background_; } |
| 47 | 48 |
| 48 // Current alpha. | 49 // Current alpha. |
| 49 int alpha() const { return alpha_; } | 50 int alpha() const { return alpha_; } |
| 50 | 51 |
| 51 // gfx::AnimationDelegate overrides: | 52 // gfx::AnimationDelegate overrides: |
| 52 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE; | 53 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE; |
| 53 | 54 |
| 54 private: | 55 private: |
| 55 BackgroundAnimatorDelegate* delegate_; | 56 BackgroundAnimatorDelegate* delegate_; |
| 56 | 57 |
| 57 const int min_alpha_; | 58 const int min_alpha_; |
| 58 const int max_alpha_; | 59 const int max_alpha_; |
| 59 | 60 |
| 60 gfx::SlideAnimation animation_; | 61 gfx::SlideAnimation animation_; |
| 61 | 62 |
| 62 // Whether the background is painted. | 63 // Whether the background is painted. |
| 63 bool paints_background_; | 64 bool paints_background_; |
| 64 | 65 |
| 65 // Current alpha value of the background. | 66 // Current alpha value of the background. |
| 66 int alpha_; | 67 int alpha_; |
| 67 | 68 |
| 68 DISALLOW_COPY_AND_ASSIGN(BackgroundAnimator); | 69 DISALLOW_COPY_AND_ASSIGN(BackgroundAnimator); |
| 69 }; | 70 }; |
| 70 | 71 |
| 71 } // namespace internal | 72 } // namespace internal |
| 72 } // namespace ash | 73 } // namespace ash |
| 73 | 74 |
| 74 #endif // ASH_SHELF_BACKGROUND_ANIMATOR_H_ | 75 #endif // ASH_SHELF_BACKGROUND_ANIMATOR_H_ |
| OLD | NEW |