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_
8 #include "ui/views/view.h"
10 #include "ui/base/animation/animation_delegate.h"
11 #include "ui/message_center/message_center_export.h"
12 #include "ui/message_center/message_center_observer.h"
13 #include "ui/message_center/notification_list.h"
14 #include "ui/views/controls/button/button.h"
24 namespace message_center
{
27 class MessageCenterBubble
;
28 class NotificationCenterButton
;
29 class MessageCenterButtonBar
;
30 class MessageCenterTray
;
31 class MessageCenterView
;
33 class MessageListView
;
34 class NotifierSettingsView
;
36 // MessageCenterView ///////////////////////////////////////////////////////////
38 class MESSAGE_CENTER_EXPORT MessageCenterView
: public views::View
,
39 public MessageCenterObserver
,
40 public ui::AnimationDelegate
{
42 MessageCenterView(MessageCenter
* message_center
,
43 MessageCenterTray
* tray
,
45 bool initially_settings_visible
,
47 virtual ~MessageCenterView();
49 void SetNotifications(const NotificationList::Notifications
& notifications
);
51 void ClearAllNotifications();
52 void OnAllNotificationsCleared();
54 size_t NumMessageViewsForTest() const;
56 void SetSettingsVisible(bool visible
);
57 void OnSettingsChanged();
58 bool settings_visible() const { return settings_visible_
; }
60 void SetIsClosing(bool is_closing
);
63 // Overridden from views::View:
64 virtual void Layout() OVERRIDE
;
65 virtual gfx::Size
GetPreferredSize() OVERRIDE
;
66 virtual int GetHeightForWidth(int width
) OVERRIDE
;
67 virtual bool OnMouseWheel(const ui::MouseWheelEvent
& event
) OVERRIDE
;
68 virtual void OnMouseExited(const ui::MouseEvent
& event
) OVERRIDE
;
70 // Overridden from MessageCenterObserver:
71 virtual void OnNotificationAdded(const std::string
& id
) OVERRIDE
;
72 virtual void OnNotificationRemoved(const std::string
& id
,
73 bool by_user
) OVERRIDE
;
74 virtual void OnNotificationUpdated(const std::string
& id
) OVERRIDE
;
76 // Overridden from ui::AnimationDelegate:
77 virtual void AnimationEnded(const ui::Animation
* animation
) OVERRIDE
;
78 virtual void AnimationProgressed(const ui::Animation
* animation
) OVERRIDE
;
79 virtual void AnimationCanceled(const ui::Animation
* animation
) OVERRIDE
;
82 friend class MessageCenterViewTest
;
84 void AddNotificationAt(const Notification
& notification
, int index
);
85 void NotificationsChanged();
86 void SetNotificationViewForTest(views::View
* view
);
88 MessageCenter
* message_center_
; // Weak reference.
89 MessageCenterTray
* tray_
; // Weak reference.
90 std::vector
<MessageView
*> message_views_
; // Weak references.
93 views::ScrollView
* scroller_
;
94 MessageListView
* message_list_view_
;
95 NotifierSettingsView
* settings_view_
;
96 MessageCenterButtonBar
* button_bar_
;
97 views::View
* no_notifications_message_view_
;
100 // Data for transition animation between settings view and message list.
101 bool settings_visible_
;
103 // Animation managing transition between message center and settings (and vice
105 scoped_ptr
<ui::MultiAnimation
> settings_transition_animation_
;
107 // Helper data to keep track of the transition between settings and
108 // message center views.
109 views::View
* source_view_
;
111 views::View
* target_view_
;
114 // True when the widget is closing so that further operations should be
118 DISALLOW_COPY_AND_ASSIGN(MessageCenterView
);
121 } // namespace message_center
123 #endif // UI_MESSAGE_CENTER_VIEWS_MESSAGE_CENTER_VIEW_H_