OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013 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_SELECTOR_H_ |
| 6 #define ASH_WM_WINDOW_SELECTOR_H_ |
| 7 |
| 8 #include <vector> |
| 9 |
| 10 #include "base/compiler_specific.h" |
| 11 #include "ui/aura/window_observer.h" |
| 12 #include "ui/base/events/event_handler.h" |
| 13 #include "ui/gfx/transform.h" |
| 14 |
| 15 namespace aura { |
| 16 class RootWindow; |
| 17 } |
| 18 |
| 19 namespace ash { |
| 20 |
| 21 class WindowSelectorDelegate; |
| 22 |
| 23 // The WindowSelector shows a grid of all of your windows and allows selecting |
| 24 // a window by clicking or tapping on it. |
| 25 class WindowSelector : public ui::EventHandler, |
| 26 public aura::WindowObserver { |
| 27 public: |
| 28 typedef std::vector<aura::Window*> WindowList; |
| 29 |
| 30 WindowSelector(const WindowList& windows, |
| 31 WindowSelectorDelegate* delegate); |
| 32 virtual ~WindowSelector(); |
| 33 |
| 34 // ui::EventHandler: |
| 35 virtual void OnEvent(ui::Event* event) OVERRIDE; |
| 36 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE; |
| 37 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; |
| 38 |
| 39 // aura::WindowObserver: |
| 40 virtual void OnWindowDestroyed(aura::Window* window) OVERRIDE; |
| 41 |
| 42 private: |
| 43 struct WindowDetails { |
| 44 WindowDetails() : window(NULL), minimized(false) {} |
| 45 |
| 46 bool operator==(const aura::Window* other_window) const { |
| 47 return window == other_window; |
| 48 } |
| 49 |
| 50 // A weak pointer to the window. |
| 51 aura::Window* window; |
| 52 |
| 53 // If true, the window was minimized and this should be restored if the |
| 54 // window was not selected. |
| 55 bool minimized; |
| 56 |
| 57 // The original transform of the window before entering overview mode. |
| 58 gfx::Transform original_transform; |
| 59 }; |
| 60 |
| 61 void HandleSelectionEvent(ui::Event* event); |
| 62 void PositionWindows(); |
| 63 void PositionWindowsOnRoot(aura::RootWindow* root_window); |
| 64 |
| 65 void SelectWindow(aura::Window*); |
| 66 |
| 67 // List of weak pointers of windows to select from. |
| 68 std::vector<WindowDetails> windows_; |
| 69 |
| 70 // Weak pointer to the selector delegate which will be called when a |
| 71 // selection is made. |
| 72 WindowSelectorDelegate* delegate_; |
| 73 |
| 74 DISALLOW_COPY_AND_ASSIGN(WindowSelector); |
| 75 }; |
| 76 |
| 77 } // namespace ash |
| 78 |
| 79 #endif // ASH_WM_WINDOW_SELECTOR_H_ |
OLD | NEW |