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

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

Issue 12328027: Audio indicator in each tab (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 10 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_renderer_data.h » ('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
===================================================================
--- chrome/browser/ui/views/tabs/tab.cc (revision 184139)
+++ chrome/browser/ui/views/tabs/tab.cc (working copy)
@@ -510,15 +510,18 @@
StartCrashAnimation();
#endif
}
-
} else if ((data_.capture_state == TabRendererData::CAPTURE_STATE_NONE) &&
(old.capture_state != TabRendererData::CAPTURE_STATE_NONE)) {
StopRecordingAnimation();
-
} else if ((data_.capture_state != TabRendererData::CAPTURE_STATE_NONE) &&
(old.capture_state == TabRendererData::CAPTURE_STATE_NONE)) {
StartRecordingAnimation();
-
+ } else if ((data_.audio_state == TabRendererData::AUDIO_STATE_NONE) &&
+ (old.audio_state != TabRendererData::AUDIO_STATE_NONE)) {
+ StopAudioPlayingAnimation();
+ } else if ((data_.audio_state != TabRendererData::AUDIO_STATE_NONE) &&
+ (old.audio_state == TabRendererData::AUDIO_STATE_NONE)) {
+ StartAudioPlayingAnimation();
} else {
if (IsPerformingCrashAnimation())
StopCrashAnimation();
@@ -1365,7 +1368,8 @@
int icon_size = frames.height();
int image_offset = loading_animation_frame_ * icon_size;
DrawIconCenter(canvas, frames, image_offset,
- icon_size, icon_size, bounds, false, SkPaint());
+ icon_size, icon_size,
+ bounds, false, SkPaint());
return;
}
@@ -1378,7 +1382,8 @@
bounds.set_y(bounds.y() + favicon_hiding_offset_);
DrawIconCenter(canvas, crashed_favicon, 0,
crashed_favicon.width(),
- crashed_favicon.height(), bounds, true, SkPaint());
+ crashed_favicon.height(),
+ bounds, true, SkPaint());
} else {
if (!data().favicon.isNull()) {
if (data().capture_state == TabRendererData::CAPTURE_STATE_PROJECTING) {
@@ -1398,25 +1403,38 @@
resized_bounds.set_y(resized_bounds.y() - 1);
DrawIconCenter(canvas, resized_icon, 0,
- resized_icon.width(),
- resized_icon.height(),
- resized_bounds, true, SkPaint());
+ resized_icon.width(),
+ resized_icon.height(),
+ resized_bounds, true, SkPaint());
ui::ThemeProvider* tp = GetThemeProvider();
gfx::ImageSkia projection_screen(
*tp->GetImageSkiaNamed(IDR_TAB_CAPTURE));
-
DrawIconCenter(canvas, projection_screen, 0,
- data().favicon.width(),
- data().favicon.height(),
- bounds, true, SkPaint());
+ data().favicon.width(),
+ data().favicon.height(),
+ bounds, true, SkPaint());
} else {
- // TODO(pkasting): Use code in tab_icon_view.cc:PaintIcon() (or switch
- // to using that class to render the favicon).
DrawIconCenter(canvas, data().favicon, 0,
- data().favicon.width(),
- data().favicon.height(),
- bounds, true, SkPaint());
+ data().favicon.width(),
+ 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());
+ }
}
}
}
@@ -1603,6 +1621,21 @@
icon_animation_.reset();
}
+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);
+}
+
+void Tab::StopAudioPlayingAnimation() {
+ if (!icon_animation_.get())
+ return;
+ icon_animation_->Stop();
+ icon_animation_.reset();
+}
+
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_renderer_data.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698