NaCl: Update revision in DEPS, e8fbd4b -> 9e3dac8
[chromium-blink-merge.git] / ui / message_center / cocoa / tray_view_controller.h
blob5d5b3af83e9ddea4c81e21e97203758c6b18b55b
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_TRAY_VIEW_CONTROLLER_H_
6 #define UI_MESSAGE_CENTER_COCOA_TRAY_VIEW_CONTROLLER_H_
8 #import <Cocoa/Cocoa.h>
10 #include <list>
11 #include <map>
12 #include <string>
14 #include "base/mac/scoped_block.h"
15 #import "base/mac/scoped_nsobject.h"
16 #include "base/strings/string16.h"
17 #include "ui/message_center/message_center_export.h"
19 @class HoverImageButton;
20 @class MCNotificationController;
21 @class MCSettingsController;
23 namespace message_center {
24 class MessageCenter;
27 @class HoverImageButton;
28 @class MCClipView;
30 namespace message_center {
31 typedef void(^TrayAnimationEndedCallback)();
34 // The view controller responsible for the content of the message center tray
35 // UI. This hosts a scroll view of all the notifications, as well as buttons
36 // to enter quiet mode and the settings panel.
37 MESSAGE_CENTER_EXPORT
38 @interface MCTrayViewController : NSViewController<NSAnimationDelegate> {
39 @private
40 // Controller of the notifications, where action messages are forwarded. Weak.
41 message_center::MessageCenter* messageCenter_;
43 // The back button shown while the settings are open.
44 base::scoped_nsobject<HoverImageButton> backButton_;
46 // The "Notifications" label at the top.
47 base::scoped_nsobject<NSTextField> title_;
49 // The 1px horizontal divider between the scroll view and the title bar.
50 base::scoped_nsobject<NSBox> divider_;
52 // The "Nothing to see here" label in an empty message center.
53 base::scoped_nsobject<NSTextField> emptyDescription_;
55 // The scroll view that contains all the notifications in its documentView.
56 base::scoped_nsobject<NSScrollView> scrollView_;
58 // The clip view that manages how scrollView_'s documentView is clipped.
59 base::scoped_nsobject<MCClipView> clipView_;
61 // Array of MCNotificationController objects, which the array owns.
62 base::scoped_nsobject<NSMutableArray> notifications_;
64 // Map of notification IDs to weak pointers of the view controllers in
65 // |notifications_|.
66 std::map<std::string, MCNotificationController*> notificationsMap_;
68 // The pause button that enters quiet mode.
69 base::scoped_nsobject<HoverImageButton> pauseButton_;
71 // The clear all notifications button. Hidden when there are no notifications.
72 base::scoped_nsobject<HoverImageButton> clearAllButton_;
74 // The settings button that shows the settings UI.
75 base::scoped_nsobject<HoverImageButton> settingsButton_;
77 // Array of MCNotificationController objects pending removal by the user.
78 // The object is owned by the array.
79 base::scoped_nsobject<NSMutableArray> notificationsPendingRemoval_;
81 // Used to animate multiple notifications simultaneously when they're being
82 // removed or repositioned.
83 base::scoped_nsobject<NSViewAnimation> animation_;
85 // The controller of the settings view. Only set while the view is open.
86 base::scoped_nsobject<MCSettingsController> settingsController_;
88 // The flag which is set when the notification removal animation is still
89 // in progress and the user clicks "Clear All" button. The clear-all animation
90 // will be delayed till the existing animation completes.
91 BOOL clearAllDelayed_;
93 // The flag which is set when the clear-all animation is in progress.
94 BOOL clearAllInProgress_;
96 // List of weak pointers of the view controllers that are visible in the
97 // scroll view and waiting to slide off one by one when the user clicks
98 // "Clear All" button.
99 std::list<MCNotificationController*> visibleNotificationsPendingClear_;
101 // Array of NSViewAnimation objects, which the array owns.
102 base::scoped_nsobject<NSMutableArray> clearAllAnimations_;
104 // The duration of the bounds animation, in the number of seconds.
105 NSTimeInterval animationDuration_;
107 // The delay to start animating clearing next notification, in the number of
108 // seconds.
109 NSTimeInterval animateClearingNextNotificationDelay_;
111 // For testing only. If set, the callback will be called when the animation
112 // ends.
113 base::mac::ScopedBlock<message_center::TrayAnimationEndedCallback>
114 testingAnimationEndedCallback_;
117 // The title that is displayed at the top of the message center tray.
118 @property(copy, nonatomic) NSString* trayTitle;
120 // Designated initializer.
121 - (id)initWithMessageCenter:(message_center::MessageCenter*)messageCenter;
123 // Called when the window is being closed.
124 - (void)onWindowClosing;
126 // Callback for when the MessageCenter model changes.
127 - (void)onMessageCenterTrayChanged;
129 // Action for the quiet mode button.
130 - (void)toggleQuietMode:(id)sender;
132 // Action for the clear all button.
133 - (void)clearAllNotifications:(id)sender;
135 // Action for the settings button.
136 - (void)showSettings:(id)sender;
138 // Updates the settings dialog in response to contents change due to something
139 // like selecting a different profile.
140 - (void)updateSettings;
142 // Hides the settings dialog if it's open.
143 - (void)showMessages:(id)sender;
145 // Cleans up settings data structures. Called when messages are shown and when
146 // closing the center directly from the settings.
147 - (void)cleanupSettings;
149 // Scroll to the topmost notification in the tray.
150 - (void)scrollToTop;
152 // Returns true if an animation is being played.
153 - (BOOL)isAnimating;
155 // Returns the maximum height of the client area of the notifications tray.
156 + (CGFloat)maxTrayClientHeight;
158 // Returns the width of the notifications tray.
159 + (CGFloat)trayWidth;
161 @end
163 // Testing API /////////////////////////////////////////////////////////////////
165 @interface MCTrayViewController (TestingAPI)
166 - (NSBox*)divider;
167 - (NSTextField*)emptyDescription;
168 - (NSScrollView*)scrollView;
169 - (HoverImageButton*)pauseButton;
170 - (HoverImageButton*)clearAllButton;
172 // Setter for changing the animation duration. The testing code could set it
173 // to a very small value to expedite the test running.
174 - (void)setAnimationDuration:(NSTimeInterval)duration;
176 // Setter for changing the clear-all animation delay. The testing code could set
177 // it to a very small value to expedite the test running.
178 - (void)setAnimateClearingNextNotificationDelay:(NSTimeInterval)delay;
180 // Setter for testingAnimationEndedCallback_. The testing code could set it
181 // to get called back when the animation ends.
182 - (void)setAnimationEndedCallback:
183 (message_center::TrayAnimationEndedCallback)callback;
184 @end
186 #endif // UI_MESSAGE_CENTER_COCOA_TRAY_VIEW_CONTROLLER_H_