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 #include "ui/gfx/animation/linear_animation.h" | 5 #include "ui/gfx/animation/linear_animation.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 | 8 |
9 #include "ui/gfx/animation/animation_container.h" | 9 #include "ui/gfx/animation/animation_container.h" |
10 #include "ui/gfx/animation/animation_delegate.h" | 10 #include "ui/gfx/animation/animation_delegate.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 } | 41 } |
42 | 42 |
43 double LinearAnimation::GetCurrentValue() const { | 43 double LinearAnimation::GetCurrentValue() const { |
44 // Default is linear relationship, subclass to adapt. | 44 // Default is linear relationship, subclass to adapt. |
45 return state_; | 45 return state_; |
46 } | 46 } |
47 | 47 |
48 void LinearAnimation::SetCurrentValue(double new_value) { | 48 void LinearAnimation::SetCurrentValue(double new_value) { |
49 new_value = std::max(0.0, std::min(1.0, new_value)); | 49 new_value = std::max(0.0, std::min(1.0, new_value)); |
50 base::TimeDelta time_delta = base::TimeDelta::FromMicroseconds( | 50 base::TimeDelta time_delta = base::TimeDelta::FromMicroseconds( |
51 duration_.InMicroseconds() * (new_value - state_)); | 51 static_cast<int64>(duration_.InMicroseconds() * (new_value - state_))); |
52 SetStartTime(start_time() - time_delta); | 52 SetStartTime(start_time() - time_delta); |
53 state_ = new_value; | 53 state_ = new_value; |
54 } | 54 } |
55 | 55 |
56 void LinearAnimation::End() { | 56 void LinearAnimation::End() { |
57 if (!is_animating()) | 57 if (!is_animating()) |
58 return; | 58 return; |
59 | 59 |
60 // NOTE: We don't use AutoReset here as Stop may end up deleting us (by way | 60 // NOTE: We don't use AutoReset here as Stop may end up deleting us (by way |
61 // of the delegate). | 61 // of the delegate). |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 // Set state_ to ensure we send ended to delegate and not canceled. | 99 // Set state_ to ensure we send ended to delegate and not canceled. |
100 state_ = 1; | 100 state_ = 1; |
101 AnimateToState(1.0); | 101 AnimateToState(1.0); |
102 } | 102 } |
103 | 103 |
104 bool LinearAnimation::ShouldSendCanceledFromStop() { | 104 bool LinearAnimation::ShouldSendCanceledFromStop() { |
105 return state_ != 1; | 105 return state_ != 1; |
106 } | 106 } |
107 | 107 |
108 } // namespace gfx | 108 } // namespace gfx |
OLD | NEW |