window_selector_item.h revision 5d1f7b1de12d16ceb2c938c56701a3e8bfa558f7
1d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved.
2d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
3d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)// found in the LICENSE file.
4d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)
5d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)#ifndef ASH_WM_OVERVIEW_WINDOW_SELECTOR_ITEM_H_
6d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)#define ASH_WM_OVERVIEW_WINDOW_SELECTOR_ITEM_H_
7d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)
8d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)#include "base/compiler_specific.h"
9d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)#include "ui/gfx/rect.h"
10d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)
11d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)namespace aura {
12d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)class Window;
13d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)}
14d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)
15d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)namespace ash {
16d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)
17d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)// This class represents an item in overview mode. An item can have one or more
18d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)// windows, of which only one can be activated by keyboard (i.e. alt+tab) but
19d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)// any can be selected with a pointer (touch or mouse).
20d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)class WindowSelectorItem {
21d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) public:
22d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)  WindowSelectorItem();
23d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)  virtual ~WindowSelectorItem();
24d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)
25d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)  // Returns the root window on which this item is shown.
261e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  virtual aura::Window* GetRootWindow() = 0;
27d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)
285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Returns true if the window selector item has |window| as a selectable
295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // window.
305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  virtual bool HasSelectableWindow(const aura::Window* window) = 0;
315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
32d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)  // Returns the targeted window given the event |target| window.
33d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)  // Returns NULL if no Window in this item was selected.
34d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)  virtual aura::Window* TargetedWindow(const aura::Window* target) = 0;
35d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)
36d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)  // Restores |window| on exiting window overview rather than returning it
37d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)  // to its previous state.
38d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)  virtual void RestoreWindowOnExit(aura::Window* window) = 0;
39d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)
40d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)  // Returns the |window| to activate on selecting of this item.
41d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)  virtual aura::Window* SelectionWindow() = 0;
42d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)
43d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)  // Removes |window| from this item. Check empty() after calling this to see
44d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)  // if the entire item is now empty.
45d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)  virtual void RemoveWindow(const aura::Window* window) = 0;
46d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)
47d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)  // Returns true if this item has no more selectable windows (i.e. after
48d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)  // calling RemoveWindow for the last contained window).
49d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)  virtual bool empty() const = 0;
50d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)
514e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  // Dispatched before beginning window overview. This will do any necessary
524e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  // one time actions such as restoring minimized windows.
534e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  virtual void PrepareForOverview() = 0;
544e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)
55d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)  // Sets the bounds of this window selector item to |target_bounds| in the
56d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)  // |root_window| root window.
571e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  void SetBounds(aura::Window* root_window,
58d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)                 const gfx::Rect& target_bounds);
59d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)
604e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  // Recomputes the positions for the windows in this selection item. This is
614e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  // dispatched when the bounds of a window change.
624e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  void RecomputeWindowTransforms();
634e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)
64d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)  const gfx::Rect& bounds() { return bounds_; }
651e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  const gfx::Rect& target_bounds() { return target_bounds_; }
66d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)
67d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) protected:
684e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  // Sets the bounds of this selector item to |target_bounds| in |root_window|.
694e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  // If |animate| the windows are animated from their current location.
701e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  virtual void SetItemBounds(aura::Window* root_window,
714e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)                             const gfx::Rect& target_bounds,
724e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)                             bool animate) = 0;
73d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)
741e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  // Sets the bounds used by the selector item's windows.
751e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  void set_bounds(const gfx::Rect& bounds) { bounds_ = bounds; }
761e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
77d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles) private:
784e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  // The root window this item is being displayed on.
791e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  aura::Window* root_window_;
801e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)
811e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  // The target bounds this selector item is fit within.
821e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  gfx::Rect target_bounds_;
834e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)
841e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  // The actual bounds of the window(s) for this item. The aspect ratio of
851e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)  // window(s) are maintained so they may not fill the target_bounds_.
86d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)  gfx::Rect bounds_;
87d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)
884e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  // True if running SetItemBounds. This prevents recursive calls resulting from
894e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  // the bounds update when calling views::corewm::RecreateWindowLayers to copy
904e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  // a window layer for display on another monitor.
914e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  bool in_bounds_update_;
924e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)
93d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)  DISALLOW_COPY_AND_ASSIGN(WindowSelectorItem);
94d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)};
95d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)
96d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)}  // namespace ash
97d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)
98d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)#endif  // ASH_WM_OVERVIEW_WINDOW_SELECTOR_ITEM_H_
99