message_center_view.h revision eb525c5499e34cc9c4b825d6d9e75bb07cc06ace
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_VIEWS_MESSAGE_CENTER_VIEW_H_ 6#define UI_MESSAGE_CENTER_VIEWS_MESSAGE_CENTER_VIEW_H_ 7 8#include "ui/views/view.h" 9 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 15namespace ui { 16class MultiAnimation; 17} // namespace ui 18 19namespace views { 20class Button; 21} // namespace views 22 23namespace message_center { 24 25class MessageCenter; 26class MessageCenterBubble; 27class MessageCenterTray; 28class MessageCenterView; 29class MessageView; 30class MessageListView; 31class NotifierSettingsView; 32 33// MessageCenterButtonBar ////////////////////////////////////////////////////// 34 35// If you know how to better hide this implementation class please do so, and 36// otherwise please refrain from using it :-). 37class MessageCenterButtonBar : public views::View { 38 public: 39 MessageCenterButtonBar(MessageCenterView* message_center_view, 40 MessageCenter* message_center); 41 virtual ~MessageCenterButtonBar(); 42 43 virtual void SetAllButtonsEnabled(bool enabled); 44 45 void SetCloseAllVisible(bool visible); 46 47 protected: 48 MessageCenterView* message_center_view() const { 49 return message_center_view_; 50 } 51 MessageCenter* message_center() const { return message_center_; } 52 MessageCenterTray* tray() const { return tray_; } 53 views::Button* close_all_button() const { return close_all_button_; } 54 void set_close_all_button(views::Button* button) { 55 close_all_button_ = button; 56 } 57 58 private: 59 MessageCenterView* message_center_view_; // Weak reference. 60 MessageCenter* message_center_; // Weak reference. 61 MessageCenterTray* tray_; // Weak reference. 62 views::Button* close_all_button_; 63 64 DISALLOW_COPY_AND_ASSIGN(MessageCenterButtonBar); 65}; 66 67// MessageCenterView /////////////////////////////////////////////////////////// 68 69class MESSAGE_CENTER_EXPORT MessageCenterView : public views::View, 70 public MessageCenterObserver, 71 public ui::AnimationDelegate { 72 public: 73 MessageCenterView(MessageCenter* message_center, 74 MessageCenterTray* tray, 75 int max_height, 76 bool initially_settings_visible); 77 virtual ~MessageCenterView(); 78 79 void SetNotifications(const NotificationList::Notifications& notifications); 80 81 void ClearAllNotifications(); 82 void OnAllNotificationsCleared(); 83 84 size_t NumMessageViewsForTest() const; 85 86 void SetSettingsVisible(bool visible); 87 bool settings_visible() const { return settings_visible_; } 88 89 protected: 90 // Overridden from views::View: 91 virtual void Layout() OVERRIDE; 92 virtual gfx::Size GetPreferredSize() OVERRIDE; 93 virtual int GetHeightForWidth(int width) OVERRIDE; 94 virtual bool OnMouseWheel(const ui::MouseWheelEvent& event) OVERRIDE; 95 virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE; 96 97 // Overridden from MessageCenterObserver: 98 virtual void OnNotificationAdded(const std::string& id) OVERRIDE; 99 virtual void OnNotificationRemoved(const std::string& id, 100 bool by_user) OVERRIDE; 101 virtual void OnNotificationUpdated(const std::string& id) OVERRIDE; 102 103 // Overridden from ui::AnimationDelegate: 104 virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE; 105 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; 106 virtual void AnimationCanceled(const ui::Animation* animation) OVERRIDE; 107 108 private: 109 friend class MessageCenterViewTest; 110 111 void AddNotificationAt(const Notification& notification, int index); 112 void NotificationsChanged(); 113 void SetNotificationViewForTest(views::View* view); 114 115 MessageCenter* message_center_; // Weak reference. 116 MessageCenterTray* tray_; // Weak reference. 117 std::vector<MessageView*> message_views_; 118 views::ScrollView* scroller_; 119 MessageListView* message_list_view_; 120 NotifierSettingsView* settings_view_; 121 MessageCenterButtonBar* button_bar_; 122 views::View* no_notifications_message_view_; 123 124 // Data for transition animation between settings view and message list. 125 bool settings_visible_; 126 views::View* source_view_; 127 views::View* target_view_; 128 int source_height_; 129 int target_height_; 130 scoped_ptr<ui::MultiAnimation> settings_transition_animation_; 131 132 DISALLOW_COPY_AND_ASSIGN(MessageCenterView); 133}; 134 135} // namespace message_center 136 137#endif // UI_MESSAGE_CENTER_VIEWS_MESSAGE_CENTER_VIEW_H_ 138