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 #ifndef ASH_WM_OVERVIEW_WINDOW_SELECTOR_H_ | 5 #ifndef ASH_WM_OVERVIEW_WINDOW_SELECTOR_H_ |
6 #define ASH_WM_OVERVIEW_WINDOW_SELECTOR_H_ | 6 #define ASH_WM_OVERVIEW_WINDOW_SELECTOR_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "ash/ash_export.h" | 11 #include "ash/ash_export.h" |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/memory/scoped_vector.h" | 14 #include "base/memory/scoped_vector.h" |
15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
16 #include "ui/aura/window_observer.h" | 16 #include "ui/aura/window_observer.h" |
17 #include "ui/aura/window_tracker.h" | 17 #include "ui/aura/window_tracker.h" |
18 #include "ui/events/event_handler.h" | 18 #include "ui/events/event_handler.h" |
19 #include "ui/gfx/display_observer.h" | 19 #include "ui/gfx/display_observer.h" |
| 20 #include "ui/views/controls/textfield/textfield_controller.h" |
20 #include "ui/wm/public/activation_change_observer.h" | 21 #include "ui/wm/public/activation_change_observer.h" |
21 | 22 |
22 namespace aura { | 23 namespace aura { |
23 class RootWindow; | 24 class RootWindow; |
24 class Window; | 25 class Window; |
25 } | 26 } |
26 | 27 |
27 namespace gfx { | 28 namespace gfx { |
28 class Rect; | 29 class Rect; |
29 } | 30 } |
30 | 31 |
31 namespace ui { | 32 namespace ui { |
32 class LocatedEvent; | 33 class LocatedEvent; |
33 } | 34 } |
34 | 35 |
| 36 namespace views { |
| 37 class Textfield; |
| 38 class Widget; |
| 39 } |
| 40 |
35 namespace ash { | 41 namespace ash { |
36 class WindowSelectorDelegate; | 42 class WindowSelectorDelegate; |
37 class WindowSelectorItem; | 43 class WindowSelectorItem; |
38 class WindowSelectorTest; | 44 class WindowSelectorTest; |
39 class WindowGrid; | 45 class WindowGrid; |
40 | 46 |
41 // The WindowSelector shows a grid of all of your windows, allowing to select | 47 // The WindowSelector shows a grid of all of your windows, allowing to select |
42 // one by clicking or tapping on it. | 48 // one by clicking or tapping on it. |
43 class ASH_EXPORT WindowSelector | 49 class ASH_EXPORT WindowSelector |
44 : public ui::EventHandler, | 50 : public gfx::DisplayObserver, |
45 public gfx::DisplayObserver, | |
46 public aura::WindowObserver, | 51 public aura::WindowObserver, |
47 public aura::client::ActivationChangeObserver { | 52 public aura::client::ActivationChangeObserver, |
| 53 public views::TextfieldController { |
48 public: | 54 public: |
49 enum Direction { | 55 enum Direction { |
50 LEFT, | 56 LEFT, |
51 UP, | 57 UP, |
52 RIGHT, | 58 RIGHT, |
53 DOWN | 59 DOWN |
54 }; | 60 }; |
55 | 61 |
56 typedef std::vector<aura::Window*> WindowList; | 62 typedef std::vector<aura::Window*> WindowList; |
57 typedef ScopedVector<WindowSelectorItem> WindowSelectorItemList; | 63 typedef ScopedVector<WindowSelectorItem> WindowSelectorItemList; |
58 | 64 |
59 WindowSelector(const WindowList& windows, | 65 WindowSelector(const WindowList& windows, |
60 WindowSelectorDelegate* delegate); | 66 WindowSelectorDelegate* delegate); |
61 virtual ~WindowSelector(); | 67 virtual ~WindowSelector(); |
62 | 68 |
63 // Cancels window selection. | 69 // Cancels window selection. |
64 void CancelSelection(); | 70 void CancelSelection(); |
65 | 71 |
66 // Called when the last window selector item from a grid is deleted. | 72 // Called when the last window selector item from a grid is deleted. |
67 void OnGridEmpty(WindowGrid* grid); | 73 void OnGridEmpty(WindowGrid* grid); |
68 | 74 |
69 // ui::EventHandler: | |
70 virtual void OnKeyEvent(ui::KeyEvent* event) OVERRIDE; | |
71 | |
72 // gfx::DisplayObserver: | 75 // gfx::DisplayObserver: |
73 virtual void OnDisplayAdded(const gfx::Display& display) OVERRIDE; | 76 virtual void OnDisplayAdded(const gfx::Display& display) OVERRIDE; |
74 virtual void OnDisplayRemoved(const gfx::Display& display) OVERRIDE; | 77 virtual void OnDisplayRemoved(const gfx::Display& display) OVERRIDE; |
75 virtual void OnDisplayMetricsChanged(const gfx::Display& display, | 78 virtual void OnDisplayMetricsChanged(const gfx::Display& display, |
76 uint32_t metrics) OVERRIDE; | 79 uint32_t metrics) OVERRIDE; |
77 | 80 |
78 // aura::WindowObserver: | 81 // aura::WindowObserver: |
79 virtual void OnWindowAdded(aura::Window* new_window) OVERRIDE; | 82 virtual void OnWindowAdded(aura::Window* new_window) OVERRIDE; |
80 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; | 83 virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; |
81 | 84 |
82 // aura::client::ActivationChangeObserver: | 85 // aura::client::ActivationChangeObserver: |
83 virtual void OnWindowActivated(aura::Window* gained_active, | 86 virtual void OnWindowActivated(aura::Window* gained_active, |
84 aura::Window* lost_active) OVERRIDE; | 87 aura::Window* lost_active) OVERRIDE; |
85 virtual void OnAttemptToReactivateWindow( | 88 virtual void OnAttemptToReactivateWindow( |
86 aura::Window* request_active, | 89 aura::Window* request_active, |
87 aura::Window* actual_active) OVERRIDE; | 90 aura::Window* actual_active) OVERRIDE; |
88 | 91 |
| 92 // views::TextfieldController: |
| 93 virtual void ContentsChanged(views::Textfield* sender, |
| 94 const base::string16& new_contents) OVERRIDE; |
| 95 virtual bool HandleKeyEvent(views::Textfield* sender, |
| 96 const ui::KeyEvent& key_event) OVERRIDE; |
| 97 |
89 private: | 98 private: |
90 friend class WindowSelectorTest; | 99 friend class WindowSelectorTest; |
91 | 100 |
92 // Begins positioning windows such that all windows are visible on the screen. | 101 // Begins positioning windows such that all windows are visible on the screen. |
93 void StartOverview(); | 102 void StartOverview(); |
94 | 103 |
95 // Position all of the windows in the overview. | 104 // Position all of the windows in the overview. |
96 void PositionWindows(bool animate); | 105 void PositionWindows(bool animate); |
97 | 106 |
98 // Hide and track all hidden windows not in the overview item list. | 107 // Hide and track all hidden windows not in the overview item list. |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 // them refer to this particular overview session and are not cumulative: | 144 // them refer to this particular overview session and are not cumulative: |
136 // The time when overview was started. | 145 // The time when overview was started. |
137 base::Time overview_start_time_; | 146 base::Time overview_start_time_; |
138 | 147 |
139 // The number of arrow key presses. | 148 // The number of arrow key presses. |
140 size_t num_key_presses_; | 149 size_t num_key_presses_; |
141 | 150 |
142 // The number of items in the overview. | 151 // The number of items in the overview. |
143 size_t num_items_; | 152 size_t num_items_; |
144 | 153 |
| 154 // Indicates if we are showing the selection widget. |
| 155 bool showing_selection_widget_; |
| 156 |
| 157 // Window text filter widget. As the user writes on it, we filter the items |
| 158 // in the overview. It is also responsible for handling overview key events, |
| 159 // such as enter key to select. |
| 160 scoped_ptr<views::Widget> text_filter_widget_; |
| 161 |
145 DISALLOW_COPY_AND_ASSIGN(WindowSelector); | 162 DISALLOW_COPY_AND_ASSIGN(WindowSelector); |
146 }; | 163 }; |
147 | 164 |
148 } // namespace ash | 165 } // namespace ash |
149 | 166 |
150 #endif // ASH_WM_OVERVIEW_WINDOW_SELECTOR_H_ | 167 #endif // ASH_WM_OVERVIEW_WINDOW_SELECTOR_H_ |
OLD | NEW |