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 <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include <memory> | 11 #include <memory> |
12 #include <set> | 12 #include <set> |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 #include "ash/ash_export.h" | 15 #include "ash/ash_export.h" |
| 16 #include "ash/wm/splitview/split_view_controller.h" |
16 #include "base/macros.h" | 17 #include "base/macros.h" |
17 #include "base/time/time.h" | 18 #include "base/time/time.h" |
18 #include "ui/aura/window_observer.h" | 19 #include "ui/aura/window_observer.h" |
19 #include "ui/display/display_observer.h" | 20 #include "ui/display/display_observer.h" |
20 #include "ui/gfx/image/image_skia.h" | 21 #include "ui/gfx/image/image_skia.h" |
21 #include "ui/views/controls/textfield/textfield_controller.h" | 22 #include "ui/views/controls/textfield/textfield_controller.h" |
22 #include "ui/wm/public/activation_change_observer.h" | 23 #include "ui/wm/public/activation_change_observer.h" |
23 | 24 |
| 25 namespace gfx { |
| 26 class Point; |
| 27 class Rect; |
| 28 } // namespace gfx |
| 29 |
24 namespace views { | 30 namespace views { |
25 class Textfield; | 31 class Textfield; |
26 class Widget; | 32 class Widget; |
27 } | 33 } |
28 | 34 |
29 namespace ash { | 35 namespace ash { |
30 class WindowSelectorDelegate; | 36 class WindowSelectorDelegate; |
31 class WindowSelectorItem; | 37 class WindowSelectorItem; |
32 class WindowSelectorTest; | 38 class WindowSelectorTest; |
33 class WindowGrid; | 39 class WindowGrid; |
| 40 class OverviewWindowDragController; |
34 | 41 |
35 // The WindowSelector shows a grid of all of your windows, allowing to select | 42 // The WindowSelector shows a grid of all of your windows, allowing to select |
36 // one by clicking or tapping on it. | 43 // one by clicking or tapping on it. |
37 class ASH_EXPORT WindowSelector : public display::DisplayObserver, | 44 class ASH_EXPORT WindowSelector : public display::DisplayObserver, |
38 public aura::WindowObserver, | 45 public aura::WindowObserver, |
39 public ::wm::ActivationChangeObserver, | 46 public ::wm::ActivationChangeObserver, |
40 public views::TextfieldController { | 47 public views::TextfieldController, |
| 48 public SplitViewController::Observer { |
41 public: | 49 public: |
42 // Returns true if the window can be selected in overview mode. | 50 // Returns true if the window can be selected in overview mode. |
43 static bool IsSelectable(aura::Window* window); | 51 static bool IsSelectable(aura::Window* window); |
44 | 52 |
45 enum Direction { LEFT, UP, RIGHT, DOWN }; | 53 enum Direction { LEFT, UP, RIGHT, DOWN }; |
46 | 54 |
47 using WindowList = std::vector<aura::Window*>; | 55 using WindowList = std::vector<aura::Window*>; |
48 | 56 |
49 explicit WindowSelector(WindowSelectorDelegate* delegate); | 57 explicit WindowSelector(WindowSelectorDelegate* delegate); |
50 ~WindowSelector() override; | 58 ~WindowSelector() override; |
(...skipping 17 matching lines...) Expand all Loading... |
68 // Accepts current selection if any. Returns true if a selection was made, | 76 // Accepts current selection if any. Returns true if a selection was made, |
69 // false otherwise. | 77 // false otherwise. |
70 bool AcceptSelection(); | 78 bool AcceptSelection(); |
71 | 79 |
72 // Activates |item's| window. | 80 // Activates |item's| window. |
73 void SelectWindow(WindowSelectorItem* item); | 81 void SelectWindow(WindowSelectorItem* item); |
74 | 82 |
75 // Called when |window| is about to get closed. | 83 // Called when |window| is about to get closed. |
76 void WindowClosing(WindowSelectorItem* window); | 84 void WindowClosing(WindowSelectorItem* window); |
77 | 85 |
| 86 // Called to set bounds for window grids. Used for split view. |
| 87 void SetBoundsForWindowGridsInScreen(const gfx::Rect& bounds); |
| 88 |
| 89 // Removes the window selector item from the overview window grid. |
| 90 void RemoveWindowSelectorItem(WindowSelectorItem* item); |
| 91 |
| 92 void InitiateDrag(WindowSelectorItem* item, |
| 93 const gfx::Point& location_in_screen); |
| 94 void Drag(WindowSelectorItem* item, const gfx::Point& location_in_screen); |
| 95 void CompleteDrag(WindowSelectorItem* item); |
| 96 |
| 97 // Positions all of the windows in the overview. |
| 98 void PositionWindows(bool animate); |
| 99 |
78 WindowSelectorDelegate* delegate() { return delegate_; } | 100 WindowSelectorDelegate* delegate() { return delegate_; } |
79 | 101 |
80 bool restoring_minimized_windows() const { | 102 bool restoring_minimized_windows() const { |
81 return restoring_minimized_windows_; | 103 return restoring_minimized_windows_; |
82 } | 104 } |
83 | 105 |
84 int text_filter_bottom() const { return text_filter_bottom_; } | 106 int text_filter_bottom() const { return text_filter_bottom_; } |
85 | 107 |
86 bool is_shut_down() const { return is_shut_down_; } | 108 bool is_shut_down() const { return is_shut_down_; } |
87 | 109 |
| 110 const std::vector<std::unique_ptr<WindowGrid>>& grid_list_for_testing() |
| 111 const { |
| 112 return grid_list_; |
| 113 } |
| 114 |
88 // display::DisplayObserver: | 115 // display::DisplayObserver: |
89 void OnDisplayAdded(const display::Display& display) override; | 116 void OnDisplayAdded(const display::Display& display) override; |
90 void OnDisplayRemoved(const display::Display& display) override; | 117 void OnDisplayRemoved(const display::Display& display) override; |
91 void OnDisplayMetricsChanged(const display::Display& display, | 118 void OnDisplayMetricsChanged(const display::Display& display, |
92 uint32_t metrics) override; | 119 uint32_t metrics) override; |
93 | 120 |
94 // aura::WindowObserver: | 121 // aura::WindowObserver: |
95 void OnWindowHierarchyChanged(const HierarchyChangeParams& params) override; | 122 void OnWindowHierarchyChanged(const HierarchyChangeParams& params) override; |
96 void OnWindowDestroying(aura::Window* window) override; | 123 void OnWindowDestroying(aura::Window* window) override; |
97 | 124 |
98 // wm::ActivationChangeObserver: | 125 // wm::ActivationChangeObserver: |
99 void OnWindowActivated(ActivationReason reason, | 126 void OnWindowActivated(ActivationReason reason, |
100 aura::Window* gained_active, | 127 aura::Window* gained_active, |
101 aura::Window* lost_active) override; | 128 aura::Window* lost_active) override; |
102 void OnAttemptToReactivateWindow(aura::Window* request_active, | 129 void OnAttemptToReactivateWindow(aura::Window* request_active, |
103 aura::Window* actual_active) override; | 130 aura::Window* actual_active) override; |
104 | 131 |
105 // views::TextfieldController: | 132 // views::TextfieldController: |
106 void ContentsChanged(views::Textfield* sender, | 133 void ContentsChanged(views::Textfield* sender, |
107 const base::string16& new_contents) override; | 134 const base::string16& new_contents) override; |
108 bool HandleKeyEvent(views::Textfield* sender, | 135 bool HandleKeyEvent(views::Textfield* sender, |
109 const ui::KeyEvent& key_event) override; | 136 const ui::KeyEvent& key_event) override; |
110 | 137 |
| 138 // SplitViewController::Observer: |
| 139 void OnSplitViewStateChanged(SplitViewController::State previous_state, |
| 140 SplitViewController::State state) override; |
| 141 |
111 private: | 142 private: |
112 friend class WindowSelectorTest; | 143 friend class WindowSelectorTest; |
113 | 144 |
114 // Returns the aura::Window for |text_filter_widget_|. | 145 // Returns the aura::Window for |text_filter_widget_|. |
115 aura::Window* GetTextFilterWidgetWindow(); | 146 aura::Window* GetTextFilterWidgetWindow(); |
116 | 147 |
117 // Position all of the windows in the overview. | |
118 void PositionWindows(bool animate); | |
119 | |
120 // Repositions and resizes |text_filter_widget_| on | 148 // Repositions and resizes |text_filter_widget_| on |
121 // DisplayMetricsChanged event. | 149 // DisplayMetricsChanged event. |
122 void RepositionTextFilterOnDisplayMetricsChange(); | 150 void RepositionTextFilterOnDisplayMetricsChange(); |
123 | 151 |
124 // |focus|, restores focus to the stored window. | 152 // |focus|, restores focus to the stored window. |
125 void ResetFocusRestoreWindow(bool focus); | 153 void ResetFocusRestoreWindow(bool focus); |
126 | 154 |
127 // Helper function that moves the selection widget to |direction| on the | 155 // Helper function that moves the selection widget to |direction| on the |
128 // corresponding window grid. | 156 // corresponding window grid. |
129 void Move(Direction direction, bool animate); | 157 void Move(Direction direction, bool animate); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 // Tracks whether minimized windows are currently being restored for overview | 214 // Tracks whether minimized windows are currently being restored for overview |
187 // mode. | 215 // mode. |
188 bool restoring_minimized_windows_; | 216 bool restoring_minimized_windows_; |
189 | 217 |
190 // The distance between the top edge of the screen and the bottom edge of | 218 // The distance between the top edge of the screen and the bottom edge of |
191 // the text filtering textfield. | 219 // the text filtering textfield. |
192 int text_filter_bottom_; | 220 int text_filter_bottom_; |
193 | 221 |
194 bool is_shut_down_ = false; | 222 bool is_shut_down_ = false; |
195 | 223 |
| 224 // The drag controller for a window in the overview mode. |
| 225 std::unique_ptr<OverviewWindowDragController> window_drag_controller_; |
| 226 |
196 DISALLOW_COPY_AND_ASSIGN(WindowSelector); | 227 DISALLOW_COPY_AND_ASSIGN(WindowSelector); |
197 }; | 228 }; |
198 | 229 |
199 } // namespace ash | 230 } // namespace ash |
200 | 231 |
201 #endif // ASH_WM_OVERVIEW_WINDOW_SELECTOR_H_ | 232 #endif // ASH_WM_OVERVIEW_WINDOW_SELECTOR_H_ |
OLD | NEW |