Commit 7541b56d authored by Tetsui Ohkubo's avatar Tetsui Ohkubo Committed by Commit Bot

message_center: Don't update opacity on swiping

According to UnifiedSystemTray spec, when a notification is in
notification center, the opacity shouldn't be updated by swiping.
For popups, opacity should be still updated.

TEST=manual
BUG=898969

Change-Id: Ic57536bf807b9eb15e2a451617b65e079aa577db
Reviewed-on: https://chromium-review.googlesource.com/c/1301138
Commit-Queue: Tetsui Ohkubo <tetsui@chromium.org>
Reviewed-by: default avatarYoshiki Iguchi <yoshiki@chromium.org>
Cr-Commit-Position: refs/heads/master@{#603439}
parent 2b66f278
...@@ -118,6 +118,7 @@ void MessageView::SetIsNested() { ...@@ -118,6 +118,7 @@ void MessageView::SetIsNested() {
is_nested_ = true; is_nested_ = true;
// Update enability since it might be changed by "is_nested" flag. // Update enability since it might be changed by "is_nested" flag.
slide_out_controller_.set_slide_mode(CalculateSlideMode()); slide_out_controller_.set_slide_mode(CalculateSlideMode());
slide_out_controller_.set_update_opacity(false);
SetBorder(views::CreateRoundedRectBorder( SetBorder(views::CreateRoundedRectBorder(
kNotificationBorderThickness, kNotificationCornerRadius, kBorderColor)); kNotificationBorderThickness, kNotificationCornerRadius, kBorderColor));
......
...@@ -260,7 +260,6 @@ void NotificationViewMDTest::UpdateNotificationViews( ...@@ -260,7 +260,6 @@ void NotificationViewMDTest::UpdateNotificationViews(
// created by the method. // created by the method.
notification_view_ = std::make_unique<NotificationViewMD>(notification); notification_view_ = std::make_unique<NotificationViewMD>(notification);
notification_view_->AddObserver(this); notification_view_->AddObserver(this);
notification_view_->SetIsNested();
notification_view_->set_owned_by_client(); notification_view_->set_owned_by_client();
views::Widget::InitParams init_params( views::Widget::InitParams init_params(
...@@ -659,6 +658,7 @@ TEST_F(NotificationViewMDTest, SlideOut) { ...@@ -659,6 +658,7 @@ TEST_F(NotificationViewMDTest, SlideOut) {
} }
TEST_F(NotificationViewMDTest, SlideOutNested) { TEST_F(NotificationViewMDTest, SlideOutNested) {
notification_view()->SetIsNested();
ui::ScopedAnimationDurationScaleMode zero_duration_scope( ui::ScopedAnimationDurationScaleMode zero_duration_scope(
ui::ScopedAnimationDurationScaleMode::ZERO_DURATION); ui::ScopedAnimationDurationScaleMode::ZERO_DURATION);
...@@ -706,6 +706,7 @@ TEST_F(NotificationViewMDTest, DisableSlideForcibly) { ...@@ -706,6 +706,7 @@ TEST_F(NotificationViewMDTest, DisableSlideForcibly) {
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
TEST_F(NotificationViewMDTest, SlideOutPinned) { TEST_F(NotificationViewMDTest, SlideOutPinned) {
notification_view()->SetIsNested();
ui::ScopedAnimationDurationScaleMode zero_duration_scope( ui::ScopedAnimationDurationScaleMode zero_duration_scope(
ui::ScopedAnimationDurationScaleMode::ZERO_DURATION); ui::ScopedAnimationDurationScaleMode::ZERO_DURATION);
...@@ -722,6 +723,7 @@ TEST_F(NotificationViewMDTest, SlideOutPinned) { ...@@ -722,6 +723,7 @@ TEST_F(NotificationViewMDTest, SlideOutPinned) {
} }
TEST_F(NotificationViewMDTest, Pinned) { TEST_F(NotificationViewMDTest, Pinned) {
notification_view()->SetIsNested();
std::unique_ptr<Notification> notification = CreateSimpleNotification(); std::unique_ptr<Notification> notification = CreateSimpleNotification();
// Visible at the initial state. // Visible at the initial state.
......
...@@ -98,7 +98,7 @@ void SlideOutController::OnGestureEvent(ui::GestureEvent* event) { ...@@ -98,7 +98,7 @@ void SlideOutController::OnGestureEvent(ui::GestureEvent* event) {
break; break;
} }
layer->SetOpacity(opacity); SetOpacityIfNecessary(opacity);
gfx::Transform transform; gfx::Transform transform;
transform.Translate(scroll_amount, 0.0); transform.Translate(scroll_amount, 0.0);
layer->SetTransform(transform); layer->SetTransform(transform);
...@@ -139,7 +139,7 @@ void SlideOutController::RestoreVisualState() { ...@@ -139,7 +139,7 @@ void SlideOutController::RestoreVisualState() {
break; break;
} }
if (layer->transform() == transform && layer->opacity() == 1.f) { if (layer->transform() == transform && opacity_ == 1.f) {
// Here, nothing are changed and no animation starts. In this case, just // Here, nothing are changed and no animation starts. In this case, just
// calls OnSlideChanged(in_progress = false) to notify end of horizontal // calls OnSlideChanged(in_progress = false) to notify end of horizontal
// slide (including animations) to observers. // slide (including animations) to observers.
...@@ -150,14 +150,14 @@ void SlideOutController::RestoreVisualState() { ...@@ -150,14 +150,14 @@ void SlideOutController::RestoreVisualState() {
// In this case, animation starts. OnImplicitAnimationsCompleted will be // In this case, animation starts. OnImplicitAnimationsCompleted will be
// called just after the animation finishes. // called just after the animation finishes.
layer->SetTransform(transform); layer->SetTransform(transform);
layer->SetOpacity(1.f); SetOpacityIfNecessary(1.f);
delegate_->OnSlideChanged(true); delegate_->OnSlideChanged(true);
} }
void SlideOutController::SlideOutAndClose(int direction) { void SlideOutController::SlideOutAndClose(int direction) {
ui::Layer* layer = delegate_->GetSlideOutLayer(); ui::Layer* layer = delegate_->GetSlideOutLayer();
const int kSwipeOutTotalDurationMS = 150; const int kSwipeOutTotalDurationMS = 150;
int swipe_out_duration = kSwipeOutTotalDurationMS * layer->opacity(); int swipe_out_duration = kSwipeOutTotalDurationMS * opacity_;
ui::ScopedLayerAnimationSettings settings(layer->GetAnimator()); ui::ScopedLayerAnimationSettings settings(layer->GetAnimator());
settings.SetTransitionDuration( settings.SetTransitionDuration(
base::TimeDelta::FromMilliseconds(swipe_out_duration)); base::TimeDelta::FromMilliseconds(swipe_out_duration));
...@@ -170,17 +170,21 @@ void SlideOutController::SlideOutAndClose(int direction) { ...@@ -170,17 +170,21 @@ void SlideOutController::SlideOutAndClose(int direction) {
// An animation starts. OnImplicitAnimationsCompleted will be called just // An animation starts. OnImplicitAnimationsCompleted will be called just
// after the animation finishes. // after the animation finishes.
layer->SetTransform(transform); layer->SetTransform(transform);
layer->SetOpacity(0.f); SetOpacityIfNecessary(0.f);
delegate_->OnSlideChanged(true); delegate_->OnSlideChanged(true);
} }
void SlideOutController::SetOpacityIfNecessary(float opacity) {
if (update_opacity_)
delegate_->GetSlideOutLayer()->SetOpacity(opacity);
opacity_ = opacity;
}
void SlideOutController::OnImplicitAnimationsCompleted() { void SlideOutController::OnImplicitAnimationsCompleted() {
delegate_->OnSlideChanged(false); delegate_->OnSlideChanged(false);
// Call Delegate::OnSlideOut() if this animation came from // Call Delegate::OnSlideOut() if this animation came from SlideOutAndClose().
// SlideOutAndClose(). if (opacity_ == 0)
ui::Layer* layer = delegate_->GetSlideOutLayer();
if (layer->opacity() == 0)
delegate_->OnSlideOut(); delegate_->OnSlideOut();
} }
......
...@@ -42,6 +42,9 @@ class MESSAGE_CENTER_EXPORT SlideOutController ...@@ -42,6 +42,9 @@ class MESSAGE_CENTER_EXPORT SlideOutController
SlideOutController(ui::EventTarget* target, Delegate* delegate); SlideOutController(ui::EventTarget* target, Delegate* delegate);
~SlideOutController() override; ~SlideOutController() override;
void set_update_opacity(bool update_opacity) {
update_opacity_ = update_opacity;
}
void set_slide_mode(SlideMode mode) { void set_slide_mode(SlideMode mode) {
// TODO(yoshiki): Close the slide when the slide mode sets to NO_SLIDE. // TODO(yoshiki): Close the slide when the slide mode sets to NO_SLIDE.
mode_ = mode; mode_ = mode;
...@@ -79,6 +82,9 @@ class MESSAGE_CENTER_EXPORT SlideOutController ...@@ -79,6 +82,9 @@ class MESSAGE_CENTER_EXPORT SlideOutController
// |direction| indicates which way the slide occurs. // |direction| indicates which way the slide occurs.
void SlideOutAndClose(int direction); void SlideOutAndClose(int direction);
// Sets the opacity of the slide out layer if |update_opacity_| is true.
void SetOpacityIfNecessary(float opacity);
ui::ScopedTargetHandler target_handling_; ui::ScopedTargetHandler target_handling_;
Delegate* delegate_; Delegate* delegate_;
...@@ -101,6 +107,12 @@ class MESSAGE_CENTER_EXPORT SlideOutController ...@@ -101,6 +107,12 @@ class MESSAGE_CENTER_EXPORT SlideOutController
// Changed only when |mode_| is FULL and |has_swipe_control_| is true. // Changed only when |mode_| is FULL and |has_swipe_control_| is true.
SwipeControlOpenState control_open_state_ = SwipeControlOpenState::CLOSED; SwipeControlOpenState control_open_state_ = SwipeControlOpenState::CLOSED;
// If false, it doesn't update the opacity.
bool update_opacity_ = true;
// Last opacity set by SetOpacityIfNecessary.
float opacity_ = 1.0;
DISALLOW_COPY_AND_ASSIGN(SlideOutController); DISALLOW_COPY_AND_ASSIGN(SlideOutController);
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment