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/wm/panels/panel_layout_manager.h" | 5 #include "ash/wm/panels/panel_layout_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "ash/screen_util.h" | 10 #include "ash/screen_util.h" |
(...skipping 830 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
841 callout_bounds.set_y(bounds.y() - callout_bounds.height()); | 841 callout_bounds.set_y(bounds.y() - callout_bounds.height()); |
842 break; | 842 break; |
843 } | 843 } |
844 callout_bounds = ScreenUtil::ConvertRectFromScreen( | 844 callout_bounds = ScreenUtil::ConvertRectFromScreen( |
845 callout_widget->GetNativeWindow()->parent(), | 845 callout_widget->GetNativeWindow()->parent(), |
846 callout_bounds); | 846 callout_bounds); |
847 | 847 |
848 SetChildBoundsDirect(callout_widget->GetNativeWindow(), callout_bounds); | 848 SetChildBoundsDirect(callout_widget->GetNativeWindow(), callout_bounds); |
849 panel_container_->StackChildAbove(callout_widget->GetNativeWindow(), | 849 panel_container_->StackChildAbove(callout_widget->GetNativeWindow(), |
850 panel); | 850 panel); |
851 callout_widget->Show(); | |
852 | 851 |
853 ui::Layer* layer = callout_widget->GetNativeWindow()->layer(); | 852 ui::Layer* layer = callout_widget->GetNativeWindow()->layer(); |
854 // If the panel is not over the callout position or has just become visible | 853 // If the panel is not over the callout position or has just become visible |
855 // then fade in the callout. | 854 // then fade in the callout. |
856 if ((distance_until_over_panel > 0 || layer->GetTargetOpacity() < 1) && | 855 if ((distance_until_over_panel > 0 || layer->GetTargetOpacity() < 1)) { |
857 panel->layer()->GetTargetTransform().IsIdentity()) { | |
858 if (distance_until_over_panel > 0 && | 856 if (distance_until_over_panel > 0 && |
859 slide_distance >= distance_until_over_panel) { | 857 slide_distance >= distance_until_over_panel) { |
860 layer->SetOpacity(0); | |
861 // If the panel is not yet over the callout, then delay fading in | 858 // If the panel is not yet over the callout, then delay fading in |
862 // the callout until after the panel should be over it. | 859 // the callout until after the panel should be over it. |
863 int delay = kPanelSlideDurationMilliseconds * | 860 int delay = kPanelSlideDurationMilliseconds * |
864 distance_until_over_panel / slide_distance; | 861 distance_until_over_panel / slide_distance; |
865 layer->SetOpacity(0); | 862 layer->SetOpacity(0); |
866 layer->GetAnimator()->StopAnimating(); | 863 layer->GetAnimator()->StopAnimating(); |
867 layer->GetAnimator()->SchedulePauseForProperties( | 864 layer->GetAnimator()->SchedulePauseForProperties( |
868 base::TimeDelta::FromMilliseconds(delay), | 865 base::TimeDelta::FromMilliseconds(delay), |
869 ui::LayerAnimationElement::OPACITY); | 866 ui::LayerAnimationElement::OPACITY); |
870 } | 867 } |
871 { | 868 ui::ScopedLayerAnimationSettings callout_settings(layer->GetAnimator()); |
872 ui::ScopedLayerAnimationSettings callout_settings(layer->GetAnimator()); | 869 callout_settings.SetPreemptionStrategy( |
873 callout_settings.SetPreemptionStrategy( | 870 ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); |
874 ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); | 871 callout_settings.SetTransitionDuration( |
875 callout_settings.SetTransitionDuration( | 872 base::TimeDelta::FromMilliseconds( |
876 base::TimeDelta::FromMilliseconds( | 873 kCalloutFadeDurationMilliseconds)); |
877 kCalloutFadeDurationMilliseconds)); | 874 layer->SetOpacity(1); |
878 layer->SetOpacity(1); | |
879 } | |
880 } | 875 } |
| 876 |
| 877 // Show after changing the opacity animation. This way we don't have a |
| 878 // state where the widget is visible but the opacity is 0. |
| 879 callout_widget->Show(); |
881 } | 880 } |
882 } | 881 } |
883 | 882 |
884 //////////////////////////////////////////////////////////////////////////////// | 883 //////////////////////////////////////////////////////////////////////////////// |
885 // keyboard::KeyboardControllerObserver implementation: | 884 // keyboard::KeyboardControllerObserver implementation: |
886 | 885 |
887 void PanelLayoutManager::OnKeyboardBoundsChanging( | 886 void PanelLayoutManager::OnKeyboardBoundsChanging( |
888 const gfx::Rect& keyboard_bounds) { | 887 const gfx::Rect& keyboard_bounds) { |
889 // This bounds change will have caused a change to the Shelf which does not | 888 // This bounds change will have caused a change to the Shelf which does not |
890 // propogate automatically to this class, so manually recalculate bounds. | 889 // propogate automatically to this class, so manually recalculate bounds. |
891 OnWindowResized(); | 890 OnWindowResized(); |
892 } | 891 } |
893 | 892 |
894 } // namespace internal | 893 } // namespace internal |
895 } // namespace ash | 894 } // namespace ash |
OLD | NEW |