OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #ifndef UI_MESSAGE_CENTER_COCOA_TRAY_VIEW_CONTROLLER_H_ | |
6 #define UI_MESSAGE_CENTER_COCOA_TRAY_VIEW_CONTROLLER_H_ | |
7 | |
8 #import <Cocoa/Cocoa.h> | |
9 | |
10 #include <list> | |
11 #include <map> | |
12 #include <string> | |
13 | |
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" | |
18 | |
19 @class HoverImageButton; | |
20 @class MCNotificationController; | |
21 @class MCSettingsController; | |
22 | |
23 namespace message_center { | |
24 class MessageCenter; | |
25 } | |
26 | |
27 @class HoverImageButton; | |
28 @class MCClipView; | |
29 | |
30 namespace message_center { | |
31 typedef void(^TrayAnimationEndedCallback)(); | |
32 } | |
33 | |
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_; | |
42 | |
43 // The back button shown while the settings are open. | |
44 base::scoped_nsobject<HoverImageButton> backButton_; | |
45 | |
46 // The "Notifications" label at the top. | |
47 base::scoped_nsobject<NSTextField> title_; | |
48 | |
49 // The 1px horizontal divider between the scroll view and the title bar. | |
50 base::scoped_nsobject<NSBox> divider_; | |
51 | |
52 // The "Nothing to see here" label in an empty message center. | |
53 base::scoped_nsobject<NSTextField> emptyDescription_; | |
54 | |
55 // The scroll view that contains all the notifications in its documentView. | |
56 base::scoped_nsobject<NSScrollView> scrollView_; | |
57 | |
58 // The clip view that manages how scrollView_'s documentView is clipped. | |
59 base::scoped_nsobject<MCClipView> clipView_; | |
60 | |
61 // Array of MCNotificationController objects, which the array owns. | |
62 base::scoped_nsobject<NSMutableArray> notifications_; | |
63 | |
64 // Map of notification IDs to weak pointers of the view controllers in | |
65 // |notifications_|. | |
66 std::map<std::string, MCNotificationController*> notificationsMap_; | |
67 | |
68 // The pause button that enters quiet mode. | |
69 base::scoped_nsobject<HoverImageButton> pauseButton_; | |
70 | |
71 // The clear all notifications button. Hidden when there are no notifications. | |
72 base::scoped_nsobject<HoverImageButton> clearAllButton_; | |
73 | |
74 // The settings button that shows the settings UI. | |
75 base::scoped_nsobject<HoverImageButton> settingsButton_; | |
76 | |
77 // Array of MCNotificationController objects pending removal by the user. | |
78 // The object is owned by the array. | |
79 base::scoped_nsobject<NSMutableArray> notificationsPendingRemoval_; | |
80 | |
81 // Used to animate multiple notifications simultaneously when they're being | |
82 // removed or repositioned. | |
83 base::scoped_nsobject<NSViewAnimation> animation_; | |
84 | |
85 // The controller of the settings view. Only set while the view is open. | |
86 base::scoped_nsobject<MCSettingsController> settingsController_; | |
87 | |
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_; | |
92 | |
93 // The flag which is set when the clear-all animation is in progress. | |
94 BOOL clearAllInProgress_; | |
95 | |
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_; | |
100 | |
101 // Array of NSViewAnimation objects, which the array owns. | |
102 base::scoped_nsobject<NSMutableArray> clearAllAnimations_; | |
103 | |
104 // The duration of the bounds animation, in the number of seconds. | |
105 NSTimeInterval animationDuration_; | |
106 | |
107 // The delay to start animating clearing next notification, in the number of | |
108 // seconds. | |
109 NSTimeInterval animateClearingNextNotificationDelay_; | |
110 | |
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_; | |
115 } | |
116 | |
117 // The title that is displayed at the top of the message center tray. | |
118 @property(copy, nonatomic) NSString* trayTitle; | |
119 | |
120 // Designated initializer. | |
121 - (id)initWithMessageCenter:(message_center::MessageCenter*)messageCenter; | |
122 | |
123 // Called when the window is being closed. | |
124 - (void)onWindowClosing; | |
125 | |
126 // Callback for when the MessageCenter model changes. | |
127 - (void)onMessageCenterTrayChanged; | |
128 | |
129 // Action for the quiet mode button. | |
130 - (void)toggleQuietMode:(id)sender; | |
131 | |
132 // Action for the clear all button. | |
133 - (void)clearAllNotifications:(id)sender; | |
134 | |
135 // Action for the settings button. | |
136 - (void)showSettings:(id)sender; | |
137 | |
138 // Updates the settings dialog in response to contents change due to something | |
139 // like selecting a different profile. | |
140 - (void)updateSettings; | |
141 | |
142 // Hides the settings dialog if it's open. | |
143 - (void)showMessages:(id)sender; | |
144 | |
145 // Cleans up settings data structures. Called when messages are shown and when | |
146 // closing the center directly from the settings. | |
147 - (void)cleanupSettings; | |
148 | |
149 // Scroll to the topmost notification in the tray. | |
150 - (void)scrollToTop; | |
151 | |
152 // Returns true if an animation is being played. | |
153 - (BOOL)isAnimating; | |
154 | |
155 // Returns the maximum height of the client area of the notifications tray. | |
156 + (CGFloat)maxTrayClientHeight; | |
157 | |
158 // Returns the width of the notifications tray. | |
159 + (CGFloat)trayWidth; | |
160 | |
161 @end | |
162 | |
163 // Testing API ///////////////////////////////////////////////////////////////// | |
164 | |
165 @interface MCTrayViewController (TestingAPI) | |
166 - (NSBox*)divider; | |
167 - (NSTextField*)emptyDescription; | |
168 - (NSScrollView*)scrollView; | |
169 - (HoverImageButton*)pauseButton; | |
170 - (HoverImageButton*)clearAllButton; | |
171 | |
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; | |
175 | |
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; | |
179 | |
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 | |
185 | |
186 #endif // UI_MESSAGE_CENTER_COCOA_TRAY_VIEW_CONTROLLER_H_ | |
OLD | NEW |