OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012 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_WINDOW_CYCLE_LIST_H_ | |
6 #define ASH_WM_WINDOW_CYCLE_LIST_H_ | |
7 | |
8 #include <vector> | |
9 | |
10 #include "ash/ash_export.h" | |
11 #include "base/basictypes.h" | |
12 #include "base/compiler_specific.h" | |
13 #include "ui/aura/window_observer.h" | |
14 | |
15 namespace ash { | |
16 | |
17 // Tracks a set of Windows that can be stepped through. This class is used by | |
18 // the WindowCycleController. | |
19 class ASH_EXPORT WindowCycleList : public aura::WindowObserver { | |
20 public: | |
21 typedef std::vector<aura::Window*> WindowList; | |
22 | |
23 enum Direction { | |
24 FORWARD, | |
25 BACKWARD | |
26 }; | |
27 | |
28 explicit WindowCycleList(const WindowList& windows); | |
29 virtual ~WindowCycleList(); | |
30 | |
31 bool empty() const { return windows_.empty(); } | |
32 | |
33 // Cycles to the next or previous window based on |direction|. | |
34 void Step(Direction direction); | |
35 | |
36 const WindowList& windows() const { return windows_; } | |
37 | |
38 private: | |
39 // Returns the index of |window| in |windows_| or -1 if it isn't there. | |
40 int GetWindowIndex(aura::Window* window); | |
41 | |
42 // aura::WindowObserver overrides: | |
43 virtual void OnWindowDestroyed(aura::Window* window) OVERRIDE; | |
44 | |
45 // List of weak pointers to windows to use while cycling with the keyboard. | |
46 // List is built when the user initiates the gesture (e.g. hits alt-tab the | |
47 // first time) and is emptied when the gesture is complete (e.g. releases the | |
48 // alt key). | |
49 WindowList windows_; | |
50 | |
51 // Current position in the |windows_| list or -1 if we're not cycling. | |
52 int current_index_; | |
53 | |
54 DISALLOW_COPY_AND_ASSIGN(WindowCycleList); | |
55 }; | |
56 | |
57 } // namespace ash | |
58 | |
59 #endif // ASH_WM_WINDOW_CYCLE_LIST_H_ | |
OLD | NEW |