platformKeys: Add per-extension sign permissions.
[chromium-blink-merge.git] / ash / wm / overview / window_selector_item.h
blob0e4aa8fa1b83de29588c4e50fea66ca7d43068cb
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 // This class represents an item in overview mode.
31 class ASH_EXPORT WindowSelectorItem : public views::ButtonListener,
32 public aura::WindowObserver {
33 public:
34 class OverviewLabelButton : public views::LabelButton {
35 public:
36 OverviewLabelButton(WindowSelectorItem* selector_item,
37 const base::string16& text);
39 ~OverviewLabelButton() override;
41 void set_top_padding(int top_padding) { top_padding_ = top_padding; }
43 // views::LabelButton:
44 void OnGestureEvent(ui::GestureEvent* event) override;
46 protected:
47 // views::LabelButton:
48 gfx::Rect GetChildAreaBounds() override;
50 private:
51 // The WindowSelectorItem that the touch gestures are delegated to.
52 // Not owned.
53 WindowSelectorItem* selector_item_;
55 // Padding on top of the button.
56 int top_padding_;
58 DISALLOW_COPY_AND_ASSIGN(OverviewLabelButton);
61 explicit WindowSelectorItem(aura::Window* window);
62 ~WindowSelectorItem() override;
64 aura::Window* GetWindow();
66 // Returns the root window on which this item is shown.
67 aura::Window* root_window() { return root_window_; }
69 // Returns true if |target| is contained in this WindowSelectorItem.
70 bool Contains(const aura::Window* target) const;
72 // Restores and animates the managed window to it's non overview mode state.
73 void RestoreWindow();
75 // Forces the managed window to be shown (ie not hidden or minimized) when
76 // calling RestoreWindow().
77 void ShowWindowOnExit();
79 // Dispatched before beginning window overview. This will do any necessary
80 // one time actions such as restoring minimized windows.
81 void PrepareForOverview();
83 // Sets the bounds of this window selector item to |target_bounds| in the
84 // |root_window_| root window. The bounds change will be animated as specified
85 // by |animation_type|.
86 void SetBounds(const gfx::Rect& target_bounds,
87 OverviewAnimationType animation_type);
89 // Recomputes the positions for the windows in this selection item. This is
90 // dispatched when the bounds of a window change.
91 void RecomputeWindowTransforms();
93 // Sends an a11y focus alert so that, if chromevox is enabled, the window
94 // label is read.
95 void SendFocusAlert() const;
97 // Sets if the item is dimmed in the overview. Changing the value will also
98 // change the visibility of the transform windows.
99 void SetDimmed(bool dimmed);
100 bool dimmed() const { return dimmed_; }
102 const gfx::Rect& target_bounds() const { return target_bounds_; }
104 // Handles the gestures on the Window
105 void OnGestureEvent(ui::GestureEvent* event);
107 // views::ButtonListener:
108 void ButtonPressed(views::Button* sender, const ui::Event& event) override;
110 // aura::WindowObserver:
111 void OnWindowDestroying(aura::Window* window) override;
112 void OnWindowTitleChanged(aura::Window* window) override;
114 private:
115 friend class WindowSelectorTest;
117 // Sets the bounds of this selector's items to |target_bounds| in
118 // |root_window_|. The bounds change will be animated as specified
119 // by |animation_type|.
120 void SetItemBounds(const gfx::Rect& target_bounds,
121 OverviewAnimationType animation_type);
123 // Changes the opacity of all the windows the item owns.
124 void SetOpacity(float opacity);
126 // Updates the window label bounds.
127 void UpdateWindowLabel(const gfx::Rect& window_bounds,
128 OverviewAnimationType animation_type);
130 // Creates the window label.
131 void CreateWindowLabel(const base::string16& title);
133 // Updates the close button's bounds. Any change in bounds will be animated
134 // from the current bounds to the new bounds as per the |animation_type|.
135 void UpdateCloseButtonLayout(OverviewAnimationType animation_type);
137 // Updates the close buttons accessibility name.
138 void UpdateCloseButtonAccessibilityName();
140 // Animates the |transform_window_| back to it's original overview mode
141 // position.
142 void ResetScrolledWindow();
144 // Returns the minimum distance at which a scroll gesture will cause this
145 // selector item to be closed.
146 int GetMinimumCloseDistance() const;
148 // True if the item is being shown in the overview, false if it's being
149 // filtered.
150 bool dimmed_;
152 // The root window this item is being displayed on.
153 aura::Window* root_window_;
155 // The contained Window's wrapper.
156 ScopedTransformOverviewWindow transform_window_;
158 // The target bounds this selector item is fit within.
159 gfx::Rect target_bounds_;
161 // True if running SetItemBounds. This prevents recursive calls resulting from
162 // the bounds update when calling ::wm::RecreateWindowLayers to copy
163 // a window layer for display on another monitor.
164 bool in_bounds_update_;
166 // Label under the window displaying its active tab name.
167 scoped_ptr<views::Widget> window_label_;
169 // View for the label under the window.
170 OverviewLabelButton* window_label_button_view_;
172 // The close buttons widget container.
173 views::Widget close_button_widget_;
175 // An easy to access close button for the window in this item. Owned by the
176 // close_button_widget_.
177 views::ImageButton* close_button_;
179 // The original X location for a scroll begin event. |original_x_| is in the
180 // local coordinate space of |window_label_button_view_|.
181 float scroll_x_origin_;
183 DISALLOW_COPY_AND_ASSIGN(WindowSelectorItem);
186 } // namespace ash
188 #endif // ASH_WM_OVERVIEW_WINDOW_SELECTOR_ITEM_H_