Revert "Reland c91b178b07b0d - Delete dead signin code (SigninGlobalError)"
[chromium-blink-merge.git] / ash / wm / overview / window_selector_item.h
blob40063a3f8a9973445b750a3dbe53b6e65660ddd8
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 "base/compiler_specific.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "ui/aura/scoped_window_targeter.h"
13 #include "ui/aura/window_observer.h"
14 #include "ui/gfx/geometry/rect.h"
15 #include "ui/views/controls/button/button.h"
16 #include "ui/views/controls/button/image_button.h"
17 #include "ui/views/controls/button/label_button.h"
19 namespace aura {
20 class Window;
23 namespace views {
24 class LabelButton;
25 class Widget;
28 namespace ash {
30 class WindowSelector;
32 // This class represents an item in overview mode.
33 class ASH_EXPORT WindowSelectorItem : public views::ButtonListener,
34 public aura::WindowObserver {
35 public:
36 class OverviewLabelButton : public views::LabelButton {
37 public:
38 OverviewLabelButton(views::ButtonListener* listener,
39 const base::string16& text);
41 ~OverviewLabelButton() override;
43 void set_top_padding(int top_padding) { top_padding_ = top_padding; }
45 protected:
46 // views::LabelButton:
47 gfx::Rect GetChildAreaBounds() override;
49 private:
50 // Padding on top of the button.
51 int top_padding_;
53 DISALLOW_COPY_AND_ASSIGN(OverviewLabelButton);
56 WindowSelectorItem(aura::Window* window, WindowSelector* window_selector);
57 ~WindowSelectorItem() override;
59 aura::Window* GetWindow();
61 // Returns the root window on which this item is shown.
62 aura::Window* root_window() { return root_window_; }
64 // Returns true if |target| is contained in this WindowSelectorItem.
65 bool Contains(const aura::Window* target) const;
67 // Restores and animates the managed window to it's non overview mode state.
68 void RestoreWindow();
70 // Forces the managed window to be shown (ie not hidden or minimized) when
71 // calling RestoreWindow().
72 void ShowWindowOnExit();
74 // Dispatched before beginning window overview. This will do any necessary
75 // one time actions such as restoring minimized windows.
76 void PrepareForOverview();
78 // Sets the bounds of this window selector item to |target_bounds| in the
79 // |root_window_| root window. The bounds change will be animated as specified
80 // by |animation_type|.
81 void SetBounds(const gfx::Rect& target_bounds,
82 OverviewAnimationType animation_type);
84 // Recomputes the positions for the windows in this selection item. This is
85 // dispatched when the bounds of a window change.
86 void RecomputeWindowTransforms();
88 // Sends an a11y focus alert so that, if chromevox is enabled, the window
89 // label is read.
90 void SendFocusAlert() const;
92 // Sets if the item is dimmed in the overview. Changing the value will also
93 // change the visibility of the transform windows.
94 void SetDimmed(bool dimmed);
95 bool dimmed() const { return dimmed_; }
97 const gfx::Rect& target_bounds() const { return target_bounds_; }
99 // views::ButtonListener:
100 void ButtonPressed(views::Button* sender, const ui::Event& event) override;
102 // aura::WindowObserver:
103 void OnWindowDestroying(aura::Window* window) override;
104 void OnWindowTitleChanged(aura::Window* window) override;
106 private:
107 friend class WindowSelectorTest;
109 // Sets the bounds of this selector's items to |target_bounds| in
110 // |root_window_|. The bounds change will be animated as specified
111 // by |animation_type|.
112 void SetItemBounds(const gfx::Rect& target_bounds,
113 OverviewAnimationType animation_type);
115 // Changes the opacity of all the windows the item owns.
116 void SetOpacity(float opacity);
118 // Updates the window label bounds.
119 void UpdateWindowLabel(const gfx::Rect& window_bounds,
120 OverviewAnimationType animation_type);
122 // Creates the window label.
123 void CreateWindowLabel(const base::string16& title);
125 // Updates the close button's bounds. Any change in bounds will be animated
126 // from the current bounds to the new bounds as per the |animation_type|.
127 void UpdateCloseButtonLayout(OverviewAnimationType animation_type);
129 // Updates the close buttons accessibility name.
130 void UpdateCloseButtonAccessibilityName();
132 // True if the item is being shown in the overview, false if it's being
133 // filtered.
134 bool dimmed_;
136 // The root window this item is being displayed on.
137 aura::Window* root_window_;
139 // The contained Window's wrapper.
140 ScopedTransformOverviewWindow transform_window_;
142 // The target bounds this selector item is fit within.
143 gfx::Rect target_bounds_;
145 // True if running SetItemBounds. This prevents recursive calls resulting from
146 // the bounds update when calling ::wm::RecreateWindowLayers to copy
147 // a window layer for display on another monitor.
148 bool in_bounds_update_;
150 // Label under the window displaying its active tab name.
151 scoped_ptr<views::Widget> window_label_;
153 // View for the label under the window.
154 OverviewLabelButton* window_label_button_view_;
156 // The close buttons widget container.
157 views::Widget close_button_widget_;
159 // An easy to access close button for the window in this item. Owned by the
160 // close_button_widget_.
161 views::ImageButton* close_button_;
163 // Pointer to the WindowSelector that owns the WindowGrid containing |this|.
164 // Guaranteed to be non-null for the lifetime of |this|.
165 WindowSelector* window_selector_;
167 DISALLOW_COPY_AND_ASSIGN(WindowSelectorItem);
170 } // namespace ash
172 #endif // ASH_WM_OVERVIEW_WINDOW_SELECTOR_ITEM_H_