| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/overview/window_selector_window.h" | 5 #include "ash/wm/overview/window_selector_window.h" |
| 6 | 6 |
| 7 #include "ash/screen_util.h" | 7 #include "ash/screen_util.h" |
| 8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "ash/shell_window_ids.h" | 9 #include "ash/shell_window_ids.h" |
| 10 #include "ash/wm/overview/scoped_transform_overview_window.h" | 10 #include "ash/wm/overview/scoped_transform_overview_window.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 button->SetImage(views::CustomButton::STATE_HOVERED, | 40 button->SetImage(views::CustomButton::STATE_HOVERED, |
| 41 rb.GetImageSkiaNamed(IDR_AURA_WINDOW_OVERVIEW_CLOSE_H)); | 41 rb.GetImageSkiaNamed(IDR_AURA_WINDOW_OVERVIEW_CLOSE_H)); |
| 42 button->SetImage(views::CustomButton::STATE_PRESSED, | 42 button->SetImage(views::CustomButton::STATE_PRESSED, |
| 43 rb.GetImageSkiaNamed(IDR_AURA_WINDOW_OVERVIEW_CLOSE_P)); | 43 rb.GetImageSkiaNamed(IDR_AURA_WINDOW_OVERVIEW_CLOSE_P)); |
| 44 widget->SetContentsView(button); | 44 widget->SetContentsView(button); |
| 45 widget->SetSize(rb.GetImageSkiaNamed(IDR_AURA_WINDOW_OVERVIEW_CLOSE)->size()); | 45 widget->SetSize(rb.GetImageSkiaNamed(IDR_AURA_WINDOW_OVERVIEW_CLOSE)->size()); |
| 46 widget->Show(); | 46 widget->Show(); |
| 47 return widget; | 47 return widget; |
| 48 } | 48 } |
| 49 | 49 |
| 50 // The time for the close button to fade in when initially shown on entering | |
| 51 // overview mode. | |
| 52 const int kCloseButtonFadeInMilliseconds = 80; | |
| 53 | |
| 54 } // namespace | 50 } // namespace |
| 55 | 51 |
| 56 WindowSelectorWindow::WindowSelectorWindow(aura::Window* window) | 52 WindowSelectorWindow::WindowSelectorWindow(aura::Window* window) |
| 57 : transform_window_(window) { | 53 : transform_window_(window) { |
| 58 } | 54 } |
| 59 | 55 |
| 60 WindowSelectorWindow::~WindowSelectorWindow() { | 56 WindowSelectorWindow::~WindowSelectorWindow() { |
| 61 } | 57 } |
| 62 | 58 |
| 63 aura::Window* WindowSelectorWindow::GetRootWindow() { | 59 aura::Window* WindowSelectorWindow::GetRootWindow() { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 | 93 |
| 98 void WindowSelectorWindow::PrepareForOverview() { | 94 void WindowSelectorWindow::PrepareForOverview() { |
| 99 transform_window_.PrepareForOverview(); | 95 transform_window_.PrepareForOverview(); |
| 100 } | 96 } |
| 101 | 97 |
| 102 void WindowSelectorWindow::SetItemBounds(aura::Window* root_window, | 98 void WindowSelectorWindow::SetItemBounds(aura::Window* root_window, |
| 103 const gfx::Rect& target_bounds, | 99 const gfx::Rect& target_bounds, |
| 104 bool animate) { | 100 bool animate) { |
| 105 gfx::Rect src_rect = transform_window_.GetBoundsInScreen(); | 101 gfx::Rect src_rect = transform_window_.GetBoundsInScreen(); |
| 106 set_bounds(ScopedTransformOverviewWindow:: | 102 set_bounds(ScopedTransformOverviewWindow:: |
| 107 ShrinkRectToFitPreservingAspectRatio(src_rect, target_bounds)); | 103 ShrinkRectToFitPreservingAspectRatio(src_rect, target_bounds)); |
| 108 transform_window_.SetTransform(root_window, | 104 transform_window_.SetTransform(root_window, |
| 109 ScopedTransformOverviewWindow::GetTransformForRect(src_rect, bounds()), | 105 ScopedTransformOverviewWindow::GetTransformForRect(src_rect, bounds()), |
| 110 animate); | 106 animate); |
| 107 // TODO move close button management to WindowSelectorItem, so that we can |
| 108 // also handle panels. |
| 109 // See http://crbug.com/352143 |
| 111 UpdateCloseButtonBounds(root_window); | 110 UpdateCloseButtonBounds(root_window); |
| 112 } | 111 } |
| 113 | 112 |
| 114 void WindowSelectorWindow::ButtonPressed(views::Button* sender, | 113 void WindowSelectorWindow::ButtonPressed(views::Button* sender, |
| 115 const ui::Event& event) { | 114 const ui::Event& event) { |
| 116 views::Widget::GetTopLevelWidgetForNativeView( | 115 views::Widget::GetTopLevelWidgetForNativeView( |
| 117 transform_window_.window())->Close(); | 116 transform_window_.window())->Close(); |
| 118 } | 117 } |
| 119 | 118 |
| 120 void WindowSelectorWindow::UpdateCloseButtonBounds(aura::Window* root_window) { | 119 void WindowSelectorWindow::UpdateCloseButtonBounds(aura::Window* root_window) { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 147 layer->GetAnimator()->StopAnimating(); | 146 layer->GetAnimator()->StopAnimating(); |
| 148 layer->GetAnimator()->SchedulePauseForProperties( | 147 layer->GetAnimator()->SchedulePauseForProperties( |
| 149 base::TimeDelta::FromMilliseconds( | 148 base::TimeDelta::FromMilliseconds( |
| 150 ScopedTransformOverviewWindow::kTransitionMilliseconds), | 149 ScopedTransformOverviewWindow::kTransitionMilliseconds), |
| 151 ui::LayerAnimationElement::OPACITY); | 150 ui::LayerAnimationElement::OPACITY); |
| 152 { | 151 { |
| 153 ui::ScopedLayerAnimationSettings settings(layer->GetAnimator()); | 152 ui::ScopedLayerAnimationSettings settings(layer->GetAnimator()); |
| 154 settings.SetPreemptionStrategy( | 153 settings.SetPreemptionStrategy( |
| 155 ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); | 154 ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); |
| 156 settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds( | 155 settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds( |
| 157 kCloseButtonFadeInMilliseconds)); | 156 WindowSelectorItem::kFadeInMilliseconds)); |
| 158 layer->SetOpacity(1); | 157 layer->SetOpacity(1); |
| 159 } | 158 } |
| 160 } else { | 159 } else { |
| 161 ui::ScopedLayerAnimationSettings settings( | 160 ui::ScopedLayerAnimationSettings settings( |
| 162 close_button_->GetNativeWindow()->layer()->GetAnimator()); | 161 close_button_->GetNativeWindow()->layer()->GetAnimator()); |
| 163 settings.SetPreemptionStrategy( | 162 settings.SetPreemptionStrategy( |
| 164 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | 163 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
| 165 settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds( | 164 settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds( |
| 166 ScopedTransformOverviewWindow::kTransitionMilliseconds)); | 165 ScopedTransformOverviewWindow::kTransitionMilliseconds)); |
| 167 close_button_->GetNativeWindow()->SetTransform(close_button_transform); | 166 close_button_->GetNativeWindow()->SetTransform(close_button_transform); |
| 168 } | 167 } |
| 169 } | 168 } |
| 170 | 169 |
| 171 } // namespace ash | 170 } // namespace ash |
| OLD | NEW |