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

Side by Side Diff: ui/message_center/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: Rebased, which led to many changes. 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(const Notification& notification,
24 NotificationList::Delegate* list_delegate, 24 NotificationList::Delegate* delegate)
25 const Notification& notification) 25 : MessageView(notification, delegate, false) {
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 SetUpView(notification); 33 SetUpView(notification);
35 } 34 }
36 35
(...skipping 20 matching lines...) Expand all
57 gfx::Insets border_insets = border()->GetInsets(); 56 gfx::Insets border_insets = border()->GetInsets();
58 size.Enlarge(border_insets.width(), border_insets.height()); 57 size.Enlarge(border_insets.width(), border_insets.height());
59 } 58 }
60 return size; 59 return size;
61 } 60 }
62 61
63 void MessageSimpleView::SetUpView(const Notification& notification) { 62 void MessageSimpleView::SetUpView(const Notification& notification) {
64 views::ImageView* icon = new views::ImageView; 63 views::ImageView* icon = new views::ImageView;
65 icon->SetImageSize( 64 icon->SetImageSize(
66 gfx::Size(kWebNotificationIconSize, kWebNotificationIconSize)); 65 gfx::Size(kWebNotificationIconSize, kWebNotificationIconSize));
67 icon->SetImage(notification.primary_icon()); 66 icon->SetImage(notification.icon());
68 67
69 views::Label* title = new views::Label(notification.title()); 68 views::Label* title = new views::Label(notification.title());
70 title->SetHorizontalAlignment(gfx::ALIGN_LEFT); 69 title->SetHorizontalAlignment(gfx::ALIGN_LEFT);
71 title->SetFont(title->font().DeriveFont(0, gfx::Font::BOLD)); 70 title->SetFont(title->font().DeriveFont(0, gfx::Font::BOLD));
72 views::Label* message = new views::Label(notification.message()); 71 views::Label* message = new views::Label(notification.message());
73 message->SetHorizontalAlignment(gfx::ALIGN_LEFT); 72 message->SetHorizontalAlignment(gfx::ALIGN_LEFT);
74 message->SetMultiLine(true); 73 message->SetMultiLine(true);
75 74
76 SkColor bg_color = notification.is_read() ? 75 SkColor bg_color = notification.is_read() ?
77 kNotificationReadColor : kNotificationColor; 76 kNotificationReadColor : kNotificationColor;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 layout->AddPaddingRow(0, kPaddingBetweenItems); 127 layout->AddPaddingRow(0, kPaddingBetweenItems);
129 } 128 }
130 129
131 void MessageSimpleView::ButtonPressed(views::Button* sender, 130 void MessageSimpleView::ButtonPressed(views::Button* sender,
132 const ui::Event& event) { 131 const ui::Event& event) {
133 bool close = (sender == old_style_close_button_.get()); 132 bool close = (sender == old_style_close_button_.get());
134 MessageView::ButtonPressed(close ? close_button() : sender, event); 133 MessageView::ButtonPressed(close ? close_button() : sender, event);
135 } 134 }
136 135
137 } // namespace message_center 136 } // namespace message_center
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698