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

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

Issue 2880243003: Make a layer for popup MessageView (Closed)
Patch Set: Created 3 years, 7 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
« no previous file with comments | « no previous file | no next file » | 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_view.h" 5 #include "ui/message_center/views/message_view.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "ui/accessibility/ax_node_data.h" 8 #include "ui/accessibility/ax_node_data.h"
9 #include "ui/base/l10n/l10n_util.h" 9 #include "ui/base/l10n/l10n_util.h"
10 #include "ui/base/models/simple_menu_model.h" 10 #include "ui/base/models/simple_menu_model.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 } // namespace 60 } // namespace
61 61
62 namespace message_center { 62 namespace message_center {
63 63
64 MessageView::MessageView(MessageCenterController* controller, 64 MessageView::MessageView(MessageCenterController* controller,
65 const Notification& notification) 65 const Notification& notification)
66 : controller_(controller), 66 : controller_(controller),
67 notification_id_(notification.id()), 67 notification_id_(notification.id()),
68 notifier_id_(notification.notifier_id()), 68 notifier_id_(notification.notifier_id()),
69 slide_out_controller_(this, this) { 69 slide_out_controller_(this, this) {
70 SetPaintToLayer();
Eliot Courtney 2017/05/19 04:32:49 Maybe add a comment as to why this has to be here?
71 layer()->SetFillsBoundsOpaquely(false);
70 SetFocusBehavior(FocusBehavior::ALWAYS); 72 SetFocusBehavior(FocusBehavior::ALWAYS);
71 73
72 // Create the opaque background that's above the view's shadow. 74 // Create the opaque background that's above the view's shadow.
73 background_view_ = new views::View(); 75 background_view_ = new views::View();
74 background_view_->set_background( 76 background_view_->set_background(
75 views::Background::CreateSolidBackground(kNotificationBackgroundColor)); 77 views::Background::CreateSolidBackground(kNotificationBackgroundColor));
76 AddChildView(background_view_); 78 AddChildView(background_view_);
77 79
78 focus_painter_ = views::Painter::CreateSolidFocusPainter( 80 focus_painter_ = views::Painter::CreateSolidFocusPainter(
79 kFocusBorderColor, gfx::Insets(0, 1, 3, 2)); 81 kFocusBorderColor, gfx::Insets(0, 1, 3, 2));
(...skipping 12 matching lines...) Expand all
92 } 94 }
93 95
94 // static 96 // static
95 gfx::Insets MessageView::GetShadowInsets() { 97 gfx::Insets MessageView::GetShadowInsets() {
96 return -gfx::ShadowValue::GetMargin( 98 return -gfx::ShadowValue::GetMargin(
97 gfx::ShadowDetails::Get(kShadowElevation, kShadowCornerRadius).values); 99 gfx::ShadowDetails::Get(kShadowElevation, kShadowCornerRadius).values);
98 } 100 }
99 101
100 void MessageView::SetIsNested() { 102 void MessageView::SetIsNested() {
101 is_nested_ = true; 103 is_nested_ = true;
102 SetPaintToLayer();
103 layer()->SetFillsBoundsOpaquely(false);
104 104
105 const auto& shadow = 105 const auto& shadow =
106 gfx::ShadowDetails::Get(kShadowElevation, kShadowCornerRadius); 106 gfx::ShadowDetails::Get(kShadowElevation, kShadowCornerRadius);
107 gfx::Insets ninebox_insets = gfx::ShadowValue::GetBlurRegion(shadow.values) + 107 gfx::Insets ninebox_insets = gfx::ShadowValue::GetBlurRegion(shadow.values) +
108 gfx::Insets(kShadowCornerRadius); 108 gfx::Insets(kShadowCornerRadius);
109 SetBorder(views::CreateBorderPainter( 109 SetBorder(views::CreateBorderPainter(
110 std::unique_ptr<views::Painter>(views::Painter::CreateImagePainter( 110 std::unique_ptr<views::Painter>(views::Painter::CreateImagePainter(
111 shadow.ninebox_image, ninebox_insets)), 111 shadow.ninebox_image, ninebox_insets)),
112 -gfx::ShadowValue::GetMargin(shadow.values))); 112 -gfx::ShadowValue::GetMargin(shadow.values)));
113 } 113 }
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 } 227 }
228 228
229 void MessageView::SetDrawBackgroundAsActive(bool active) { 229 void MessageView::SetDrawBackgroundAsActive(bool active) {
230 background_view_->background()-> 230 background_view_->background()->
231 SetNativeControlColor(active ? kHoveredButtonBackgroundColor : 231 SetNativeControlColor(active ? kHoveredButtonBackgroundColor :
232 kNotificationBackgroundColor); 232 kNotificationBackgroundColor);
233 SchedulePaint(); 233 SchedulePaint();
234 } 234 }
235 235
236 } // namespace message_center 236 } // namespace message_center
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698