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

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

Issue 12326091: Made notification center notifications collapsed and expandable. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase, rebase, and rebase again! 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
« no previous file with comments | « ui/message_center/views/message_simple_view.h ('k') | ui/message_center/views/message_view.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/views/message_simple_view.h" 5 #include "ui/message_center/views/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"
11 #include "ui/views/background.h" 10 #include "ui/views/background.h"
12 #include "ui/views/controls/button/image_button.h" 11 #include "ui/views/controls/button/image_button.h"
13 #include "ui/views/controls/image_view.h" 12 #include "ui/views/controls/image_view.h"
14 #include "ui/views/controls/label.h" 13 #include "ui/views/controls/label.h"
15 #include "ui/views/controls/scroll_view.h" 14 #include "ui/views/controls/scroll_view.h"
16 #include "ui/views/layout/grid_layout.h" 15 #include "ui/views/layout/grid_layout.h"
17 16
18 namespace message_center { 17 namespace message_center {
19 18
20 const SkColor kNotificationColor = SkColorSetRGB(0xfe, 0xfe, 0xfe); 19 const SkColor kNotificationColor = SkColorSetRGB(0xfe, 0xfe, 0xfe);
21 const SkColor kNotificationReadColor = SkColorSetRGB(0xfa, 0xfa, 0xfa); 20 const SkColor kNotificationReadColor = SkColorSetRGB(0xfa, 0xfa, 0xfa);
22 21
23 MessageSimpleView::MessageSimpleView( 22 MessageSimpleView::MessageSimpleView(const Notification& notification,
24 NotificationList::Delegate* list_delegate, 23 NotificationChangeObserver* observer)
25 const Notification& notification) 24 : MessageView(notification, observer, false) {
26 : MessageView(list_delegate, notification) {
27 views::ImageButton* close = new views::ImageButton(this); 25 views::ImageButton* close = new views::ImageButton(this);
28 close->SetImage( 26 close->SetImage(
29 views::CustomButton::STATE_NORMAL, 27 views::CustomButton::STATE_NORMAL,
30 ResourceBundle::GetSharedInstance().GetImageSkiaNamed(IDR_MESSAGE_CLOSE)); 28 ResourceBundle::GetSharedInstance().GetImageSkiaNamed(IDR_MESSAGE_CLOSE));
31 close->SetImageAlignment(views::ImageButton::ALIGN_CENTER, 29 close->SetImageAlignment(views::ImageButton::ALIGN_CENTER,
32 views::ImageButton::ALIGN_MIDDLE); 30 views::ImageButton::ALIGN_MIDDLE);
33 old_style_close_button_.reset(close); 31 old_style_close_button_.reset(close);
34 SetUpView(notification); 32 SetUpView(notification);
35 } 33 }
36 34
(...skipping 20 matching lines...) Expand all
57 gfx::Insets border_insets = border()->GetInsets(); 55 gfx::Insets border_insets = border()->GetInsets();
58 size.Enlarge(border_insets.width(), border_insets.height()); 56 size.Enlarge(border_insets.width(), border_insets.height());
59 } 57 }
60 return size; 58 return size;
61 } 59 }
62 60
63 void MessageSimpleView::SetUpView(const Notification& notification) { 61 void MessageSimpleView::SetUpView(const Notification& notification) {
64 views::ImageView* icon = new views::ImageView; 62 views::ImageView* icon = new views::ImageView;
65 icon->SetImageSize( 63 icon->SetImageSize(
66 gfx::Size(kWebNotificationIconSize, kWebNotificationIconSize)); 64 gfx::Size(kWebNotificationIconSize, kWebNotificationIconSize));
67 icon->SetImage(notification.primary_icon().AsImageSkia()); 65 icon->SetImage(notification.icon().AsImageSkia());
68 66
69 views::Label* title = new views::Label(notification.title()); 67 views::Label* title = new views::Label(notification.title());
70 title->SetHorizontalAlignment(gfx::ALIGN_LEFT); 68 title->SetHorizontalAlignment(gfx::ALIGN_LEFT);
71 title->SetFont(title->font().DeriveFont(0, gfx::Font::BOLD)); 69 title->SetFont(title->font().DeriveFont(0, gfx::Font::BOLD));
72 views::Label* message = new views::Label(notification.message()); 70 views::Label* message = new views::Label(notification.message());
73 message->SetHorizontalAlignment(gfx::ALIGN_LEFT); 71 message->SetHorizontalAlignment(gfx::ALIGN_LEFT);
74 message->SetMultiLine(true); 72 message->SetMultiLine(true);
75 73
76 SkColor bg_color = notification.is_read() ? 74 SkColor bg_color = notification.is_read() ?
77 kNotificationReadColor : kNotificationColor; 75 kNotificationReadColor : kNotificationColor;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 layout->AddPaddingRow(0, kPaddingBetweenItems); 126 layout->AddPaddingRow(0, kPaddingBetweenItems);
129 } 127 }
130 128
131 void MessageSimpleView::ButtonPressed(views::Button* sender, 129 void MessageSimpleView::ButtonPressed(views::Button* sender,
132 const ui::Event& event) { 130 const ui::Event& event) {
133 bool close = (sender == old_style_close_button_.get()); 131 bool close = (sender == old_style_close_button_.get());
134 MessageView::ButtonPressed(close ? close_button() : sender, event); 132 MessageView::ButtonPressed(close ? close_button() : sender, event);
135 } 133 }
136 134
137 } // namespace message_center 135 } // namespace message_center
OLDNEW
« no previous file with comments | « ui/message_center/views/message_simple_view.h ('k') | ui/message_center/views/message_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698