Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 base::AutoReset<bool> auto_reset_updating_bounds(&updating_bounds_, true); |
| 654 | 654 |
| 655 // Setting visibility after enabling animations cause the visibile property to | |
| 656 // animate. Enable visibility here so that opacity can animate. | |
| 657 if (target_bounds.status_opacity) | |
| 658 shelf_->status_area_widget()->Show(); | |
|
flackr
2014/09/23 19:14:03
This doesn't cause the invalid window state (Visib
jonross
2014/09/23 20:50:06
This apparently does trigger an invalid state, how
jonross
2014/09/23 21:06:20
Moved it for correctness.
| |
| 659 | |
| 655 ui::ScopedLayerAnimationSettings shelf_animation_setter( | 660 ui::ScopedLayerAnimationSettings shelf_animation_setter( |
| 656 GetLayer(shelf_)->GetAnimator()); | 661 GetLayer(shelf_)->GetAnimator()); |
| 657 ui::ScopedLayerAnimationSettings status_animation_setter( | 662 ui::ScopedLayerAnimationSettings status_animation_setter( |
| 658 GetLayer(shelf_->status_area_widget())->GetAnimator()); | 663 GetLayer(shelf_->status_area_widget())->GetAnimator()); |
| 659 if (animate) { | 664 if (animate) { |
| 660 int duration = duration_override_in_ms_ ? duration_override_in_ms_ : | 665 int duration = duration_override_in_ms_ ? duration_override_in_ms_ : |
| 661 kCrossFadeDurationMS; | 666 kCrossFadeDurationMS; |
| 662 shelf_animation_setter.SetTransitionDuration( | 667 shelf_animation_setter.SetTransitionDuration( |
| 663 base::TimeDelta::FromMilliseconds(duration)); | 668 base::TimeDelta::FromMilliseconds(duration)); |
| 664 shelf_animation_setter.SetTweenType(gfx::Tween::EASE_OUT); | 669 shelf_animation_setter.SetTweenType(gfx::Tween::EASE_OUT); |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 679 | 684 |
| 680 GetLayer(shelf_)->SetOpacity(target_bounds.opacity); | 685 GetLayer(shelf_)->SetOpacity(target_bounds.opacity); |
| 681 shelf_->SetBounds(ScreenUtil::ConvertRectToScreen( | 686 shelf_->SetBounds(ScreenUtil::ConvertRectToScreen( |
| 682 shelf_->GetNativeView()->parent(), | 687 shelf_->GetNativeView()->parent(), |
| 683 target_bounds.shelf_bounds_in_root)); | 688 target_bounds.shelf_bounds_in_root)); |
| 684 | 689 |
| 685 GetLayer(shelf_->status_area_widget())->SetOpacity( | 690 GetLayer(shelf_->status_area_widget())->SetOpacity( |
| 686 target_bounds.status_opacity); | 691 target_bounds.status_opacity); |
| 687 | 692 |
| 688 // Having a window which is visible but does not have an opacity is an illegal | 693 // 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. | 694 // state. We therefore hide the shelf here if required. |
| 690 if (!target_bounds.status_opacity) | 695 if (!target_bounds.status_opacity) |
| 691 shelf_->status_area_widget()->Hide(); | 696 shelf_->status_area_widget()->Hide(); |
| 692 else if (target_bounds.status_opacity) | |
| 693 shelf_->status_area_widget()->Show(); | |
| 694 | 697 |
| 695 // TODO(harrym): Once status area widget is a child view of shelf | 698 // TODO(harrym): Once status area widget is a child view of shelf |
| 696 // this can be simplified. | 699 // this can be simplified. |
| 697 gfx::Rect status_bounds = target_bounds.status_bounds_in_shelf; | 700 gfx::Rect status_bounds = target_bounds.status_bounds_in_shelf; |
| 698 status_bounds.set_x(status_bounds.x() + | 701 status_bounds.set_x(status_bounds.x() + |
| 699 target_bounds.shelf_bounds_in_root.x()); | 702 target_bounds.shelf_bounds_in_root.x()); |
| 700 status_bounds.set_y(status_bounds.y() + | 703 status_bounds.set_y(status_bounds.y() + |
| 701 target_bounds.shelf_bounds_in_root.y()); | 704 target_bounds.shelf_bounds_in_root.y()); |
| 702 shelf_->status_area_widget()->SetBounds( | 705 shelf_->status_area_widget()->SetBounds( |
| 703 ScreenUtil::ConvertRectToScreen( | 706 ScreenUtil::ConvertRectToScreen( |
| (...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1140 | 1143 |
| 1141 void ShelfLayoutManager::SessionStateChanged( | 1144 void ShelfLayoutManager::SessionStateChanged( |
| 1142 SessionStateDelegate::SessionState state) { | 1145 SessionStateDelegate::SessionState state) { |
| 1143 TargetBounds target_bounds; | 1146 TargetBounds target_bounds; |
| 1144 CalculateTargetBounds(state_, &target_bounds); | 1147 CalculateTargetBounds(state_, &target_bounds); |
| 1145 UpdateBoundsAndOpacity(target_bounds, true, NULL); | 1148 UpdateBoundsAndOpacity(target_bounds, true, NULL); |
| 1146 UpdateVisibilityState(); | 1149 UpdateVisibilityState(); |
| 1147 } | 1150 } |
| 1148 | 1151 |
| 1149 } // namespace ash | 1152 } // namespace ash |
| OLD | NEW |