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/throb_animation.h" | 5 #include "app/throb_animation.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 static const int kDefaultThrobDurationMS = 400; | 9 static const int kDefaultThrobDurationMS = 400; |
10 | 10 |
(...skipping 29 matching lines...) Expand all Loading... |
40 void ThrobAnimation::Show() { | 40 void ThrobAnimation::Show() { |
41 ResetForSlide(); | 41 ResetForSlide(); |
42 SlideAnimation::Show(); | 42 SlideAnimation::Show(); |
43 } | 43 } |
44 | 44 |
45 void ThrobAnimation::Hide() { | 45 void ThrobAnimation::Hide() { |
46 ResetForSlide(); | 46 ResetForSlide(); |
47 SlideAnimation::Hide(); | 47 SlideAnimation::Hide(); |
48 } | 48 } |
49 | 49 |
| 50 void ThrobAnimation::SetSlideDuration(int duration) { |
| 51 slide_duration_ = duration; |
| 52 } |
| 53 |
50 void ThrobAnimation::Step(base::TimeTicks time_now) { | 54 void ThrobAnimation::Step(base::TimeTicks time_now) { |
51 LinearAnimation::Step(time_now); | 55 LinearAnimation::Step(time_now); |
52 | 56 |
53 if (!is_animating() && throbbing_) { | 57 if (!is_animating() && throbbing_) { |
54 // Were throbbing a finished a cycle. Start the next cycle unless we're at | 58 // Were throbbing a finished a cycle. Start the next cycle unless we're at |
55 // the end of the cycles, in which case we stop. | 59 // the end of the cycles, in which case we stop. |
56 cycles_remaining_--; | 60 cycles_remaining_--; |
57 if (IsShowing()) { | 61 if (IsShowing()) { |
58 // We want to stop hidden, hence this doesn't check cycles_remaining_. | 62 // We want to stop hidden, hence this doesn't check cycles_remaining_. |
59 SlideAnimation::Hide(); | 63 SlideAnimation::Hide(); |
60 } else if (cycles_remaining_ > 0) { | 64 } else if (cycles_remaining_ > 0) { |
61 SlideAnimation::Show(); | 65 SlideAnimation::Show(); |
62 } else { | 66 } else { |
63 // We're done throbbing. | 67 // We're done throbbing. |
64 throbbing_ = false; | 68 throbbing_ = false; |
65 } | 69 } |
66 } | 70 } |
67 } | 71 } |
68 | 72 |
69 void ThrobAnimation::ResetForSlide() { | 73 void ThrobAnimation::ResetForSlide() { |
70 SlideAnimation::SetSlideDuration(slide_duration_); | 74 SlideAnimation::SetSlideDuration(slide_duration_); |
71 cycles_remaining_ = 0; | 75 cycles_remaining_ = 0; |
72 throbbing_ = false; | 76 throbbing_ = false; |
73 } | 77 } |
OLD | NEW |