OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 UI_BASE_ANIMATION_LINEAR_ANIMATION_H_ | 5 #ifndef UI_BASE_ANIMATION_LINEAR_ANIMATION_H_ |
6 #define UI_BASE_ANIMATION_LINEAR_ANIMATION_H_ | 6 #define UI_BASE_ANIMATION_LINEAR_ANIMATION_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/time.h" | 9 #include "base/time.h" |
10 #include "ui/base/animation/animation.h" | 10 #include "ui/base/animation/animation.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 // duration can change between calls to Start() and we need to | 24 // duration can change between calls to Start() and we need to |
25 // expose this interface. | 25 // expose this interface. |
26 LinearAnimation(int frame_rate, AnimationDelegate* delegate); | 26 LinearAnimation(int frame_rate, AnimationDelegate* delegate); |
27 | 27 |
28 // Initializes all fields. | 28 // Initializes all fields. |
29 LinearAnimation(int duration, int frame_rate, AnimationDelegate* delegate); | 29 LinearAnimation(int duration, int frame_rate, AnimationDelegate* delegate); |
30 | 30 |
31 // Gets the value for the current state, according to the animation curve in | 31 // Gets the value for the current state, according to the animation curve in |
32 // use. This class provides only for a linear relationship, however subclasses | 32 // use. This class provides only for a linear relationship, however subclasses |
33 // can override this to provide others. | 33 // can override this to provide others. |
34 virtual double GetCurrentValue() const; | 34 virtual double GetCurrentValue() const OVERRIDE; |
35 | 35 |
36 // Skip to the end of the current animation. | 36 // Skip to the end of the current animation. |
37 void End(); | 37 void End(); |
38 | 38 |
39 // Changes the length of the animation. This resets the current | 39 // Changes the length of the animation. This resets the current |
40 // state of the animation to the beginning. | 40 // state of the animation to the beginning. |
41 void SetDuration(int duration); | 41 void SetDuration(int duration); |
42 | 42 |
43 protected: | 43 protected: |
44 // Called when the animation progresses. Subclasses override this to | 44 // Called when the animation progresses. Subclasses override this to |
45 // efficiently update their state. | 45 // efficiently update their state. |
46 virtual void AnimateToState(double state) = 0; | 46 virtual void AnimateToState(double state) = 0; |
47 | 47 |
48 // Invoked by the AnimationContainer when the animation is running to advance | 48 // Invoked by the AnimationContainer when the animation is running to advance |
49 // the animation. Use |time_now| rather than Time::Now to avoid multiple | 49 // the animation. Use |time_now| rather than Time::Now to avoid multiple |
50 // animations running at the same time diverging. | 50 // animations running at the same time diverging. |
51 virtual void Step(base::TimeTicks time_now); | 51 virtual void Step(base::TimeTicks time_now) OVERRIDE; |
52 | 52 |
53 // Overriden to advance to the end (if End was invoked). | 53 // Overriden to advance to the end (if End was invoked). |
54 virtual void AnimationStopped(); | 54 virtual void AnimationStopped() OVERRIDE; |
55 | 55 |
56 // Overriden to return true if state is not 1. | 56 // Overriden to return true if state is not 1. |
57 virtual bool ShouldSendCanceledFromStop(); | 57 virtual bool ShouldSendCanceledFromStop() OVERRIDE; |
58 | 58 |
59 private: | 59 private: |
60 base::TimeDelta duration_; | 60 base::TimeDelta duration_; |
61 | 61 |
62 // Current state, on a scale from 0.0 to 1.0. | 62 // Current state, on a scale from 0.0 to 1.0. |
63 double state_; | 63 double state_; |
64 | 64 |
65 // If true, we're in end. This is used to determine if the animation should | 65 // If true, we're in end. This is used to determine if the animation should |
66 // be advanced to the end from AnimationStopped. | 66 // be advanced to the end from AnimationStopped. |
67 bool in_end_; | 67 bool in_end_; |
68 | 68 |
69 DISALLOW_COPY_AND_ASSIGN(LinearAnimation); | 69 DISALLOW_COPY_AND_ASSIGN(LinearAnimation); |
70 }; | 70 }; |
71 | 71 |
72 } // namespace ui | 72 } // namespace ui |
73 | 73 |
74 #endif // APP_LINEAR_ANIMATION_H_ | 74 #endif // APP_LINEAR_ANIMATION_H_ |
OLD | NEW |