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_simple_view.h" | 5 #include "ui/message_center/message_simple_view.h" |
6 | 6 |
7 #include "grit/ui_resources.h" | 7 #include "grit/ui_resources.h" |
8 #include "ui/base/resource/resource_bundle.h" | 8 #include "ui/base/resource/resource_bundle.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/background.h" | 11 #include "ui/views/background.h" |
12 #include "ui/views/controls/button/image_button.h" | 12 #include "ui/views/controls/button/image_button.h" |
13 #include "ui/views/controls/image_view.h" | 13 #include "ui/views/controls/image_view.h" |
14 #include "ui/views/controls/label.h" | 14 #include "ui/views/controls/label.h" |
15 #include "ui/views/controls/scroll_view.h" | 15 #include "ui/views/controls/scroll_view.h" |
16 #include "ui/views/layout/grid_layout.h" | 16 #include "ui/views/layout/grid_layout.h" |
17 | 17 |
18 namespace message_center { | 18 namespace message_center { |
19 | 19 |
20 const SkColor kNotificationColor = SkColorSetRGB(0xfe, 0xfe, 0xfe); | 20 const SkColor kNotificationColor = SkColorSetRGB(0xfe, 0xfe, 0xfe); |
21 const SkColor kNotificationReadColor = SkColorSetRGB(0xfa, 0xfa, 0xfa); | 21 const SkColor kNotificationReadColor = SkColorSetRGB(0xfa, 0xfa, 0xfa); |
22 | 22 |
23 MessageSimpleView::MessageSimpleView( | 23 MessageSimpleView::MessageSimpleView( |
24 NotificationList::Delegate* list_delegate, | 24 NotificationList::Delegate* list_delegate, |
25 const Notification& notification) | 25 Notification* notification) |
26 : MessageView(list_delegate, notification) { | 26 : MessageView(list_delegate, notification) { |
27 views::ImageButton* close = new views::ImageButton(this); | 27 views::ImageButton* close = new views::ImageButton(this); |
28 close->SetImage( | 28 close->SetImage( |
29 views::CustomButton::STATE_NORMAL, | 29 views::CustomButton::STATE_NORMAL, |
30 ResourceBundle::GetSharedInstance().GetImageSkiaNamed(IDR_MESSAGE_CLOSE)); | 30 ResourceBundle::GetSharedInstance().GetImageSkiaNamed(IDR_MESSAGE_CLOSE)); |
31 close->SetImageAlignment(views::ImageButton::ALIGN_CENTER, | 31 close->SetImageAlignment(views::ImageButton::ALIGN_CENTER, |
32 views::ImageButton::ALIGN_MIDDLE); | 32 views::ImageButton::ALIGN_MIDDLE); |
33 old_style_close_button_.reset(close); | 33 old_style_close_button_.reset(close); |
34 } | 34 } |
35 | 35 |
(...skipping 20 matching lines...) Expand all Loading... |
56 gfx::Insets border_insets = border()->GetInsets(); | 56 gfx::Insets border_insets = border()->GetInsets(); |
57 size.Enlarge(border_insets.width(), border_insets.height()); | 57 size.Enlarge(border_insets.width(), border_insets.height()); |
58 } | 58 } |
59 return size; | 59 return size; |
60 } | 60 } |
61 | 61 |
62 void MessageSimpleView::SetUpView() { | 62 void MessageSimpleView::SetUpView() { |
63 views::ImageView* icon = new views::ImageView; | 63 views::ImageView* icon = new views::ImageView; |
64 icon->SetImageSize( | 64 icon->SetImageSize( |
65 gfx::Size(kWebNotificationIconSize, kWebNotificationIconSize)); | 65 gfx::Size(kWebNotificationIconSize, kWebNotificationIconSize)); |
66 icon->SetImage(notification().primary_icon); | 66 icon->SetImage(notification()->primary_icon()); |
67 | 67 |
68 views::Label* title = new views::Label(notification().title); | 68 views::Label* title = new views::Label(notification()->title()); |
69 title->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 69 title->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
70 title->SetFont(title->font().DeriveFont(0, gfx::Font::BOLD)); | 70 title->SetFont(title->font().DeriveFont(0, gfx::Font::BOLD)); |
71 views::Label* message = new views::Label(notification().message); | 71 views::Label* message = new views::Label(notification()->message()); |
72 message->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 72 message->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
73 message->SetMultiLine(true); | 73 message->SetMultiLine(true); |
74 | 74 |
75 SkColor bg_color = notification().is_read ? | 75 SkColor bg_color = notification()->is_read() ? |
76 kNotificationReadColor : kNotificationColor; | 76 kNotificationReadColor : kNotificationColor; |
77 content_view_.reset(new views::View); | 77 content_view_.reset(new views::View); |
78 content_view_->set_background( | 78 content_view_->set_background( |
79 views::Background::CreateSolidBackground(bg_color)); | 79 views::Background::CreateSolidBackground(bg_color)); |
80 AddChildView(content_view_.get()); | 80 AddChildView(content_view_.get()); |
81 views::GridLayout* layout = new views::GridLayout(content_view_.get()); | 81 views::GridLayout* layout = new views::GridLayout(content_view_.get()); |
82 content_view_->SetLayoutManager(layout); | 82 content_view_->SetLayoutManager(layout); |
83 | 83 |
84 views::ColumnSet* columns = layout->AddColumnSet(0); | 84 views::ColumnSet* columns = layout->AddColumnSet(0); |
85 | 85 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 layout->AddPaddingRow(0, kPaddingBetweenItems); | 127 layout->AddPaddingRow(0, kPaddingBetweenItems); |
128 } | 128 } |
129 | 129 |
130 void MessageSimpleView::ButtonPressed(views::Button* sender, | 130 void MessageSimpleView::ButtonPressed(views::Button* sender, |
131 const ui::Event& event) { | 131 const ui::Event& event) { |
132 bool close = (sender == old_style_close_button_.get()); | 132 bool close = (sender == old_style_close_button_.get()); |
133 MessageView::ButtonPressed(close ? close_button() : sender, event); | 133 MessageView::ButtonPressed(close ? close_button() : sender, event); |
134 } | 134 } |
135 | 135 |
136 } // namespace message_center | 136 } // namespace message_center |
OLD | NEW |