| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_UI_VIEWS_TABS_MEDIA_INDICATOR_BUTTON_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_TABS_MEDIA_INDICATOR_BUTTON_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_TABS_MEDIA_INDICATOR_BUTTON_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_TABS_MEDIA_INDICATOR_BUTTON_H_ |
| 7 | 7 |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "chrome/browser/ui/tabs/tab_utils.h" | 9 #include "chrome/browser/ui/tabs/tab_utils.h" |
| 10 #include "ui/views/controls/button/image_button.h" | 10 #include "ui/views/controls/button/image_button.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 // button functionality is enabled and begins handling mouse events. Otherwise, | 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 | 24 // this view behaves like an image and all mouse events will be handled by the |
| 25 // Tab (its parent View). | 25 // Tab (its parent View). |
| 26 class MediaIndicatorButton : public views::ImageButton, | 26 class MediaIndicatorButton : public views::ImageButton, |
| 27 public views::ViewTargeterDelegate { | 27 public views::ViewTargeterDelegate { |
| 28 public: | 28 public: |
| 29 // The MediaIndicatorButton's class name. | 29 // The MediaIndicatorButton's class name. |
| 30 static const char kViewClassName[]; | 30 static const char kViewClassName[]; |
| 31 | 31 |
| 32 MediaIndicatorButton(); | 32 MediaIndicatorButton(); |
| 33 virtual ~MediaIndicatorButton(); | 33 ~MediaIndicatorButton() override; |
| 34 | 34 |
| 35 // Returns the current TabMediaState except, while the indicator image is | 35 // Returns the current TabMediaState except, while the indicator image is |
| 36 // fading out, returns the prior TabMediaState. | 36 // fading out, returns the prior TabMediaState. |
| 37 TabMediaState showing_media_state() const { | 37 TabMediaState showing_media_state() const { |
| 38 return showing_media_state_; | 38 return showing_media_state_; |
| 39 } | 39 } |
| 40 | 40 |
| 41 // Updates ImageButton images, starts fade animations, and | 41 // Updates ImageButton images, starts fade animations, and |
| 42 // activates/deactivates button functionality as appropriate. | 42 // activates/deactivates button functionality as appropriate. |
| 43 void TransitionToMediaState(TabMediaState next_state); | 43 void TransitionToMediaState(TabMediaState next_state); |
| 44 | 44 |
| 45 protected: | 45 protected: |
| 46 // views::View: | 46 // views::View: |
| 47 virtual const char* GetClassName() const override; | 47 const char* GetClassName() const override; |
| 48 virtual View* GetTooltipHandlerForPoint(const gfx::Point& point) override; | 48 View* GetTooltipHandlerForPoint(const gfx::Point& point) override; |
| 49 virtual bool OnMouseDragged(const ui::MouseEvent& event) override; | 49 bool OnMouseDragged(const ui::MouseEvent& event) override; |
| 50 virtual void OnPaint(gfx::Canvas* canvas) override; | 50 void OnPaint(gfx::Canvas* canvas) override; |
| 51 | 51 |
| 52 // views::ViewTargeterDelegate | 52 // views::ViewTargeterDelegate |
| 53 virtual bool DoesIntersectRect(const View* target, | 53 bool DoesIntersectRect(const View* target, |
| 54 const gfx::Rect& rect) const override; | 54 const gfx::Rect& rect) const override; |
| 55 | 55 |
| 56 // views::Button: | 56 // views::Button: |
| 57 virtual void NotifyClick(const ui::Event& event) override; | 57 void NotifyClick(const ui::Event& event) override; |
| 58 | 58 |
| 59 private: | 59 private: |
| 60 class FadeAnimationDelegate; | 60 class FadeAnimationDelegate; |
| 61 | 61 |
| 62 TabMediaState media_state_; | 62 TabMediaState media_state_; |
| 63 | 63 |
| 64 // Media indicator fade-in/out animation (i.e., only on show/hide, not a | 64 // Media indicator fade-in/out animation (i.e., only on show/hide, not a |
| 65 // continuous animation). | 65 // continuous animation). |
| 66 scoped_ptr<gfx::AnimationDelegate> fade_animation_delegate_; | 66 scoped_ptr<gfx::AnimationDelegate> fade_animation_delegate_; |
| 67 scoped_ptr<gfx::Animation> fade_animation_; | 67 scoped_ptr<gfx::Animation> fade_animation_; |
| 68 TabMediaState showing_media_state_; | 68 TabMediaState showing_media_state_; |
| 69 | 69 |
| 70 DISALLOW_COPY_AND_ASSIGN(MediaIndicatorButton); | 70 DISALLOW_COPY_AND_ASSIGN(MediaIndicatorButton); |
| 71 }; | 71 }; |
| 72 | 72 |
| 73 #endif // CHROME_BROWSER_UI_VIEWS_TABS_MEDIA_INDICATOR_BUTTON_H_ | 73 #endif // CHROME_BROWSER_UI_VIEWS_TABS_MEDIA_INDICATOR_BUTTON_H_ |
| OLD | NEW |