[Ozone-Gbm] Explicitly crash if trying software rendering on GBM
[chromium-blink-merge.git] / ash / wm / overview / window_selector_item.h
blob063b141e92a594c728efcd9633144251fd19bc28
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(views::ButtonListener* listener,
37 const base::string16& text);
39 ~OverviewLabelButton() override;
41 void set_top_padding(int top_padding) { top_padding_ = top_padding; }
43 protected:
44 // views::LabelButton:
45 gfx::Rect GetChildAreaBounds() override;
47 private:
48 // Padding on top of the button.
49 int top_padding_;
51 DISALLOW_COPY_AND_ASSIGN(OverviewLabelButton);
54 explicit WindowSelectorItem(aura::Window* window);
55 ~WindowSelectorItem() override;
57 aura::Window* GetWindow();
59 // Returns the root window on which this item is shown.
60 aura::Window* root_window() { return root_window_; }
62 // Returns true if |target| is contained in this WindowSelectorItem.
63 bool Contains(const aura::Window* target) const;
65 // Restores and animates the managed window to it's non overview mode state.
66 void RestoreWindow();
68 // Forces the managed window to be shown (ie not hidden or minimized) when
69 // calling RestoreWindow().
70 void ShowWindowOnExit();
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(const gfx::Rect& target_bounds,
80 OverviewAnimationType animation_type);
82 // Recomputes the positions for the windows in this selection item. This is
83 // dispatched when the bounds of a window change.
84 void RecomputeWindowTransforms();
86 // Sends an a11y focus alert so that, if chromevox is enabled, the window
87 // label is read.
88 void SendFocusAlert() const;
90 // Sets if the item is dimmed in the overview. Changing the value will also
91 // change the visibility of the transform windows.
92 void SetDimmed(bool dimmed);
93 bool dimmed() const { return dimmed_; }
95 const gfx::Rect& target_bounds() const { return target_bounds_; }
97 // views::ButtonListener:
98 void ButtonPressed(views::Button* sender, const ui::Event& event) override;
100 // aura::WindowObserver:
101 void OnWindowDestroying(aura::Window* window) override;
102 void OnWindowTitleChanged(aura::Window* window) override;
104 private:
105 friend class WindowSelectorTest;
107 // Sets the bounds of this selector's items to |target_bounds| in
108 // |root_window_|. The bounds change will be animated as specified
109 // by |animation_type|.
110 void SetItemBounds(const gfx::Rect& target_bounds,
111 OverviewAnimationType animation_type);
113 // Changes the opacity of all the windows the item owns.
114 void SetOpacity(float opacity);
116 // Updates the window label bounds.
117 void UpdateWindowLabel(const gfx::Rect& window_bounds,
118 OverviewAnimationType animation_type);
120 // Creates the window label.
121 void CreateWindowLabel(const base::string16& title);
123 // Updates the close button's bounds. Any change in bounds will be animated
124 // from the current bounds to the new bounds as per the |animation_type|.
125 void UpdateCloseButtonLayout(OverviewAnimationType animation_type);
127 // Updates the close buttons accessibility name.
128 void UpdateCloseButtonAccessibilityName();
130 // True if the item is being shown in the overview, false if it's being
131 // filtered.
132 bool dimmed_;
134 // The root window this item is being displayed on.
135 aura::Window* root_window_;
137 // The contained Window's wrapper.
138 ScopedTransformOverviewWindow transform_window_;
140 // The target bounds this selector item is fit within.
141 gfx::Rect target_bounds_;
143 // True if running SetItemBounds. This prevents recursive calls resulting from
144 // the bounds update when calling ::wm::RecreateWindowLayers to copy
145 // a window layer for display on another monitor.
146 bool in_bounds_update_;
148 // Label under the window displaying its active tab name.
149 scoped_ptr<views::Widget> window_label_;
151 // View for the label under the window.
152 OverviewLabelButton* window_label_button_view_;
154 // The close buttons widget container.
155 views::Widget close_button_widget_;
157 // An easy to access close button for the window in this item. Owned by the
158 // close_button_widget_.
159 views::ImageButton* close_button_;
161 DISALLOW_COPY_AND_ASSIGN(WindowSelectorItem);
164 } // namespace ash
166 #endif // ASH_WM_OVERVIEW_WINDOW_SELECTOR_ITEM_H_