| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef UI_MESSAGE_CENTER_MESSAGE_VIEW_H_ | 5 #ifndef UI_MESSAGE_CENTER_MESSAGE_VIEW_H_ |
| 6 #define UI_MESSAGE_CENTER_MESSAGE_VIEW_H_ | 6 #define UI_MESSAGE_CENTER_MESSAGE_VIEW_H_ |
| 7 | 7 |
| 8 #include "ui/gfx/insets.h" | 8 #include "ui/gfx/insets.h" |
| 9 #include "ui/message_center/notification.h" | 9 #include "ui/message_center/notification.h" |
| 10 #include "ui/message_center/notification_list.h" | 10 #include "ui/message_center/notification_list.h" |
| 11 #include "ui/views/controls/button/button.h" | 11 #include "ui/views/controls/button/button.h" |
| 12 #include "ui/views/controls/slide_out_view.h" | 12 #include "ui/views/controls/slide_out_view.h" |
| 13 #include "ui/views/view.h" | |
| 14 | 13 |
| 15 namespace views { | 14 namespace views { |
| 16 class ImageButton; | 15 class ImageButton; |
| 16 class ImageView; |
| 17 class ScrollView; | 17 class ScrollView; |
| 18 } | 18 } |
| 19 | 19 |
| 20 namespace message_center { | 20 namespace message_center { |
| 21 | 21 |
| 22 // Individual notifications constants. | 22 // Individual notifications constants. |
| 23 const int kPaddingBetweenItems = 10; | 23 const int kPaddingBetweenItems = 10; |
| 24 const int kPaddingHorizontal = 18; | 24 const int kPaddingHorizontal = 18; |
| 25 const int kWebNotificationButtonWidth = 32; | 25 const int kWebNotificationButtonWidth = 32; |
| 26 const int kWebNotificationIconSize = 40; | 26 const int kWebNotificationIconSize = 40; |
| 27 const int kWebNotificationWidth = 300; | 27 const int kWebNotificationWidth = 300; |
| 28 | 28 |
| 29 // An abstract class that forms the basis of a view for a notification entry. | 29 // An abstract class that forms the basis of a view for a notification entry. |
| 30 class MessageView : public views::SlideOutView, | 30 class MessageView : public views::SlideOutView, |
| 31 public views::ButtonListener { | 31 public views::ButtonListener { |
| 32 public: | 32 public: |
| 33 MessageView(NotificationList::Delegate* list_delegate, | 33 MessageView(const Notification& notification, |
| 34 const Notification& notification); | 34 NotificationList::Delegate* delegate, |
| 35 | 35 bool expanded); |
| 36 virtual ~MessageView(); | 36 virtual ~MessageView(); |
| 37 | 37 |
| 38 // Returns the insets for the shadow it will have for rich notification. | 38 // Returns the insets for the shadow it will have for rich notification. |
| 39 static gfx::Insets GetShadowInsets(); | 39 static gfx::Insets GetShadowInsets(); |
| 40 | 40 |
| 41 void set_scroller(views::ScrollView* scroller) { scroller_ = scroller; } | 41 // Adjust to any change in notification data or expanded status. |
| 42 virtual void Update(const Notification& notification); |
| 42 | 43 |
| 43 // Overridden from views::View. | 44 // Overridden from views::View: |
| 44 virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE; | 45 virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE; |
| 45 | 46 |
| 46 // Overridden from ui::EventHandler. | 47 // Overridden from ui::EventHandler: |
| 47 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; | 48 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; |
| 48 | 49 |
| 49 // Overridden from ButtonListener. | 50 // Overridden from ButtonListener: |
| 50 virtual void ButtonPressed(views::Button* sender, | 51 virtual void ButtonPressed(views::Button* sender, |
| 51 const ui::Event& event) OVERRIDE; | 52 const ui::Event& event) OVERRIDE; |
| 52 | 53 |
| 54 void set_scroller(views::ScrollView* scroller) { scroller_ = scroller; } |
| 55 |
| 53 protected: | 56 protected: |
| 54 MessageView(); | 57 MessageView(); |
| 55 | 58 |
| 56 // Shows the menu for the notification. | 59 // Shows the menu for the notification. |
| 57 void ShowMenu(gfx::Point screen_location); | 60 void ShowMenu(gfx::Point screen_location); |
| 58 | 61 |
| 59 // Overridden from views::SlideOutView. | 62 // Overridden from views::SlideOutView: |
| 60 virtual void OnSlideOut() OVERRIDE; | 63 virtual void OnSlideOut() OVERRIDE; |
| 61 | 64 |
| 62 NotificationList::Delegate* list_delegate() { return list_delegate_; } | 65 NotificationList::Delegate* delegate() { return delegate_; } |
| 63 const std::string& notification_id() { return notification_id_; } | 66 const std::string& notification_id() { return notification_id_; } |
| 64 const string16& display_source() const { return display_source_; } | 67 const string16& display_source() const { return display_source_; } |
| 65 const std::string& extension_id() const { return extension_id_; } | 68 const std::string& extension_id() const { return extension_id_; } |
| 66 views::ImageButton* close_button() { return close_button_.get(); } | 69 views::ImageButton* close_button() { return close_button_.get(); } |
| 70 views::ImageButton* expand_button() { return expand_button_.get(); } |
| 67 views::ScrollView* scroller() { return scroller_; } | 71 views::ScrollView* scroller() { return scroller_; } |
| 72 const bool is_expanded() { return is_expanded_; } |
| 68 | 73 |
| 69 private: | 74 private: |
| 70 NotificationList::Delegate* list_delegate_; // Weak, global (MessageCenter). | 75 NotificationList::Delegate* delegate_; // Weak reference. |
| 71 std::string notification_id_; | 76 std::string notification_id_; |
| 72 string16 display_source_; | 77 string16 display_source_; |
| 73 std::string extension_id_; | 78 std::string extension_id_; |
| 74 | 79 |
| 75 scoped_ptr<views::ImageButton> close_button_; | 80 scoped_ptr<views::ImageButton> close_button_; |
| 81 scoped_ptr<views::ImageButton> expand_button_; |
| 82 views::ScrollView* scroller_; |
| 76 | 83 |
| 77 views::ScrollView* scroller_; | 84 bool is_expanded_; |
| 78 | 85 |
| 79 DISALLOW_COPY_AND_ASSIGN(MessageView); | 86 DISALLOW_COPY_AND_ASSIGN(MessageView); |
| 80 }; | 87 }; |
| 81 | 88 |
| 82 } // namespace message_center | 89 } // namespace message_center |
| 83 | 90 |
| 84 #endif // UI_MESSAGE_CENTER_MESSAGE_VIEW_H_ | 91 #endif // UI_MESSAGE_CENTER_MESSAGE_VIEW_H_ |
| OLD | NEW |