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_GFX_ANIMATION_ANIMATION_H_ | 5 #ifndef UI_GFX_ANIMATION_ANIMATION_H_ |
6 #define UI_GFX_ANIMATION_ANIMATION_H_ | 6 #define UI_GFX_ANIMATION_ANIMATION_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 | 21 |
22 // Base class used in implementing animations. You only need use this class if | 22 // Base class used in implementing animations. You only need use this class if |
23 // you're implementing a new animation type, otherwise you'll likely want one of | 23 // you're implementing a new animation type, otherwise you'll likely want one of |
24 // LinearAnimation, SlideAnimation, ThrobAnimation or MultiAnimation. | 24 // LinearAnimation, SlideAnimation, ThrobAnimation or MultiAnimation. |
25 // | 25 // |
26 // To subclass override Step, which is invoked as the animation progresses and | 26 // To subclass override Step, which is invoked as the animation progresses and |
27 // GetCurrentValue() to return the value appropriate to the animation. | 27 // GetCurrentValue() to return the value appropriate to the animation. |
28 class GFX_EXPORT Animation : public AnimationContainerElement { | 28 class GFX_EXPORT Animation : public AnimationContainerElement { |
29 public: | 29 public: |
30 explicit Animation(base::TimeDelta timer_interval); | 30 explicit Animation(base::TimeDelta timer_interval); |
31 virtual ~Animation(); | 31 ~Animation() override; |
32 | 32 |
33 // Starts the animation. Does nothing if the animation is already running. | 33 // Starts the animation. Does nothing if the animation is already running. |
34 void Start(); | 34 void Start(); |
35 | 35 |
36 // Stops the animation. Does nothing if the animation is not running. | 36 // Stops the animation. Does nothing if the animation is not running. |
37 void Stop(); | 37 void Stop(); |
38 | 38 |
39 // Gets the value for the current state, according to the animation | 39 // Gets the value for the current state, according to the animation |
40 // curve in use. | 40 // curve in use. |
41 virtual double GetCurrentValue() const = 0; | 41 virtual double GetCurrentValue() const = 0; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 // Invoked from stop to determine if cancel should be invoked. If this returns | 74 // Invoked from stop to determine if cancel should be invoked. If this returns |
75 // true the delegate is notified the animation was canceled, otherwise the | 75 // true the delegate is notified the animation was canceled, otherwise the |
76 // delegate is notified the animation stopped. | 76 // delegate is notified the animation stopped. |
77 virtual bool ShouldSendCanceledFromStop(); | 77 virtual bool ShouldSendCanceledFromStop(); |
78 | 78 |
79 AnimationContainer* container() { return container_.get(); } | 79 AnimationContainer* container() { return container_.get(); } |
80 base::TimeTicks start_time() const { return start_time_; } | 80 base::TimeTicks start_time() const { return start_time_; } |
81 AnimationDelegate* delegate() { return delegate_; } | 81 AnimationDelegate* delegate() { return delegate_; } |
82 | 82 |
83 // AnimationContainer::Element overrides | 83 // AnimationContainer::Element overrides |
84 virtual void SetStartTime(base::TimeTicks start_time) override; | 84 void SetStartTime(base::TimeTicks start_time) override; |
85 virtual void Step(base::TimeTicks time_now) = 0; | 85 virtual void Step(base::TimeTicks time_now) = 0; |
86 virtual base::TimeDelta GetTimerInterval() const override; | 86 base::TimeDelta GetTimerInterval() const override; |
87 | 87 |
88 private: | 88 private: |
89 // Interval for the animation. | 89 // Interval for the animation. |
90 const base::TimeDelta timer_interval_; | 90 const base::TimeDelta timer_interval_; |
91 | 91 |
92 // If true we're running. | 92 // If true we're running. |
93 bool is_animating_; | 93 bool is_animating_; |
94 | 94 |
95 // Our delegate; may be null. | 95 // Our delegate; may be null. |
96 AnimationDelegate* delegate_; | 96 AnimationDelegate* delegate_; |
97 | 97 |
98 // Container we're in. If non-null we're animating. | 98 // Container we're in. If non-null we're animating. |
99 scoped_refptr<AnimationContainer> container_; | 99 scoped_refptr<AnimationContainer> container_; |
100 | 100 |
101 // Time we started at. | 101 // Time we started at. |
102 base::TimeTicks start_time_; | 102 base::TimeTicks start_time_; |
103 | 103 |
104 DISALLOW_COPY_AND_ASSIGN(Animation); | 104 DISALLOW_COPY_AND_ASSIGN(Animation); |
105 }; | 105 }; |
106 | 106 |
107 } // namespace gfx | 107 } // namespace gfx |
108 | 108 |
109 #endif // UI_GFX_ANIMATION_ANIMATION_H_ | 109 #endif // UI_GFX_ANIMATION_ANIMATION_H_ |
OLD | NEW |