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

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

Issue 308053004: Add appIconMask to notification API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 6 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/views/message_view.h" 5 #include "ui/message_center/views/message_view.h"
6 6
7 #include "grit/ui_resources.h" 7 #include "grit/ui_resources.h"
8 #include "grit/ui_strings.h" 8 #include "grit/ui_strings.h"
9 #include "ui/accessibility/ax_view_state.h" 9 #include "ui/accessibility/ax_view_state.h"
10 #include "ui/base/l10n/l10n_util.h" 10 #include "ui/base/l10n/l10n_util.h"
11 #include "ui/base/models/simple_menu_model.h" 11 #include "ui/base/models/simple_menu_model.h"
12 #include "ui/base/resource/resource_bundle.h" 12 #include "ui/base/resource/resource_bundle.h"
13 #include "ui/compositor/scoped_layer_animation_settings.h" 13 #include "ui/compositor/scoped_layer_animation_settings.h"
14 #include "ui/gfx/canvas.h" 14 #include "ui/gfx/canvas.h"
15 #include "ui/message_center/message_center.h" 15 #include "ui/message_center/message_center.h"
16 #include "ui/message_center/message_center_style.h" 16 #include "ui/message_center/message_center_style.h"
17 #include "ui/message_center/views/padded_button.h" 17 #include "ui/message_center/views/padded_button.h"
18 #include "ui/message_center/views/small_image_mask.h"
18 #include "ui/views/background.h" 19 #include "ui/views/background.h"
19 #include "ui/views/controls/button/image_button.h" 20 #include "ui/views/controls/button/image_button.h"
20 #include "ui/views/controls/image_view.h" 21 #include "ui/views/controls/image_view.h"
21 #include "ui/views/controls/scroll_view.h" 22 #include "ui/views/controls/scroll_view.h"
22 #include "ui/views/focus/focus_manager.h" 23 #include "ui/views/focus/focus_manager.h"
23 #include "ui/views/painter.h" 24 #include "ui/views/painter.h"
24 #include "ui/views/shadow_border.h" 25 #include "ui/views/shadow_border.h"
25 26
26 namespace { 27 namespace {
27 28
(...skipping 19 matching lines...) Expand all
47 scroller_(NULL), 48 scroller_(NULL),
48 display_source_(display_source) { 49 display_source_(display_source) {
49 SetFocusable(true); 50 SetFocusable(true);
50 51
51 // Create the opaque background that's above the view's shadow. 52 // Create the opaque background that's above the view's shadow.
52 background_view_ = new views::View(); 53 background_view_ = new views::View();
53 background_view_->set_background( 54 background_view_->set_background(
54 views::Background::CreateSolidBackground(kNotificationBackgroundColor)); 55 views::Background::CreateSolidBackground(kNotificationBackgroundColor));
55 AddChildView(background_view_); 56 AddChildView(background_view_);
56 57
58 const gfx::ImageSkia masked_small_image = GetMaskedSmallImage(small_image);
57 views::ImageView* small_image_view = new views::ImageView(); 59 views::ImageView* small_image_view = new views::ImageView();
58 small_image_view->SetImage(small_image); 60 small_image_view->SetImage(masked_small_image);
59 small_image_view->SetImageSize(gfx::Size(kSmallImageSize, kSmallImageSize)); 61 small_image_view->SetImageSize(gfx::Size(kSmallImageSize, kSmallImageSize));
60 // The small image view should be added to view hierarchy by the derived 62 // The small image view should be added to view hierarchy by the derived
61 // class. This ensures that it is on top of other views. 63 // class. This ensures that it is on top of other views.
62 small_image_view->set_owned_by_client(); 64 small_image_view->set_owned_by_client();
63 small_image_view_.reset(small_image_view); 65 small_image_view_.reset(small_image_view);
64 66
65 PaddedButton *close = new PaddedButton(this); 67 PaddedButton *close = new PaddedButton(this);
66 close->SetPadding(-kCloseIconRightPadding, kCloseIconTopPadding); 68 close->SetPadding(-kCloseIconRightPadding, kCloseIconTopPadding);
67 close->SetNormalImage(IDR_NOTIFICATION_CLOSE); 69 close->SetNormalImage(IDR_NOTIFICATION_CLOSE);
68 close->SetHoveredImage(IDR_NOTIFICATION_CLOSE_HOVER); 70 close->SetHoveredImage(IDR_NOTIFICATION_CLOSE_HOVER);
69 close->SetPressedImage(IDR_NOTIFICATION_CLOSE_PRESSED); 71 close->SetPressedImage(IDR_NOTIFICATION_CLOSE_PRESSED);
70 close->set_animate_on_state_change(false); 72 close->set_animate_on_state_change(false);
71 close->SetAccessibleName(l10n_util::GetStringUTF16( 73 close->SetAccessibleName(l10n_util::GetStringUTF16(
72 IDS_MESSAGE_CENTER_CLOSE_NOTIFICATION_BUTTON_ACCESSIBLE_NAME)); 74 IDS_MESSAGE_CENTER_CLOSE_NOTIFICATION_BUTTON_ACCESSIBLE_NAME));
73 // The close button should be added to view hierarchy by the derived class. 75 // The close button should be added to view hierarchy by the derived class.
74 // This ensures that it is on top of other views. 76 // This ensures that it is on top of other views.
75 close->set_owned_by_client(); 77 close->set_owned_by_client();
76 close_button_.reset(close); 78 close_button_.reset(close);
77 79
78 focus_painter_ = views::Painter::CreateSolidFocusPainter( 80 focus_painter_ = views::Painter::CreateSolidFocusPainter(
79 kFocusBorderColor, 81 kFocusBorderColor,
80 gfx::Insets(0, 1, 3, 2)).Pass(); 82 gfx::Insets(0, 1, 3, 2)).Pass();
81 } 83 }
82 84
83 MessageView::~MessageView() { 85 MessageView::~MessageView() {
84 } 86 }
85 87
86 void MessageView::UpdateWithNotification(const Notification& notification) { 88 void MessageView::UpdateWithNotification(const Notification& notification) {
87 small_image_view_->SetImage(notification.small_image().AsImageSkia()); 89 const gfx::ImageSkia masked_small_image =
90 GetMaskedSmallImage(notification.small_image().AsImageSkia());
91 small_image_view_->SetImage(masked_small_image);
88 display_source_ = notification.display_source(); 92 display_source_ = notification.display_source();
89 } 93 }
90 94
91 // static 95 // static
92 gfx::Insets MessageView::GetShadowInsets() { 96 gfx::Insets MessageView::GetShadowInsets() {
93 return gfx::Insets(kShadowBlur / 2 - kShadowOffset, 97 return gfx::Insets(kShadowBlur / 2 - kShadowOffset,
94 kShadowBlur / 2, 98 kShadowBlur / 2,
95 kShadowBlur / 2 + kShadowOffset, 99 kShadowBlur / 2 + kShadowOffset,
96 kShadowBlur / 2); 100 kShadowBlur / 2);
97 } 101 }
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 if (sender == close_button()) { 223 if (sender == close_button()) {
220 controller_->RemoveNotification(notification_id_, true); // By user. 224 controller_->RemoveNotification(notification_id_, true); // By user.
221 } 225 }
222 } 226 }
223 227
224 void MessageView::OnSlideOut() { 228 void MessageView::OnSlideOut() {
225 controller_->RemoveNotification(notification_id_, true); // By user. 229 controller_->RemoveNotification(notification_id_, true); // By user.
226 } 230 }
227 231
228 } // namespace message_center 232 } // namespace message_center
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698