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 const base::string16
& title
);
53 virtual ~MessageCenterView();
55 void SetNotifications(const NotificationList::Notifications
& notifications
);
57 void ClearAllNotifications();
58 void OnAllNotificationsCleared();
60 size_t NumMessageViewsForTest() const;
62 void SetSettingsVisible(bool visible
);
63 void OnSettingsChanged();
64 bool settings_visible() const { return settings_visible_
; }
65 MessageCenterTray
* tray() { return tray_
; }
67 void SetIsClosing(bool is_closing
);
70 // Overridden from views::View:
71 virtual void Layout() OVERRIDE
;
72 virtual gfx::Size
GetPreferredSize() const OVERRIDE
;
73 virtual int GetHeightForWidth(int width
) const OVERRIDE
;
74 virtual bool OnMouseWheel(const ui::MouseWheelEvent
& event
) OVERRIDE
;
75 virtual void OnMouseExited(const ui::MouseEvent
& event
) OVERRIDE
;
77 // Overridden from MessageCenterObserver:
78 virtual void OnNotificationAdded(const std::string
& id
) OVERRIDE
;
79 virtual void OnNotificationRemoved(const std::string
& id
,
80 bool by_user
) OVERRIDE
;
81 virtual void OnNotificationUpdated(const std::string
& id
) OVERRIDE
;
83 // Overridden from MessageCenterController:
84 virtual void ClickOnNotification(const std::string
& notification_id
) OVERRIDE
;
85 virtual void RemoveNotification(const std::string
& notification_id
,
86 bool by_user
) OVERRIDE
;
87 virtual scoped_ptr
<ui::MenuModel
> CreateMenuModel(
88 const NotifierId
& notifier_id
,
89 const base::string16
& display_source
) OVERRIDE
;
90 virtual bool HasClickedListener(const std::string
& notification_id
) OVERRIDE
;
91 virtual void ClickOnNotificationButton(const std::string
& notification_id
,
92 int button_index
) OVERRIDE
;
94 // Overridden from gfx::AnimationDelegate:
95 virtual void AnimationEnded(const gfx::Animation
* animation
) OVERRIDE
;
96 virtual void AnimationProgressed(const gfx::Animation
* animation
) OVERRIDE
;
97 virtual void AnimationCanceled(const gfx::Animation
* animation
) OVERRIDE
;
100 friend class MessageCenterViewTest
;
102 void AddNotificationAt(const Notification
& notification
, int index
);
103 void NotificationsChanged();
104 void SetNotificationViewForTest(MessageView
* view
);
106 MessageCenter
* message_center_
; // Weak reference.
107 MessageCenterTray
* tray_
; // Weak reference.
109 // Map notification_id->NotificationView*. It contains all NotificationViews
110 // currently displayed in MessageCenter.
111 typedef std::map
<std::string
, NotificationView
*> NotificationViewsMap
;
112 NotificationViewsMap notification_views_
; // Weak.
115 views::ScrollView
* scroller_
;
116 scoped_ptr
<MessageListView
> message_list_view_
;
117 scoped_ptr
<views::View
> empty_list_view_
;
118 NotifierSettingsView
* settings_view_
;
119 MessageCenterButtonBar
* button_bar_
;
122 // Data for transition animation between settings view and message list.
123 bool settings_visible_
;
125 // Animation managing transition between message center and settings (and vice
127 scoped_ptr
<gfx::MultiAnimation
> settings_transition_animation_
;
129 // Helper data to keep track of the transition between settings and
130 // message center views.
131 views::View
* source_view_
;
133 views::View
* target_view_
;
136 // True when the widget is closing so that further operations should be
140 scoped_ptr
<MessageViewContextMenuController
> context_menu_controller_
;
142 DISALLOW_COPY_AND_ASSIGN(MessageCenterView
);
145 } // namespace message_center
147 #endif // UI_MESSAGE_CENTER_VIEWS_MESSAGE_CENTER_VIEW_H_