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_OVERVIEW_H_ | 5 #ifndef ASH_WM_OVERVIEW_WINDOW_OVERVIEW_H_ |
6 #define ASH_WM_OVERVIEW_WINDOW_OVERVIEW_H_ | 6 #define ASH_WM_OVERVIEW_WINDOW_OVERVIEW_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
11 #include "ui/base/events/event_handler.h" | 11 #include "ui/base/events/event_handler.h" |
12 | 12 |
13 namespace aura { | 13 namespace aura { |
| 14 class Window; |
14 class RootWindow; | 15 class RootWindow; |
15 } | 16 } |
16 | 17 |
17 namespace ui { | 18 namespace ui { |
18 class LocatedEvent; | 19 class LocatedEvent; |
19 } | 20 } |
20 | 21 |
21 namespace views { | 22 namespace views { |
22 class Widget; | 23 class Widget; |
23 } | 24 } |
24 | 25 |
25 namespace ash { | 26 namespace ash { |
26 | 27 |
27 class WindowSelector; | 28 class WindowSelector; |
28 class WindowSelectorWindow; | 29 class WindowSelectorItem; |
29 | 30 |
30 // The WindowOverview shows a grid of all of your windows and allows selecting | 31 // The WindowOverview shows a grid of all of your windows and allows selecting |
31 // a window by clicking or tapping on it. It also displays a selection widget | 32 // a window by clicking or tapping on it. It also displays a selection widget |
32 // used to indicate the current selection when alt-tabbing between windows. | 33 // used to indicate the current selection when alt-tabbing between windows. |
33 class WindowOverview : public ui::EventHandler { | 34 class WindowOverview : public ui::EventHandler { |
34 public: | 35 public: |
35 typedef ScopedVector<WindowSelectorWindow> WindowSelectorWindowList; | 36 typedef ScopedVector<WindowSelectorItem> WindowSelectorItemList; |
36 | 37 |
37 // Enters an overview mode displaying |windows| and dispatches methods | 38 // Enters an overview mode displaying |windows| and dispatches methods |
38 // on |window_selector| when a window is selected or selection is canceled. | 39 // on |window_selector| when a window is selected or selection is canceled. |
39 // If |single_root_window| is not NULL, all windows will be positioned on the | 40 // If |single_root_window| is not NULL, all windows will be positioned on the |
40 // given root window. | 41 // given root window. |
41 WindowOverview(WindowSelector* window_selector, | 42 WindowOverview(WindowSelector* window_selector, |
42 WindowSelectorWindowList* windows, | 43 WindowSelectorItemList* windows, |
43 aura::RootWindow* single_root_window); | 44 aura::RootWindow* single_root_window); |
44 virtual ~WindowOverview(); | 45 virtual ~WindowOverview(); |
45 | 46 |
46 // Sets the selected window to be the window in position |index|. | 47 // Sets the selected window to be the window in position |index|. |
47 void SetSelection(size_t index); | 48 void SetSelection(size_t index); |
48 | 49 |
49 // Dispatched when the list of windows has changed. | 50 // Dispatched when the list of windows has changed. |
50 void OnWindowsChanged(); | 51 void OnWindowsChanged(); |
51 | 52 |
52 // ui::EventHandler: | 53 // ui::EventHandler: |
53 virtual void OnEvent(ui::Event* event) OVERRIDE; | 54 virtual void OnEvent(ui::Event* event) OVERRIDE; |
54 virtual void OnKeyEvent(ui::KeyEvent* event) OVERRIDE; | 55 virtual void OnKeyEvent(ui::KeyEvent* event) OVERRIDE; |
55 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE; | 56 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE; |
56 virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE; | 57 virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE; |
57 | 58 |
58 private: | 59 private: |
59 // Returns the target of |event| or NULL if the event is not targeted at | 60 // Returns the target of |event| or NULL if the event is not targeted at |
60 // any of the windows in the selector. | 61 // any of the windows in the selector. |
61 WindowSelectorWindow* GetEventTarget(ui::LocatedEvent* event); | 62 aura::Window* GetEventTarget(ui::LocatedEvent* event); |
62 | 63 |
63 // Position all of the windows based on the current selection mode. | 64 // Position all of the windows based on the current selection mode. |
64 void PositionWindows(); | 65 void PositionWindows(); |
65 // Position all of the windows from |root_window| on |root_window|. | 66 // Position all of the windows from |root_window| on |root_window|. |
66 void PositionWindowsFromRoot(aura::RootWindow* root_window); | 67 void PositionWindowsFromRoot(aura::RootWindow* root_window); |
67 // Position all of the |windows| to fit on the |root_window|. | 68 // Position all of the |windows| to fit on the |root_window|. |
68 void PositionWindowsOnRoot(aura::RootWindow* root_window, | 69 void PositionWindowsOnRoot(aura::RootWindow* root_window, |
69 const std::vector<WindowSelectorWindow*>& windows); | 70 const std::vector<WindowSelectorItem*>& windows); |
70 | 71 |
71 void InitializeSelectionWidget(); | 72 void InitializeSelectionWidget(); |
72 | 73 |
73 // Updates the selection widget's location to the currently selected window. | 74 // Updates the selection widget's location to the currently selected window. |
74 // If |animate| the transition to the new location is animated. | 75 // If |animate| the transition to the new location is animated. |
75 void UpdateSelectionLocation(bool animate); | 76 void UpdateSelectionLocation(bool animate); |
76 | 77 |
77 // Weak pointer to the window selector which owns this class. | 78 // Weak pointer to the window selector which owns this class. |
78 WindowSelector* window_selector_; | 79 WindowSelector* window_selector_; |
79 | 80 |
80 // A weak pointer to the collection of windows in the overview wrapped by a | 81 // A weak pointer to the collection of windows in the overview wrapped by a |
81 // helper class which restores their state and helps transform them to other | 82 // helper class which restores their state and helps transform them to other |
82 // root windows. | 83 // root windows. |
83 WindowSelectorWindowList* windows_; | 84 WindowSelectorItemList* windows_; |
84 | 85 |
85 // Widget indicating which window is currently selected. | 86 // Widget indicating which window is currently selected. |
86 scoped_ptr<views::Widget> selection_widget_; | 87 scoped_ptr<views::Widget> selection_widget_; |
87 | 88 |
88 // If NULL, each root window displays an overview of the windows in that | 89 // If NULL, each root window displays an overview of the windows in that |
89 // display. Otherwise, all windows are in a single overview on | 90 // display. Otherwise, all windows are in a single overview on |
90 // |single_root_window_|. | 91 // |single_root_window_|. |
91 aura::RootWindow* single_root_window_; | 92 aura::RootWindow* single_root_window_; |
92 | 93 |
93 DISALLOW_COPY_AND_ASSIGN(WindowOverview); | 94 DISALLOW_COPY_AND_ASSIGN(WindowOverview); |
94 }; | 95 }; |
95 | 96 |
96 } // namespace ash | 97 } // namespace ash |
97 | 98 |
98 #endif // ASH_WM_OVERVIEW_WINDOW_OVERVIEW_H_ | 99 #endif // ASH_WM_OVERVIEW_WINDOW_OVERVIEW_H_ |
OLD | NEW |