OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "app/multi_animation.h" | 5 #include "app/multi_animation.h" |
6 | 6 |
7 #include "app/animation_delegate.h" | 7 #include "app/animation_delegate.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 | 9 |
10 // Default interval, in ms. | 10 // Default interval, in ms. |
(...skipping 13 matching lines...) Expand all Loading... | |
24 parts_(parts), | 24 parts_(parts), |
25 cycle_time_ms_(TotalTime(parts)), | 25 cycle_time_ms_(TotalTime(parts)), |
26 current_value_(0), | 26 current_value_(0), |
27 current_part_index_(0), | 27 current_part_index_(0), |
28 continuous_(true) { | 28 continuous_(true) { |
29 DCHECK(!parts_.empty()); | 29 DCHECK(!parts_.empty()); |
30 } | 30 } |
31 | 31 |
32 MultiAnimation::~MultiAnimation() {} | 32 MultiAnimation::~MultiAnimation() {} |
33 | 33 |
34 void MultiAnimation::Reset() { | |
35 Stop(); | |
36 current_value_ = 0; | |
sky
2010/12/06 17:38:12
current_value and current_parent_index should be s
Evan Stade
2010/12/06 22:15:48
I think I've done what you intended
| |
37 current_part_index_ = 0; | |
38 } | |
39 | |
34 void MultiAnimation::Step(base::TimeTicks time_now) { | 40 void MultiAnimation::Step(base::TimeTicks time_now) { |
35 double last_value = current_value_; | 41 double last_value = current_value_; |
36 size_t last_index = current_part_index_; | 42 size_t last_index = current_part_index_; |
37 | 43 |
38 int delta = static_cast<int>((time_now - start_time()).InMilliseconds()); | 44 int delta = static_cast<int>((time_now - start_time()).InMilliseconds()); |
39 if (delta >= cycle_time_ms_ && !continuous_) { | 45 if (delta >= cycle_time_ms_ && !continuous_) { |
40 current_part_index_ = parts_.size() - 1; | 46 current_part_index_ = parts_.size() - 1; |
41 current_value_ = Tween::CalculateValue(parts_[current_part_index_].type, 1); | 47 current_value_ = Tween::CalculateValue(parts_[current_part_index_].type, 1); |
42 Stop(); | 48 Stop(); |
43 return; | 49 return; |
(...skipping 21 matching lines...) Expand all Loading... | |
65 return parts_[i]; | 71 return parts_[i]; |
66 } | 72 } |
67 | 73 |
68 *time_ms -= parts_[i].time_ms; | 74 *time_ms -= parts_[i].time_ms; |
69 } | 75 } |
70 NOTREACHED(); | 76 NOTREACHED(); |
71 *time_ms = 0; | 77 *time_ms = 0; |
72 *part_index = 0; | 78 *part_index = 0; |
73 return parts_[0]; | 79 return parts_[0]; |
74 } | 80 } |
OLD | NEW |