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

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

Issue 2633643002: [ash-md] Reduces dimensions of texture layers in overview mode (Closed)
Patch Set: [ash-md] Reduces dimensions of texture layers in overview mode (test) Created 3 years, 11 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/ash_strings.grd ('k') | ash/common/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
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef ASH_COMMON_WM_OVERVIEW_WINDOW_SELECTOR_ITEM_H_ 5 #ifndef ASH_COMMON_WM_OVERVIEW_WINDOW_SELECTOR_ITEM_H_
6 #define ASH_COMMON_WM_OVERVIEW_WINDOW_SELECTOR_ITEM_H_ 6 #define ASH_COMMON_WM_OVERVIEW_WINDOW_SELECTOR_ITEM_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "ash/ash_export.h" 10 #include "ash/ash_export.h"
11 #include "ash/common/wm/overview/scoped_transform_overview_window.h" 11 #include "ash/common/wm/overview/scoped_transform_overview_window.h"
12 #include "ash/common/wm_window_observer.h" 12 #include "ash/common/wm_window_observer.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "ui/gfx/geometry/insets.h" 14 #include "ui/gfx/geometry/insets.h"
15 #include "ui/gfx/geometry/rect.h" 15 #include "ui/gfx/geometry/rect.h"
16 #include "ui/views/controls/button/button.h" 16 #include "ui/views/controls/button/button.h"
17 #include "ui/views/controls/button/image_button.h" 17 #include "ui/views/controls/button/image_button.h"
18 #include "ui/views/controls/button/label_button.h" 18 #include "ui/views/controls/label.h"
19 #include "ui/views/widget/widget.h" 19 #include "ui/views/widget/widget.h"
20 20
21 namespace gfx { 21 namespace gfx {
22 class SlideAnimation; 22 class SlideAnimation;
23 } 23 }
24 24
25 namespace views { 25 namespace views {
26 class ImageButton; 26 class ImageButton;
27 } 27 }
28 28
29 namespace wm { 29 namespace wm {
30 class Shadow; 30 class Shadow;
31 } 31 }
32 32
33 namespace ash { 33 namespace ash {
34 34
35 class WindowSelector; 35 class WindowSelector;
36 class WmWindow; 36 class WmWindow;
37 37
38 // This class represents an item in overview mode. 38 // This class represents an item in overview mode.
39 class ASH_EXPORT WindowSelectorItem : public views::ButtonListener, 39 class ASH_EXPORT WindowSelectorItem : public views::ButtonListener,
40 public WmWindowObserver { 40 public WmWindowObserver {
41 public: 41 public:
42 class OverviewLabelButton : public views::LabelButton {
43 public:
44 OverviewLabelButton(views::ButtonListener* listener,
45 const base::string16& text);
46
47 ~OverviewLabelButton() override;
48
49 // Makes sure that text is readable with |background_color|.
50 void SetBackgroundColorHint(SkColor background_color);
51
52 // Resets the listener so that the listener can go out of scope.
53 void ResetListener() { listener_ = nullptr; }
54
55 void set_padding(const gfx::Insets& padding) { padding_ = padding; }
56
57 protected:
58 // views::LabelButton:
59 gfx::Rect GetChildAreaBounds() override;
60
61 private:
62 // Padding on all sides to correctly place the text inside the view.
63 gfx::Insets padding_;
64
65 DISALLOW_COPY_AND_ASSIGN(OverviewLabelButton);
66 };
67
68 // An image button with a close window icon. 42 // An image button with a close window icon.
69 class OverviewCloseButton : public views::ImageButton { 43 class OverviewCloseButton : public views::ImageButton {
70 public: 44 public:
71 explicit OverviewCloseButton(views::ButtonListener* listener); 45 explicit OverviewCloseButton(views::ButtonListener* listener);
72 ~OverviewCloseButton() override; 46 ~OverviewCloseButton() override;
73 47
74 // Resets the listener so that the listener can go out of scope. 48 // Resets the listener so that the listener can go out of scope.
75 void ResetListener() { listener_ = nullptr; } 49 void ResetListener() { listener_ = nullptr; }
76 50
77 private: 51 private:
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 // descendants of the window returned by GetWindow()). 83 // descendants of the window returned by GetWindow()).
110 gfx::Rect GetTargetBoundsInScreen() const; 84 gfx::Rect GetTargetBoundsInScreen() const;
111 85
112 // Sets the bounds of this window selector item to |target_bounds| in the 86 // Sets the bounds of this window selector item to |target_bounds| in the
113 // |root_window_| root window. The bounds change will be animated as specified 87 // |root_window_| root window. The bounds change will be animated as specified
114 // by |animation_type|. 88 // by |animation_type|.
115 void SetBounds(const gfx::Rect& target_bounds, 89 void SetBounds(const gfx::Rect& target_bounds,
116 OverviewAnimationType animation_type); 90 OverviewAnimationType animation_type);
117 91
118 // Activates or deactivates selection depending on |selected|. 92 // Activates or deactivates selection depending on |selected|.
119 // Currently does nothing unless Material Design is enabled. With Material 93 // In selected state the item's caption is shown transparent and blends with
120 // Design the item's caption is shown transparent in selected state and blends 94 // the selection widget.
121 // with the selection widget.
122 void SetSelected(bool selected); 95 void SetSelected(bool selected);
123 96
124 // Sends an accessibility event indicating that this window became selected 97 // Sends an accessibility event indicating that this window became selected
125 // so that it's highlighted and announced if accessibility features are 98 // so that it's highlighted and announced if accessibility features are
126 // enabled. 99 // enabled.
127 void SendAccessibleSelectionEvent(); 100 void SendAccessibleSelectionEvent();
128 101
129 // Closes |transform_window_|. 102 // Closes |transform_window_|.
130 void CloseWindow(); 103 void CloseWindow();
131 104
(...skipping 30 matching lines...) Expand all
162 135
163 // Sets the bounds of this selector's items to |target_bounds| in 136 // Sets the bounds of this selector's items to |target_bounds| in
164 // |root_window_|. The bounds change will be animated as specified 137 // |root_window_|. The bounds change will be animated as specified
165 // by |animation_type|. 138 // by |animation_type|.
166 void SetItemBounds(const gfx::Rect& target_bounds, 139 void SetItemBounds(const gfx::Rect& target_bounds,
167 OverviewAnimationType animation_type); 140 OverviewAnimationType animation_type);
168 141
169 // Changes the opacity of all the windows the item owns. 142 // Changes the opacity of all the windows the item owns.
170 void SetOpacity(float opacity); 143 void SetOpacity(float opacity);
171 144
172 // Updates the window label bounds.
173 void UpdateWindowLabel(const gfx::Rect& window_bounds,
174 OverviewAnimationType animation_type);
175
176 // Creates the window label. 145 // Creates the window label.
177 void CreateWindowLabel(const base::string16& title); 146 void CreateWindowLabel(const base::string16& title);
178 147
179 // Updates the close button's and title label's bounds. Any change in bounds 148 // Updates the close button's and title label's bounds. Any change in bounds
180 // will be animated from the current bounds to the new bounds as per the 149 // will be animated from the current bounds to the new bounds as per the
181 // |animation_type|. |mode| allows distinguishing the first time update which 150 // |animation_type|. |mode| allows distinguishing the first time update which
182 // allows setting the initial bounds properly or exiting overview to fade out 151 // allows setting the initial bounds properly or exiting overview to fade out
183 // gradually. 152 // gradually.
184 void UpdateHeaderLayout(HeaderFadeInMode mode, 153 void UpdateHeaderLayout(HeaderFadeInMode mode,
185 OverviewAnimationType animation_type); 154 OverviewAnimationType animation_type);
186 155
187 // Animates opacity of the |transform_window_| and its caption to |opacity| 156 // Animates opacity of the |transform_window_| and its caption to |opacity|
188 // using |animation_type|. 157 // using |animation_type|.
189 void AnimateOpacity(float opacity, OverviewAnimationType animation_type); 158 void AnimateOpacity(float opacity, OverviewAnimationType animation_type);
190 159
191 // Updates the close buttons accessibility name. 160 // Updates the accessibility name to match the window title.
192 void UpdateCloseButtonAccessibilityName(); 161 void UpdateAccessibilityName();
193 162
194 // Fades out a window caption when exiting overview mode. 163 // Fades out a window caption when exiting overview mode.
195 void FadeOut(std::unique_ptr<views::Widget> widget); 164 void FadeOut(std::unique_ptr<views::Widget> widget);
196 165
197 // Allows a test to directly set animation state. 166 // Allows a test to directly set animation state.
198 gfx::SlideAnimation* GetBackgroundViewAnimation(); 167 gfx::SlideAnimation* GetBackgroundViewAnimation();
199 168
200 WmWindow* GetOverviewWindowForMinimizedStateForTest(); 169 WmWindow* GetOverviewWindowForMinimizedStateForTest();
201 170
202 // True if the item is being shown in the overview, false if it's being 171 // True if the item is being shown in the overview, false if it's being
(...skipping 11 matching lines...) Expand all
214 183
215 // True if running SetItemBounds. This prevents recursive calls resulting from 184 // True if running SetItemBounds. This prevents recursive calls resulting from
216 // the bounds update when calling ::wm::RecreateWindowLayers to copy 185 // the bounds update when calling ::wm::RecreateWindowLayers to copy
217 // a window layer for display on another monitor. 186 // a window layer for display on another monitor.
218 bool in_bounds_update_; 187 bool in_bounds_update_;
219 188
220 // True when |this| item is visually selected. Item header is made transparent 189 // True when |this| item is visually selected. Item header is made transparent
221 // when the item is selected. 190 // when the item is selected.
222 bool selected_; 191 bool selected_;
223 192
224 // Label displaying its name (active tab for tabbed windows). 193 // A widget that covers the |transform_window_|. The widget has
225 // With Material Design this Widget owns |caption_container_view_| and is 194 // |caption_container_view_| as its contents view. The widget is backed by a
226 // shown above the |transform_window_|. 195 // NOT_DRAWN layer since most of its surface is transparent.
227 // Otherwise it is shown under the window. 196 std::unique_ptr<views::Widget> item_widget_;
228 std::unique_ptr<views::Widget> window_label_;
229 197
230 // Shadow around the item in overview. 198 // Shadow around the item in overview.
231 std::unique_ptr<::wm::Shadow> shadow_; 199 std::unique_ptr<::wm::Shadow> shadow_;
232 200
233 // Container view that owns |window_label_button_view_| and |close_button_|. 201 // Container view that owns a Button view covering the |transform_window_|.
234 // Only used with Material Design. 202 // That button serves as an event shield to receive all events such as clicks
203 // targeting the |transform_window_| or the overview header above the window.
204 // The shield button owns |background_view_| which owns |label_view_|
205 // and |close_button_|.
235 CaptionContainerView* caption_container_view_; 206 CaptionContainerView* caption_container_view_;
236 207
237 // View for the label below the window or (with material design) above it. 208 // A View for the text label above the window owned by the |background_view_|.
238 OverviewLabelButton* window_label_button_view_; 209 views::Label* label_view_;
239 210
240 // A close button for the window in this item. Owned by the 211 // A close button for the window in this item owned by the |background_view_|.
241 // |caption_container_view_| with Material Design or by |close_button_widget_|
242 // otherwise.
243 OverviewCloseButton* close_button_; 212 OverviewCloseButton* close_button_;
244 213
245 // Pointer to the WindowSelector that owns the WindowGrid containing |this|. 214 // Pointer to the WindowSelector that owns the WindowGrid containing |this|.
246 // Guaranteed to be non-null for the lifetime of |this|. 215 // Guaranteed to be non-null for the lifetime of |this|.
247 WindowSelector* window_selector_; 216 WindowSelector* window_selector_;
248 217
249 // Pointer to a view that covers the original header and has rounded top 218 // Pointer to a view that covers the original header and has rounded top
250 // corners. This view can have its color and opacity animated. 219 // corners. This view can have its color and opacity animated. It has a layer
220 // which is the only textured layer used by the |item_widget_|.
251 RoundedContainerView* background_view_; 221 RoundedContainerView* background_view_;
252 222
253 DISALLOW_COPY_AND_ASSIGN(WindowSelectorItem); 223 DISALLOW_COPY_AND_ASSIGN(WindowSelectorItem);
254 }; 224 };
255 225
256 } // namespace ash 226 } // namespace ash
257 227
258 #endif // ASH_COMMON_WM_OVERVIEW_WINDOW_SELECTOR_ITEM_H_ 228 #endif // ASH_COMMON_WM_OVERVIEW_WINDOW_SELECTOR_ITEM_H_
OLDNEW
« no previous file with comments | « ash/ash_strings.grd ('k') | ash/common/wm/overview/window_selector_item.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698