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