Index: chrome/browser/ui/tabs/tab_audio_indicator.h |
diff --git a/chrome/browser/ui/tabs/tab_audio_indicator.h b/chrome/browser/ui/tabs/tab_audio_indicator.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..f3741bacc16f433355647040a078bd972e32bd4d |
--- /dev/null |
+++ b/chrome/browser/ui/tabs/tab_audio_indicator.h |
@@ -0,0 +1,73 @@ |
+// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CHROME_BROWSER_UI_TABS_TAB_AUDIO_INDICATOR_H_ |
+#define CHROME_BROWSER_UI_TABS_TAB_AUDIO_INDICATOR_H_ |
+ |
+#include <vector> |
+ |
+#include "base/compiler_specific.h" |
+#include "base/gtest_prod_util.h" |
+#include "base/memory/scoped_ptr.h" |
+#include "ui/base/animation/animation_delegate.h" |
+ |
+namespace gfx { |
+class Canvas; |
+class Rect; |
+} |
+namespace ui { |
+class Animation; |
+class LinearAnimation; |
+} |
+ |
+// This class is used to draw an animating tab audio indicator. |
+class TabAudioIndicator : public ui::AnimationDelegate { |
+ public: |
+ class Delegate { |
+ public: |
+ virtual void ScheduleAudioIndicatorPaint() = 0; |
+ }; |
sky
2013/03/12 03:59:43
protected: virtual ~Delegate() {}
sail
2013/03/12 04:24:33
Done.
|
+ |
+ explicit TabAudioIndicator(Delegate* delegate); |
sky
2013/03/12 03:59:43
Can you make this take an AnimationContainer so th
sail
2013/03/12 04:24:33
Done.
sail
2013/03/12 06:15:58
Actually, had to move this to a setter so that the
|
+ virtual ~TabAudioIndicator(); |
+ |
+ void SetIsPlayingAudio(bool is_playing_audio); |
+ bool IsAnimating(); |
+ |
+ void Paint(gfx::Canvas* canvas, const gfx::Rect& rect); |
+ |
+ private: |
+ FRIEND_TEST_ALL_PREFIXES(TabAudioIndicatorTest, AnimationState); |
+ FRIEND_TEST_ALL_PREFIXES(TabAudioIndicatorTest, SchedulePaint); |
+ |
+ // AnimationDelegate: |
+ virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; |
+ virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE; |
+ |
+ // Gets the equalizer levels for all 3 columns. The values are tweened between |
+ // the current and target frame. |
+ std::vector<int> GetCurrentEqualizerLevels() const; |
+ |
+ Delegate* delegate_; |
+ scoped_ptr<ui::LinearAnimation> animation_; |
+ |
+ // The equalizer frame that's currently being displayed. |
+ size_t frame_index_; |
+ |
+ // The equalizer levels that were last displayed. This is used to prevent |
+ // unnecessary drawing when animation progress doesn't result in equalizer |
+ // levels changing. |
+ std::vector<int> last_displayed_equalizer_levels_; |
+ |
+ enum State { |
sky
2013/03/12 03:59:43
enums should be first in a section.
sail
2013/03/12 04:24:33
Done.
|
+ STATE_NOT_ANIMATING, |
+ STATE_ANIMATING, |
+ STATE_ANIMATION_ENDING, |
+ }; |
+ State state_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(TabAudioIndicator); |
+}; |
+ |
+#endif // CHROME_BROWSER_UI_TABS_TAB_AUDIO_INDICATOR_H_ |