Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(695)

Side by Side Diff: ash/wm/overview/window_grid.h

Issue 251103005: Added arrow key navigation to Overview Mode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Replaced unittest by a better one, fixed lints, minor tweaks. Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef ASH_WM_OVERVIEW_WINDOW_GRID_H_
6 #define ASH_WM_OVERVIEW_WINDOW_GRID_H_
7
8 #include <vector>
9
10 #include "ash/wm/overview/window_selector.h"
11 #include "base/macros.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "ui/aura/window_observer.h"
14
15 namespace aura {
16 class Window;
17 }
18
19 namespace views {
20 class Widget;
21 }
22
23 namespace ash {
24
25 class WindowSelectorItem;
26
27 // Represents a grid of windows in the Overview Mode in a particular root
28 // window, and manages a selection widget that can be moved with the arrow keys.
29 // The idea behind the movement strategy is that it should be possible to access
30 // any window pressing a given arrow key repeatedly.
31 // +-------+ +-------+ +-------+
32 // | 0 | | 1 | | 2 |
33 // +-------+ +-------+ +-------+
34 // +-------+ +-------+ +-------+
35 // | 3 | | 4 | | 5 |
36 // +-------+ +-------+ +-------+
37 // +-------+
38 // | 6 |
39 // +-------+
40 // Example sequences:
41 // - Going right to left
42 // 0, 1, 2, 3, 4, 5, 6
43 // - Going "top" to "bottom"
44 // 0, 3, 6, 1, 4, 2, 5
45 // The selector is switched to the next window grid (if available) or wrapped if
46 // it reaches the end of its movement sequence.
47 class WindowGrid : public aura::WindowObserver {
48 public:
49 WindowGrid(aura::Window* root_window,
50 const std::vector<aura::Window*>& window_list,
51 WindowSelector* window_selector);
52 ~WindowGrid();
53
54 // Positions all the windows in the grid.
55 void PositionWindows(bool animate);
56
57 // Updates |selected_index_| according to the specified |direction| and calls
58 // MoveSelectionWidget(). Returns |true| if the new selection index is out of
59 // this window grid bounds.
60 bool Move(WindowSelector::Direction direction);
61
62 // Returns the target selected window, or NULL if there is none selected.
63 WindowSelectorItem* SelectedWindow() const;
64
65 // Returns true if a window is contained in any of the WindowSelectorItems
66 // this grid owns.
67 bool Contains(const aura::Window* window) const;
68
69 // Returns true if the grid has no more windows.
70 bool empty() const { return window_list_.empty(); }
71
72 // Returns how many window selector items are in the grid.
73 const size_t size() const { return window_list_.size(); }
74
75 // Returns true if the selection widget is active.
76 bool is_selecting() const { return selection_widget_ != NULL; }
77
78 // Returns the root window in which the grid displays the windows.
79 const aura::Window* root_window() const { return root_window_; }
80
81 const std::vector<WindowSelectorItem*>& window_list() const {
82 return window_list_.get();
83 }
84
85 // aura::WindowObserver:
86 void OnWindowDestroying(aura::Window* window);
87 // TODO(nsatragno): Handle window bounds changed in WindowSelectorItem.
88 virtual void OnWindowBoundsChanged(aura::Window* window,
89 const gfx::Rect& old_bounds,
90 const gfx::Rect& new_bounds) OVERRIDE;
91
92 private:
93 // Internal function to initialize the selection widget.
94 void InitSelectionWidget(WindowSelector::Direction direction);
95
96 // Moves the selection widget to the specified |direction|.
97 void MoveSelectionWidget(WindowSelector::Direction direction,
98 bool recreate_selection_widget,
99 bool out_of_bounds);
100
101 // Moves the selection widget to the targeted window.
102 void MoveSelectionWidgetToTarget();
103
104 // Returns the target bounds of the currently selected item.
105 const gfx::Rect GetSelectionBounds() const;
106
107 // Root window the grid is in.
108 aura::Window* root_window_;
109
110 // Pointer to the window selector that spawned this grid.
111 WindowSelector* window_selector_;
112
113 // Vector containing all the windows in this grid.
114 ScopedVector<WindowSelectorItem> window_list_;
115
116 // Vector containing the observed windows.
117 std::set<aura::Window*> observed_windows_;
118
119 // Widget that indicates to the user which is the selected window.
120 scoped_ptr<views::Widget> selection_widget_;
121
122 // Current selected window position.
123 size_t selected_index_;
124
125 // Number of columns in the grid.
126 size_t num_columns_;
127
128 DISALLOW_COPY_AND_ASSIGN(WindowGrid);
129 };
130
131 } // namespace ash
132
133 #endif // ASH_WM_OVERVIEW_WINDOW_GRID_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698