File: popup_controller.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 (99 lines) | stat: -rw-r--r-- 3,207 bytes parent folder | download | duplicates (4)
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
94
95
96
97
98
99
// Copyright (c) 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 UI_MESSAGE_CENTER_COCOA_POPUP_CONTROLLER_H_
#define UI_MESSAGE_CENTER_COCOA_POPUP_CONTROLLER_H_

#import <Cocoa/Cocoa.h>

#include <string>

#import "base/mac/scoped_nsobject.h"
#import "ui/base/cocoa/tracking_area.h"
#include "ui/message_center/message_center_export.h"

namespace message_center {
class MessageCenter;
class Notification;
}

@class MCNotificationController;
@class MCPopupCollection;

// A window controller that hosts a notification as a popup balloon on the
// user's desktop. The window controller manages its lifetime because the
// popup collection will be destructed when the last popup is closed.
MESSAGE_CENTER_EXPORT
@interface MCPopupController : NSWindowController<NSAnimationDelegate>  {
 @private
  // Global message center. Weak.
  message_center::MessageCenter* messageCenter_;

  // The collection that contains the popup. Weak.
  MCPopupCollection* popupCollection_;

  // The view controller that provide's the popup content view.
  base::scoped_nsobject<MCNotificationController> notificationController_;

  // If the swipe-away gesture received NSEventPhaseEnded.
  BOOL swipeGestureEnded_;

  // The frame of the popup before any swipe animation started. Used to
  // calculate the animating position of the window when swiping away.
  NSRect originalFrame_;

  // Is the popup currently being closed?
  BOOL isClosing_;

#ifndef NDEBUG
  // Has the popup been closed before being dealloc-ed.
  BOOL hasBeenClosed_;
#endif

  // The current bounds of the popup frame if no animation is playing.
  // Otherwise, it is the target bounds of the popup frame.
  NSRect bounds_;

  // Used to play animation when the popup shows, changes bounds and closes.
  base::scoped_nsobject<NSViewAnimation> boundsAnimation_;

  // Used to track the popup for mouse entered and exited events.
  ui::ScopedCrTrackingArea trackingArea_;
}

// Designated initializer.
- (id)initWithNotification:(const message_center::Notification*)notification
             messageCenter:(message_center::MessageCenter*)messageCenter
           popupCollection:(MCPopupCollection*)popupCollection;

// Accessor for the view controller.
- (MCNotificationController*)notificationController;

// Accessor for the notification model object.
- (const message_center::Notification*)notification;

// Gets the notification ID. This string is owned by the NotificationController
// rather than the model object, so it's safe to use after the Notification has
// been deleted.
- (const std::string&)notificationID;

// Shows the window with the sliding animation.
- (void)showWithAnimation:(NSRect)newBounds;

// Closes the window with the fade-out animation.
- (void)closeWithAnimation;

// Tells that the popupCollection_ is gone.
- (void)markPopupCollectionGone;

// Returns the window bounds. This is the target bounds to go to if the bounds
// animation is playing.
- (NSRect)bounds;

// Changes the window bounds with animation.
- (void)setBounds:(NSRect)newBounds;

@end

#endif  // UI_MESSAGE_CENTER_COCOA_POPUP_CONTROLLER_H_