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