1 // Copyright (c) 2013 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.
5 #ifndef UI_MESSAGE_CENTER_COCOA_POPUP_CONTROLLER_H_
6 #define UI_MESSAGE_CENTER_COCOA_POPUP_CONTROLLER_H_
8 #import <Cocoa/Cocoa.h>
12 #import "base/mac/scoped_nsobject.h"
13 #import "ui/base/cocoa/tracking_area.h"
14 #include "ui/message_center/message_center_export.h"
16 namespace message_center
{
21 @
class MCNotificationController
;
22 @
class MCPopupCollection
;
24 // A window controller that hosts a notification as a popup balloon on the
25 // user's desktop. The window controller manages its lifetime because the
26 // popup collection will be destructed when the last popup is closed.
28 @interface MCPopupController
: NSWindowController
<NSAnimationDelegate
> {
30 // Global message center. Weak.
31 message_center::MessageCenter
* messageCenter_
;
33 // The collection that contains the popup. Weak.
34 MCPopupCollection
* popupCollection_
;
36 // The view controller that provide's the popup content view.
37 base::scoped_nsobject
<MCNotificationController
> notificationController_
;
39 // If the swipe-away gesture received NSEventPhaseEnded.
40 BOOL swipeGestureEnded_
;
42 // The frame of the popup before any swipe animation started. Used to
43 // calculate the animating position of the window when swiping away.
44 NSRect originalFrame_
;
46 // Is the popup currently being closed?
50 // Has the popup been closed before being dealloc-ed.
54 // The current bounds of the popup frame if no animation is playing.
55 // Otherwise, it is the target bounds of the popup frame.
58 // Used to play animation when the popup shows, changes bounds and closes.
59 base::scoped_nsobject
<NSViewAnimation
> boundsAnimation_
;
61 // Used to track the popup for mouse entered and exited events.
62 ui::ScopedCrTrackingArea trackingArea_
;
65 // Designated initializer.
66 - (id
)initWithNotification
:(const message_center::Notification
*)notification
67 messageCenter
:(message_center::MessageCenter
*)messageCenter
68 popupCollection
:(MCPopupCollection
*)popupCollection
;
70 // Accessor for the view controller.
71 - (MCNotificationController
*)notificationController
;
73 // Accessor for the notification model object.
74 - (const message_center::Notification
*)notification
;
76 // Gets the notification ID. This string is owned by the NotificationController
77 // rather than the model object, so it's safe to use after the Notification has
79 - (const std::string
&)notificationID
;
81 // Shows the window with the sliding animation.
82 - (void)showWithAnimation
:(NSRect
)newBounds
;
84 // Closes the window with the fade-out animation.
85 - (void)closeWithAnimation
;
87 // Tells that the popupCollection_ is gone.
88 - (void)markPopupCollectionGone
;
90 // Returns the window bounds. This is the target bounds to go to if the bounds
91 // animation is playing.
94 // Changes the window bounds with animation.
95 - (void)setBounds
:(NSRect
)newBounds
;
99 #endif // UI_MESSAGE_CENTER_COCOA_POPUP_CONTROLLER_H_