OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "chrome/browser/ui/tabs/tab_audio_indicator.h" | 5 #include "chrome/browser/ui/tabs/tab_audio_indicator.h" |
6 | 6 |
7 #include "grit/theme_resources.h" | 7 #include "grit/theme_resources.h" |
8 #include "ui/base/animation/animation_container.h" | 8 #include "ui/base/animation/animation_container.h" |
9 #include "ui/base/animation/linear_animation.h" | 9 #include "ui/base/animation/linear_animation.h" |
10 #include "ui/base/resource/resource_bundle.h" | 10 #include "ui/base/resource/resource_bundle.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 void TabAudioIndicator::SetAnimationContainer( | 62 void TabAudioIndicator::SetAnimationContainer( |
63 ui::AnimationContainer* animation_container) { | 63 ui::AnimationContainer* animation_container) { |
64 animation_container_ = animation_container; | 64 animation_container_ = animation_container; |
65 } | 65 } |
66 | 66 |
67 void TabAudioIndicator::SetIsPlayingAudio(bool is_playing_audio) { | 67 void TabAudioIndicator::SetIsPlayingAudio(bool is_playing_audio) { |
68 if (is_playing_audio && state_ != STATE_ANIMATING) { | 68 if (is_playing_audio && state_ != STATE_ANIMATING) { |
69 state_ = STATE_ANIMATING; | 69 state_ = STATE_ANIMATING; |
70 animation_.reset( | 70 animation_.reset( |
71 new ui::LinearAnimation(kAnimationCycleDurationMs, kFPS, this)); | 71 new ui::LinearAnimation(kAnimationCycleDurationMs, kFPS, this)); |
72 animation_->SetContainer(animation_container_); | 72 animation_->SetContainer(animation_container_.get()); |
73 animation_->Start(); | 73 animation_->Start(); |
74 } else if (!is_playing_audio && state_ == STATE_ANIMATING) { | 74 } else if (!is_playing_audio && state_ == STATE_ANIMATING) { |
75 state_ = STATE_ANIMATION_ENDING; | 75 state_ = STATE_ANIMATION_ENDING; |
76 animation_.reset( | 76 animation_.reset( |
77 new ui::LinearAnimation(kAnimationEndingDurationMs, kFPS, this)); | 77 new ui::LinearAnimation(kAnimationEndingDurationMs, kFPS, this)); |
78 animation_->SetContainer(animation_container_); | 78 animation_->SetContainer(animation_container_.get()); |
79 animation_->Start(); | 79 animation_->Start(); |
80 } | 80 } |
81 } | 81 } |
82 | 82 |
83 bool TabAudioIndicator::IsAnimating() { | 83 bool TabAudioIndicator::IsAnimating() { |
84 return state_ != STATE_NOT_ANIMATING; | 84 return state_ != STATE_NOT_ANIMATING; |
85 } | 85 } |
86 | 86 |
87 void TabAudioIndicator::Paint(gfx::Canvas* canvas, const gfx::Rect& rect) { | 87 void TabAudioIndicator::Paint(gfx::Canvas* canvas, const gfx::Rect& rect) { |
88 canvas->Save(); | 88 canvas->Save(); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 // level and the target equalizer level. | 156 // level and the target equalizer level. |
157 for (size_t i = 0; i < kEqualizerColumnCount; ++i) { | 157 for (size_t i = 0; i < kEqualizerColumnCount; ++i) { |
158 int start = kEqualizerFrames[frame_index_][i]; | 158 int start = kEqualizerFrames[frame_index_][i]; |
159 int end = state_ == STATE_ANIMATION_ENDING | 159 int end = state_ == STATE_ANIMATION_ENDING |
160 ? 0 | 160 ? 0 |
161 : kEqualizerFrames[next_frame_index][i]; | 161 : kEqualizerFrames[next_frame_index][i]; |
162 levels.push_back(animation_->CurrentValueBetween(start, end)); | 162 levels.push_back(animation_->CurrentValueBetween(start, end)); |
163 } | 163 } |
164 return levels; | 164 return levels; |
165 } | 165 } |
OLD | NEW |