Chromium Code Reviews| 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_overview.h" | 5 #include "ash/wm/overview/window_overview.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "ash/metrics/user_metrics_recorder.h" | 9 #include "ash/metrics/user_metrics_recorder.h" |
| 10 #include "ash/screen_util.h" | 10 #include "ash/screen_util.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 42 // The minimum number of cards along the major axis (i.e. horizontally on a | 42 // The minimum number of cards along the major axis (i.e. horizontally on a |
| 43 // landscape orientation). | 43 // landscape orientation). |
| 44 const int kMinCardsMajor = 3; | 44 const int kMinCardsMajor = 3; |
| 45 | 45 |
| 46 // The duration of transition animations on the overview selector. | 46 // The duration of transition animations on the overview selector. |
| 47 const int kOverviewSelectorTransitionMilliseconds = 100; | 47 const int kOverviewSelectorTransitionMilliseconds = 100; |
| 48 | 48 |
| 49 // The color and opacity of the overview selector. | 49 // The color and opacity of the overview selector. |
| 50 const SkColor kWindowOverviewSelectionColor = SK_ColorBLACK; | 50 const SkColor kWindowOverviewSelectionColor = SK_ColorBLACK; |
| 51 const float kWindowOverviewSelectionOpacity = 0.5f; | 51 const float kWindowOverviewSelectionOpacity = 0.5f; |
| 52 // When a window layer gets hidden, and the window remains "logically visible", | |
| 53 // it is illegal to fade the layer to 0. We therefore use a fraction which is | |
| 54 // resolving to an alpha of 0 but tells a comparison otherwise. | |
| 55 const float kWindowLayerNotShown = 0.001f; | |
|
sky
2014/03/12 19:31:40
Ugh. Why can't you actually hide here and evervy w
| |
| 52 | 56 |
| 53 // The padding or amount of the window selector widget visible around the edges | 57 // The padding or amount of the window selector widget visible around the edges |
| 54 // of the currently selected window. | 58 // of the currently selected window. |
| 55 const int kWindowOverviewSelectionPadding = 25; | 59 const int kWindowOverviewSelectionPadding = 25; |
| 56 | 60 |
| 57 // A comparator for locating a given target window. | 61 // A comparator for locating a given target window. |
| 58 struct WindowSelectorItemComparator | 62 struct WindowSelectorItemComparator |
| 59 : public std::unary_function<WindowSelectorItem*, bool> { | 63 : public std::unary_function<WindowSelectorItem*, bool> { |
| 60 explicit WindowSelectorItemComparator(const aura::Window* target_window) | 64 explicit WindowSelectorItemComparator(const aura::Window* target_window) |
| 61 : target(target_window) { | 65 : target(target_window) { |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 210 ui::ScopedLayerAnimationSettings animation_settings( | 214 ui::ScopedLayerAnimationSettings animation_settings( |
| 211 old_selection->layer()->GetAnimator()); | 215 old_selection->layer()->GetAnimator()); |
| 212 animation_settings.SetTransitionDuration( | 216 animation_settings.SetTransitionDuration( |
| 213 base::TimeDelta::FromMilliseconds( | 217 base::TimeDelta::FromMilliseconds( |
| 214 kOverviewSelectorTransitionMilliseconds)); | 218 kOverviewSelectorTransitionMilliseconds)); |
| 215 animation_settings.SetPreemptionStrategy( | 219 animation_settings.SetPreemptionStrategy( |
| 216 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | 220 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
| 217 old_selection->SetBoundsInScreen( | 221 old_selection->SetBoundsInScreen( |
| 218 GetSelectionBounds(selection_index_) + fade_out_direction, | 222 GetSelectionBounds(selection_index_) + fade_out_direction, |
| 219 dst_display); | 223 dst_display); |
| 220 old_selection->layer()->SetOpacity(0); | 224 old_selection->layer()->SetOpacity(kWindowLayerNotShown); |
| 221 InitializeSelectionWidget(); | 225 InitializeSelectionWidget(); |
| 222 selection_widget_->GetNativeWindow()->SetBoundsInScreen( | 226 selection_widget_->GetNativeWindow()->SetBoundsInScreen( |
| 223 target_bounds - fade_out_direction, dst_display); | 227 target_bounds - fade_out_direction, dst_display); |
| 224 } | 228 } |
| 225 ui::ScopedLayerAnimationSettings animation_settings( | 229 ui::ScopedLayerAnimationSettings animation_settings( |
| 226 selection_widget_->GetNativeWindow()->layer()->GetAnimator()); | 230 selection_widget_->GetNativeWindow()->layer()->GetAnimator()); |
| 227 animation_settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds( | 231 animation_settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds( |
| 228 kOverviewSelectorTransitionMilliseconds)); | 232 kOverviewSelectorTransitionMilliseconds)); |
| 229 animation_settings.SetPreemptionStrategy( | 233 animation_settings.SetPreemptionStrategy( |
| 230 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | 234 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 346 ui::ScopedLayerAnimationSettings settings( | 350 ui::ScopedLayerAnimationSettings settings( |
| 347 (*iter)->layer()->GetAnimator()); | 351 (*iter)->layer()->GetAnimator()); |
| 348 settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds( | 352 settings.SetTransitionDuration(base::TimeDelta::FromMilliseconds( |
| 349 ScopedTransformOverviewWindow::kTransitionMilliseconds)); | 353 ScopedTransformOverviewWindow::kTransitionMilliseconds)); |
| 350 settings.SetPreemptionStrategy( | 354 settings.SetPreemptionStrategy( |
| 351 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | 355 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
| 352 (*iter)->Hide(); | 356 (*iter)->Hide(); |
| 353 // Hiding the window can result in it being destroyed. | 357 // Hiding the window can result in it being destroyed. |
| 354 if (!hidden_windows_.Contains(*iter)) | 358 if (!hidden_windows_.Contains(*iter)) |
| 355 continue; | 359 continue; |
| 356 (*iter)->layer()->SetOpacity(0); | 360 (*iter)->layer()->SetOpacity(kWindowLayerNotShown); |
| 357 } | 361 } |
| 358 } | 362 } |
| 359 | 363 |
| 360 void WindowOverview::PositionWindows() { | 364 void WindowOverview::PositionWindows() { |
| 361 if (single_root_window_) { | 365 if (single_root_window_) { |
| 362 std::vector<WindowSelectorItem*> windows; | 366 std::vector<WindowSelectorItem*> windows; |
| 363 for (WindowSelectorItemList::iterator iter = windows_->begin(); | 367 for (WindowSelectorItemList::iterator iter = windows_->begin(); |
| 364 iter != windows_->end(); ++iter) { | 368 iter != windows_->end(); ++iter) { |
| 365 windows.push_back(*iter); | 369 windows.push_back(*iter); |
| 366 } | 370 } |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 440 params.accept_events = false; | 444 params.accept_events = false; |
| 441 selection_widget_->set_focus_on_creation(false); | 445 selection_widget_->set_focus_on_creation(false); |
| 442 selection_widget_->Init(params); | 446 selection_widget_->Init(params); |
| 443 views::View* content_view = new views::View; | 447 views::View* content_view = new views::View; |
| 444 content_view->set_background( | 448 content_view->set_background( |
| 445 views::Background::CreateSolidBackground(kWindowOverviewSelectionColor)); | 449 views::Background::CreateSolidBackground(kWindowOverviewSelectionColor)); |
| 446 selection_widget_->SetContentsView(content_view); | 450 selection_widget_->SetContentsView(content_view); |
| 447 selection_widget_->Show(); | 451 selection_widget_->Show(); |
| 448 selection_widget_->GetNativeWindow()->parent()->StackChildAtBottom( | 452 selection_widget_->GetNativeWindow()->parent()->StackChildAtBottom( |
| 449 selection_widget_->GetNativeWindow()); | 453 selection_widget_->GetNativeWindow()); |
| 450 selection_widget_->GetNativeWindow()->layer()->SetOpacity(0); | 454 selection_widget_->GetNativeWindow()->layer()->SetOpacity( |
| 455 kWindowLayerNotShown); | |
| 451 } | 456 } |
| 452 | 457 |
| 453 gfx::Rect WindowOverview::GetSelectionBounds(size_t index) { | 458 gfx::Rect WindowOverview::GetSelectionBounds(size_t index) { |
| 454 gfx::Rect bounds((*windows_)[index]->bounds()); | 459 gfx::Rect bounds((*windows_)[index]->bounds()); |
| 455 bounds.Inset(-kWindowOverviewSelectionPadding, | 460 bounds.Inset(-kWindowOverviewSelectionPadding, |
| 456 -kWindowOverviewSelectionPadding); | 461 -kWindowOverviewSelectionPadding); |
| 457 return bounds; | 462 return bounds; |
| 458 } | 463 } |
| 459 | 464 |
| 460 } // namespace ash | 465 } // namespace ash |
| OLD | NEW |