OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef ASH_WM_OVERVIEW_WINDOW_OVERVIEW_H_ | |
6 #define ASH_WM_OVERVIEW_WINDOW_OVERVIEW_H_ | |
7 | |
8 #include "base/compiler_specific.h" | |
9 #include "base/memory/scoped_ptr.h" | |
10 #include "base/memory/scoped_vector.h" | |
11 #include "base/time/time.h" | |
12 #include "ui/aura/window_tracker.h" | |
13 #include "ui/events/event_handler.h" | |
14 #include "ui/gfx/display_observer.h" | |
15 #include "ui/gfx/rect.h" | |
16 | |
17 namespace aura { | |
18 class Window; | |
19 namespace client { | |
20 class CursorClient; | |
21 } | |
22 } // namespace aura | |
23 | |
24 namespace ui { | |
25 class LocatedEvent; | |
26 } | |
27 | |
28 namespace views { | |
29 class Widget; | |
30 } | |
31 | |
32 namespace ash { | |
33 | |
34 class WindowSelector; | |
35 class WindowSelectorItem; | |
36 | |
37 // The WindowOverview shows a grid of all of your windows and allows selecting | |
38 // a window by clicking or tapping on it. It also displays a selection widget | |
39 // used to indicate the current selection when alt-tabbing between windows. | |
40 class WindowOverview : public ui::EventHandler, | |
41 public gfx::DisplayObserver { | |
42 public: | |
43 typedef ScopedVector<WindowSelectorItem> WindowSelectorItemList; | |
44 | |
45 // Enters an overview mode displaying |windows| and dispatches methods | |
46 // on |window_selector| when a window is selected or selection is canceled. | |
47 // If |single_root_window| is not NULL, all windows will be positioned on the | |
48 // given root window. | |
49 WindowOverview(WindowSelector* window_selector, | |
50 WindowSelectorItemList* windows); | |
51 virtual ~WindowOverview(); | |
52 | |
53 // Sets the selected window to be the window in position |index|. | |
54 void SetSelection(size_t index); | |
55 | |
56 // Dispatched when the list of windows has changed. | |
57 void OnWindowsChanged(); | |
58 | |
59 // ui::EventHandler: | |
60 virtual void OnKeyEvent(ui::KeyEvent* event) OVERRIDE; | |
61 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE; | |
62 virtual void OnScrollEvent(ui::ScrollEvent* event) OVERRIDE; | |
63 virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE; | |
64 | |
65 // gfx::DisplayObserver: | |
66 virtual void OnDisplayBoundsChanged(const gfx::Display& display) OVERRIDE; | |
67 virtual void OnDisplayAdded(const gfx::Display& display) OVERRIDE; | |
68 virtual void OnDisplayRemoved(const gfx::Display& display) OVERRIDE; | |
69 | |
70 private: | |
71 // Returns the target of |event| or NULL if the event is not targeted at | |
72 // any of the windows in the selector. | |
73 aura::Window* GetEventTarget(ui::LocatedEvent* event); | |
74 | |
75 // Returns the top-level window selected by targeting |window| or NULL if | |
76 // no overview window was found for |window|. | |
77 aura::Window* GetTargetedWindow(aura::Window* window); | |
78 | |
79 // Hide and track all hidden windows not in overview. | |
80 void HideAndTrackNonOverviewWindows(); | |
81 | |
82 // Position all of the windows based on the current selection mode. | |
83 void PositionWindows(bool animate); | |
84 // Position all of the windows from |root_window| on |root_window|. | |
85 void PositionWindowsFromRoot(aura::Window* root_window, bool animate); | |
86 | |
87 // Creates the selection widget. | |
88 void InitializeSelectionWidget(); | |
89 | |
90 // Returns the bounds for the selection widget for the windows_ at |index|. | |
91 gfx::Rect GetSelectionBounds(size_t index); | |
92 | |
93 // Weak pointer to the window selector which owns this class. | |
94 WindowSelector* window_selector_; | |
95 | |
96 // A weak pointer to the collection of windows in the overview wrapped by a | |
97 // helper class which restores their state and helps transform them to other | |
98 // root windows. | |
99 WindowSelectorItemList* windows_; | |
100 | |
101 // Widget indicating which window is currently selected. | |
102 scoped_ptr<views::Widget> selection_widget_; | |
103 | |
104 // Index of the currently selected window. This is used to determine when the | |
105 // selection changes rows and use a different animation. | |
106 size_t selection_index_; | |
107 | |
108 // The time when overview was started. | |
109 base::Time overview_start_time_; | |
110 | |
111 // The cursor client used to lock the current cursor during overview. | |
112 aura::client::CursorClient* cursor_client_; | |
113 | |
114 // Tracks windows which were hidden because they were not part of the | |
115 // overview. | |
116 aura::WindowTracker hidden_windows_; | |
117 | |
118 DISALLOW_COPY_AND_ASSIGN(WindowOverview); | |
119 }; | |
120 | |
121 } // namespace ash | |
122 | |
123 #endif // ASH_WM_OVERVIEW_WINDOW_OVERVIEW_H_ | |
OLD | NEW |