| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_COCOA_TABS_ALERT_INDICATOR_BUTTON_COCOA_H_ | 5 #ifndef CHROME_BROWSER_UI_COCOA_TABS_ALERT_INDICATOR_BUTTON_COCOA_H_ |
| 6 #define CHROME_BROWSER_UI_COCOA_TABS_ALERT_INDICATOR_BUTTON_COCOA_H_ | 6 #define CHROME_BROWSER_UI_COCOA_TABS_ALERT_INDICATOR_BUTTON_COCOA_H_ |
| 7 | 7 |
| 8 #include <memory> |
| 9 |
| 8 #import "base/mac/scoped_nsobject.h" | 10 #import "base/mac/scoped_nsobject.h" |
| 9 #include "base/memory/scoped_ptr.h" | |
| 10 #include "chrome/browser/ui/tabs/tab_utils.h" | 11 #include "chrome/browser/ui/tabs/tab_utils.h" |
| 11 #import "ui/base/cocoa/hover_button.h" | 12 #import "ui/base/cocoa/hover_button.h" |
| 12 | 13 |
| 13 namespace gfx { | 14 namespace gfx { |
| 14 class Animation; | 15 class Animation; |
| 15 class AnimationDelegate; | 16 class AnimationDelegate; |
| 16 } // namespace gfx | 17 } // namespace gfx |
| 17 | 18 |
| 18 // This is an HoverButton subclass that serves as both the alert indicator icon | 19 // This is an HoverButton subclass that serves as both the alert indicator icon |
| 19 // (audio, tab capture, etc.), and as a mute button. It is meant to only be | 20 // (audio, tab capture, etc.), and as a mute button. It is meant to only be |
| 20 // used as a subview of TabView. | 21 // used as a subview of TabView. |
| 21 // | 22 // |
| 22 // When the indicator is transitioned to the audio playing or muting state, the | 23 // 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 // 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 // this view behaves like an image and all mouse events will be handled by the |
| 25 // its superview. | 26 // its superview. |
| 26 // | 27 // |
| 27 // Note: Send the |-setClickTarget:withAction:| message instead of the | 28 // Note: Send the |-setClickTarget:withAction:| message instead of the |
| 28 // |-setTarget:| and |-setAction:| messages to be notified of button clicks. | 29 // |-setTarget:| and |-setAction:| messages to be notified of button clicks. |
| 29 @interface AlertIndicatorButton : HoverButton { | 30 @interface AlertIndicatorButton : HoverButton { |
| 30 @private | 31 @private |
| 31 class FadeAnimationDelegate; | 32 class FadeAnimationDelegate; |
| 32 | 33 |
| 33 // Current TabAlertState. When animating fade-in/out, this reflects the | 34 // Current TabAlertState. When animating fade-in/out, this reflects the |
| 34 // indicator state at the end of the animation. | 35 // indicator state at the end of the animation. |
| 35 TabAlertState alertState_; | 36 TabAlertState alertState_; |
| 36 | 37 |
| 37 // Alert indicator fade-in/out animation (i.e., only on show/hide, not a | 38 // Alert indicator fade-in/out animation (i.e., only on show/hide, not a |
| 38 // continuous animation). | 39 // continuous animation). |
| 39 scoped_ptr<gfx::AnimationDelegate> fadeAnimationDelegate_; | 40 std::unique_ptr<gfx::AnimationDelegate> fadeAnimationDelegate_; |
| 40 scoped_ptr<gfx::Animation> fadeAnimation_; | 41 std::unique_ptr<gfx::Animation> fadeAnimation_; |
| 41 TabAlertState showingAlertState_; | 42 TabAlertState showingAlertState_; |
| 42 | 43 |
| 43 // Target and action invoked whenever a fade-in/out animation completes. This | 44 // Target and action invoked whenever a fade-in/out animation completes. This |
| 44 // is used by TabController to layout the TabView after an indicator has | 45 // is used by TabController to layout the TabView after an indicator has |
| 45 // completely faded out. | 46 // completely faded out. |
| 46 id animationDoneTarget_; // weak | 47 id animationDoneTarget_; // weak |
| 47 SEL animationDoneAction_; | 48 SEL animationDoneAction_; |
| 48 | 49 |
| 49 // The image to show when the mouse hovers over the button. | 50 // The image to show when the mouse hovers over the button. |
| 50 base::scoped_nsobject<NSImage> affordanceImage_; | 51 base::scoped_nsobject<NSImage> affordanceImage_; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 74 // weak reference on |target| is held. | 75 // weak reference on |target| is held. |
| 75 - (void)setAnimationDoneTarget:(id)target withAction:(SEL)action; | 76 - (void)setAnimationDoneTarget:(id)target withAction:(SEL)action; |
| 76 | 77 |
| 77 // Request a message be sent to |target| whenever the enabled button has been | 78 // Request a message be sent to |target| whenever the enabled button has been |
| 78 // clicked. A weak reference on |target| is held. | 79 // clicked. A weak reference on |target| is held. |
| 79 - (void)setClickTarget:(id)target withAction:(SEL)action; | 80 - (void)setClickTarget:(id)target withAction:(SEL)action; |
| 80 | 81 |
| 81 @end | 82 @end |
| 82 | 83 |
| 83 #endif // CHROME_BROWSER_UI_COCOA_TABS_ALERT_INDICATOR_BUTTON_COCOA_H_ | 84 #endif // CHROME_BROWSER_UI_COCOA_TABS_ALERT_INDICATOR_BUTTON_COCOA_H_ |
| OLD | NEW |