Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(86)

Side by Side Diff: ui/message_center/message_simple_view.cc

Issue 12277024: Notificaitons refactor step 2 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: steven's feedback Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 : MessageView(list_delegate) {
26 : MessageView(list_delegate, notification) {
27 views::ImageButton* close = new views::ImageButton(this); 26 views::ImageButton* close = new views::ImageButton(this);
28 close->SetImage( 27 close->SetImage(
29 views::CustomButton::STATE_NORMAL, 28 views::CustomButton::STATE_NORMAL,
30 ResourceBundle::GetSharedInstance().GetImageSkiaNamed(IDR_MESSAGE_CLOSE)); 29 ResourceBundle::GetSharedInstance().GetImageSkiaNamed(IDR_MESSAGE_CLOSE));
31 close->SetImageAlignment(views::ImageButton::ALIGN_CENTER, 30 close->SetImageAlignment(views::ImageButton::ALIGN_CENTER,
32 views::ImageButton::ALIGN_MIDDLE); 31 views::ImageButton::ALIGN_MIDDLE);
33 old_style_close_button_.reset(close); 32 old_style_close_button_.reset(close);
34 } 33 }
35 34
36 MessageSimpleView::~MessageSimpleView() { 35 MessageSimpleView::~MessageSimpleView() {
(...skipping 15 matching lines...) Expand all
52 if (!content_view_) 51 if (!content_view_)
53 return gfx::Size(); 52 return gfx::Size();
54 gfx::Size size = content_view_->GetPreferredSize(); 53 gfx::Size size = content_view_->GetPreferredSize();
55 if (border()) { 54 if (border()) {
56 gfx::Insets border_insets = border()->GetInsets(); 55 gfx::Insets border_insets = border()->GetInsets();
57 size.Enlarge(border_insets.width(), border_insets.height()); 56 size.Enlarge(border_insets.width(), border_insets.height());
58 } 57 }
59 return size; 58 return size;
60 } 59 }
61 60
62 void MessageSimpleView::SetUpView() { 61 void MessageSimpleView::SetUpView(const Notification& notification) {
62 MessageView::SetUpView(notification);
63
63 views::ImageView* icon = new views::ImageView; 64 views::ImageView* icon = new views::ImageView;
64 icon->SetImageSize( 65 icon->SetImageSize(
65 gfx::Size(kWebNotificationIconSize, kWebNotificationIconSize)); 66 gfx::Size(kWebNotificationIconSize, kWebNotificationIconSize));
66 icon->SetImage(notification().primary_icon); 67 icon->SetImage(notification.primary_icon());
67 68
68 views::Label* title = new views::Label(notification().title); 69 views::Label* title = new views::Label(notification.title());
69 title->SetHorizontalAlignment(gfx::ALIGN_LEFT); 70 title->SetHorizontalAlignment(gfx::ALIGN_LEFT);
70 title->SetFont(title->font().DeriveFont(0, gfx::Font::BOLD)); 71 title->SetFont(title->font().DeriveFont(0, gfx::Font::BOLD));
71 views::Label* message = new views::Label(notification().message); 72 views::Label* message = new views::Label(notification.message());
72 message->SetHorizontalAlignment(gfx::ALIGN_LEFT); 73 message->SetHorizontalAlignment(gfx::ALIGN_LEFT);
73 message->SetMultiLine(true); 74 message->SetMultiLine(true);
74 75
75 SkColor bg_color = notification().is_read ? 76 SkColor bg_color = notification.is_read() ?
76 kNotificationReadColor : kNotificationColor; 77 kNotificationReadColor : kNotificationColor;
77 content_view_.reset(new views::View); 78 content_view_.reset(new views::View);
78 content_view_->set_background( 79 content_view_->set_background(
79 views::Background::CreateSolidBackground(bg_color)); 80 views::Background::CreateSolidBackground(bg_color));
80 AddChildView(content_view_.get()); 81 AddChildView(content_view_.get());
81 views::GridLayout* layout = new views::GridLayout(content_view_.get()); 82 views::GridLayout* layout = new views::GridLayout(content_view_.get());
82 content_view_->SetLayoutManager(layout); 83 content_view_->SetLayoutManager(layout);
83 84
84 views::ColumnSet* columns = layout->AddColumnSet(0); 85 views::ColumnSet* columns = layout->AddColumnSet(0);
85 86
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 layout->AddPaddingRow(0, kPaddingBetweenItems); 128 layout->AddPaddingRow(0, kPaddingBetweenItems);
128 } 129 }
129 130
130 void MessageSimpleView::ButtonPressed(views::Button* sender, 131 void MessageSimpleView::ButtonPressed(views::Button* sender,
131 const ui::Event& event) { 132 const ui::Event& event) {
132 bool close = (sender == old_style_close_button_.get()); 133 bool close = (sender == old_style_close_button_.get());
133 MessageView::ButtonPressed(close ? close_button() : sender, event); 134 MessageView::ButtonPressed(close ? close_button() : sender, event);
134 } 135 }
135 136
136 } // namespace message_center 137 } // namespace message_center
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698