Revert of Rename isSystemLocationEnabled to isLocationEnabled. (patchset #1 id:1...
[chromium-blink-merge.git] / ash / wm / overview / window_selector_item.h
blob970e2817ac33731f000d32b47f7139f771c13df3
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.
5 #ifndef ASH_WM_OVERVIEW_WINDOW_SELECTOR_ITEM_H_
6 #define ASH_WM_OVERVIEW_WINDOW_SELECTOR_ITEM_H_
8 #include "base/compiler_specific.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "ui/aura/window_observer.h"
11 #include "ui/gfx/rect.h"
12 #include "ui/views/controls/button/button.h"
14 namespace aura {
15 class Window;
18 namespace views {
19 class Label;
20 class Widget;
23 namespace ash {
24 class TransparentActivateWindowButton;
26 // This class represents an item in overview mode. An item can have one or more
27 // windows, of which only one can be activated by keyboard (i.e. alt+tab) but
28 // any can be selected with a pointer (touch or mouse).
29 class WindowSelectorItem : public views::ButtonListener,
30 public aura::WindowObserver {
31 public:
32 WindowSelectorItem();
33 ~WindowSelectorItem() override;
35 // Returns the root window on which this item is shown.
36 virtual aura::Window* GetRootWindow() = 0;
38 // Returns true if the window selector item has |window| as a selectable
39 // window.
40 virtual bool HasSelectableWindow(const aura::Window* window) = 0;
42 // Returns true if |target| is contained in this WindowSelectorItem.
43 virtual bool Contains(const aura::Window* target) = 0;
45 // Restores |window| on exiting window overview rather than returning it
46 // to its previous state.
47 virtual void RestoreWindowOnExit(aura::Window* window) = 0;
49 // Returns the |window| to activate on selecting of this item.
50 virtual aura::Window* SelectionWindow() = 0;
52 // Removes |window| from this item. Check empty() after calling this to see
53 // if the entire item is now empty.
54 virtual void RemoveWindow(const aura::Window* window);
56 // Returns true if this item has no more selectable windows (i.e. after
57 // calling RemoveWindow for the last contained window).
58 virtual bool empty() const = 0;
60 // Dispatched before beginning window overview. This will do any necessary
61 // one time actions such as restoring minimized windows.
62 virtual void PrepareForOverview() = 0;
64 // Sets the bounds of this window selector item to |target_bounds| in the
65 // |root_window| root window.
66 void SetBounds(aura::Window* root_window,
67 const gfx::Rect& target_bounds,
68 bool animate);
70 // Recomputes the positions for the windows in this selection item. This is
71 // dispatched when the bounds of a window change.
72 void RecomputeWindowTransforms();
74 // Sends an a11y focus alert so that, if chromevox is enabled, the window
75 // label is read.
76 void SendFocusAlert() const;
78 // Sets if the item is dimmed in the overview. Changing the value will also
79 // change the visibility of the transform windows.
80 virtual void SetDimmed(bool dimmed);
81 bool dimmed() const { return dimmed_; }
83 const gfx::Rect& bounds() const { return bounds_; }
84 const gfx::Rect& target_bounds() const { return target_bounds_; }
86 // views::ButtonListener:
87 void ButtonPressed(views::Button* sender, const ui::Event& event) override;
89 // aura::WindowObserver:
90 void OnWindowTitleChanged(aura::Window* window) override;
92 protected:
93 // Sets the bounds of this selector's items to |target_bounds| in
94 // |root_window|. If |animate| the windows are animated from their current
95 // location.
96 virtual void SetItemBounds(aura::Window* root_window,
97 const gfx::Rect& target_bounds,
98 bool animate) = 0;
100 // Sets the bounds used by the selector item's windows.
101 void set_bounds(const gfx::Rect& bounds) { bounds_ = bounds; }
103 // Changes the opacity of all the windows the item owns.
104 virtual void SetOpacity(float opacity);
106 // True if the item is being shown in the overview, false if it's being
107 // filtered.
108 bool dimmed_;
110 private:
111 friend class WindowSelectorTest;
113 // Creates |close_button_| if it does not exist and updates the bounds based
114 // on GetCloseButtonTargetBounds()
115 void UpdateCloseButtonBounds(aura::Window* root_window, bool animate);
117 // Creates a label to display under the window selector item.
118 void UpdateWindowLabels(const gfx::Rect& target_bounds,
119 aura::Window* root_window,
120 bool animate);
122 // Initializes window_label_.
123 void CreateWindowLabel(const base::string16& title);
125 // The root window this item is being displayed on.
126 aura::Window* root_window_;
128 // The target bounds this selector item is fit within.
129 gfx::Rect target_bounds_;
131 // The actual bounds of the window(s) for this item. The aspect ratio of
132 // window(s) are maintained so they may not fill the target_bounds_.
133 gfx::Rect bounds_;
135 // True if running SetItemBounds. This prevents recursive calls resulting from
136 // the bounds update when calling ::wm::RecreateWindowLayers to copy
137 // a window layer for display on another monitor.
138 bool in_bounds_update_;
140 // Label under the window displaying its active tab name.
141 scoped_ptr<views::Widget> window_label_;
143 // View for the label under the window.
144 views::Label* window_label_view_;
146 // An easy to access close button for the window in this item.
147 scoped_ptr<views::Widget> close_button_;
149 // Transparent window on top of the real windows in the overview that
150 // activates them on click or tap.
151 scoped_ptr<TransparentActivateWindowButton> activate_window_button_;
153 DISALLOW_COPY_AND_ASSIGN(WindowSelectorItem);
156 } // namespace ash
158 #endif // ASH_WM_OVERVIEW_WINDOW_SELECTOR_ITEM_H_