Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6774)

Unified Diff: chrome/browser/ui/views/tabs/tab.cc

Issue 12757002: Audio indicator: Views UI (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/views/tabs/tab.h ('k') | chrome/browser/ui/views/tabs/tab_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/tabs/tab.cc
diff --git a/chrome/browser/ui/views/tabs/tab.cc b/chrome/browser/ui/views/tabs/tab.cc
index 0aa29a00f5d332c85f336c04b9ca51b37b95f1ce..33625dbc732997a32d12734db6ccefba91388e57 100644
--- a/chrome/browser/ui/views/tabs/tab.cc
+++ b/chrome/browser/ui/views/tabs/tab.cc
@@ -474,6 +474,8 @@ Tab::Tab(TabController* controller)
AddChildView(close_button_);
set_context_menu_controller(this);
+
+ tab_audio_indicator_.reset(new TabAudioIndicator(this));
}
Tab::~Tab() {
@@ -482,6 +484,7 @@ Tab::~Tab() {
void Tab::set_animation_container(ui::AnimationContainer* container) {
animation_container_ = container;
hover_controller_.SetAnimationContainer(container);
+ tab_audio_indicator_->SetAnimationContainer(container);
}
bool Tab::IsActive() const {
@@ -520,20 +523,8 @@ void Tab::SetData(const TabRendererData& data) {
}
} else if (!data_.CaptureActive() && old.CaptureActive()) {
StopIconAnimation();
- if (data_.AudioActive())
- StartAudioPlayingAnimation();
} else if (data_.CaptureActive() && !old.CaptureActive()) {
- // Capture indicator overrides the audio indicator if presently shown.
- old.audio_state = TabRendererData::AUDIO_STATE_NONE;
- data_.audio_state = TabRendererData::AUDIO_STATE_NONE;
StartRecordingAnimation();
- } else if (!data_.CaptureActive()) {
- // Start or stop the audio indicator only if not capturing.
- if (!data_.AudioActive() && old.AudioActive()) {
- StopIconAnimation();
- } else if (data_.AudioActive() && !old.AudioActive()) {
- StartAudioPlayingAnimation();
- }
} else {
if (IsPerformingCrashAnimation())
StopIconAnimation();
@@ -547,6 +538,8 @@ void Tab::SetData(const TabRendererData& data) {
}
}
+ tab_audio_indicator_->SetIsPlayingAudio(data_.AudioActive());
+
DataChanged(old);
Layout();
@@ -668,6 +661,16 @@ int Tab::GetImmersiveHeight() {
}
////////////////////////////////////////////////////////////////////////////////
+// Tab, TabAudioIndicator::Delegate overrides:
+
+void Tab::ScheduleAudioIndicatorPaint() {
+ // No need to schedule a paint if another animation is active. The other
+ // animation will do its own scheduling.
+ if (!icon_animation_)
+ ScheduleIconPaint();
+}
+
+////////////////////////////////////////////////////////////////////////////////
// Tab, AnimationDelegate overrides:
void Tab::AnimationProgressed(const ui::Animation* animation) {
@@ -1429,21 +1432,10 @@ void Tab::PaintIcon(gfx::Canvas* canvas) {
data().favicon.height(),
bounds, true, SkPaint());
- if (data().audio_state == TabRendererData::AUDIO_STATE_PLAYING) {
- // If audio is playing, we draw on top of the icon the
- // current equalizer animiation frame.
- ui::ThemeProvider* tp = GetThemeProvider();
- gfx::ImageSkia equalizer(*tp->GetImageSkiaNamed(IDR_AUDIO_ANIMATION));
- int icon_size = equalizer.height();
- int number_of_frames = equalizer.width() / icon_size;
- int frame = static_cast<int>(
- icon_animation_->GetCurrentValue() * number_of_frames);
- int image_offset = frame * icon_size;
- DrawIconAtLocation(canvas, equalizer, image_offset,
- bounds.x(), bounds.y() + 1,
- icon_size, icon_size,
- false, SkPaint());
- }
+ // Draw the audio indicator UI only if no other icon animation is
+ // active.
+ if (!icon_animation_ && tab_audio_indicator_->IsAnimating())
+ tab_audio_indicator_->Paint(canvas, bounds);
}
}
}
@@ -1699,14 +1691,6 @@ void Tab::StartRecordingAnimation() {
icon_animation_.reset(animation);
}
-void Tab::StartAudioPlayingAnimation() {
- ui::ThrobAnimation* animation = new ui::ThrobAnimation(this);
- animation->SetTweenType(ui::Tween::LINEAR);
- animation->SetThrobDuration(2000);
- animation->StartThrobbing(-1);
- icon_animation_.reset(animation);
-}
-
bool Tab::IsPerformingCrashAnimation() const {
return icon_animation_.get() && data_.IsCrashed();
}
« no previous file with comments | « chrome/browser/ui/views/tabs/tab.h ('k') | chrome/browser/ui/views/tabs/tab_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698