| OLD | NEW | 
|---|
| (Empty) |  | 
|  | 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 | 
|  | 3 // found in the LICENSE file. | 
|  | 4 | 
|  | 5 #ifndef CHROME_BROWSER_UI_TABS_TAB_AUDIO_INDICATOR_H_ | 
|  | 6 #define CHROME_BROWSER_UI_TABS_TAB_AUDIO_INDICATOR_H_ | 
|  | 7 | 
|  | 8 #include <vector> | 
|  | 9 | 
|  | 10 #include "base/compiler_specific.h" | 
|  | 11 #include "base/gtest_prod_util.h" | 
|  | 12 #include "base/memory/ref_counted.h" | 
|  | 13 #include "base/memory/scoped_ptr.h" | 
|  | 14 #include "ui/base/animation/animation_delegate.h" | 
|  | 15 | 
|  | 16 namespace gfx { | 
|  | 17 class Canvas; | 
|  | 18 class Rect; | 
|  | 19 } | 
|  | 20 namespace ui { | 
|  | 21 class Animation; | 
|  | 22 class AnimationContainer; | 
|  | 23 class LinearAnimation; | 
|  | 24 } | 
|  | 25 | 
|  | 26 // This class is used to draw an animating tab audio indicator. | 
|  | 27 class TabAudioIndicator : public ui::AnimationDelegate { | 
|  | 28  public: | 
|  | 29   class Delegate { | 
|  | 30    public: | 
|  | 31     virtual void ScheduleAudioIndicatorPaint() = 0; | 
|  | 32 | 
|  | 33    protected: | 
|  | 34     virtual ~Delegate() {} | 
|  | 35   }; | 
|  | 36 | 
|  | 37   explicit TabAudioIndicator(Delegate* delegate); | 
|  | 38   virtual ~TabAudioIndicator(); | 
|  | 39 | 
|  | 40   void SetAnimationContainer(ui::AnimationContainer* animation_container); | 
|  | 41   void SetIsPlayingAudio(bool is_playing_audio); | 
|  | 42   bool IsAnimating(); | 
|  | 43 | 
|  | 44   void Paint(gfx::Canvas* canvas, const gfx::Rect& rect); | 
|  | 45 | 
|  | 46  private: | 
|  | 47   enum State { | 
|  | 48     STATE_NOT_ANIMATING, | 
|  | 49     STATE_ANIMATING, | 
|  | 50     STATE_ANIMATION_ENDING, | 
|  | 51   }; | 
|  | 52 | 
|  | 53   FRIEND_TEST_ALL_PREFIXES(TabAudioIndicatorTest, AnimationState); | 
|  | 54   FRIEND_TEST_ALL_PREFIXES(TabAudioIndicatorTest, SchedulePaint); | 
|  | 55 | 
|  | 56   // AnimationDelegate: | 
|  | 57   virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; | 
|  | 58   virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE; | 
|  | 59 | 
|  | 60   // Gets the equalizer levels for all 3 columns. The values are tweened between | 
|  | 61   // the current and target frame. | 
|  | 62   std::vector<int> GetCurrentEqualizerLevels() const; | 
|  | 63 | 
|  | 64   Delegate* delegate_; | 
|  | 65   scoped_ptr<ui::LinearAnimation> animation_; | 
|  | 66   scoped_refptr<ui::AnimationContainer> animation_container_; | 
|  | 67 | 
|  | 68   // The equalizer frame that's currently being displayed. | 
|  | 69   size_t frame_index_; | 
|  | 70 | 
|  | 71   // The equalizer levels that were last displayed. This is used to prevent | 
|  | 72   // unnecessary drawing when animation progress doesn't result in equalizer | 
|  | 73   // levels changing. | 
|  | 74   std::vector<int> last_displayed_equalizer_levels_; | 
|  | 75 | 
|  | 76   State state_; | 
|  | 77 | 
|  | 78   DISALLOW_COPY_AND_ASSIGN(TabAudioIndicator); | 
|  | 79 }; | 
|  | 80 | 
|  | 81 #endif  // CHROME_BROWSER_UI_TABS_TAB_AUDIO_INDICATOR_H_ | 
| OLD | NEW | 
|---|