Put WeakPtrFactory member last in USBEventRouter
[chromium-blink-merge.git] / ash / wm / overview / window_selector_item.h
blob584d2758929ac36442240948171031f7bb494e0e
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 "ash/ash_export.h"
9 #include "ash/wm/overview/scoped_transform_overview_window.h"
10 #include "ash/wm/overview/transparent_activate_window_button.h"
11 #include "ash/wm/overview/transparent_activate_window_button_delegate.h"
12 #include "base/compiler_specific.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "ui/aura/window_observer.h"
15 #include "ui/gfx/geometry/rect.h"
16 #include "ui/views/controls/button/button.h"
17 #include "ui/views/controls/button/image_button.h"
19 namespace aura {
20 class Window;
23 namespace views {
24 class Label;
25 class Widget;
28 namespace ash {
30 // This class represents an item in overview mode. An item can have one or more
31 // windows, of which only one can be activated by keyboard (i.e. alt+tab) but
32 // any can be selected with a pointer (touch or mouse).
33 class ASH_EXPORT WindowSelectorItem
34 : public views::ButtonListener,
35 public aura::WindowObserver,
36 public TransparentActivateWindowButtonDelegate {
37 public:
38 explicit WindowSelectorItem(aura::Window* root_window);
39 ~WindowSelectorItem() override;
41 // Returns the root window on which this item is shown.
42 aura::Window* root_window() { return root_window_; }
44 // Adds a window to this selector item. Windows should be added in reverse
45 // visible order so that the transparent overlay ordering matches the visible
46 // ordering. Each |window| should have the same root window as |this| was
47 // instantiated with.
48 void AddWindow(aura::Window* window);
50 // Returns true if the window selector item has |window| as a selectable
51 // window.
52 bool HasSelectableWindow(const aura::Window* window) const;
54 // Returns true if |target| is contained in this WindowSelectorItem.
55 bool Contains(const aura::Window* target) const;
57 // Restores |window| on exiting window overview rather than returning it
58 // to its previous state.
59 void RestoreWindowOnExit(aura::Window* window);
61 // Returns the |window| to activate on selecting of this item.
62 aura::Window* SelectionWindow() const;
64 // Removes |window| from this item. Check empty() after calling this to see
65 // if the entire item is now empty.
66 void RemoveWindow(const aura::Window* window);
68 // Returns true if this item has no more selectable windows (i.e. after
69 // calling RemoveWindow for the last contained window).
70 bool empty() const;
72 // Dispatched before beginning window overview. This will do any necessary
73 // one time actions such as restoring minimized windows.
74 void PrepareForOverview();
76 // Sets the bounds of this window selector item to |target_bounds| in the
77 // |root_window| root window. The bounds change will be animated as specified
78 // by |animation_type|.
79 void SetBounds(aura::Window* root_window,
80 const gfx::Rect& target_bounds,
81 OverviewAnimationType animation_type);
83 // Recomputes the positions for the windows in this selection item. This is
84 // dispatched when the bounds of a window change.
85 void RecomputeWindowTransforms();
87 // Sends an a11y focus alert so that, if chromevox is enabled, the window
88 // label is read.
89 void SendFocusAlert() const;
91 // Sets if the item is dimmed in the overview. Changing the value will also
92 // change the visibility of the transform windows.
93 void SetDimmed(bool dimmed);
94 bool dimmed() const { return dimmed_; }
96 const gfx::Rect& target_bounds() const { return target_bounds_; }
98 // views::ButtonListener:
99 void ButtonPressed(views::Button* sender, const ui::Event& event) override;
101 // aura::WindowObserver:
102 void OnWindowTitleChanged(aura::Window* window) override;
104 // ash::TransparentActivateWindowButtonDelegate:
105 void Select() override;
107 private:
108 friend class WindowSelectorTest;
110 typedef ScopedVector<ScopedTransformOverviewWindow> TransformWindows;
112 // Sets the bounds of this selector's items to |target_bounds| in
113 // |root_window|. The bounds change will be animated as specified
114 // by |animation_type|.
115 void SetItemBounds(aura::Window* root_window,
116 const gfx::Rect& target_bounds,
117 OverviewAnimationType animation_type);
119 // Changes the opacity of all the windows the item owns.
120 void SetOpacity(float opacity);
122 // Updates the window label's bounds to |target_bounds|. Will create a new
123 // window label and fade it in if it doesn't exist. The bounds change is
124 // animated as specified by the |animation_type|.
125 void UpdateWindowLabels(const gfx::Rect& target_bounds,
126 OverviewAnimationType animation_type);
128 // Initializes window_label_.
129 void CreateWindowLabel(const base::string16& title);
131 // Updates the bounds and accessibility names for all the transparent
132 // overlays.
133 void UpdateSelectorButtons();
135 // Updates the close button's bounds. Any change in bounds will be animated
136 // from the current bounds to the new bounds as per the |animation_type|.
137 void UpdateCloseButtonLayout(OverviewAnimationType animation_type);
139 // Updates the close buttons accessibility name.
140 void UpdateCloseButtonAccessibilityName();
142 // Returns the ScopedTransformOverviewWindow to activate or close.
143 ScopedTransformOverviewWindow* SelectionTransformWindow() const;
145 // True if the item is being shown in the overview, false if it's being
146 // filtered.
147 bool dimmed_;
149 // The root window this item is being displayed on.
150 aura::Window* root_window_;
152 // The target bounds this selector item is fit within.
153 gfx::Rect target_bounds_;
155 // True if running SetItemBounds. This prevents recursive calls resulting from
156 // the bounds update when calling ::wm::RecreateWindowLayers to copy
157 // a window layer for display on another monitor.
158 bool in_bounds_update_;
160 // Label under the window displaying its active tab name.
161 scoped_ptr<views::Widget> window_label_;
163 // View for the label under the window.
164 views::Label* window_label_view_;
166 // The close buttons widget container.
167 views::Widget close_button_widget_;
169 // An easy to access close button for the window in this item. Owned by the
170 // close_button_widget_.
171 views::ImageButton* close_button_;
173 // Transparent overlay that covers the entire bounds of the
174 // WindowSelectorItem and is stacked in front of all windows but behind each
175 // Windows' own TransparentActivateWindowButton.
176 scoped_ptr<TransparentActivateWindowButton>
177 selector_item_activate_window_button_;
179 // List of all Windows added to this and their associated helper classes.
180 TransformWindows transform_windows_;
182 DISALLOW_COPY_AND_ASSIGN(WindowSelectorItem);
185 } // namespace ash
187 #endif // ASH_WM_OVERVIEW_WINDOW_SELECTOR_ITEM_H_