Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Side by Side Diff: ash/wm/overview/window_selector_item.h

Issue 2087153003: Moves common code in ash/wm/overview to ash/common/wm/overview (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/wm/overview/window_selector_delegate.h ('k') | ash/wm/overview/window_selector_item.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
5 #ifndef ASH_WM_OVERVIEW_WINDOW_SELECTOR_ITEM_H_
6 #define ASH_WM_OVERVIEW_WINDOW_SELECTOR_ITEM_H_
7
8 #include <memory>
9
10 #include "ash/ash_export.h"
11 #include "ash/common/wm_window_observer.h"
12 #include "ash/wm/overview/scoped_transform_overview_window.h"
13 #include "base/macros.h"
14 #include "ui/gfx/geometry/insets.h"
15 #include "ui/gfx/geometry/rect.h"
16 #include "ui/views/controls/button/button.h"
17 #include "ui/views/controls/button/label_button.h"
18 #include "ui/views/widget/widget.h"
19
20 namespace views {
21 class ImageButton;
22 }
23
24 namespace ash {
25
26 class WindowSelector;
27 class WmWindow;
28
29 // This class represents an item in overview mode.
30 class ASH_EXPORT WindowSelectorItem : public views::ButtonListener,
31 public WmWindowObserver {
32 public:
33 class OverviewLabelButton : public views::LabelButton {
34 public:
35 OverviewLabelButton(views::ButtonListener* listener,
36 const base::string16& text);
37
38 ~OverviewLabelButton() override;
39
40 // Makes sure that text is readable with |background_color|.
41 void SetBackgroundColor(SkColor background_color);
42
43 void set_padding(const gfx::Insets& padding) { padding_ = padding; }
44
45 protected:
46 // views::LabelButton:
47 gfx::Rect GetChildAreaBounds() override;
48
49 private:
50 // Padding on all sides to correctly place the text inside the view.
51 gfx::Insets padding_;
52
53 DISALLOW_COPY_AND_ASSIGN(OverviewLabelButton);
54 };
55
56 WindowSelectorItem(WmWindow* window, WindowSelector* window_selector);
57 ~WindowSelectorItem() override;
58
59 WmWindow* GetWindow();
60
61 // Returns the root window on which this item is shown.
62 WmWindow* root_window() { return root_window_; }
63
64 // Returns true if |target| is contained in this WindowSelectorItem.
65 bool Contains(const WmWindow* target) const;
66
67 // Restores and animates the managed window to it's non overview mode state.
68 void RestoreWindow();
69
70 // Forces the managed window to be shown (ie not hidden or minimized) when
71 // calling RestoreWindow().
72 void ShowWindowOnExit();
73
74 // Dispatched before beginning window overview. This will do any necessary
75 // one time actions such as restoring minimized windows.
76 void PrepareForOverview();
77
78 // Calculates and returns an optimal scale ratio. With MD this is only
79 // taking into account |size.height()| as the width can vary. Without MD this
80 // returns the scale that allows the item to fully fit within |size|.
81 float GetItemScale(const gfx::Size& size);
82
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);
88
89 // Activates or deactivates selection depending on |selected|.
90 // Currently does nothing unless Material Design is enabled. With Material
91 // Design the item's caption is shown transparent in selected state and blends
92 // with the selection widget.
93 void SetSelected(bool selected);
94
95 // Recomputes the positions for the windows in this selection item. This is
96 // dispatched when the bounds of a window change.
97 void RecomputeWindowTransforms();
98
99 // Sends an accessibility event indicating that this window became selected
100 // so that it's highlighted and announced if accessibility features are
101 // enabled.
102 void SendAccessibleSelectionEvent();
103
104 // Sets if the item is dimmed in the overview. Changing the value will also
105 // change the visibility of the transform windows.
106 void SetDimmed(bool dimmed);
107 bool dimmed() const { return dimmed_; }
108
109 const gfx::Rect& target_bounds() const { return target_bounds_; }
110
111 // views::ButtonListener:
112 void ButtonPressed(views::Button* sender, const ui::Event& event) override;
113
114 // WmWindowObserver:
115 void OnWindowDestroying(WmWindow* window) override;
116 void OnWindowTitleChanged(WmWindow* window) override;
117
118 private:
119 class CaptionContainerView;
120 friend class WindowSelectorTest;
121
122 // Sets the bounds of this selector's items to |target_bounds| in
123 // |root_window_|. The bounds change will be animated as specified
124 // by |animation_type|.
125 void SetItemBounds(const gfx::Rect& target_bounds,
126 OverviewAnimationType animation_type);
127
128 // Changes the opacity of all the windows the item owns.
129 void SetOpacity(float opacity);
130
131 // Updates the window label bounds.
132 void UpdateWindowLabel(const gfx::Rect& window_bounds,
133 OverviewAnimationType animation_type);
134
135 // Creates the window label.
136 void CreateWindowLabel(const base::string16& title);
137
138 // Updates the close button's and title label's bounds. Any change in bounds
139 // will be animated from the current bounds to the new bounds as per the
140 // |animation_type|.
141 void UpdateHeaderLayout(OverviewAnimationType animation_type);
142
143 // Updates the close buttons accessibility name.
144 void UpdateCloseButtonAccessibilityName();
145
146 // True if the item is being shown in the overview, false if it's being
147 // filtered.
148 bool dimmed_;
149
150 // The root window this item is being displayed on.
151 WmWindow* root_window_;
152
153 // The contained Window's wrapper.
154 ScopedTransformOverviewWindow transform_window_;
155
156 // The target bounds this selector item is fit within.
157 gfx::Rect target_bounds_;
158
159 // True if running SetItemBounds. This prevents recursive calls resulting from
160 // the bounds update when calling ::wm::RecreateWindowLayers to copy
161 // a window layer for display on another monitor.
162 bool in_bounds_update_;
163
164 // Label displaying its name (active tab for tabbed windows).
165 // With Material Design this Widget owns |caption_container_view_| and is
166 // shown above the |transform_window_|.
167 // Otherwise it is shown under the window.
168 std::unique_ptr<views::Widget> window_label_;
169
170 // Label background widget used to fade in opacity when moving selection.
171 std::unique_ptr<views::Widget> window_label_selector_;
172
173 // Container view that owns |window_label_button_view_| and |close_button_|.
174 // Only used with Material Design.
175 CaptionContainerView* caption_container_view_;
176
177 // View for the label below the window or (with material design) above it.
178 OverviewLabelButton* window_label_button_view_;
179
180 // The close buttons widget container. Not used with Material Design.
181 std::unique_ptr<views::Widget> close_button_widget_;
182
183 // A close button for the window in this item. Owned by the
184 // |caption_container_view_| with Material Design or by |close_button_widget_|
185 // otherwise.
186 views::ImageButton* close_button_;
187
188 // Pointer to the WindowSelector that owns the WindowGrid containing |this|.
189 // Guaranteed to be non-null for the lifetime of |this|.
190 WindowSelector* window_selector_;
191
192 DISALLOW_COPY_AND_ASSIGN(WindowSelectorItem);
193 };
194
195 } // namespace ash
196
197 #endif // ASH_WM_OVERVIEW_WINDOW_SELECTOR_ITEM_H_
OLDNEW
« no previous file with comments | « ash/wm/overview/window_selector_delegate.h ('k') | ash/wm/overview/window_selector_item.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698