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 #include "ui/message_center/message_view_multiple.h" | 5 #include "ui/message_center/notification_view.h" |
6 | 6 |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "grit/ui_resources.h" | 8 #include "grit/ui_resources.h" |
9 #include "ui/base/accessibility/accessible_view_state.h" | 9 #include "ui/base/accessibility/accessible_view_state.h" |
10 #include "ui/base/resource/resource_bundle.h" | 10 #include "ui/base/resource/resource_bundle.h" |
11 #include "ui/base/text/text_elider.h" | 11 #include "ui/base/text/text_elider.h" |
12 #include "ui/gfx/canvas.h" | 12 #include "ui/gfx/canvas.h" |
13 #include "ui/gfx/size.h" | 13 #include "ui/gfx/size.h" |
14 #include "ui/message_center/message_center_constants.h" | 14 #include "ui/message_center/message_center_constants.h" |
15 #include "ui/native_theme/native_theme.h" | 15 #include "ui/native_theme/native_theme.h" |
(...skipping 26 matching lines...) Expand all Loading... |
42 const SkColor kTitleColor = SkColorSetRGB(68, 68, 68); | 42 const SkColor kTitleColor = SkColorSetRGB(68, 68, 68); |
43 const SkColor kTitleBackgroundColor = SK_ColorWHITE; | 43 const SkColor kTitleBackgroundColor = SK_ColorWHITE; |
44 const SkColor kMessageColor = SkColorSetRGB(136, 136, 136); | 44 const SkColor kMessageColor = SkColorSetRGB(136, 136, 136); |
45 const SkColor kMessageBackgroundColor = SK_ColorBLACK; | 45 const SkColor kMessageBackgroundColor = SK_ColorBLACK; |
46 | 46 |
47 // Static function to create an empty border to be used as padding. | 47 // Static function to create an empty border to be used as padding. |
48 views::Border* MakePadding(int top, int left, int bottom, int right) { | 48 views::Border* MakePadding(int top, int left, int bottom, int right) { |
49 return views::Border::CreateEmptyBorder(top, left, bottom, right); | 49 return views::Border::CreateEmptyBorder(top, left, bottom, right); |
50 } | 50 } |
51 | 51 |
52 // ItemViews are responsible for drawing each MessageViewMultiple item's title | 52 // ItemViews are responsible for drawing each NotificationView item's title and |
53 // and message next to each other within a single column. | 53 // message next to each other within a single column. |
54 class ItemView : public views::View { | 54 class ItemView : public views::View { |
55 public: | 55 public: |
56 ItemView(const message_center::NotificationList::NotificationItem& item); | 56 ItemView(const message_center::NotificationList::NotificationItem& item); |
57 virtual ~ItemView(); | 57 virtual ~ItemView(); |
58 | 58 |
59 private: | 59 private: |
60 DISALLOW_COPY_AND_ASSIGN(ItemView); | 60 DISALLOW_COPY_AND_ASSIGN(ItemView); |
61 }; | 61 }; |
62 | 62 |
63 ItemView::ItemView( | 63 ItemView::ItemView( |
(...skipping 21 matching lines...) Expand all Loading... |
85 SchedulePaint(); | 85 SchedulePaint(); |
86 } | 86 } |
87 | 87 |
88 ItemView::~ItemView() { | 88 ItemView::~ItemView() { |
89 } | 89 } |
90 | 90 |
91 } // namespace | 91 } // namespace |
92 | 92 |
93 namespace message_center { | 93 namespace message_center { |
94 | 94 |
95 MessageViewMultiple::MessageViewMultiple( | 95 NotificationView::NotificationView( |
96 NotificationList::Delegate* list_delegate, | 96 NotificationList::Delegate* list_delegate, |
97 const NotificationList::Notification& notification) | 97 const NotificationList::Notification& notification) |
98 : MessageView(list_delegate, notification) { | 98 : MessageView(list_delegate, notification) { |
99 } | 99 } |
100 | 100 |
101 MessageViewMultiple::~MessageViewMultiple() { | 101 NotificationView::~NotificationView() { |
102 } | 102 } |
103 | 103 |
104 // TODO(dharcourt): Make this a subclass of BaseFormatView or of a | 104 void NotificationView::SetUpView() { |
105 // BaseFormatView superclass and leverage that class' SetUpView(). | |
106 void MessageViewMultiple::SetUpView() { | |
107 set_background(views::Background::CreateSolidBackground(kBackgroundColor)); | 105 set_background(views::Background::CreateSolidBackground(kBackgroundColor)); |
108 | 106 |
109 views::GridLayout* layout = new views::GridLayout(this); | 107 views::GridLayout* layout = new views::GridLayout(this); |
110 SetLayoutManager(layout); | 108 SetLayoutManager(layout); |
111 | 109 |
112 // Three columns (icon, text, close button) surrounded by padding. The icon | 110 // Three columns (icon, text, close button) surrounded by padding. The icon |
113 // and close button columns and the padding have fixed widths and the text | 111 // and close button columns and the padding have fixed widths and the text |
114 // column fills up the remaining space. To minimize the number of columns and | 112 // column fills up the remaining space. To minimize the number of columns and |
115 // simplify column spanning padding is applied to each view within columns | 113 // simplify column spanning padding is applied to each view within columns |
116 // instead of through padding columns. | 114 // instead of through padding columns. |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 layout->StartRow(0, 0); | 172 layout->StartRow(0, 0); |
175 layout->SkipColumns(1); | 173 layout->SkipColumns(1); |
176 ItemView* item = new ItemView(notification_.items[i]); | 174 ItemView* item = new ItemView(notification_.items[i]); |
177 item->set_border(MakePadding(0, 0, bottom_padding, kTextToClosePadding)); | 175 item->set_border(MakePadding(0, 0, bottom_padding, kTextToClosePadding)); |
178 layout->AddView(item); | 176 layout->AddView(item); |
179 layout->SkipColumns(1); | 177 layout->SkipColumns(1); |
180 } | 178 } |
181 } | 179 } |
182 | 180 |
183 } // namespace message_center | 181 } // namespace message_center |
OLD | NEW |