| OLD | NEW |
| (Empty) |
| 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_LAUNCHER_BACKGROUND_ANIMATOR_H_ | |
| 6 #define ASH_LAUNCHER_BACKGROUND_ANIMATOR_H_ | |
| 7 | |
| 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" | |
| 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 launcher and system tray to animate the | |
| 26 // background (alpha). | |
| 27 class ASH_EXPORT BackgroundAnimator : public ui::AnimationDelegate { | |
| 28 public: | |
| 29 // How the background can be changed. | |
| 30 enum ChangeType { | |
| 31 CHANGE_ANIMATE, | |
| 32 CHANGE_IMMEDIATE | |
| 33 }; | |
| 34 | |
| 35 BackgroundAnimator(BackgroundAnimatorDelegate* delegate, | |
| 36 int min_alpha, | |
| 37 int max_alpha); | |
| 38 virtual ~BackgroundAnimator(); | |
| 39 | |
| 40 // Sets whether a background is rendered. Initial value is false. If |type| | |
| 41 // is |CHANGE_IMMEDIATE| and an animation is not in progress this notifies | |
| 42 // the delegate immediately (synchronously from this method). | |
| 43 void SetPaintsBackground(bool value, ChangeType type); | |
| 44 bool paints_background() const { return paints_background_; } | |
| 45 | |
| 46 // Current alpha. | |
| 47 int alpha() const { return alpha_; } | |
| 48 | |
| 49 // ui::AnimationDelegate overrides: | |
| 50 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; | |
| 51 | |
| 52 private: | |
| 53 BackgroundAnimatorDelegate* delegate_; | |
| 54 | |
| 55 const int min_alpha_; | |
| 56 const int max_alpha_; | |
| 57 | |
| 58 ui::SlideAnimation animation_; | |
| 59 | |
| 60 // Whether the background is painted. | |
| 61 bool paints_background_; | |
| 62 | |
| 63 // Current alpha value of the background. | |
| 64 int alpha_; | |
| 65 | |
| 66 DISALLOW_COPY_AND_ASSIGN(BackgroundAnimator); | |
| 67 }; | |
| 68 | |
| 69 } // namespace internal | |
| 70 } // namespace ash | |
| 71 | |
| 72 #endif // ASH_LAUNCHER_BACKGROUND_ANIMATOR_H_ | |
| OLD | NEW |