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

Side by Side Diff: chrome/browser/ui/tabs/tab_audio_indicator.h

Issue 12744003: Audio indicator: cross platform drawing and animation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address review comments 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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/scoped_ptr.h"
13 #include "ui/base/animation/animation_delegate.h"
14
15 namespace gfx {
16 class Canvas;
17 class Rect;
18 }
19 namespace ui {
20 class Animation;
21 class LinearAnimation;
22 }
23
24 // This class is used to draw an animating tab audio indicator.
25 class TabAudioIndicator : public ui::AnimationDelegate {
26 public:
27 class Delegate {
28 public:
29 virtual void ScheduleAudioIndicatorPaint() = 0;
30 };
sky 2013/03/12 03:59:43 protected: virtual ~Delegate() {}
sail 2013/03/12 04:24:33 Done.
31
32 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
33 virtual ~TabAudioIndicator();
34
35 void SetIsPlayingAudio(bool is_playing_audio);
36 bool IsAnimating();
37
38 void Paint(gfx::Canvas* canvas, const gfx::Rect& rect);
39
40 private:
41 FRIEND_TEST_ALL_PREFIXES(TabAudioIndicatorTest, AnimationState);
42 FRIEND_TEST_ALL_PREFIXES(TabAudioIndicatorTest, SchedulePaint);
43
44 // AnimationDelegate:
45 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE;
46 virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE;
47
48 // Gets the equalizer levels for all 3 columns. The values are tweened between
49 // the current and target frame.
50 std::vector<int> GetCurrentEqualizerLevels() const;
51
52 Delegate* delegate_;
53 scoped_ptr<ui::LinearAnimation> animation_;
54
55 // The equalizer frame that's currently being displayed.
56 size_t frame_index_;
57
58 // The equalizer levels that were last displayed. This is used to prevent
59 // unnecessary drawing when animation progress doesn't result in equalizer
60 // levels changing.
61 std::vector<int> last_displayed_equalizer_levels_;
62
63 enum State {
sky 2013/03/12 03:59:43 enums should be first in a section.
sail 2013/03/12 04:24:33 Done.
64 STATE_NOT_ANIMATING,
65 STATE_ANIMATING,
66 STATE_ANIMATION_ENDING,
67 };
68 State state_;
69
70 DISALLOW_COPY_AND_ASSIGN(TabAudioIndicator);
71 };
72
73 #endif // CHROME_BROWSER_UI_TABS_TAB_AUDIO_INDICATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698