OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_grid.h" | 5 #include "ash/wm/overview/window_grid.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <functional> | 8 #include <functional> |
9 #include <set> | 9 #include <set> |
10 #include <utility> | 10 #include <utility> |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 #include "ui/views/view.h" | 43 #include "ui/views/view.h" |
44 #include "ui/views/widget/widget.h" | 44 #include "ui/views/widget/widget.h" |
45 #include "ui/wm/core/coordinate_conversion.h" | 45 #include "ui/wm/core/coordinate_conversion.h" |
46 #include "ui/wm/core/shadow.h" | 46 #include "ui/wm/core/shadow.h" |
47 #include "ui/wm/core/shadow_types.h" | 47 #include "ui/wm/core/shadow_types.h" |
48 #include "ui/wm/core/window_animations.h" | 48 #include "ui/wm/core/window_animations.h" |
49 | 49 |
50 namespace ash { | 50 namespace ash { |
51 namespace { | 51 namespace { |
52 | 52 |
53 using Windows = aura::Window::Windows; | |
54 | |
55 // A comparator for locating a given target window. | |
56 struct WindowSelectorItemComparator { | |
57 explicit WindowSelectorItemComparator(const aura::Window* target_window) | |
58 : target(target_window) {} | |
59 | |
60 bool operator()(std::unique_ptr<WindowSelectorItem>& window) const { | |
61 return window->GetWindow() == target; | |
62 } | |
63 | |
64 const aura::Window* target; | |
65 }; | |
66 | |
67 // Time it takes for the selector widget to move to the next target. The same | 53 // Time it takes for the selector widget to move to the next target. The same |
68 // time is used for fading out shield widget when the overview mode is opened | 54 // time is used for fading out shield widget when the overview mode is opened |
69 // or closed. | 55 // or closed. |
70 const int kOverviewSelectorTransitionMilliseconds = 250; | 56 const int kOverviewSelectorTransitionMilliseconds = 250; |
71 | 57 |
72 // The color and opacity of the screen shield in overview. | 58 // The color and opacity of the screen shield in overview. |
73 const SkColor kShieldColor = SkColorSetARGB(255, 0, 0, 0); | 59 const SkColor kShieldColor = SkColorSetARGB(255, 0, 0, 0); |
74 const float kShieldOpacity = 0.7f; | 60 const float kShieldOpacity = 0.7f; |
75 | 61 |
76 // The color and opacity of the overview selector. | 62 // The color and opacity of the overview selector. |
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
562 ->CreateOverviewAnimationSettings( | 548 ->CreateOverviewAnimationSettings( |
563 OverviewAnimationType::OVERVIEW_ANIMATION_CLOSING_SELECTOR_ITEM, | 549 OverviewAnimationType::OVERVIEW_ANIMATION_CLOSING_SELECTOR_ITEM, |
564 selection_widget_window); | 550 selection_widget_window); |
565 selection_widget_->SetOpacity(0.f); | 551 selection_widget_->SetOpacity(0.f); |
566 } | 552 } |
567 | 553 |
568 void WindowGrid::OnWindowDestroying(aura::Window* window) { | 554 void WindowGrid::OnWindowDestroying(aura::Window* window) { |
569 window_observer_.Remove(window); | 555 window_observer_.Remove(window); |
570 window_state_observer_.Remove(wm::GetWindowState(window)); | 556 window_state_observer_.Remove(wm::GetWindowState(window)); |
571 auto iter = std::find_if(window_list_.begin(), window_list_.end(), | 557 auto iter = std::find_if(window_list_.begin(), window_list_.end(), |
572 WindowSelectorItemComparator(window)); | 558 [window](std::unique_ptr<WindowSelectorItem>& item) { |
573 | 559 return item->GetWindow() == window; |
| 560 }); |
574 DCHECK(iter != window_list_.end()); | 561 DCHECK(iter != window_list_.end()); |
575 | 562 |
576 size_t removed_index = iter - window_list_.begin(); | 563 size_t removed_index = iter - window_list_.begin(); |
577 window_list_.erase(iter); | 564 window_list_.erase(iter); |
578 | 565 |
579 if (empty()) { | 566 if (empty()) { |
580 // If the grid is now empty, notify the window selector so that it erases us | 567 // If the grid is now empty, notify the window selector so that it erases us |
581 // from its grid list. | 568 // from its grid list. |
582 window_selector_->OnGridEmpty(this); | 569 window_selector_->OnGridEmpty(this); |
583 return; | 570 return; |
(...skipping 14 matching lines...) Expand all Loading... |
598 | 585 |
599 void WindowGrid::OnWindowBoundsChanged(aura::Window* window, | 586 void WindowGrid::OnWindowBoundsChanged(aura::Window* window, |
600 const gfx::Rect& old_bounds, | 587 const gfx::Rect& old_bounds, |
601 const gfx::Rect& new_bounds) { | 588 const gfx::Rect& new_bounds) { |
602 // During preparation, window bounds can change. Ignore bounds | 589 // During preparation, window bounds can change. Ignore bounds |
603 // change notifications in this case; we'll reposition soon. | 590 // change notifications in this case; we'll reposition soon. |
604 if (!prepared_for_overview_) | 591 if (!prepared_for_overview_) |
605 return; | 592 return; |
606 | 593 |
607 auto iter = std::find_if(window_list_.begin(), window_list_.end(), | 594 auto iter = std::find_if(window_list_.begin(), window_list_.end(), |
608 WindowSelectorItemComparator(window)); | 595 [window](std::unique_ptr<WindowSelectorItem>& item) { |
| 596 return item->GetWindow() == window; |
| 597 }); |
609 DCHECK(iter != window_list_.end()); | 598 DCHECK(iter != window_list_.end()); |
610 | 599 |
611 // Immediately finish any active bounds animation. | 600 // Immediately finish any active bounds animation. |
612 window->layer()->GetAnimator()->StopAnimatingProperty( | 601 window->layer()->GetAnimator()->StopAnimatingProperty( |
613 ui::LayerAnimationElement::BOUNDS); | 602 ui::LayerAnimationElement::BOUNDS); |
614 PositionWindows(false); | 603 PositionWindows(false); |
615 } | 604 } |
616 | 605 |
617 void WindowGrid::OnPostWindowStateTypeChange(wm::WindowState* window_state, | 606 void WindowGrid::OnPostWindowStateTypeChange(wm::WindowState* window_state, |
618 wm::WindowStateType old_type) { | 607 wm::WindowStateType old_type) { |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
833 *min_right = left; | 822 *min_right = left; |
834 if (*max_right < left) | 823 if (*max_right < left) |
835 *max_right = left; | 824 *max_right = left; |
836 } | 825 } |
837 *max_bottom = top + height; | 826 *max_bottom = top + height; |
838 } | 827 } |
839 return windows_fit; | 828 return windows_fit; |
840 } | 829 } |
841 | 830 |
842 } // namespace ash | 831 } // namespace ash |
OLD | NEW |