| 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 11 matching lines...) Expand all Loading... |
| 75 } | 71 } |
| 76 | 72 |
| 77 void WindowSelectorWindow::RestoreWindowOnExit(aura::Window* window) { | 73 void WindowSelectorWindow::RestoreWindowOnExit(aura::Window* window) { |
| 78 transform_window_.RestoreWindowOnExit(); | 74 transform_window_.RestoreWindowOnExit(); |
| 79 } | 75 } |
| 80 | 76 |
| 81 aura::Window* WindowSelectorWindow::SelectionWindow() { | 77 aura::Window* WindowSelectorWindow::SelectionWindow() { |
| 82 return transform_window_.window(); | 78 return transform_window_.window(); |
| 83 } | 79 } |
| 84 | 80 |
| 81 const aura::Window* WindowSelectorWindow::SelectionWindow() const { |
| 82 return transform_window_.window(); |
| 83 } |
| 84 |
| 85 void WindowSelectorWindow::RemoveWindow(const aura::Window* window) { | 85 void WindowSelectorWindow::RemoveWindow(const aura::Window* window) { |
| 86 DCHECK_EQ(transform_window_.window(), window); | 86 DCHECK_EQ(transform_window_.window(), window); |
| 87 transform_window_.OnWindowDestroyed(); | 87 transform_window_.OnWindowDestroyed(); |
| 88 // Remove the close button now so that the exited mouse event which is | 88 // Remove the close button now so that the exited mouse event which is |
| 89 // delivered to the destroyed button as it is destroyed does not happen while | 89 // delivered to the destroyed button as it is destroyed does not happen while |
| 90 // this item is being removed from the list of windows in overview. | 90 // this item is being removed from the list of windows in overview. |
| 91 close_button_.reset(); | 91 close_button_.reset(); |
| 92 } | 92 } |
| 93 | 93 |
| 94 bool WindowSelectorWindow::empty() const { | 94 bool WindowSelectorWindow::empty() const { |
| 95 return transform_window_.window() == NULL; | 95 return transform_window_.window() == NULL; |
| 96 } | 96 } |
| 97 | 97 |
| 98 void WindowSelectorWindow::PrepareForOverview() { | 98 void WindowSelectorWindow::PrepareForOverview() { |
| 99 transform_window_.PrepareForOverview(); | 99 transform_window_.PrepareForOverview(); |
| 100 } | 100 } |
| 101 | 101 |
| 102 void WindowSelectorWindow::SetItemBounds(aura::Window* root_window, | 102 void WindowSelectorWindow::SetItemBounds(aura::Window* root_window, |
| 103 const gfx::Rect& target_bounds, | 103 const gfx::Rect& target_bounds, |
| 104 bool animate) { | 104 bool animate) { |
| 105 gfx::Rect src_rect = transform_window_.GetBoundsInScreen(); | 105 gfx::Rect src_rect = transform_window_.GetBoundsInScreen(); |
| 106 set_bounds(ScopedTransformOverviewWindow:: | 106 set_bounds(ScopedTransformOverviewWindow:: |
| 107 ShrinkRectToFitPreservingAspectRatio(src_rect, target_bounds)); | 107 ShrinkRectToFitPreservingAspectRatio(src_rect, target_bounds)); |
| 108 transform_window_.SetTransform(root_window, | 108 transform_window_.SetTransform(root_window, |
| 109 ScopedTransformOverviewWindow::GetTransformForRect(src_rect, bounds()), | 109 ScopedTransformOverviewWindow::GetTransformForRect(src_rect, bounds()), |
| 110 animate); | 110 animate); |
| 111 // TODO move close button management to WindowSelectorItem, so that we can |
| 112 // also handle panels. |
| 113 // See http://crbug.com/352143 |
| 111 UpdateCloseButtonBounds(root_window); | 114 UpdateCloseButtonBounds(root_window); |
| 112 } | 115 } |
| 113 | 116 |
| 114 void WindowSelectorWindow::ButtonPressed(views::Button* sender, | 117 void WindowSelectorWindow::ButtonPressed(views::Button* sender, |
| 115 const ui::Event& event) { | 118 const ui::Event& event) { |
| 116 views::Widget::GetTopLevelWidgetForNativeView( | 119 views::Widget::GetTopLevelWidgetForNativeView( |
| 117 transform_window_.window())->Close(); | 120 transform_window_.window())->Close(); |
| 118 } | 121 } |
| 119 | 122 |
| 120 void WindowSelectorWindow::UpdateCloseButtonBounds(aura::Window* root_window) { | 123 void WindowSelectorWindow::UpdateCloseButtonBounds(aura::Window* root_window) { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 147 layer->GetAnimator()->StopAnimating(); | 150 layer->GetAnimator()->StopAnimating(); |
| 148 layer->GetAnimator()->SchedulePauseForProperties( | 151 layer->GetAnimator()->SchedulePauseForProperties( |
| 149 base::TimeDelta::FromMilliseconds( | 152 base::TimeDelta::FromMilliseconds( |
| 150 ScopedTransformOverviewWindow::kTransitionMilliseconds), | 153 ScopedTransformOverviewWindow::kTransitionMilliseconds), |
| 151 ui::LayerAnimationElement::OPACITY); | 154 ui::LayerAnimationElement::OPACITY); |
| 152 { | 155 { |
| 153 ui::ScopedLayerAnimationSettings settings(layer->GetAnimator()); | 156 ui::ScopedLayerAnimationSettings settings(layer->GetAnimator()); |
| 154 settings.SetPreemptionStrategy( | 157 settings.SetPreemptionStrategy( |
| 155 ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); | 158 ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); |
| 156 settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds( | 159 settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds( |
| 157 kCloseButtonFadeInMilliseconds)); | 160 WindowSelectorItem::kFadeInMilliseconds)); |
| 158 layer->SetOpacity(1); | 161 layer->SetOpacity(1); |
| 159 } | 162 } |
| 160 } else { | 163 } else { |
| 161 ui::ScopedLayerAnimationSettings settings( | 164 ui::ScopedLayerAnimationSettings settings( |
| 162 close_button_->GetNativeWindow()->layer()->GetAnimator()); | 165 close_button_->GetNativeWindow()->layer()->GetAnimator()); |
| 163 settings.SetPreemptionStrategy( | 166 settings.SetPreemptionStrategy( |
| 164 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | 167 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
| 165 settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds( | 168 settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds( |
| 166 ScopedTransformOverviewWindow::kTransitionMilliseconds)); | 169 ScopedTransformOverviewWindow::kTransitionMilliseconds)); |
| 167 close_button_->GetNativeWindow()->SetTransform(close_button_transform); | 170 close_button_->GetNativeWindow()->SetTransform(close_button_transform); |
| 168 } | 171 } |
| 169 } | 172 } |
| 170 | 173 |
| 171 } // namespace ash | 174 } // namespace ash |
| OLD | NEW |