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

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: Fixed a bug with panels and changing windows bounds 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 // +-------+ +-------+ +-------+
36 // | 3 | | 4 | | 5 |
37 // | | | | | |
38 // +-------+ +-------+ +-------+
39 // +-------+
40 // | 6 |
41 // | |
42 // +-------+
43 // Example sequences:
44 // - Going right to left
45 // 0, 1, 2, 3, 4, 5, 6
46 // - Going "top" to "bottom"
47 // 0, 3, 6, 1, 4, 2, 5
48 // The selector is switched to the next window grid (if available) or wrapped if
49 // it reaches the end of its movement sequence.
50 class WindowGrid : public aura::WindowObserver {
51 public:
52 WindowGrid(aura::Window* root_window,
53 const std::vector<aura::Window*>& window_list,
54 WindowSelector* window_selector);
55 ~WindowGrid();
56
57 // Moves the selection widget to the specified |direction|. Returns true if,
58 // after moving, the widget is out of bounds.
59 bool Move(WindowSelector::Direction direction);
60
61 // Positions all the windows in the grid.
62 void PositionWindows(bool animate);
63
64 // Returns the target selected window, or NULL if there is none selected.
65 WindowSelectorItem* SelectedWindow() const;
66
67 // Returns true if the grid has no more windows.
68 bool empty() const { return window_list_.empty(); }
69
70 // Returns how many window selector items are in the grid.
71 const size_t size() const { return window_list_.size(); }
72
73 // Returns true if the selection widget is active.
74 bool is_selecting() const { return selection_widget_ != NULL; }
75
76 // Returns the root window in which the grid displays the windows.
77 const aura::Window* root_window() const { return root_window_; }
78
79 const std::vector<WindowSelectorItem*>& window_list() const {
80 return window_list_.get();
81 }
82
83 // aura::WindowObserver:
84 void OnWindowDestroying(aura::Window* window);
85 // TODO(nsatragno): Handle window bounds changed in WindowSelectorItem.
86 virtual void OnWindowBoundsChanged(aura::Window* window,
87 const gfx::Rect& old_bounds,
88 const gfx::Rect& new_bounds) OVERRIDE;
89
90 private:
91 // Internal function to initialize the selection widget.
92 void InitSelectionWidget(WindowSelector::Direction direction);
93
94 // Updates |selected_index_| according to the specified |direction|. Returns
95 // |true| if the new selection index is out of this window grid bounds.
96 // recreate_selection_widget is set to true if the selection has to "jump" to
97 // the border of the grid.
98 bool MoveSelectedIndex(WindowSelector::Direction direction,
99 bool* recreate_selection_widget);
100
101 // Returns the target bounds of the currently selected item.
102 const gfx::Rect GetSelectionBounds() const;
103
104 // Root window the grid is in.
105 aura::Window* root_window_;
106
107 // Pointer to the window selector that spawned this grid.
108 WindowSelector* window_selector_;
109
110 // Vector containing all the windows in this grid.
111 ScopedVector<WindowSelectorItem> window_list_;
112
113 // Vector containing the observed windows.
114 std::vector<aura::Window*> observed_windows_;
flackr 2014/06/04 22:25:06 Why vector instead of set? It seems we require qui
Nina 2014/06/05 18:04:35 Changed to use a set.
115
116 // Widget that indicates to the user which is the selected window.
117 scoped_ptr<views::Widget> selection_widget_;
118
119 // Current selected window position.
120 size_t selected_index_;
121
122 // Number of columns in the grid.
123 size_t num_columns_;
124
125 DISALLOW_COPY_AND_ASSIGN(WindowGrid);
126 };
127
128 } // namespace ash
129
130 #endif // ASH_WM_OVERVIEW_WINDOW_GRID_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698