Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2014 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_VIEWS_TABS_MEDIA_INDICATOR_BUTTON_H_ | |
| 6 #define CHROME_BROWSER_UI_VIEWS_TABS_MEDIA_INDICATOR_BUTTON_H_ | |
| 7 | |
| 8 #include "base/memory/scoped_ptr.h" | |
| 9 #include "chrome/browser/ui/tabs/tab_utils.h" | |
| 10 #include "ui/views/controls/button/image_button.h" | |
| 11 #include "ui/views/view_targeter_delegate.h" | |
| 12 | |
| 13 namespace gfx { | |
| 14 class Animation; | |
| 15 class AnimationDelegate; | |
| 16 } | |
| 17 | |
| 18 // This is an ImageButton subclass that serves as both the media indicator icon | |
| 19 // (audio, tab capture, etc.), and as a mute button. It is meant to only be | |
| 20 // used as a child view of Tab. | |
| 21 // | |
| 22 // When the indicator is transitioned to the audio playing or muting state, the | |
| 23 // button functionality is enabled and begins handling mouse events. Otherwise, | |
| 24 // this view behaves like an image and all mouse events will be handled by the | |
| 25 // Tab (its parent View). | |
| 26 class MediaIndicatorButton : public views::ImageButton, | |
| 27 public views::ViewTargeterDelegate { | |
| 28 public: | |
| 29 MediaIndicatorButton(); | |
| 30 virtual ~MediaIndicatorButton(); | |
| 31 | |
| 32 // Returns the current TabMediaState except, while the indicator image is | |
| 33 // fading out, returns the prior TabMediaState. | |
| 34 TabMediaState showing_media_state() const { | |
| 35 return showing_media_state_; | |
| 36 } | |
| 37 | |
| 38 // Updates ImageButton images, starts fade animations, and | |
| 39 // activates/deactivates button functionality as appropriate. | |
| 40 void TransitionToMediaState(TabMediaState next_state); | |
| 41 | |
| 42 static const char kViewClassName[]; | |
|
sky
2014/09/25 19:25:05
nit: this should be first in the section (see styl
miu
2014/09/25 22:49:36
Done.
| |
| 43 | |
| 44 protected: | |
| 45 // views::View: | |
| 46 virtual const char* GetClassName() const OVERRIDE; | |
| 47 virtual View* GetTooltipHandlerForPoint(const gfx::Point& point) OVERRIDE; | |
| 48 virtual bool OnMouseDragged(const ui::MouseEvent& event) OVERRIDE; | |
| 49 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | |
| 50 | |
| 51 // views::ViewTargeterDelegate | |
| 52 virtual bool DoesIntersectRect(const View* target, | |
| 53 const gfx::Rect& rect) const OVERRIDE; | |
| 54 | |
| 55 // views::Button: | |
| 56 virtual void NotifyClick(const ui::Event& event) OVERRIDE; | |
| 57 | |
| 58 private: | |
| 59 class FadeAnimationDelegate; | |
| 60 | |
| 61 TabMediaState media_state_; | |
| 62 | |
| 63 // Media indicator fade-in/out animation (i.e., only on show/hide, not a | |
| 64 // continuous animation). | |
| 65 scoped_ptr<gfx::AnimationDelegate> fade_animation_delegate_; | |
| 66 scoped_ptr<gfx::Animation> fade_animation_; | |
| 67 TabMediaState showing_media_state_; | |
| 68 | |
| 69 DISALLOW_COPY_AND_ASSIGN(MediaIndicatorButton); | |
| 70 }; | |
| 71 | |
| 72 #endif // CHROME_BROWSER_UI_VIEWS_TABS_MEDIA_INDICATOR_BUTTON_H_ | |
| OLD | NEW |