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

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

Issue 11926032: Updated the look of web and basic notifications to match latest mockups. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ui/message_center/message_simple_view.h"
6
7 #include "grit/ui_resources.h"
8 #include "ui/base/resource/resource_bundle.h"
9 #include "ui/views/controls/button/image_button.h"
10 #include "ui/views/controls/image_view.h"
11 #include "ui/views/controls/label.h"
12 #include "ui/views/controls/scroll_view.h"
13 #include "ui/views/layout/grid_layout.h"
14
15 namespace message_center {
16
17 const SkColor kNotificationColor = SkColorSetRGB(0xfe, 0xfe, 0xfe);
18 const SkColor kNotificationReadColor = SkColorSetRGB(0xfa, 0xfa, 0xfa);
19
20 MessageSimpleView::MessageSimpleView(
21 NotificationList::Delegate* list_delegate,
22 const NotificationList::Notification& notification)
23 : MessageView(list_delegate, notification) {
24 }
25
26 MessageSimpleView::~MessageSimpleView() {
27 }
28
29 void MessageSimpleView::SetUpView() {
30 SkColor bg_color = notification().is_read ?
31 kNotificationReadColor : kNotificationColor;
32 set_background(views::Background::CreateSolidBackground(bg_color));
33
34 views::ImageView* icon = new views::ImageView;
35 icon->SetImageSize(
36 gfx::Size(kWebNotificationIconSize, kWebNotificationIconSize));
37 icon->SetImage(notification().primary_icon);
38
39 views::Label* title = new views::Label(notification().title);
40 title->SetHorizontalAlignment(gfx::ALIGN_LEFT);
41 title->SetFont(title->font().DeriveFont(0, gfx::Font::BOLD));
42 views::Label* message = new views::Label(notification().message);
43 message->SetHorizontalAlignment(gfx::ALIGN_LEFT);
44 message->SetMultiLine(true);
45
46 views::GridLayout* layout = new views::GridLayout(this);
47 SetLayoutManager(layout);
48
49 views::ColumnSet* columns = layout->AddColumnSet(0);
50
51 const int padding_width = kPaddingHorizontal / 2;
52 columns->AddPaddingColumn(0, padding_width);
53
54 // Notification Icon.
55 columns->AddColumn(views::GridLayout::CENTER, views::GridLayout::LEADING,
56 0, /* resize percent */
57 views::GridLayout::FIXED,
58 kWebNotificationIconSize, kWebNotificationIconSize);
59
60 columns->AddPaddingColumn(0, padding_width);
61
62 // Notification message text.
63 const int message_width = kWebNotificationWidth - kWebNotificationIconSize -
64 kWebNotificationButtonWidth - (padding_width * 3) -
65 (scroller() ? scroller()->GetScrollBarWidth() : 0);
66 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL,
67 100, /* resize percent */
68 views::GridLayout::FIXED,
69 message_width, message_width);
70
71 columns->AddPaddingColumn(0, padding_width);
72 message->SizeToFit(message_width);
73
74 // Close button.
75 columns->AddColumn(views::GridLayout::CENTER, views::GridLayout::LEADING,
76 0, /* resize percent */
77 views::GridLayout::FIXED,
78 kWebNotificationButtonWidth,
79 kWebNotificationButtonWidth);
80
81 // Layout rows
82 layout->AddPaddingRow(0, kPaddingBetweenItems);
83
84 layout->StartRow(0, 0);
85 layout->AddView(icon, 1, 2);
86 layout->AddView(title, 1, 1);
87 layout->AddView(close_button(), 1, 1);
88
89 layout->StartRow(0, 0);
90 layout->SkipColumns(2);
91 layout->AddView(message, 1, 1);
92 layout->AddPaddingRow(0, kPaddingBetweenItems);
93 }
94
95 } // namespace message_center
dharcourt 2013/01/19 03:06:13 MessageSimpleView replaced by NotificationView.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698