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

Side by Side Diff: ash/shelf/shelf_layout_manager.cc

Issue 596863003: Status Trays delayed visibility (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 unified diff | Download patch
« no previous file with comments | « no previous file | ash/shelf/shelf_layout_manager_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "ash/shelf/shelf_layout_manager.h" 5 #include "ash/shelf/shelf_layout_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <cstring> 9 #include <cstring>
10 #include <string> 10 #include <string>
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 old_state.auto_hide_state != state_.auto_hide_state) { 643 old_state.auto_hide_state != state_.auto_hide_state) {
644 FOR_EACH_OBSERVER(ShelfLayoutManagerObserver, observers_, 644 FOR_EACH_OBSERVER(ShelfLayoutManagerObserver, observers_,
645 OnAutoHideStateChanged(state_.auto_hide_state)); 645 OnAutoHideStateChanged(state_.auto_hide_state));
646 } 646 }
647 } 647 }
648 648
649 void ShelfLayoutManager::UpdateBoundsAndOpacity( 649 void ShelfLayoutManager::UpdateBoundsAndOpacity(
650 const TargetBounds& target_bounds, 650 const TargetBounds& target_bounds,
651 bool animate, 651 bool animate,
652 ui::ImplicitAnimationObserver* observer) { 652 ui::ImplicitAnimationObserver* observer) {
653 base::AutoReset<bool> auto_reset_updating_bounds(&updating_bounds_, true); 653 {
654 base::AutoReset<bool> auto_reset_updating_bounds(&updating_bounds_, true);
flackr 2014/09/23 21:56:22 nit: I think this should be scoped to the entire m
jonross 2014/09/23 22:03:35 Done.
654 655
655 ui::ScopedLayerAnimationSettings shelf_animation_setter( 656 ui::ScopedLayerAnimationSettings shelf_animation_setter(
656 GetLayer(shelf_)->GetAnimator()); 657 GetLayer(shelf_)->GetAnimator());
657 ui::ScopedLayerAnimationSettings status_animation_setter( 658 ui::ScopedLayerAnimationSettings status_animation_setter(
658 GetLayer(shelf_->status_area_widget())->GetAnimator()); 659 GetLayer(shelf_->status_area_widget())->GetAnimator());
659 if (animate) { 660 if (animate) {
660 int duration = duration_override_in_ms_ ? duration_override_in_ms_ : 661 int duration = duration_override_in_ms_ ? duration_override_in_ms_ :
661 kCrossFadeDurationMS; 662 kCrossFadeDurationMS;
662 shelf_animation_setter.SetTransitionDuration( 663 shelf_animation_setter.SetTransitionDuration(
663 base::TimeDelta::FromMilliseconds(duration)); 664 base::TimeDelta::FromMilliseconds(duration));
664 shelf_animation_setter.SetTweenType(gfx::Tween::EASE_OUT); 665 shelf_animation_setter.SetTweenType(gfx::Tween::EASE_OUT);
665 shelf_animation_setter.SetPreemptionStrategy( 666 shelf_animation_setter.SetPreemptionStrategy(
666 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); 667 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
667 status_animation_setter.SetTransitionDuration( 668 status_animation_setter.SetTransitionDuration(
668 base::TimeDelta::FromMilliseconds(duration)); 669 base::TimeDelta::FromMilliseconds(duration));
669 status_animation_setter.SetTweenType(gfx::Tween::EASE_OUT); 670 status_animation_setter.SetTweenType(gfx::Tween::EASE_OUT);
670 status_animation_setter.SetPreemptionStrategy( 671 status_animation_setter.SetPreemptionStrategy(
671 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); 672 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
672 } else { 673 } else {
673 StopAnimating(); 674 StopAnimating();
674 shelf_animation_setter.SetTransitionDuration(base::TimeDelta()); 675 shelf_animation_setter.SetTransitionDuration(base::TimeDelta());
675 status_animation_setter.SetTransitionDuration(base::TimeDelta()); 676 status_animation_setter.SetTransitionDuration(base::TimeDelta());
677 }
678 if (observer)
679 status_animation_setter.AddObserver(observer);
680
681 GetLayer(shelf_)->SetOpacity(target_bounds.opacity);
682 shelf_->SetBounds(ScreenUtil::ConvertRectToScreen(
683 shelf_->GetNativeView()->parent(),
684 target_bounds.shelf_bounds_in_root));
685
686 GetLayer(shelf_->status_area_widget())->SetOpacity(
687 target_bounds.status_opacity);
688
689 // Having a window which is visible but does not have an opacity is an
690 // illegal state. We therefore hide the shelf here if required.
691 if (!target_bounds.status_opacity)
692 shelf_->status_area_widget()->Hide();
693 // Setting visibility during an animation causes the visibility property to
694 // animate. Override the animation settings to immediately set the
695 // visibility property. Opacity will still animate.
696
697 // TODO(harrym): Once status area widget is a child view of shelf
698 // this can be simplified.
699 gfx::Rect status_bounds = target_bounds.status_bounds_in_shelf;
700 status_bounds.set_x(status_bounds.x() +
701 target_bounds.shelf_bounds_in_root.x());
702 status_bounds.set_y(status_bounds.y() +
703 target_bounds.shelf_bounds_in_root.y());
704 shelf_->status_area_widget()->SetBounds(
705 ScreenUtil::ConvertRectToScreen(
706 shelf_->status_area_widget()->GetNativeView()->parent(),
707 status_bounds));
708 SessionStateDelegate* session_state_delegate =
709 Shell::GetInstance()->session_state_delegate();
710 if (!state_.is_screen_locked) {
711 gfx::Insets insets;
712 // If user session is blocked (login to new user session or add user to
713 // the existing session - multi-profile) then give 100% of work area only
714 // if keyboard is not shown.
715 if (!session_state_delegate->IsUserSessionBlocked() ||
716 !keyboard_bounds_.IsEmpty()) {
717 insets = target_bounds.work_area_insets;
718 }
719 Shell::GetInstance()->SetDisplayWorkAreaInsets(root_window_, insets);
720 }
676 } 721 }
677 if (observer)
678 status_animation_setter.AddObserver(observer);
679 722
680 GetLayer(shelf_)->SetOpacity(target_bounds.opacity); 723 // Setting visibility during an animation causes the visibility property to
681 shelf_->SetBounds(ScreenUtil::ConvertRectToScreen( 724 // animate. Set the visibility property without an animation.
682 shelf_->GetNativeView()->parent(), 725 if (target_bounds.status_opacity)
683 target_bounds.shelf_bounds_in_root));
684
685 GetLayer(shelf_->status_area_widget())->SetOpacity(
686 target_bounds.status_opacity);
687
688 // Having a window which is visible but does not have an opacity is an illegal
689 // state. We therefore show / hide the shelf here if required.
690 if (!target_bounds.status_opacity)
691 shelf_->status_area_widget()->Hide();
692 else if (target_bounds.status_opacity)
693 shelf_->status_area_widget()->Show(); 726 shelf_->status_area_widget()->Show();
694
695 // TODO(harrym): Once status area widget is a child view of shelf
696 // this can be simplified.
697 gfx::Rect status_bounds = target_bounds.status_bounds_in_shelf;
698 status_bounds.set_x(status_bounds.x() +
699 target_bounds.shelf_bounds_in_root.x());
700 status_bounds.set_y(status_bounds.y() +
701 target_bounds.shelf_bounds_in_root.y());
702 shelf_->status_area_widget()->SetBounds(
703 ScreenUtil::ConvertRectToScreen(
704 shelf_->status_area_widget()->GetNativeView()->parent(),
705 status_bounds));
706 SessionStateDelegate* session_state_delegate =
707 Shell::GetInstance()->session_state_delegate();
708 if (!state_.is_screen_locked) {
709 gfx::Insets insets;
710 // If user session is blocked (login to new user session or add user to
711 // the existing session - multi-profile) then give 100% of work area only if
712 // keyboard is not shown.
713 if (!session_state_delegate->IsUserSessionBlocked() ||
714 !keyboard_bounds_.IsEmpty()) {
715 insets = target_bounds.work_area_insets;
716 }
717 Shell::GetInstance()->SetDisplayWorkAreaInsets(root_window_, insets);
718 }
719 } 727 }
720 728
721 void ShelfLayoutManager::StopAnimating() { 729 void ShelfLayoutManager::StopAnimating() {
722 GetLayer(shelf_)->GetAnimator()->StopAnimating(); 730 GetLayer(shelf_)->GetAnimator()->StopAnimating();
723 GetLayer(shelf_->status_area_widget())->GetAnimator()->StopAnimating(); 731 GetLayer(shelf_->status_area_widget())->GetAnimator()->StopAnimating();
724 } 732 }
725 733
726 void ShelfLayoutManager::GetShelfSize(int* width, int* height) { 734 void ShelfLayoutManager::GetShelfSize(int* width, int* height) {
727 *width = *height = 0; 735 *width = *height = 0;
728 gfx::Size status_size( 736 gfx::Size status_size(
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
1140 1148
1141 void ShelfLayoutManager::SessionStateChanged( 1149 void ShelfLayoutManager::SessionStateChanged(
1142 SessionStateDelegate::SessionState state) { 1150 SessionStateDelegate::SessionState state) {
1143 TargetBounds target_bounds; 1151 TargetBounds target_bounds;
1144 CalculateTargetBounds(state_, &target_bounds); 1152 CalculateTargetBounds(state_, &target_bounds);
1145 UpdateBoundsAndOpacity(target_bounds, true, NULL); 1153 UpdateBoundsAndOpacity(target_bounds, true, NULL);
1146 UpdateVisibilityState(); 1154 UpdateVisibilityState();
1147 } 1155 }
1148 1156
1149 } // namespace ash 1157 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/shelf/shelf_layout_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698