1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
|
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef UI_MESSAGE_CENTER_VIEWS_MESSAGE_CENTER_VIEW_H_
#define UI_MESSAGE_CENTER_VIEWS_MESSAGE_CENTER_VIEW_H_
#include "ui/gfx/animation/animation_delegate.h"
#include "ui/message_center/message_center_export.h"
#include "ui/message_center/message_center_observer.h"
#include "ui/message_center/notification_list.h"
#include "ui/message_center/views/message_center_controller.h"
#include "ui/message_center/views/message_view.h"
#include "ui/views/controls/button/button.h"
#include "ui/views/view.h"
namespace gfx {
class MultiAnimation;
} // namespace gfx
namespace views {
class Button;
} // namespace views
namespace message_center {
class MessageCenter;
class MessageCenterBubble;
class NotificationCenterButton;
class MessageCenterButtonBar;
class MessageCenterTray;
class MessageCenterView;
class MessageView;
class MessageViewContextMenuController;
class MessageListView;
class NotificationView;
class NotifierSettingsView;
// MessageCenterView ///////////////////////////////////////////////////////////
class MESSAGE_CENTER_EXPORT MessageCenterView : public views::View,
public MessageCenterObserver,
public MessageCenterController,
public gfx::AnimationDelegate {
public:
MessageCenterView(MessageCenter* message_center,
MessageCenterTray* tray,
int max_height,
bool initially_settings_visible,
bool top_down,
const base::string16& title);
virtual ~MessageCenterView();
void SetNotifications(const NotificationList::Notifications& notifications);
void ClearAllNotifications();
void OnAllNotificationsCleared();
size_t NumMessageViewsForTest() const;
void SetSettingsVisible(bool visible);
void OnSettingsChanged();
bool settings_visible() const { return settings_visible_; }
MessageCenterTray* tray() { return tray_; }
void SetIsClosing(bool is_closing);
protected:
// Overridden from views::View:
virtual void Layout() override;
virtual gfx::Size GetPreferredSize() const override;
virtual int GetHeightForWidth(int width) const override;
virtual bool OnMouseWheel(const ui::MouseWheelEvent& event) override;
virtual void OnMouseExited(const ui::MouseEvent& event) override;
// Overridden from MessageCenterObserver:
virtual void OnNotificationAdded(const std::string& id) override;
virtual void OnNotificationRemoved(const std::string& id,
bool by_user) override;
virtual void OnNotificationUpdated(const std::string& id) override;
// Overridden from MessageCenterController:
virtual void ClickOnNotification(const std::string& notification_id) override;
virtual void RemoveNotification(const std::string& notification_id,
bool by_user) override;
virtual scoped_ptr<ui::MenuModel> CreateMenuModel(
const NotifierId& notifier_id,
const base::string16& display_source) override;
virtual bool HasClickedListener(const std::string& notification_id) override;
virtual void ClickOnNotificationButton(const std::string& notification_id,
int button_index) override;
// Overridden from gfx::AnimationDelegate:
virtual void AnimationEnded(const gfx::Animation* animation) override;
virtual void AnimationProgressed(const gfx::Animation* animation) override;
virtual void AnimationCanceled(const gfx::Animation* animation) override;
private:
friend class MessageCenterViewTest;
void AddNotificationAt(const Notification& notification, int index);
void NotificationsChanged();
void SetNotificationViewForTest(MessageView* view);
MessageCenter* message_center_; // Weak reference.
MessageCenterTray* tray_; // Weak reference.
// Map notification_id->NotificationView*. It contains all NotificationViews
// currently displayed in MessageCenter.
typedef std::map<std::string, NotificationView*> NotificationViewsMap;
NotificationViewsMap notification_views_; // Weak.
// Child views.
views::ScrollView* scroller_;
scoped_ptr<MessageListView> message_list_view_;
scoped_ptr<views::View> empty_list_view_;
NotifierSettingsView* settings_view_;
MessageCenterButtonBar* button_bar_;
bool top_down_;
// Data for transition animation between settings view and message list.
bool settings_visible_;
// Animation managing transition between message center and settings (and vice
// versa).
scoped_ptr<gfx::MultiAnimation> settings_transition_animation_;
// Helper data to keep track of the transition between settings and
// message center views.
views::View* source_view_;
int source_height_;
views::View* target_view_;
int target_height_;
// True when the widget is closing so that further operations should be
// ignored.
bool is_closing_;
scoped_ptr<MessageViewContextMenuController> context_menu_controller_;
DISALLOW_COPY_AND_ASSIGN(MessageCenterView);
};
} // namespace message_center
#endif // UI_MESSAGE_CENTER_VIEWS_MESSAGE_CENTER_VIEW_H_
|