Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(276)

Side by Side Diff: ash/common/wm/background_animator.h

Issue 2053113002: Replaced BackgroundAnimator with ShelfBackgroundAnimator. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moved ash/test/material_design_controller_test_api.(h|cc) to ash/common/material_design/test/. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_COMMON_WM_BACKGROUND_ANIMATOR_H_ 5 #ifndef ASH_COMMON_WM_BACKGROUND_ANIMATOR_H_
6 #define ASH_COMMON_WM_BACKGROUND_ANIMATOR_H_ 6 #define ASH_COMMON_WM_BACKGROUND_ANIMATOR_H_
7 7
8 #include "ash/ash_export.h" 8 #include "ash/ash_export.h"
9 #include "base/macros.h" 9 #include "base/macros.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 #include "ui/gfx/animation/tween.h"
James Cook 2016/06/14 17:50:02 do you need this?
bruthig 2016/07/26 19:50:02 Whoops, removed.
12 13
13 namespace ash { 14 namespace ash {
14 15
15 // How the background can be changed. 16 // How the background can be changed.
16 enum BackgroundAnimatorChangeType { 17 enum BackgroundAnimatorChangeType {
17 BACKGROUND_CHANGE_ANIMATE, 18 BACKGROUND_CHANGE_ANIMATE,
18 BACKGROUND_CHANGE_IMMEDIATE 19 BACKGROUND_CHANGE_IMMEDIATE
19 }; 20 };
20 21
22 class BackgroundAnimator;
23
21 // Delegate is notified any time the background changes. 24 // Delegate is notified any time the background changes.
22 class ASH_EXPORT BackgroundAnimatorDelegate { 25 class ASH_EXPORT BackgroundAnimatorDelegate {
23 public: 26 public:
24 virtual void UpdateBackground(int alpha) = 0; 27 virtual void UpdateBackground(BackgroundAnimator* animator, int alpha) = 0;
28
29 virtual void BackgroundAnimationEnded(BackgroundAnimator* animator,
James Cook 2016/06/14 17:50:02 optional: Consider making this Ended vs. Canceled
bruthig 2016/07/26 19:50:02 Canceled isn't actually needed so it has been remo
30 bool successful) = 0;
25 31
26 protected: 32 protected:
27 virtual ~BackgroundAnimatorDelegate() {} 33 virtual ~BackgroundAnimatorDelegate() {}
28 }; 34 };
29 35
30 // BackgroundAnimator is used by the shelf to animate the background (alpha). 36 // BackgroundAnimator is used by the shelf to animate the background (alpha).
31 class ASH_EXPORT BackgroundAnimator : public gfx::AnimationDelegate { 37 class ASH_EXPORT BackgroundAnimator : public gfx::AnimationDelegate {
32 public: 38 public:
33 BackgroundAnimator(BackgroundAnimatorDelegate* delegate, 39 BackgroundAnimator(BackgroundAnimatorDelegate* delegate,
34 int min_alpha, 40 int min_alpha,
35 int max_alpha); 41 int max_alpha);
36 ~BackgroundAnimator() override; 42 ~BackgroundAnimator() override;
37 43
38 // Sets the transition time in ms. 44 // Sets the transition time in ms.
39 void SetDuration(int time_in_ms); 45 void SetDuration(int time_in_ms);
40 46
47 // Stops the animation. Does nothing if the animation is not running.
48 void Stop();
49
41 // Sets whether a background is rendered. Initial value is false. If |type| 50 // Sets whether a background is rendered. Initial value is false. If |type|
42 // is |CHANGE_IMMEDIATE| and an animation is not in progress this notifies 51 // is |CHANGE_IMMEDIATE| and an animation is not in progress this notifies
43 // the delegate immediately (synchronously from this method). 52 // the delegate immediately (synchronously from this method).
44 void SetPaintsBackground(bool value, BackgroundAnimatorChangeType type); 53 void SetPaintsBackground(bool value, BackgroundAnimatorChangeType type);
45 bool paints_background() const { return paints_background_; } 54 bool paints_background() const { return paints_background_; }
46 55
47 // Current alpha. 56 // Current alpha.
48 int alpha() const { return alpha_; } 57 int alpha() const { return alpha_; }
49 58
50 // gfx::AnimationDelegate overrides: 59 // gfx::AnimationDelegate overrides:
51 void AnimationProgressed(const gfx::Animation* animation) override; 60 void AnimationProgressed(const gfx::Animation* animation) override;
61 void AnimationEnded(const gfx::Animation* animation) override;
62 void AnimationCanceled(const gfx::Animation* animation) override;
52 63
53 private: 64 private:
54 BackgroundAnimatorDelegate* delegate_; 65 BackgroundAnimatorDelegate* delegate_;
55 66
56 const int min_alpha_; 67 const int min_alpha_;
57 const int max_alpha_; 68 const int max_alpha_;
58 69
59 gfx::SlideAnimation animation_; 70 gfx::SlideAnimation animation_;
60 71
61 // Whether the background is painted. 72 // Whether the background is painted.
62 bool paints_background_; 73 bool paints_background_;
63 74
64 // Current alpha value of the background. 75 // Current alpha value of the background.
65 int alpha_; 76 int alpha_;
66 77
67 DISALLOW_COPY_AND_ASSIGN(BackgroundAnimator); 78 DISALLOW_COPY_AND_ASSIGN(BackgroundAnimator);
68 }; 79 };
69 80
70 } // namespace ash 81 } // namespace ash
71 82
72 #endif // ASH_COMMON_WM_BACKGROUND_ANIMATOR_H_ 83 #endif // ASH_COMMON_WM_BACKGROUND_ANIMATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698