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

Unified Diff: ui/message_center/views/message_view.cc

Issue 2849523005: CrOS: Fix appearance of notification toasts when sliding out via gesture (Closed)
Patch Set: Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: ui/message_center/views/message_view.cc
diff --git a/ui/message_center/views/message_view.cc b/ui/message_center/views/message_view.cc
index 7591a5bf9f6de1d0401ebdb6c965e140af000488..a1fa32c3faa1cfdd9c55a4834a6082574dd81dd7 100644
--- a/ui/message_center/views/message_view.cc
+++ b/ui/message_center/views/message_view.cc
@@ -25,6 +25,7 @@
#include "ui/views/controls/scroll_view.h"
#include "ui/views/focus/focus_manager.h"
#include "ui/views/painter.h"
+#include "ui/views/widget/widget.h"
namespace {
@@ -64,7 +65,8 @@ MessageView::MessageView(MessageCenterController* controller,
const Notification& notification)
: controller_(controller),
notification_id_(notification.id()),
- notifier_id_(notification.notifier_id()) {
+ notifier_id_(notification.notifier_id()),
+ slide_out_controller_(this, this) {
SetFocusBehavior(FocusBehavior::ALWAYS);
// Create the opaque background that's above the view's shadow.
@@ -85,7 +87,7 @@ MessageView::~MessageView() {
void MessageView::UpdateWithNotification(const Notification& notification) {
display_source_ = notification.display_source();
accessible_name_ = CreateAccessibleName(notification);
- set_slide_out_enabled(!notification.pinned());
+ slide_out_controller_.set_enabled(!notification.pinned());
}
// static
@@ -94,7 +96,11 @@ gfx::Insets MessageView::GetShadowInsets() {
gfx::ShadowDetails::Get(kShadowElevation, kShadowCornerRadius).values);
}
-void MessageView::CreateShadowBorder() {
+void MessageView::SetIsNested() {
+ is_nested_ = true;
+ SetPaintToLayer();
+ layer()->SetFillsBoundsOpaquely(false);
+
const auto& shadow =
gfx::ShadowDetails::Get(kShadowElevation, kShadowCornerRadius);
gfx::Insets ninebox_insets = gfx::ShadowValue::GetBlurRegion(shadow.values) +
@@ -145,18 +151,15 @@ bool MessageView::OnKeyReleased(const ui::KeyEvent& event) {
}
void MessageView::OnPaint(gfx::Canvas* canvas) {
- SlideOutView::OnPaint(canvas);
views::Painter::PaintFocusPainter(this, canvas, focus_painter_.get());
}
void MessageView::OnFocus() {
- SlideOutView::OnFocus();
// We paint a focus indicator.
SchedulePaint();
}
void MessageView::OnBlur() {
- SlideOutView::OnBlur();
// We paint a focus indicator.
SchedulePaint();
}
@@ -199,11 +202,6 @@ void MessageView::OnGestureEvent(ui::GestureEvent* event) {
}
}
- SlideOutView::OnGestureEvent(event);
- // Do not return here by checking handled(). SlideOutView calls SetHandled()
- // even though the scroll gesture doesn't make no (or little) effects on the
- // slide-out behavior. See http://crbug.com/172991
-
if (!event->IsScrollGestureEvent() && !event->IsFlingScrollEvent())
return;
@@ -212,14 +210,18 @@ void MessageView::OnGestureEvent(ui::GestureEvent* event) {
event->SetHandled();
}
-void MessageView::OnCloseButtonPressed() {
- controller_->RemoveNotification(notification_id_, true); // By user.
+ui::Layer* MessageView::GetSlideOutLayer() {
+ return is_nested_ ? layer() : GetWidget()->GetLayer();
sky 2017/04/28 22:35:36 Is it possible for this to be called when is_neste
Evan Stade 2017/04/28 23:18:38 I don't think so. It is only called from inside Sl
}
void MessageView::OnSlideOut() {
controller_->RemoveNotification(notification_id_, true); // By user.
}
+void MessageView::OnCloseButtonPressed() {
+ controller_->RemoveNotification(notification_id_, true); // By user.
+}
+
void MessageView::SetDrawBackgroundAsActive(bool active) {
background_view_->background()->
SetNativeControlColor(active ? kHoveredButtonBackgroundColor :

Powered by Google App Engine
This is Rietveld 408576698