| OLD | NEW |
| 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 SetFocusBehavior(FocusBehavior::ALWAYS); | 70 SetFocusBehavior(FocusBehavior::ALWAYS); |
| 71 | 71 |
| 72 // Paint to a dedicated layer to make the layer non-opaque. |
| 73 SetPaintToLayer(); |
| 74 layer()->SetFillsBoundsOpaquely(false); |
| 75 |
| 72 // Create the opaque background that's above the view's shadow. | 76 // Create the opaque background that's above the view's shadow. |
| 73 background_view_ = new views::View(); | 77 background_view_ = new views::View(); |
| 74 background_view_->set_background( | 78 background_view_->set_background( |
| 75 views::Background::CreateSolidBackground(kNotificationBackgroundColor)); | 79 views::Background::CreateSolidBackground(kNotificationBackgroundColor)); |
| 76 AddChildView(background_view_); | 80 AddChildView(background_view_); |
| 77 | 81 |
| 78 focus_painter_ = views::Painter::CreateSolidFocusPainter( | 82 focus_painter_ = views::Painter::CreateSolidFocusPainter( |
| 79 kFocusBorderColor, gfx::Insets(0, 1, 3, 2)); | 83 kFocusBorderColor, gfx::Insets(0, 1, 3, 2)); |
| 80 | 84 |
| 81 UpdateWithNotification(notification); | 85 UpdateWithNotification(notification); |
| 82 } | 86 } |
| 83 | 87 |
| 84 MessageView::~MessageView() { | 88 MessageView::~MessageView() { |
| 85 } | 89 } |
| 86 | 90 |
| 87 void MessageView::UpdateWithNotification(const Notification& notification) { | 91 void MessageView::UpdateWithNotification(const Notification& notification) { |
| 88 display_source_ = notification.display_source(); | 92 display_source_ = notification.display_source(); |
| 89 accessible_name_ = CreateAccessibleName(notification); | 93 accessible_name_ = CreateAccessibleName(notification); |
| 90 slide_out_controller_.set_enabled(!notification.pinned()); | 94 slide_out_controller_.set_enabled(!notification.pinned()); |
| 91 } | 95 } |
| 92 | 96 |
| 93 // static | 97 // static |
| 94 gfx::Insets MessageView::GetShadowInsets() { | 98 gfx::Insets MessageView::GetShadowInsets() { |
| 95 return -gfx::ShadowValue::GetMargin( | 99 return -gfx::ShadowValue::GetMargin( |
| 96 gfx::ShadowDetails::Get(kShadowElevation, kShadowCornerRadius).values); | 100 gfx::ShadowDetails::Get(kShadowElevation, kShadowCornerRadius).values); |
| 97 } | 101 } |
| 98 | 102 |
| 99 void MessageView::SetIsNested() { | 103 void MessageView::SetIsNested() { |
| 100 is_nested_ = true; | 104 is_nested_ = true; |
| 101 SetPaintToLayer(); | |
| 102 layer()->SetFillsBoundsOpaquely(false); | |
| 103 | 105 |
| 104 const auto& shadow = | 106 const auto& shadow = |
| 105 gfx::ShadowDetails::Get(kShadowElevation, kShadowCornerRadius); | 107 gfx::ShadowDetails::Get(kShadowElevation, kShadowCornerRadius); |
| 106 gfx::Insets ninebox_insets = gfx::ShadowValue::GetBlurRegion(shadow.values) + | 108 gfx::Insets ninebox_insets = gfx::ShadowValue::GetBlurRegion(shadow.values) + |
| 107 gfx::Insets(kShadowCornerRadius); | 109 gfx::Insets(kShadowCornerRadius); |
| 108 SetBorder(views::CreateBorderPainter( | 110 SetBorder(views::CreateBorderPainter( |
| 109 std::unique_ptr<views::Painter>(views::Painter::CreateImagePainter( | 111 std::unique_ptr<views::Painter>(views::Painter::CreateImagePainter( |
| 110 shadow.ninebox_image, ninebox_insets)), | 112 shadow.ninebox_image, ninebox_insets)), |
| 111 -gfx::ShadowValue::GetMargin(shadow.values))); | 113 -gfx::ShadowValue::GetMargin(shadow.values))); |
| 112 } | 114 } |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 } | 230 } |
| 229 | 231 |
| 230 void MessageView::SetDrawBackgroundAsActive(bool active) { | 232 void MessageView::SetDrawBackgroundAsActive(bool active) { |
| 231 background_view_->background()-> | 233 background_view_->background()-> |
| 232 SetNativeControlColor(active ? kHoveredButtonBackgroundColor : | 234 SetNativeControlColor(active ? kHoveredButtonBackgroundColor : |
| 233 kNotificationBackgroundColor); | 235 kNotificationBackgroundColor); |
| 234 SchedulePaint(); | 236 SchedulePaint(); |
| 235 } | 237 } |
| 236 | 238 |
| 237 } // namespace message_center | 239 } // namespace message_center |
| OLD | NEW |