File: alert_indicator_button_cocoa.h

package info (click to toggle)
chromium-browser 57.0.2987.98-1~deb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 2,637,852 kB
  • ctags: 2,544,394
  • sloc: cpp: 12,815,961; ansic: 3,676,222; python: 1,147,112; asm: 526,608; java: 523,212; xml: 286,794; perl: 92,654; sh: 86,408; objc: 73,271; makefile: 27,698; cs: 18,487; yacc: 13,031; tcl: 12,957; pascal: 4,875; ml: 4,716; lex: 3,904; sql: 3,862; ruby: 1,982; lisp: 1,508; php: 1,368; exp: 404; awk: 325; csh: 117; jsp: 39; sed: 37
file content (93 lines) | stat: -rw-r--r-- 3,539 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_UI_COCOA_TABS_ALERT_INDICATOR_BUTTON_COCOA_H_
#define CHROME_BROWSER_UI_COCOA_TABS_ALERT_INDICATOR_BUTTON_COCOA_H_

#include <memory>

#import "base/mac/scoped_nsobject.h"
#import "chrome/browser/ui/cocoa/themed_window.h"
#include "chrome/browser/ui/tabs/tab_utils.h"
#import "ui/base/cocoa/hover_button.h"

namespace gfx {
class Animation;
class AnimationDelegate;
}  // namespace gfx

// This is an HoverButton subclass that serves as both the alert indicator icon
// (audio, tab capture, etc.), and as a mute button.  It is meant to only be
// used as a subview of TabView.
//
// When the indicator is transitioned to the audio playing or muting state, the
// button functionality is enabled and begins handling mouse events.  Otherwise,
// this view behaves like an image and all mouse events will be handled by the
// its superview.
//
// Note: Send the |-setClickTarget:withAction:| message instead of the
// |-setTarget:| and |-setAction:| messages to be notified of button clicks.
@interface AlertIndicatorButton : HoverButton <ThemedWindowDrawing> {
 @private
  class FadeAnimationDelegate;

  // Current TabAlertState.  When animating fade-in/out, this reflects the
  // indicator state at the end of the animation.
  TabAlertState alertState_;

  // Alert indicator fade-in/out animation (i.e., only on show/hide, not a
  // continuous animation).
  std::unique_ptr<gfx::AnimationDelegate> fadeAnimationDelegate_;
  std::unique_ptr<gfx::Animation> fadeAnimation_;
  TabAlertState showingAlertState_;

  // Set to YES while the button is in the temporary dormant period after mute
  // has been toggled.
  BOOL isDormant_;

  // Target and action invoked whenever a fade-in/out animation completes.  This
  // is used by TabController to layout the TabView after an indicator has
  // completely faded out.
  id animationDoneTarget_;  // weak
  SEL animationDoneAction_;

  // The image to show when the mouse hovers over the button.
  base::scoped_nsobject<NSImage> affordanceImage_;

  // Target and action invoked whenever an enabled button is clicked.
  id clickTarget_;  // weak
  SEL clickAction_;
}

@property(readonly, nonatomic) TabAlertState showingAlertState;

// Initialize a new AlertIndicatorButton in TabAlertState::NONE (i.e., a
// non-active indicator).
- (id)init;

// Updates button images, starts fade animations, and activates/deactivates
// button functionality as appropriate.
- (void)transitionToAlertState:(TabAlertState)nextState;

// Determines whether the AlertIndicatorButtonCocoa will be clickable for
// toggling muting.  This should be called whenever the frame of this view is
// changed, and also whenever the active/inactive state of the tab has changed.
// Internally, |-transitionToAlertState:| will call this.
- (void)updateEnabledForMuteToggle;

// Register a message be sent to |target| whenever fade animations complete.  A
// weak reference on |target| is held.
- (void)setAnimationDoneTarget:(id)target withAction:(SEL)action;

// Request a message be sent to |target| whenever the enabled button has been
// clicked.  A weak reference on |target| is held.
- (void)setClickTarget:(id)target withAction:(SEL)action;

// ThemedWindowDrawing protocol support.
- (void)windowDidChangeTheme;
- (void)windowDidChangeActive;

@end

#endif  // CHROME_BROWSER_UI_COCOA_TABS_ALERT_INDICATOR_BUTTON_COCOA_H_