Chromium Code Reviews| Index: ash/wm/window_selector.h |
| diff --git a/ash/wm/window_selector.h b/ash/wm/window_selector.h |
| index 900787db4054262b3cb937a08270b3772c5fd444..bbd8cc2da2dd5a0c2a37d58fdc2f2f05601bf6f3 100644 |
| --- a/ash/wm/window_selector.h |
| +++ b/ash/wm/window_selector.h |
| @@ -8,6 +8,8 @@ |
| #include <vector> |
| #include "base/compiler_specific.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "base/memory/scoped_vector.h" |
| #include "ui/aura/window_observer.h" |
| #include "ui/base/events/event_handler.h" |
| #include "ui/gfx/transform.h" |
| @@ -16,21 +18,49 @@ namespace aura { |
| class RootWindow; |
| } |
| +namespace ui { |
| +class LocatedEvent; |
| +} |
| + |
| +namespace views { |
| +class Widget; |
| +} |
| + |
| namespace ash { |
| class WindowSelectorDelegate; |
| +class WindowSelectorWindow; |
| // The WindowSelector shows a grid of all of your windows and allows selecting |
| -// a window by clicking or tapping on it. |
| +// a window by clicking or tapping on it (OVERVIEW mode) or by alt-tabbing to |
| +// it (CYCLE mode). |
| class WindowSelector : public ui::EventHandler, |
| public aura::WindowObserver { |
| public: |
| + enum Direction { |
| + FORWARD, |
| + BACKWARD |
| + }; |
| + enum Mode { |
| + CYCLE, |
| + OVERVIEW |
| + }; |
| + |
| typedef std::vector<aura::Window*> WindowList; |
| WindowSelector(const WindowList& windows, |
| + Mode mode, |
| WindowSelectorDelegate* delegate); |
| virtual ~WindowSelector(); |
| + // Step to the next window in |direction|. |
| + void Step(Direction direction); |
| + |
| + // Select the current window. |
| + void SelectWindow(); |
| + |
| + Mode mode() { return mode_; } |
| + |
| // ui::EventHandler: |
| virtual void OnEvent(ui::Event* event) OVERRIDE; |
| virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE; |
| @@ -40,37 +70,47 @@ class WindowSelector : public ui::EventHandler, |
| virtual void OnWindowDestroyed(aura::Window* window) OVERRIDE; |
| private: |
| - struct WindowDetails { |
| - WindowDetails() : window(NULL), minimized(false) {} |
| - |
| - bool operator==(const aura::Window* other_window) const { |
| - return window == other_window; |
| - } |
| - |
| - // A weak pointer to the window. |
| - aura::Window* window; |
| + // Returns the target of |event| or NULL if the event is not targeted at |
| + // any of the windows in the selector. |
| + WindowSelectorWindow* GetEventTarget(ui::LocatedEvent* event); |
| - // If true, the window was minimized and this should be restored if the |
| - // window was not selected. |
| - bool minimized; |
| - |
| - // The original transform of the window before entering overview mode. |
| - gfx::Transform original_transform; |
| - }; |
| + // Handles a selection event for |target|. |
| + void HandleSelectionEvent(WindowSelectorWindow* target); |
| - void HandleSelectionEvent(ui::Event* event); |
| + // Position all of the windows based on the current selection mode. |
| void PositionWindows(); |
| - void PositionWindowsOnRoot(aura::RootWindow* root_window); |
| + // Position all of the windows from |root_window| on |root_window|. |
| + void PositionWindowsFromRoot(aura::RootWindow* root_window); |
| + // Position all of the |windows| to fit on the |root_window|. |
| + void PositionWindowsOnRoot(aura::RootWindow* root_window, |
| + const std::vector<WindowSelectorWindow*>& windows); |
| - void SelectWindow(aura::Window*); |
| + void InitializeSelectionWidget(); |
|
Daniel Erat
2013/08/09 20:54:35
nit: add a blank line after this line
flackr
2013/08/09 22:15:36
Done.
|
| + // Updates the selection widget's location to the currently selected window. |
| + // If |animate| the transition to the new location is animated. |
| + void UpdateSelectionLocation(bool animate); |
| - // List of weak pointers of windows to select from. |
| - std::vector<WindowDetails> windows_; |
| + // The collection of windows in the overview wrapped by a helper class which |
| + // restores their state and helps transform them to other root windows. |
| + ScopedVector<WindowSelectorWindow> windows_; |
| + |
| + // The window selection mode. |
| + Mode mode_; |
| // Weak pointer to the selector delegate which will be called when a |
| // selection is made. |
| WindowSelectorDelegate* delegate_; |
| + // Index of the currently selected window if the mode is CYCLE. |
| + size_t selected_window_; |
| + |
| + // Widget indicating which window is currently selected. |
| + scoped_ptr<views::Widget> selection_widget_; |
| + |
| + // If not NULL, this is the root window selection is taking place in used |
|
Daniel Erat
2013/08/09 20:54:35
nit: i found this a bit hard to parse. how about t
flackr
2013/08/09 22:15:36
Done.
|
| + // for CYCLE mode. |
| + aura::RootWindow* selection_root_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(WindowSelector); |
| }; |