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