| 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 #ifndef ASH_WM_OVERVIEW_WINDOW_GRID_H_ | 5 #ifndef ASH_WM_OVERVIEW_WINDOW_GRID_H_ |
| 6 #define ASH_WM_OVERVIEW_WINDOW_GRID_H_ | 6 #define ASH_WM_OVERVIEW_WINDOW_GRID_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "ash/wm/overview/window_selector.h" | 11 #include "ash/wm/overview/window_selector.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "ui/aura/window_observer.h" | 14 #include "ui/aura/window_observer.h" |
| 15 | 15 |
| 16 namespace aura { | 16 namespace aura { |
| 17 class Window; | 17 class Window; |
| 18 class ScopedWindowTargeter; |
| 18 } | 19 } |
| 19 | 20 |
| 20 namespace views { | 21 namespace views { |
| 21 class Widget; | 22 class Widget; |
| 22 } | 23 } |
| 23 | 24 |
| 24 namespace ash { | 25 namespace ash { |
| 25 | 26 |
| 26 class WindowSelectorItem; | 27 class WindowSelectorItem; |
| 27 | 28 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 38 // +-------+ | 39 // +-------+ |
| 39 // | 6 | | 40 // | 6 | |
| 40 // +-------+ | 41 // +-------+ |
| 41 // Example sequences: | 42 // Example sequences: |
| 42 // - Going right to left | 43 // - Going right to left |
| 43 // 0, 1, 2, 3, 4, 5, 6 | 44 // 0, 1, 2, 3, 4, 5, 6 |
| 44 // - Going "top" to "bottom" | 45 // - Going "top" to "bottom" |
| 45 // 0, 3, 6, 1, 4, 2, 5 | 46 // 0, 3, 6, 1, 4, 2, 5 |
| 46 // The selector is switched to the next window grid (if available) or wrapped if | 47 // The selector is switched to the next window grid (if available) or wrapped if |
| 47 // it reaches the end of its movement sequence. | 48 // it reaches the end of its movement sequence. |
| 48 class ASH_EXPORT WindowGrid : public aura::WindowObserver { | 49 class ASH_EXPORT WindowGrid : public aura::WindowObserver, |
| 50 public ui::EventHandler { |
| 49 public: | 51 public: |
| 50 WindowGrid(aura::Window* root_window, | 52 WindowGrid(aura::Window* root_window, |
| 51 const std::vector<aura::Window*>& window_list, | 53 const std::vector<aura::Window*>& window_list, |
| 52 WindowSelector* window_selector); | 54 WindowSelector* window_selector); |
| 53 ~WindowGrid() override; | 55 ~WindowGrid() override; |
| 54 | 56 |
| 55 // Prepares the windows in this grid for overview. This will restore all | 57 // Prepares the windows in this grid for overview. This will restore all |
| 56 // minimized windows and ensure they are visible. | 58 // minimized windows and ensure they are visible. |
| 57 void PrepareForOverview(); | 59 void PrepareForOverview(); |
| 58 | 60 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 return window_list_.get(); | 95 return window_list_.get(); |
| 94 } | 96 } |
| 95 | 97 |
| 96 // aura::WindowObserver: | 98 // aura::WindowObserver: |
| 97 void OnWindowDestroying(aura::Window* window) override; | 99 void OnWindowDestroying(aura::Window* window) override; |
| 98 // TODO(flackr): Handle window bounds changed in WindowSelectorItem. | 100 // TODO(flackr): Handle window bounds changed in WindowSelectorItem. |
| 99 void OnWindowBoundsChanged(aura::Window* window, | 101 void OnWindowBoundsChanged(aura::Window* window, |
| 100 const gfx::Rect& old_bounds, | 102 const gfx::Rect& old_bounds, |
| 101 const gfx::Rect& new_bounds) override; | 103 const gfx::Rect& new_bounds) override; |
| 102 | 104 |
| 105 // ui::EventHandler: |
| 106 void OnMouseEvent(ui::MouseEvent* mouse) override; |
| 107 |
| 108 void OnGestureEvent(ui::GestureEvent* gesture) override; |
| 109 |
| 103 private: | 110 private: |
| 104 friend class WindowSelectorTest; | 111 friend class WindowSelectorTest; |
| 105 | 112 |
| 106 // Internal function to initialize the selection widget. | 113 // Internal function to initialize the selection widget. |
| 107 void InitSelectionWidget(WindowSelector::Direction direction); | 114 void InitSelectionWidget(WindowSelector::Direction direction); |
| 108 | 115 |
| 109 // Moves the selection widget to the specified |direction|. | 116 // Moves the selection widget to the specified |direction|. |
| 110 void MoveSelectionWidget(WindowSelector::Direction direction, | 117 void MoveSelectionWidget(WindowSelector::Direction direction, |
| 111 bool recreate_selection_widget, | 118 bool recreate_selection_widget, |
| 112 bool out_of_bounds, | 119 bool out_of_bounds, |
| 113 bool animate); | 120 bool animate); |
| 114 | 121 |
| 122 // Handles taps and clicks. |
| 123 void HandleTap(ui::LocatedEvent* event) const; |
| 124 |
| 125 // Returns the window at which the event is located. |
| 126 aura::Window* GetWindowAt(ui::LocatedEvent* event, |
| 127 aura::Window* container) const; |
| 128 |
| 115 // Moves the selection widget to the targeted window. | 129 // Moves the selection widget to the targeted window. |
| 116 void MoveSelectionWidgetToTarget(bool animate); | 130 void MoveSelectionWidgetToTarget(bool animate); |
| 117 | 131 |
| 118 // Returns the target bounds of the currently selected item. | 132 // Returns the target bounds of the currently selected item. |
| 119 const gfx::Rect GetSelectionBounds() const; | 133 const gfx::Rect GetSelectionBounds() const; |
| 120 | 134 |
| 121 // Root window the grid is in. | 135 // Root window the grid is in. |
| 122 aura::Window* root_window_; | 136 aura::Window* root_window_; |
| 123 | 137 |
| 124 // Pointer to the window selector that spawned this grid. | 138 // Pointer to the window selector that spawned this grid. |
| 125 WindowSelector* window_selector_; | 139 WindowSelector* window_selector_; |
| 126 | 140 |
| 127 // Vector containing all the windows in this grid. | 141 // Vector containing all the windows in this grid. |
| 128 ScopedVector<WindowSelectorItem> window_list_; | 142 ScopedVector<WindowSelectorItem> window_list_; |
| 129 | 143 |
| 130 // Vector containing the observed windows. | 144 // Vector containing the observed windows. |
| 131 std::set<aura::Window*> observed_windows_; | 145 std::set<aura::Window*> observed_windows_; |
| 132 | 146 |
| 133 // Widget that indicates to the user which is the selected window. | 147 // Widget that indicates to the user which is the selected window. |
| 134 scoped_ptr<views::Widget> selection_widget_; | 148 scoped_ptr<views::Widget> selection_widget_; |
| 135 | 149 |
| 136 // Current selected window position. | 150 // Current selected window position. |
| 137 size_t selected_index_; | 151 size_t selected_index_; |
| 138 | 152 |
| 139 // Number of columns in the grid. | 153 // Number of columns in the grid. |
| 140 size_t num_columns_; | 154 size_t num_columns_; |
| 141 | 155 |
| 156 // The container where the static targeter is set. |
| 157 aura::Window* static_targeter_container_; |
| 158 |
| 159 // Holds and restores the panel container's targeter. |
| 160 scoped_ptr<aura::ScopedWindowTargeter> scoped_panel_targeter_; |
| 161 |
| 142 DISALLOW_COPY_AND_ASSIGN(WindowGrid); | 162 DISALLOW_COPY_AND_ASSIGN(WindowGrid); |
| 143 }; | 163 }; |
| 144 | 164 |
| 145 } // namespace ash | 165 } // namespace ash |
| 146 | 166 |
| 147 #endif // ASH_WM_OVERVIEW_WINDOW_GRID_H_ | 167 #endif // ASH_WM_OVERVIEW_WINDOW_GRID_H_ |
| OLD | NEW |