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?
49 // The current bounds of the popup frame if no animation is playing.
50 // Otherwise, it is the target bounds of the popup frame.
53 // Used to play animation when the popup shows, changes bounds and closes.
54 base::scoped_nsobject
<NSViewAnimation
> boundsAnimation_
;
56 // Used to track the popup for mouse entered and exited events.
57 ui::ScopedCrTrackingArea trackingArea_
;
60 // Designated initializer.
61 - (id
)initWithNotification
:(const message_center::Notification
*)notification
62 messageCenter
:(message_center::MessageCenter
*)messageCenter
63 popupCollection
:(MCPopupCollection
*)popupCollection
;
65 // Accessor for the view controller.
66 - (MCNotificationController
*)notificationController
;
68 // Accessor for the notification model object.
69 - (const message_center::Notification
*)notification
;
71 // Gets the notification ID. This string is owned by the NotificationController
72 // rather than the model object, so it's safe to use after the Notification has
74 - (const std::string
&)notificationID
;
76 // Shows the window with the sliding animation.
77 - (void)showWithAnimation
:(NSRect
)newBounds
;
79 // Closes the window with the fade-out animation.
80 - (void)closeWithAnimation
;
82 // Tells that the popupCollection_ is gone.
83 - (void)markPopupCollectionGone
;
85 // Returns the window bounds. This is the target bounds to go to if the bounds
86 // animation is playing.
89 // Changes the window bounds with animation.
90 - (void)setBounds
:(NSRect
)newBounds
;
94 #endif // UI_MESSAGE_CENTER_COCOA_POPUP_CONTROLLER_H_