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