| 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/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "ash/shell_window_ids.h" | 8 #include "ash/shell_window_ids.h" |
| 9 #include "ash/wm/overview/scoped_transform_overview_window.h" | 9 #include "ash/wm/overview/scoped_transform_overview_window.h" |
| 10 #include "grit/ash_resources.h" | 10 #include "grit/ash_resources.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 button->SetImage(views::CustomButton::STATE_HOVERED, | 39 button->SetImage(views::CustomButton::STATE_HOVERED, |
| 40 rb.GetImageSkiaNamed(IDR_AURA_WINDOW_OVERVIEW_CLOSE_H)); | 40 rb.GetImageSkiaNamed(IDR_AURA_WINDOW_OVERVIEW_CLOSE_H)); |
| 41 button->SetImage(views::CustomButton::STATE_PRESSED, | 41 button->SetImage(views::CustomButton::STATE_PRESSED, |
| 42 rb.GetImageSkiaNamed(IDR_AURA_WINDOW_OVERVIEW_CLOSE_P)); | 42 rb.GetImageSkiaNamed(IDR_AURA_WINDOW_OVERVIEW_CLOSE_P)); |
| 43 widget->SetContentsView(button); | 43 widget->SetContentsView(button); |
| 44 widget->SetSize(rb.GetImageSkiaNamed(IDR_AURA_WINDOW_OVERVIEW_CLOSE)->size()); | 44 widget->SetSize(rb.GetImageSkiaNamed(IDR_AURA_WINDOW_OVERVIEW_CLOSE)->size()); |
| 45 widget->Show(); | 45 widget->Show(); |
| 46 return widget; | 46 return widget; |
| 47 } | 47 } |
| 48 | 48 |
| 49 // The time for the close button to fade in when initially shown on entering | |
| 50 // overview mode. | |
| 51 const int kCloseButtonFadeInMilliseconds = 80; | |
| 52 | |
| 53 } // namespace | 49 } // namespace |
| 54 | 50 |
| 55 WindowSelectorWindow::WindowSelectorWindow(aura::Window* window) | 51 WindowSelectorWindow::WindowSelectorWindow(aura::Window* window) |
| 56 : transform_window_(window) { | 52 : transform_window_(window) { |
| 57 } | 53 } |
| 58 | 54 |
| 59 WindowSelectorWindow::~WindowSelectorWindow() { | 55 WindowSelectorWindow::~WindowSelectorWindow() { |
| 60 } | 56 } |
| 61 | 57 |
| 62 aura::Window* WindowSelectorWindow::GetRootWindow() { | 58 aura::Window* WindowSelectorWindow::GetRootWindow() { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 74 } | 70 } |
| 75 | 71 |
| 76 void WindowSelectorWindow::RestoreWindowOnExit(aura::Window* window) { | 72 void WindowSelectorWindow::RestoreWindowOnExit(aura::Window* window) { |
| 77 transform_window_.RestoreWindowOnExit(); | 73 transform_window_.RestoreWindowOnExit(); |
| 78 } | 74 } |
| 79 | 75 |
| 80 aura::Window* WindowSelectorWindow::SelectionWindow() { | 76 aura::Window* WindowSelectorWindow::SelectionWindow() { |
| 81 return transform_window_.window(); | 77 return transform_window_.window(); |
| 82 } | 78 } |
| 83 | 79 |
| 80 const aura::Window* WindowSelectorWindow::SelectionWindow() const { |
| 81 return transform_window_.window(); |
| 82 } |
| 83 |
| 84 void WindowSelectorWindow::RemoveWindow(const aura::Window* window) { | 84 void WindowSelectorWindow::RemoveWindow(const aura::Window* window) { |
| 85 DCHECK_EQ(transform_window_.window(), window); | 85 DCHECK_EQ(transform_window_.window(), window); |
| 86 transform_window_.OnWindowDestroyed(); | 86 transform_window_.OnWindowDestroyed(); |
| 87 // Remove the close button now so that the exited mouse event which is | 87 // Remove the close button now so that the exited mouse event which is |
| 88 // delivered to the destroyed button as it is destroyed does not happen while | 88 // delivered to the destroyed button as it is destroyed does not happen while |
| 89 // this item is being removed from the list of windows in overview. | 89 // this item is being removed from the list of windows in overview. |
| 90 close_button_.reset(); | 90 close_button_.reset(); |
| 91 } | 91 } |
| 92 | 92 |
| 93 bool WindowSelectorWindow::empty() const { | 93 bool WindowSelectorWindow::empty() const { |
| 94 return transform_window_.window() == NULL; | 94 return transform_window_.window() == NULL; |
| 95 } | 95 } |
| 96 | 96 |
| 97 void WindowSelectorWindow::PrepareForOverview() { | 97 void WindowSelectorWindow::PrepareForOverview() { |
| 98 transform_window_.PrepareForOverview(); | 98 transform_window_.PrepareForOverview(); |
| 99 } | 99 } |
| 100 | 100 |
| 101 void WindowSelectorWindow::SetItemBounds(aura::Window* root_window, | 101 void WindowSelectorWindow::SetItemBounds(aura::Window* root_window, |
| 102 const gfx::Rect& target_bounds, | 102 const gfx::Rect& target_bounds, |
| 103 bool animate) { | 103 bool animate) { |
| 104 gfx::Rect src_rect = transform_window_.GetBoundsInScreen(); | 104 gfx::Rect src_rect = transform_window_.GetBoundsInScreen(); |
| 105 set_bounds(ScopedTransformOverviewWindow:: | 105 set_bounds(ScopedTransformOverviewWindow:: |
| 106 ShrinkRectToFitPreservingAspectRatio(src_rect, target_bounds)); | 106 ShrinkRectToFitPreservingAspectRatio(src_rect, target_bounds)); |
| 107 transform_window_.SetTransform(root_window, | 107 transform_window_.SetTransform(root_window, |
| 108 ScopedTransformOverviewWindow::GetTransformForRect(src_rect, bounds()), | 108 ScopedTransformOverviewWindow::GetTransformForRect(src_rect, bounds()), |
| 109 animate); | 109 animate); |
| 110 // TODO move close button management to WindowSelectorItem, so that we can |
| 111 // also handle panels. |
| 112 // See http://crbug.com/352143 |
| 110 UpdateCloseButtonBounds(); | 113 UpdateCloseButtonBounds(); |
| 111 } | 114 } |
| 112 | 115 |
| 113 void WindowSelectorWindow::ButtonPressed(views::Button* sender, | 116 void WindowSelectorWindow::ButtonPressed(views::Button* sender, |
| 114 const ui::Event& event) { | 117 const ui::Event& event) { |
| 115 views::Widget::GetTopLevelWidgetForNativeView( | 118 views::Widget::GetTopLevelWidgetForNativeView( |
| 116 transform_window_.window())->Close(); | 119 transform_window_.window())->Close(); |
| 117 } | 120 } |
| 118 | 121 |
| 119 void WindowSelectorWindow::UpdateCloseButtonBounds() { | 122 void WindowSelectorWindow::UpdateCloseButtonBounds() { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 146 layer->GetAnimator()->StopAnimating(); | 149 layer->GetAnimator()->StopAnimating(); |
| 147 layer->GetAnimator()->SchedulePauseForProperties( | 150 layer->GetAnimator()->SchedulePauseForProperties( |
| 148 base::TimeDelta::FromMilliseconds( | 151 base::TimeDelta::FromMilliseconds( |
| 149 ScopedTransformOverviewWindow::kTransitionMilliseconds), | 152 ScopedTransformOverviewWindow::kTransitionMilliseconds), |
| 150 ui::LayerAnimationElement::OPACITY); | 153 ui::LayerAnimationElement::OPACITY); |
| 151 { | 154 { |
| 152 ui::ScopedLayerAnimationSettings settings(layer->GetAnimator()); | 155 ui::ScopedLayerAnimationSettings settings(layer->GetAnimator()); |
| 153 settings.SetPreemptionStrategy( | 156 settings.SetPreemptionStrategy( |
| 154 ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); | 157 ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); |
| 155 settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds( | 158 settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds( |
| 156 kCloseButtonFadeInMilliseconds)); | 159 WindowSelectorItem::kFadeInMilliseconds)); |
| 157 layer->SetOpacity(1); | 160 layer->SetOpacity(1); |
| 158 } | 161 } |
| 159 } else { | 162 } else { |
| 160 ui::ScopedLayerAnimationSettings settings( | 163 ui::ScopedLayerAnimationSettings settings( |
| 161 close_button_->GetNativeWindow()->layer()->GetAnimator()); | 164 close_button_->GetNativeWindow()->layer()->GetAnimator()); |
| 162 settings.SetPreemptionStrategy( | 165 settings.SetPreemptionStrategy( |
| 163 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | 166 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
| 164 settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds( | 167 settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds( |
| 165 ScopedTransformOverviewWindow::kTransitionMilliseconds)); | 168 ScopedTransformOverviewWindow::kTransitionMilliseconds)); |
| 166 close_button_->GetNativeWindow()->SetTransform(close_button_transform); | 169 close_button_->GetNativeWindow()->SetTransform(close_button_transform); |
| 167 } | 170 } |
| 168 } | 171 } |
| 169 | 172 |
| 170 } // namespace ash | 173 } // namespace ash |
| OLD | NEW |