- add sources.
[platform/framework/web/crosswalk.git] / src / ash / wm / overview / window_overview.h
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
3 // found in the LICENSE file.
4
5 #ifndef ASH_WM_OVERVIEW_WINDOW_OVERVIEW_H_
6 #define ASH_WM_OVERVIEW_WINDOW_OVERVIEW_H_
7
8 #include "base/compiler_specific.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/scoped_vector.h"
11 #include "base/time/time.h"
12 #include "ui/aura/window_tracker.h"
13 #include "ui/events/event_handler.h"
14 #include "ui/gfx/rect.h"
15
16 namespace aura {
17 class Window;
18 namespace client {
19 class CursorClient;
20 }
21 }  // namespace aura
22
23 namespace ui {
24 class LocatedEvent;
25 }
26
27 namespace views {
28 class Widget;
29 }
30
31 namespace ash {
32
33 class WindowSelector;
34 class WindowSelectorItem;
35
36 // The WindowOverview shows a grid of all of your windows and allows selecting
37 // a window by clicking or tapping on it. It also displays a selection widget
38 // used to indicate the current selection when alt-tabbing between windows.
39 class WindowOverview : public ui::EventHandler {
40  public:
41   typedef ScopedVector<WindowSelectorItem> WindowSelectorItemList;
42
43   // Enters an overview mode displaying |windows| and dispatches methods
44   // on |window_selector| when a window is selected or selection is canceled.
45   // If |single_root_window| is not NULL, all windows will be positioned on the
46   // given root window.
47   WindowOverview(WindowSelector* window_selector,
48                  WindowSelectorItemList* windows,
49                  aura::Window* single_root_window);
50   virtual ~WindowOverview();
51
52   // Sets the selected window to be the window in position |index|.
53   void SetSelection(size_t index);
54
55   // Dispatched when the list of windows has changed.
56   void OnWindowsChanged();
57
58   // Moves the overview to only |root_window|.
59   void MoveToSingleRootWindow(aura::Window* root_window);
60
61   // ui::EventHandler:
62   virtual void OnKeyEvent(ui::KeyEvent* event) OVERRIDE;
63   virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE;
64   virtual void OnScrollEvent(ui::ScrollEvent* event) OVERRIDE;
65   virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE;
66
67  private:
68   // Returns the target of |event| or NULL if the event is not targeted at
69   // any of the windows in the selector.
70   aura::Window* GetEventTarget(ui::LocatedEvent* event);
71
72   // Returns the top-level window selected by targeting |window| or NULL if
73   // no overview window was found for |window|.
74   aura::Window* GetTargetedWindow(aura::Window* window);
75
76   // Hide and track all hidden windows not in overview.
77   void HideAndTrackNonOverviewWindows();
78
79   // Position all of the windows based on the current selection mode.
80   void PositionWindows();
81   // Position all of the windows from |root_window| on |root_window|.
82   void PositionWindowsFromRoot(aura::Window* root_window);
83   // Position all of the |windows| to fit on the |root_window|.
84   void PositionWindowsOnRoot(aura::Window* root_window,
85                              const std::vector<WindowSelectorItem*>& windows);
86
87   // Creates the selection widget.
88   void InitializeSelectionWidget();
89
90   // Returns the bounds for the selection widget for the windows_ at |index|.
91   gfx::Rect GetSelectionBounds(size_t index);
92
93   // Weak pointer to the window selector which owns this class.
94   WindowSelector* window_selector_;
95
96   // A weak pointer to the collection of windows in the overview wrapped by a
97   // helper class which restores their state and helps transform them to other
98   // root windows.
99   WindowSelectorItemList* windows_;
100
101   // Widget indicating which window is currently selected.
102   scoped_ptr<views::Widget> selection_widget_;
103
104   // Index of the currently selected window. This is used to determine when the
105   // selection changes rows and use a different animation.
106   size_t selection_index_;
107
108   // If NULL, each root window displays an overview of the windows in that
109   // display. Otherwise, all windows are in a single overview on
110   // |single_root_window_|.
111   aura::Window* single_root_window_;
112
113   // The time when overview was started.
114   base::Time overview_start_time_;
115
116   // The cursor client used to lock the current cursor during overview.
117   aura::client::CursorClient* cursor_client_;
118
119   // Tracks windows which were hidden because they were not part of the
120   // overview.
121   aura::WindowTracker hidden_windows_;
122
123   DISALLOW_COPY_AND_ASSIGN(WindowOverview);
124 };
125
126 }  // namespace ash
127
128 #endif  // ASH_WM_OVERVIEW_WINDOW_OVERVIEW_H_