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_VIEWS_MESSAGE_CENTER_VIEW_H_
6 #define UI_MESSAGE_CENTER_VIEWS_MESSAGE_CENTER_VIEW_H_
9 #include "ui/gfx/animation/animation_delegate.h"
10 #include "ui/message_center/message_center_export.h"
11 #include "ui/message_center/message_center_observer.h"
12 #include "ui/message_center/notification_list.h"
13 #include "ui/message_center/views/message_center_controller.h"
14 #include "ui/message_center/views/message_view.h"
15 #include "ui/views/controls/button/button.h"
16 #include "ui/views/view.h"
26 namespace message_center {
29 class MessageCenterBubble;
30 class NotificationCenterButton;
31 class MessageCenterButtonBar;
32 class MessageCenterTray;
33 class MessageCenterView;
35 class MessageViewContextMenuController;
36 class MessageListView;
37 class NotificationView;
38 class NotifierSettingsView;
40 // MessageCenterView ///////////////////////////////////////////////////////////
42 class MESSAGE_CENTER_EXPORT MessageCenterView : public views::View,
43 public MessageCenterObserver,
44 public MessageCenterController,
45 public gfx::AnimationDelegate {
47 MessageCenterView(MessageCenter* message_center,
48 MessageCenterTray* tray,
50 bool initially_settings_visible,
52 virtual ~MessageCenterView();
54 void SetNotifications(const NotificationList::Notifications& notifications);
56 void ClearAllNotifications();
57 void OnAllNotificationsCleared();
59 size_t NumMessageViewsForTest() const;
61 void SetSettingsVisible(bool visible);
62 void OnSettingsChanged();
63 bool settings_visible() const { return settings_visible_; }
65 void SetIsClosing(bool is_closing);
68 // Overridden from views::View:
69 virtual void Layout() OVERRIDE;
70 virtual gfx::Size GetPreferredSize() OVERRIDE;
71 virtual int GetHeightForWidth(int width) OVERRIDE;
72 virtual bool OnMouseWheel(const ui::MouseWheelEvent& event) OVERRIDE;
73 virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE;
75 // Overridden from MessageCenterObserver:
76 virtual void OnNotificationAdded(const std::string& id) OVERRIDE;
77 virtual void OnNotificationRemoved(const std::string& id,
78 bool by_user) OVERRIDE;
79 virtual void OnNotificationUpdated(const std::string& id) OVERRIDE;
81 // Overridden from MessageCenterController:
82 virtual void ClickOnNotification(const std::string& notification_id) OVERRIDE;
83 virtual void RemoveNotification(const std::string& notification_id,
84 bool by_user) OVERRIDE;
85 virtual scoped_ptr<ui::MenuModel> CreateMenuModel(
86 const NotifierId& notifier_id,
87 const base::string16& display_source) OVERRIDE;
88 virtual bool HasClickedListener(const std::string& notification_id) OVERRIDE;
89 virtual void ClickOnNotificationButton(const std::string& notification_id,
90 int button_index) OVERRIDE;
92 // Overridden from gfx::AnimationDelegate:
93 virtual void AnimationEnded(const gfx::Animation* animation) OVERRIDE;
94 virtual void AnimationProgressed(const gfx::Animation* animation) OVERRIDE;
95 virtual void AnimationCanceled(const gfx::Animation* animation) OVERRIDE;
98 friend class MessageCenterViewTest;
100 void AddNotificationAt(const Notification& notification, int index);
101 void NotificationsChanged();
102 void SetNotificationViewForTest(MessageView* view);
104 MessageCenter* message_center_; // Weak reference.
105 MessageCenterTray* tray_; // Weak reference.
107 // Map notification_id->NotificationView*. It contains all NotificaitonViews
108 // currently displayed in MessageCenter.
109 typedef std::map<std::string, NotificationView*> NotificationViewsMap;
110 NotificationViewsMap notification_views_; // Weak.
113 views::ScrollView* scroller_;
114 scoped_ptr<MessageListView> message_list_view_;
115 scoped_ptr<views::View> empty_list_view_;
116 NotifierSettingsView* settings_view_;
117 MessageCenterButtonBar* button_bar_;
120 // Data for transition animation between settings view and message list.
121 bool settings_visible_;
123 // Animation managing transition between message center and settings (and vice
125 scoped_ptr<gfx::MultiAnimation> settings_transition_animation_;
127 // Helper data to keep track of the transition between settings and
128 // message center views.
129 views::View* source_view_;
131 views::View* target_view_;
134 // True when the widget is closing so that further operations should be
138 scoped_ptr<MessageViewContextMenuController> context_menu_controller_;
140 DISALLOW_COPY_AND_ASSIGN(MessageCenterView);
143 } // namespace message_center
145 #endif // UI_MESSAGE_CENTER_VIEWS_MESSAGE_CENTER_VIEW_H_