Commit 50e36d1c authored by jonross's avatar jonross Committed by Commit bot

Status Trays delayed visibility

Change the shelf visibility animation so that the status area is visible before animating any properties. This way it is rendering for the full animation.

TEST=ShelfLayoutManagerTest.SetAutoHideBehavior
BUG=416618

Review URL: https://codereview.chromium.org/596863003

Cr-Commit-Position: refs/heads/master@{#296307}
parent 6c9a2707
...@@ -651,71 +651,78 @@ void ShelfLayoutManager::UpdateBoundsAndOpacity( ...@@ -651,71 +651,78 @@ void ShelfLayoutManager::UpdateBoundsAndOpacity(
bool animate, bool animate,
ui::ImplicitAnimationObserver* observer) { ui::ImplicitAnimationObserver* observer) {
base::AutoReset<bool> auto_reset_updating_bounds(&updating_bounds_, true); base::AutoReset<bool> auto_reset_updating_bounds(&updating_bounds_, true);
{
ui::ScopedLayerAnimationSettings shelf_animation_setter( ui::ScopedLayerAnimationSettings shelf_animation_setter(
GetLayer(shelf_)->GetAnimator()); GetLayer(shelf_)->GetAnimator());
ui::ScopedLayerAnimationSettings status_animation_setter( ui::ScopedLayerAnimationSettings status_animation_setter(
GetLayer(shelf_->status_area_widget())->GetAnimator()); GetLayer(shelf_->status_area_widget())->GetAnimator());
if (animate) { if (animate) {
int duration = duration_override_in_ms_ ? duration_override_in_ms_ : int duration = duration_override_in_ms_ ? duration_override_in_ms_ :
kCrossFadeDurationMS; kCrossFadeDurationMS;
shelf_animation_setter.SetTransitionDuration( shelf_animation_setter.SetTransitionDuration(
base::TimeDelta::FromMilliseconds(duration)); base::TimeDelta::FromMilliseconds(duration));
shelf_animation_setter.SetTweenType(gfx::Tween::EASE_OUT); shelf_animation_setter.SetTweenType(gfx::Tween::EASE_OUT);
shelf_animation_setter.SetPreemptionStrategy( shelf_animation_setter.SetPreemptionStrategy(
ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
status_animation_setter.SetTransitionDuration( status_animation_setter.SetTransitionDuration(
base::TimeDelta::FromMilliseconds(duration)); base::TimeDelta::FromMilliseconds(duration));
status_animation_setter.SetTweenType(gfx::Tween::EASE_OUT); status_animation_setter.SetTweenType(gfx::Tween::EASE_OUT);
status_animation_setter.SetPreemptionStrategy( status_animation_setter.SetPreemptionStrategy(
ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
} else { } else {
StopAnimating(); StopAnimating();
shelf_animation_setter.SetTransitionDuration(base::TimeDelta()); shelf_animation_setter.SetTransitionDuration(base::TimeDelta());
status_animation_setter.SetTransitionDuration(base::TimeDelta()); status_animation_setter.SetTransitionDuration(base::TimeDelta());
} }
if (observer) if (observer)
status_animation_setter.AddObserver(observer); status_animation_setter.AddObserver(observer);
GetLayer(shelf_)->SetOpacity(target_bounds.opacity); GetLayer(shelf_)->SetOpacity(target_bounds.opacity);
shelf_->SetBounds(ScreenUtil::ConvertRectToScreen( shelf_->SetBounds(ScreenUtil::ConvertRectToScreen(
shelf_->GetNativeView()->parent(), shelf_->GetNativeView()->parent(),
target_bounds.shelf_bounds_in_root)); target_bounds.shelf_bounds_in_root));
GetLayer(shelf_->status_area_widget())->SetOpacity( GetLayer(shelf_->status_area_widget())->SetOpacity(
target_bounds.status_opacity); target_bounds.status_opacity);
// Having a window which is visible but does not have an opacity is an illegal // Having a window which is visible but does not have an opacity is an
// state. We therefore show / hide the shelf here if required. // illegal state. We therefore hide the shelf here if required.
if (!target_bounds.status_opacity) if (!target_bounds.status_opacity)
shelf_->status_area_widget()->Hide(); shelf_->status_area_widget()->Hide();
else if (target_bounds.status_opacity) // Setting visibility during an animation causes the visibility property to
shelf_->status_area_widget()->Show(); // animate. Override the animation settings to immediately set the
// visibility property. Opacity will still animate.
// TODO(harrym): Once status area widget is a child view of shelf
// this can be simplified. // TODO(harrym): Once status area widget is a child view of shelf
gfx::Rect status_bounds = target_bounds.status_bounds_in_shelf; // this can be simplified.
status_bounds.set_x(status_bounds.x() + gfx::Rect status_bounds = target_bounds.status_bounds_in_shelf;
target_bounds.shelf_bounds_in_root.x()); status_bounds.set_x(status_bounds.x() +
status_bounds.set_y(status_bounds.y() + target_bounds.shelf_bounds_in_root.x());
target_bounds.shelf_bounds_in_root.y()); status_bounds.set_y(status_bounds.y() +
shelf_->status_area_widget()->SetBounds( target_bounds.shelf_bounds_in_root.y());
ScreenUtil::ConvertRectToScreen( shelf_->status_area_widget()->SetBounds(
shelf_->status_area_widget()->GetNativeView()->parent(), ScreenUtil::ConvertRectToScreen(
status_bounds)); shelf_->status_area_widget()->GetNativeView()->parent(),
SessionStateDelegate* session_state_delegate = status_bounds));
Shell::GetInstance()->session_state_delegate(); SessionStateDelegate* session_state_delegate =
if (!state_.is_screen_locked) { Shell::GetInstance()->session_state_delegate();
gfx::Insets insets; if (!state_.is_screen_locked) {
// If user session is blocked (login to new user session or add user to gfx::Insets insets;
// the existing session - multi-profile) then give 100% of work area only if // If user session is blocked (login to new user session or add user to
// keyboard is not shown. // the existing session - multi-profile) then give 100% of work area only
if (!session_state_delegate->IsUserSessionBlocked() || // if keyboard is not shown.
!keyboard_bounds_.IsEmpty()) { if (!session_state_delegate->IsUserSessionBlocked() ||
insets = target_bounds.work_area_insets; !keyboard_bounds_.IsEmpty()) {
insets = target_bounds.work_area_insets;
}
Shell::GetInstance()->SetDisplayWorkAreaInsets(root_window_, insets);
} }
Shell::GetInstance()->SetDisplayWorkAreaInsets(root_window_, insets);
} }
// Setting visibility during an animation causes the visibility property to
// animate. Set the visibility property without an animation.
if (target_bounds.status_opacity)
shelf_->status_area_widget()->Show();
} }
void ShelfLayoutManager::StopAnimating() { void ShelfLayoutManager::StopAnimating() {
......
...@@ -1074,7 +1074,14 @@ TEST_F(ShelfLayoutManagerTest, SetAutoHideBehavior) { ...@@ -1074,7 +1074,14 @@ TEST_F(ShelfLayoutManagerTest, SetAutoHideBehavior) {
window).work_area().bottom(), window).work_area().bottom(),
widget->GetWorkAreaBoundsInScreen().bottom()); widget->GetWorkAreaBoundsInScreen().bottom());
ui::ScopedAnimationDurationScaleMode animation_duration(
ui::ScopedAnimationDurationScaleMode::SLOW_DURATION);
shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
ShelfWidget* shelf_widget = GetShelfWidget();
EXPECT_TRUE(shelf_widget->status_area_widget()->IsVisible());
StepWidgetLayerAnimatorToEnd(shelf_widget);
StepWidgetLayerAnimatorToEnd(shelf_widget->status_area_widget());
EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state());
EXPECT_EQ(Shell::GetScreen()->GetDisplayNearestWindow( EXPECT_EQ(Shell::GetScreen()->GetDisplayNearestWindow(
window).work_area().bottom(), window).work_area().bottom(),
......
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