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

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

Issue 2239233002: [ash-md] Fades overview header in and out (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: [ash-md] Fades overview header in and out (rebase) Created 4 years, 3 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
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 #include "ash/common/wm/overview/window_selector_item.h" 5 #include "ash/common/wm/overview/window_selector_item.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "ash/common/material_design/material_design_controller.h" 10 #include "ash/common/material_design/material_design_controller.h"
11 #include "ash/common/metrics/user_metrics_action.h" 11 #include "ash/common/metrics/user_metrics_action.h"
12 #include "ash/common/shell_window_ids.h" 12 #include "ash/common/shell_window_ids.h"
13 #include "ash/common/wm/overview/cleanup_animation_observer.h"
13 #include "ash/common/wm/overview/overview_animation_type.h" 14 #include "ash/common/wm/overview/overview_animation_type.h"
14 #include "ash/common/wm/overview/scoped_overview_animation_settings.h" 15 #include "ash/common/wm/overview/scoped_overview_animation_settings.h"
15 #include "ash/common/wm/overview/scoped_overview_animation_settings_factory.h" 16 #include "ash/common/wm/overview/scoped_overview_animation_settings_factory.h"
16 #include "ash/common/wm/overview/scoped_transform_overview_window.h" 17 #include "ash/common/wm/overview/scoped_transform_overview_window.h"
17 #include "ash/common/wm/overview/window_selector.h" 18 #include "ash/common/wm/overview/window_selector.h"
18 #include "ash/common/wm/overview/window_selector_controller.h" 19 #include "ash/common/wm/overview/window_selector_controller.h"
19 #include "ash/common/wm/window_state.h" 20 #include "ash/common/wm/window_state.h"
20 #include "ash/common/wm_lookup.h" 21 #include "ash/common/wm_lookup.h"
21 #include "ash/common/wm_root_window_controller.h" 22 #include "ash/common/wm_root_window_controller.h"
22 #include "ash/common/wm_shell.h" 23 #include "ash/common/wm_shell.h"
23 #include "ash/common/wm_window.h" 24 #include "ash/common/wm_window.h"
24 #include "ash/common/wm_window_property.h" 25 #include "ash/common/wm_window_property.h"
25 #include "base/auto_reset.h" 26 #include "base/auto_reset.h"
26 #include "base/strings/string_util.h" 27 #include "base/strings/string_util.h"
27 #include "base/strings/utf_string_conversions.h" 28 #include "base/strings/utf_string_conversions.h"
28 #include "base/time/time.h" 29 #include "base/time/time.h"
29 #include "grit/ash_resources.h" 30 #include "grit/ash_resources.h"
30 #include "grit/ash_strings.h" 31 #include "grit/ash_strings.h"
31 #include "ui/base/l10n/l10n_util.h" 32 #include "ui/base/l10n/l10n_util.h"
32 #include "ui/base/resource/resource_bundle.h" 33 #include "ui/base/resource/resource_bundle.h"
34 #include "ui/compositor/layer_animation_sequence.h"
33 #include "ui/gfx/canvas.h" 35 #include "ui/gfx/canvas.h"
36 #include "ui/gfx/color_utils.h"
34 #include "ui/gfx/geometry/safe_integer_conversions.h" 37 #include "ui/gfx/geometry/safe_integer_conversions.h"
35 #include "ui/gfx/geometry/vector2d.h" 38 #include "ui/gfx/geometry/vector2d.h"
36 #include "ui/gfx/paint_vector_icon.h" 39 #include "ui/gfx/paint_vector_icon.h"
37 #include "ui/gfx/transform_util.h" 40 #include "ui/gfx/transform_util.h"
38 #include "ui/gfx/vector_icons_public.h" 41 #include "ui/gfx/vector_icons_public.h"
39 #include "ui/strings/grit/ui_strings.h" 42 #include "ui/strings/grit/ui_strings.h"
40 #include "ui/views/background.h" 43 #include "ui/views/background.h"
41 #include "ui/views/border.h" 44 #include "ui/views/border.h"
42 #include "ui/views/controls/button/image_button.h" 45 #include "ui/views/controls/button/image_button.h"
43 #include "ui/views/layout/box_layout.h" 46 #include "ui/views/layout/box_layout.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 93
91 // Height of an item header in Material Design. 94 // Height of an item header in Material Design.
92 static const int kHeaderHeight = 32; 95 static const int kHeaderHeight = 32;
93 96
94 // Opacity for dimmed items. 97 // Opacity for dimmed items.
95 static const float kDimmedItemOpacity = 0.5f; 98 static const float kDimmedItemOpacity = 0.5f;
96 99
97 // Opacity for fading out during closing a window. 100 // Opacity for fading out during closing a window.
98 static const float kClosingItemOpacity = 0.8f; 101 static const float kClosingItemOpacity = 0.8f;
99 102
103 // Opacity for the item header.
104 static const float kHeaderOpacity =
105 (SkColorGetA(kLabelBackgroundColor) / 255.f);
106
107 // The time duration for fade out animations when exiting overview mode.
108 static const int kTransitionMilliseconds = 300;
109
100 // Duration of background opacity transition for the selected label. 110 // Duration of background opacity transition for the selected label.
101 static const int kSelectorFadeInMilliseconds = 350; 111 static const int kSelectorFadeInMilliseconds = 350;
102 112
103 // Before closing a window animate both the window and the caption to shrink by 113 // Before closing a window animate both the window and the caption to shrink by
104 // this fraction of size. 114 // this fraction of size.
105 static const float kPreCloseScale = 0.02f; 115 static const float kPreCloseScale = 0.02f;
106 116
107 // Convenience method to fade in a Window with predefined animation settings. 117 // Convenience method to fade in a Window with predefined animation settings.
108 // Note: The fade in animation will occur after a delay where the delay is how 118 // Note: The fade in animation will occur after a delay where the delay is how
109 // long the lay out animations take. 119 // long the lay out animations take.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 rb.GetImageSkiaNamed(IDR_AURA_WINDOW_OVERVIEW_CLOSE)); 159 rb.GetImageSkiaNamed(IDR_AURA_WINDOW_OVERVIEW_CLOSE));
150 SetImage(views::CustomButton::STATE_HOVERED, 160 SetImage(views::CustomButton::STATE_HOVERED,
151 rb.GetImageSkiaNamed(IDR_AURA_WINDOW_OVERVIEW_CLOSE_H)); 161 rb.GetImageSkiaNamed(IDR_AURA_WINDOW_OVERVIEW_CLOSE_H));
152 SetImage(views::CustomButton::STATE_PRESSED, 162 SetImage(views::CustomButton::STATE_PRESSED,
153 rb.GetImageSkiaNamed(IDR_AURA_WINDOW_OVERVIEW_CLOSE_P)); 163 rb.GetImageSkiaNamed(IDR_AURA_WINDOW_OVERVIEW_CLOSE_P));
154 } 164 }
155 } 165 }
156 166
157 OverviewCloseButton::~OverviewCloseButton() {} 167 OverviewCloseButton::~OverviewCloseButton() {}
158 168
169 } // namespace
170
159 // A View having rounded corners and a specified background color which is 171 // A View having rounded corners and a specified background color which is
160 // only painted within the bounds defined by the rounded corners. 172 // only painted within the bounds defined by the rounded corners.
161 // TODO(varkha): This duplicates code from RoundedImageView. Refactor these 173 // TODO(varkha): This duplicates code from RoundedImageView. Refactor these
162 // classes and move into ui/views. 174 // classes and move into ui/views.
163 class RoundedContainerView : public views::View { 175 class WindowSelectorItem::RoundedContainerView
176 : public views::View,
177 public gfx::AnimationDelegate,
178 public ui::LayerAnimationObserver {
164 public: 179 public:
165 RoundedContainerView(int corner_radius, SkColor background) 180 RoundedContainerView(WindowSelectorItem* item,
166 : corner_radius_(corner_radius), background_(background) {} 181 int corner_radius,
182 SkColor background)
183 : item_(item),
184 corner_radius_(corner_radius),
185 previous_color_(background),
186 color_(background),
187 last_alpha_(0),
188 current_value_(0),
189 layer_(nullptr),
190 animation_(new gfx::SlideAnimation(this)) {}
167 191
168 ~RoundedContainerView() override {} 192 ~RoundedContainerView() override {}
169 193
194 void OnItemRestored() { item_ = nullptr; }
195
196 void ObserveLayer(ui::Layer* layer) {
197 layer_ = layer;
198 layer_->GetAnimator()->AddObserver(this);
199 }
200
201 void set_color(SkColor color) { color_ = color; }
202
203 void SetBackgroundOpacity(float opacity) {
bruthig 2016/09/02 16:00:12 nit: IMO this would be better named as AnimateBack
varkha 2016/09/08 00:09:50 Done.
204 animation_->SetSlideDuration(kSelectorFadeInMilliseconds);
205 animation_->Reset(0);
206 animation_->Show();
207 color_ = SkColorSetA(color_, opacity * 255);
208 }
209
170 void OnPaint(gfx::Canvas* canvas) override { 210 void OnPaint(gfx::Canvas* canvas) override {
171 views::View::OnPaint(canvas); 211 views::View::OnPaint(canvas);
172
173 SkScalar radius = SkIntToScalar(corner_radius_); 212 SkScalar radius = SkIntToScalar(corner_radius_);
174 const SkScalar kRadius[8] = {radius, radius, radius, radius, 213 const SkScalar kRadius[8] = {radius, radius, radius, radius, 0, 0, 0, 0};
175 radius, radius, radius, radius};
176 SkPath path; 214 SkPath path;
177 gfx::Rect bounds(size()); 215 gfx::Rect bounds(size());
178 bounds.set_height(bounds.height() + radius);
179 path.addRoundRect(gfx::RectToSkRect(bounds), kRadius); 216 path.addRoundRect(gfx::RectToSkRect(bounds), kRadius);
180 217
181 SkPaint paint; 218 SkPaint paint;
182 paint.setAntiAlias(true); 219 paint.setAntiAlias(true);
183 canvas->ClipPath(path, true); 220 canvas->ClipPath(path, true);
184 canvas->DrawColor(background_); 221
222 SkColor color = previous_color_;
223 if (color_ != color)
224 color = color_utils::AlphaBlend(color_, previous_color_, current_value_);
225 canvas->DrawColor(color);
226 last_alpha_ = SkColorGetA(color);
185 } 227 }
186 228
187 private: 229 private:
230 // gfx::AnimationDelegate:
231 void AnimationEnded(const gfx::Animation* animation) override {
232 previous_color_ = color_;
233 }
234
235 void AnimationProgressed(const gfx::Animation* animation) override {
236 current_value_ = animation_->CurrentValueBetween(0, 255);
237 SchedulePaintInRect(GetLocalBounds());
238 }
239
240 void AnimationCanceled(const gfx::Animation* animation) override {
241 previous_color_ = color_;
242 current_value_ = 255;
243 SchedulePaintInRect(GetLocalBounds());
244 }
245
246 // ui::LayerAnimationObserver:
247 void OnLayerAnimationEnded(ui::LayerAnimationSequence* sequence) override {
248 if (0 != (sequence->properties() &
249 ui::LayerAnimationElement::AnimatableProperty::OPACITY)) {
250 if (item_)
251 item_->HideHeaderAndSetShape(0);
252 if (layer_) {
253 layer_->GetAnimator()->RemoveObserver(this);
254 layer_ = nullptr;
255 }
256 animation_->SetSlideDuration(400);
bruthig 2016/09/02 16:00:12 nit: Can the 400 be made a named constant like kSe
varkha 2016/09/02 21:38:37 Done.
257 animation_->Reset(0);
258 animation_->Show();
259 }
260 }
261
262 void OnLayerAnimationAborted(ui::LayerAnimationSequence* sequence) override {
263 if (0 != (sequence->properties() &
264 ui::LayerAnimationElement::AnimatableProperty::OPACITY)) {
265 if (layer_) {
266 layer_->GetAnimator()->RemoveObserver(this);
267 layer_ = nullptr;
268 }
269 }
270 }
271
272 void OnLayerAnimationScheduled(
273 ui::LayerAnimationSequence* sequence) override {}
274
275 WindowSelectorItem* item_;
188 int corner_radius_; 276 int corner_radius_;
189 SkColor background_; 277 SkColor previous_color_;
278 SkColor color_;
279 int last_alpha_;
280 int current_value_;
281 ui::Layer* layer_;
282 std::unique_ptr<gfx::SlideAnimation> animation_;
bruthig 2016/09/02 16:00:12 Is a SlideAnimation required or would a LinearAnim
varkha 2016/09/08 00:09:50 SlideAnimation saves from some of the headaches li
190 283
191 DISALLOW_COPY_AND_ASSIGN(RoundedContainerView); 284 DISALLOW_COPY_AND_ASSIGN(RoundedContainerView);
192 }; 285 };
193 286
194 } // namespace
195
196 bool WindowSelectorItem::use_mask_ = false; 287 bool WindowSelectorItem::use_mask_ = false;
197 bool WindowSelectorItem::use_shape_ = false; 288 bool WindowSelectorItem::use_shape_ = false;
198 289
199 WindowSelectorItem::OverviewLabelButton::OverviewLabelButton( 290 WindowSelectorItem::OverviewLabelButton::OverviewLabelButton(
200 views::ButtonListener* listener, 291 views::ButtonListener* listener,
201 const base::string16& text) 292 const base::string16& text)
202 : LabelButton(listener, text) {} 293 : LabelButton(listener, text) {}
203 294
204 WindowSelectorItem::OverviewLabelButton::~OverviewLabelButton() {} 295 WindowSelectorItem::OverviewLabelButton::~OverviewLabelButton() {}
205 296
(...skipping 10 matching lines...) Expand all
216 bounds.Inset(padding_); 307 bounds.Inset(padding_);
217 if (ash::MaterialDesignController::IsOverviewMaterial()) 308 if (ash::MaterialDesignController::IsOverviewMaterial())
218 bounds.Inset(kHorizontalLabelPaddingMD, 0, kHorizontalLabelPaddingMD, 0); 309 bounds.Inset(kHorizontalLabelPaddingMD, 0, kHorizontalLabelPaddingMD, 0);
219 return bounds; 310 return bounds;
220 } 311 }
221 312
222 // Container View that has an item label and a close button as children. 313 // Container View that has an item label and a close button as children.
223 class WindowSelectorItem::CaptionContainerView : public views::View { 314 class WindowSelectorItem::CaptionContainerView : public views::View {
224 public: 315 public:
225 CaptionContainerView(WindowSelectorItem::OverviewLabelButton* label, 316 CaptionContainerView(WindowSelectorItem::OverviewLabelButton* label,
226 views::ImageButton* close_button) 317 views::ImageButton* close_button,
227 : label_(label), close_button_(close_button) { 318 WindowSelectorItem::RoundedContainerView* background)
319 : label_(label), close_button_(close_button), background_(background) {
320 AddChildView(background_);
228 AddChildView(label_); 321 AddChildView(label_);
229 AddChildView(close_button_); 322 AddChildView(close_button_);
230 } 323 }
231 324
232 protected: 325 protected:
233 // views::View: 326 // views::View:
234 void Layout() override { 327 void Layout() override {
235 // Position close button in the top right corner sized to its icon size and 328 // Position close button in the top right corner sized to its icon size and
236 // the label in the top left corner as tall as the button and extending to 329 // the label in the top left corner as tall as the button and extending to
237 // the button's left edge. 330 // the button's left edge.
238 // The rest of this container view serves as a shield to prevent input 331 // The rest of this container view serves as a shield to prevent input
239 // events from reaching the transformed window in overview. 332 // events from reaching the transformed window in overview.
240 gfx::Rect bounds(GetLocalBounds()); 333 gfx::Rect bounds(GetLocalBounds());
241 bounds.Inset(kWindowSelectorMargin, kWindowSelectorMargin); 334 bounds.Inset(kWindowSelectorMargin, kWindowSelectorMargin);
335 gfx::Rect background_bounds(bounds);
336 background_bounds.set_height(close_button_->GetPreferredSize().height());
337 background_bounds.set_y(background_bounds.y() +
338 close_button_->GetPreferredSize().height() -
339 background_bounds.height());
340 background_->SetBoundsRect(background_bounds);
341
242 const int visible_height = close_button_->GetPreferredSize().height(); 342 const int visible_height = close_button_->GetPreferredSize().height();
243 gfx::Insets label_padding(0, 0, bounds.height() - visible_height, 343 gfx::Insets label_padding(0, 0, bounds.height() - visible_height,
244 visible_height); 344 visible_height);
245 label_->set_padding(label_padding); 345 label_->set_padding(label_padding);
246 label_->SetBoundsRect(bounds); 346 label_->SetBoundsRect(bounds);
247 bounds.set_x(bounds.right() - visible_height); 347 bounds.set_x(bounds.right() - visible_height);
248 bounds.set_width(visible_height); 348 bounds.set_width(visible_height);
249 bounds.set_height(visible_height); 349 bounds.set_height(visible_height);
250 close_button_->SetBoundsRect(bounds); 350 close_button_->SetBoundsRect(bounds);
251 } 351 }
252 352
253 void OnBoundsChanged(const gfx::Rect& previous_bounds) override { Layout(); }
254
255 private: 353 private:
256 WindowSelectorItem::OverviewLabelButton* label_; 354 WindowSelectorItem::OverviewLabelButton* label_;
257 views::ImageButton* close_button_; 355 views::ImageButton* close_button_;
356 WindowSelectorItem::RoundedContainerView* background_;
258 357
259 DISALLOW_COPY_AND_ASSIGN(CaptionContainerView); 358 DISALLOW_COPY_AND_ASSIGN(CaptionContainerView);
260 }; 359 };
261 360
262 WindowSelectorItem::WindowSelectorItem(WmWindow* window, 361 WindowSelectorItem::WindowSelectorItem(WmWindow* window,
263 WindowSelector* window_selector) 362 WindowSelector* window_selector)
264 : dimmed_(false), 363 : dimmed_(false),
265 root_window_(window->GetRootWindow()), 364 root_window_(window->GetRootWindow()),
266 transform_window_(window), 365 transform_window_(window),
267 in_bounds_update_(false), 366 in_bounds_update_(false),
367 selected_(false),
368 first_time_update_(true),
268 caption_container_view_(nullptr), 369 caption_container_view_(nullptr),
269 window_label_button_view_(nullptr), 370 window_label_button_view_(nullptr),
270 close_button_(new OverviewCloseButton(this)), 371 close_button_(new OverviewCloseButton(this)),
271 window_selector_(window_selector) { 372 window_selector_(window_selector),
373 background_view_(nullptr) {
272 CreateWindowLabel(window->GetTitle()); 374 CreateWindowLabel(window->GetTitle());
273 if (!ash::MaterialDesignController::IsOverviewMaterial()) { 375 if (!ash::MaterialDesignController::IsOverviewMaterial()) {
274 views::Widget::InitParams params; 376 views::Widget::InitParams params;
275 params.type = views::Widget::InitParams::TYPE_POPUP; 377 params.type = views::Widget::InitParams::TYPE_POPUP;
276 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 378 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
277 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; 379 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
278 params.name = "OverviewModeCloseButton"; 380 params.name = "OverviewModeCloseButton";
279 close_button_widget_.reset(new views::Widget); 381 close_button_widget_.reset(new views::Widget);
280 close_button_widget_->set_focus_on_creation(false); 382 close_button_widget_->set_focus_on_creation(false);
281 window->GetRootWindowController()->ConfigureWidgetInitParamsForContainer( 383 window->GetRootWindowController()->ConfigureWidgetInitParamsForContainer(
(...skipping 11 matching lines...) Expand all
293 close_button_rect.set_x(-close_button_rect.width() / 2); 395 close_button_rect.set_x(-close_button_rect.width() / 2);
294 close_button_rect.set_y(-close_button_rect.height() / 2); 396 close_button_rect.set_y(-close_button_rect.height() / 2);
295 WmLookup::Get() 397 WmLookup::Get()
296 ->GetWindowForWidget(close_button_widget_.get()) 398 ->GetWindowForWidget(close_button_widget_.get())
297 ->SetBounds(close_button_rect); 399 ->SetBounds(close_button_rect);
298 } 400 }
299 GetWindow()->AddObserver(this); 401 GetWindow()->AddObserver(this);
300 } 402 }
301 403
302 WindowSelectorItem::~WindowSelectorItem() { 404 WindowSelectorItem::~WindowSelectorItem() {
405 if (background_view_)
406 background_view_->OnItemRestored();
303 GetWindow()->RemoveObserver(this); 407 GetWindow()->RemoveObserver(this);
304 } 408 }
305 409
306 WmWindow* WindowSelectorItem::GetWindow() { 410 WmWindow* WindowSelectorItem::GetWindow() {
307 return transform_window_.window(); 411 return transform_window_.window();
308 } 412 }
309 413
310 void WindowSelectorItem::RestoreWindow() { 414 void WindowSelectorItem::RestoreWindow() {
311 transform_window_.RestoreWindow(); 415 transform_window_.RestoreWindow();
416 if (background_view_)
417 background_view_->OnItemRestored();
418 UpdateHeaderLayout(
419 OverviewAnimationType::OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS);
420 FadeOut(std::move(window_label_));
312 } 421 }
313 422
314 void WindowSelectorItem::ShowWindowOnExit() { 423 void WindowSelectorItem::ShowWindowOnExit() {
315 transform_window_.ShowWindowOnExit(); 424 transform_window_.ShowWindowOnExit();
316 } 425 }
317 426
318 void WindowSelectorItem::PrepareForOverview() { 427 void WindowSelectorItem::PrepareForOverview() {
319 transform_window_.PrepareForOverview(); 428 transform_window_.PrepareForOverview();
320 } 429 }
321 430
(...skipping 18 matching lines...) Expand all
340 // SetItemBounds is called before UpdateHeaderLayout so the header can 449 // SetItemBounds is called before UpdateHeaderLayout so the header can
341 // properly use the updated windows bounds. 450 // properly use the updated windows bounds.
342 UpdateHeaderLayout(animation_type); 451 UpdateHeaderLayout(animation_type);
343 if (!ash::MaterialDesignController::IsOverviewMaterial()) 452 if (!ash::MaterialDesignController::IsOverviewMaterial())
344 UpdateWindowLabel(target_bounds, animation_type); 453 UpdateWindowLabel(target_bounds, animation_type);
345 } 454 }
346 455
347 void WindowSelectorItem::SetSelected(bool selected) { 456 void WindowSelectorItem::SetSelected(bool selected) {
348 if (!ash::MaterialDesignController::IsOverviewMaterial()) 457 if (!ash::MaterialDesignController::IsOverviewMaterial())
349 return; 458 return;
350 WmWindow* window = 459 selected_ = selected;
351 WmLookup::Get()->GetWindowForWidget(window_label_selector_.get()); 460 background_view_->SetBackgroundOpacity(selected ? 0.0f : kHeaderOpacity);
352 ui::ScopedLayerAnimationSettings animation_settings(
353 window->GetLayer()->GetAnimator());
354 animation_settings.SetTransitionDuration(
355 base::TimeDelta::FromMilliseconds(kSelectorFadeInMilliseconds));
356 animation_settings.SetTweenType(selected ? gfx::Tween::FAST_OUT_LINEAR_IN
357 : gfx::Tween::LINEAR_OUT_SLOW_IN);
358 animation_settings.SetPreemptionStrategy(
359 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
360 window->SetOpacity(selected ? 0.0f : 1.0f);
361 461
362 ui::ScopedLayerAnimationSettings animation_settings_shadow( 462 if (shadow_) {
363 shadow_->shadow_layer()->GetAnimator()); 463 ui::ScopedLayerAnimationSettings animation_settings_shadow(
364 animation_settings_shadow.SetTransitionDuration( 464 shadow_->shadow_layer()->GetAnimator());
365 base::TimeDelta::FromMilliseconds(kSelectorFadeInMilliseconds)); 465 animation_settings_shadow.SetTransitionDuration(
366 animation_settings_shadow.SetTweenType(selected 466 base::TimeDelta::FromMilliseconds(kSelectorFadeInMilliseconds));
367 ? gfx::Tween::FAST_OUT_LINEAR_IN 467 animation_settings_shadow.SetTweenType(
368 : gfx::Tween::LINEAR_OUT_SLOW_IN); 468 selected ? gfx::Tween::FAST_OUT_LINEAR_IN
369 animation_settings_shadow.SetPreemptionStrategy( 469 : gfx::Tween::LINEAR_OUT_SLOW_IN);
370 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); 470 animation_settings_shadow.SetPreemptionStrategy(
371 shadow_->shadow_layer()->SetOpacity(selected ? 0.0f : 1.0f); 471 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
472 shadow_->shadow_layer()->SetOpacity(selected ? 0.0f : 1.0f);
473 }
372 } 474 }
373 475
374 void WindowSelectorItem::RecomputeWindowTransforms() { 476 void WindowSelectorItem::RecomputeWindowTransforms() {
375 if (in_bounds_update_ || target_bounds_.IsEmpty()) 477 if (in_bounds_update_ || target_bounds_.IsEmpty())
376 return; 478 return;
377 base::AutoReset<bool> auto_reset_in_bounds_update(&in_bounds_update_, true); 479 base::AutoReset<bool> auto_reset_in_bounds_update(&in_bounds_update_, true);
378 gfx::Rect inset_bounds(target_bounds_); 480 gfx::Rect inset_bounds(target_bounds_);
379 if (ash::MaterialDesignController::IsOverviewMaterial()) 481 if (ash::MaterialDesignController::IsOverviewMaterial())
380 inset_bounds.Inset(kWindowMarginMD, kWindowMarginMD); 482 inset_bounds.Inset(kWindowMarginMD, kWindowMarginMD);
381 else 483 else
(...skipping 20 matching lines...) Expand all
402 // scaling animation. 504 // scaling animation.
403 AnimateOpacity(kClosingItemOpacity, animation_type); 505 AnimateOpacity(kClosingItemOpacity, animation_type);
404 506
405 // Fade out the window and the label, effectively hiding them. 507 // Fade out the window and the label, effectively hiding them.
406 AnimateOpacity( 508 AnimateOpacity(
407 0.0, OverviewAnimationType::OVERVIEW_ANIMATION_CLOSE_SELECTOR_ITEM); 509 0.0, OverviewAnimationType::OVERVIEW_ANIMATION_CLOSE_SELECTOR_ITEM);
408 } 510 }
409 transform_window_.Close(); 511 transform_window_.Close();
410 } 512 }
411 513
514 void WindowSelectorItem::HideHeaderAndSetShape(int radius) {
515 transform_window_.HideHeaderAndSetShape(use_mask_, use_shape_, radius);
bruthig 2016/09/02 16:00:12 [Discussed offline] Since HideHeaderAndSetShape()
varkha 2016/09/08 00:09:50 Agreed. I will be posting removal of those command
516 }
517
412 void WindowSelectorItem::SetDimmed(bool dimmed) { 518 void WindowSelectorItem::SetDimmed(bool dimmed) {
413 dimmed_ = dimmed; 519 dimmed_ = dimmed;
414 SetOpacity(dimmed ? kDimmedItemOpacity : 1.0f); 520 SetOpacity(dimmed ? kDimmedItemOpacity : 1.0f);
415 } 521 }
416 522
417 void WindowSelectorItem::ButtonPressed(views::Button* sender, 523 void WindowSelectorItem::ButtonPressed(views::Button* sender,
418 const ui::Event& event) { 524 const ui::Event& event) {
419 if (sender == close_button_) { 525 if (sender == close_button_) {
420 WmShell::Get()->RecordUserMetricsAction(UMA_WINDOW_OVERVIEW_CLOSE_BUTTON); 526 WmShell::Get()->RecordUserMetricsAction(UMA_WINDOW_OVERVIEW_CLOSE_BUTTON);
421 CloseWindow(); 527 CloseWindow();
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 top_view_inset = transform_window_.GetTopInset(); 572 top_view_inset = transform_window_.GetTopInset();
467 title_height = close_button_->GetPreferredSize().height(); 573 title_height = close_button_->GetPreferredSize().height();
468 } 574 }
469 gfx::Rect selector_item_bounds = 575 gfx::Rect selector_item_bounds =
470 ScopedTransformOverviewWindow::ShrinkRectToFitPreservingAspectRatio( 576 ScopedTransformOverviewWindow::ShrinkRectToFitPreservingAspectRatio(
471 screen_rect, target_bounds, top_view_inset, title_height); 577 screen_rect, target_bounds, top_view_inset, title_height);
472 gfx::Transform transform = ScopedTransformOverviewWindow::GetTransformForRect( 578 gfx::Transform transform = ScopedTransformOverviewWindow::GetTransformForRect(
473 screen_rect, selector_item_bounds); 579 screen_rect, selector_item_bounds);
474 ScopedTransformOverviewWindow::ScopedAnimationSettings animation_settings; 580 ScopedTransformOverviewWindow::ScopedAnimationSettings animation_settings;
475 transform_window_.BeginScopedAnimation(animation_type, &animation_settings); 581 transform_window_.BeginScopedAnimation(animation_type, &animation_settings);
476 // Rounded corners are achieved by using a mask layer on the original window 582 transform_window_.SetTransform(root_window_, transform, use_mask_);
477 // before the transform. Dividing by scale factor obtains the corner radius
478 // which when scaled will yield |kLabelBackgroundRadius|.
479 transform_window_.SetTransform(
480 root_window_, transform, use_mask_, use_shape_,
481 (kLabelBackgroundRadius / GetItemScale(target_bounds.size())));
482 transform_window_.set_overview_transform(transform); 583 transform_window_.set_overview_transform(transform);
483 } 584 }
484 585
485 void WindowSelectorItem::SetOpacity(float opacity) { 586 void WindowSelectorItem::SetOpacity(float opacity) {
486 window_label_->SetOpacity(opacity); 587 window_label_->SetOpacity(opacity);
588 if (background_view_) {
589 background_view_->SetBackgroundOpacity(selected_ ? 0.f : kHeaderOpacity *
590 opacity);
591 }
592
487 if (!ash::MaterialDesignController::IsOverviewMaterial()) 593 if (!ash::MaterialDesignController::IsOverviewMaterial())
488 close_button_widget_->SetOpacity(opacity); 594 close_button_widget_->SetOpacity(opacity);
489 595
490 transform_window_.SetOpacity(opacity); 596 transform_window_.SetOpacity(opacity);
491 } 597 }
492 598
493 void WindowSelectorItem::UpdateWindowLabel( 599 void WindowSelectorItem::UpdateWindowLabel(
494 const gfx::Rect& window_bounds, 600 const gfx::Rect& window_bounds,
495 OverviewAnimationType animation_type) { 601 OverviewAnimationType animation_type) {
496 if (!window_label_->IsVisible()) { 602 if (!window_label_->IsVisible()) {
(...skipping 10 matching lines...) Expand all
507 animation_type, 613 animation_type,
508 WmLookup::Get()->GetWindowForWidget(window_label_.get())); 614 WmLookup::Get()->GetWindowForWidget(window_label_.get()));
509 615
510 WmWindow* window_label_window = 616 WmWindow* window_label_window =
511 WmLookup::Get()->GetWindowForWidget(window_label_.get()); 617 WmLookup::Get()->GetWindowForWidget(window_label_.get());
512 window_label_window->SetBounds(label_bounds); 618 window_label_window->SetBounds(label_bounds);
513 } 619 }
514 620
515 void WindowSelectorItem::CreateWindowLabel(const base::string16& title) { 621 void WindowSelectorItem::CreateWindowLabel(const base::string16& title) {
516 const bool material = ash::MaterialDesignController::IsOverviewMaterial(); 622 const bool material = ash::MaterialDesignController::IsOverviewMaterial();
517 window_label_.reset(new views::Widget); 623
518 views::Widget::InitParams params; 624 if (material) {
519 params.type = views::Widget::InitParams::TYPE_POPUP; 625 background_view_ = new RoundedContainerView(
bruthig 2016/09/02 16:00:12 nit: It would be helpful to have a comment about w
varkha 2016/09/08 00:09:50 Done.
520 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 626 this, kLabelBackgroundRadius, transform_window_.GetTopColor());
521 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; 627 }
522 params.visible_on_all_workspaces = true; 628
523 params.name = "OverviewModeLabel"; 629 views::Widget::InitParams params_label;
524 window_label_->set_focus_on_creation(false); 630 params_label.type = views::Widget::InitParams::TYPE_POPUP;
631 params_label.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
632 params_label.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
633 params_label.visible_on_all_workspaces = true;
634 params_label.name = "OverviewModeLabel";
635 params_label.activatable =
636 views::Widget::InitParams::Activatable::ACTIVATABLE_DEFAULT;
637 params_label.accept_events = true;
525 root_window_->GetRootWindowController() 638 root_window_->GetRootWindowController()
526 ->ConfigureWidgetInitParamsForContainer( 639 ->ConfigureWidgetInitParamsForContainer(
527 window_label_.get(), kShellWindowId_StatusContainer, &params); 640 window_label_.get(),
528 window_label_->Init(params); 641 transform_window_.window()->GetParent()->GetShellWindowId(),
642 &params_label);
643 window_label_.reset(new views::Widget);
644 window_label_->set_focus_on_creation(false);
645 window_label_->Init(params_label);
529 window_label_button_view_ = new OverviewLabelButton(this, title); 646 window_label_button_view_ = new OverviewLabelButton(this, title);
530 window_label_button_view_->SetBorder(views::Border::NullBorder()); 647 window_label_button_view_->SetBorder(views::Border::NullBorder());
531 window_label_button_view_->SetEnabledTextColors(kLabelColor); 648 window_label_button_view_->SetEnabledTextColors(kLabelColor);
532 window_label_button_view_->set_animate_on_state_change(false); 649 window_label_button_view_->set_animate_on_state_change(false);
533 if (material) { 650 if (material) {
651 WmWindow* label_window =
652 WmLookup::Get()->GetWindowForWidget(window_label_.get());
653 label_window->GetParent()->StackChildAbove(label_window,
654 transform_window_.window());
534 window_label_button_view_->SetHorizontalAlignment(gfx::ALIGN_LEFT); 655 window_label_button_view_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
535 } else { 656 } else {
536 window_label_button_view_->SetHorizontalAlignment(gfx::ALIGN_CENTER); 657 window_label_button_view_->SetHorizontalAlignment(gfx::ALIGN_CENTER);
537 window_label_button_view_->SetTextShadows(gfx::ShadowValues( 658 window_label_button_view_->SetTextShadows(gfx::ShadowValues(
538 1, gfx::ShadowValue(gfx::Vector2d(0, kVerticalShadowOffset), 659 1, gfx::ShadowValue(gfx::Vector2d(0, kVerticalShadowOffset),
539 kShadowBlur, kLabelShadow))); 660 kShadowBlur, kLabelShadow)));
540 } 661 }
541 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); 662 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
542 window_label_button_view_->SetFontList(bundle.GetFontList( 663 window_label_button_view_->SetFontList(bundle.GetFontList(
543 material ? ui::ResourceBundle::BaseFont : ui::ResourceBundle::BoldFont)); 664 material ? ui::ResourceBundle::BaseFont : ui::ResourceBundle::BoldFont));
544 if (material) { 665 if (material) {
545 // Hint at the background color that the label will be drawn onto (for 666 // Hint at the background color that the label will be drawn onto (for
546 // subpixel antialiasing). Does not actually set the background color. 667 // subpixel antialiasing). Does not actually set the background color.
547 window_label_button_view_->SetBackgroundColorHint(kLabelBackgroundColor); 668 window_label_button_view_->SetBackgroundColorHint(kLabelBackgroundColor);
548 caption_container_view_ = 669 caption_container_view_ = new CaptionContainerView(
549 new CaptionContainerView(window_label_button_view_, close_button_); 670 window_label_button_view_, close_button_, background_view_);
550 window_label_->SetContentsView(caption_container_view_); 671 window_label_->SetContentsView(caption_container_view_);
551 window_label_button_view_->SetVisible(false); 672 window_label_button_view_->SetVisible(false);
673 window_label_->SetOpacity(0);
552 window_label_->Show(); 674 window_label_->Show();
553 675
554 shadow_.reset(new ::wm::Shadow()); 676 shadow_.reset(new ::wm::Shadow());
555 shadow_->Init(::wm::Shadow::STYLE_INACTIVE); 677 shadow_->Init(::wm::Shadow::STYLE_INACTIVE);
556 shadow_->layer()->SetVisible(true); 678 shadow_->layer()->SetVisible(true);
557 window_label_->GetLayer()->Add(shadow_->layer()); 679 window_label_->GetLayer()->Add(shadow_->layer());
558 window_label_->GetLayer()->SetMasksToBounds(false); 680 window_label_->GetLayer()->SetMasksToBounds(false);
559 681 UpdateHeaderLayout(OverviewAnimationType::OVERVIEW_ANIMATION_NONE);
560 views::View* background_view =
561 new RoundedContainerView(kLabelBackgroundRadius, kLabelBackgroundColor);
562 window_label_selector_.reset(new views::Widget);
563 params.activatable = views::Widget::InitParams::Activatable::ACTIVATABLE_NO;
564 params.accept_events = false;
565 params.name = "OverviewModeLabelSelector";
566 window_label_selector_->Init(params);
567 window_label_selector_->set_focus_on_creation(false);
568 window_label_selector_->SetContentsView(background_view);
569 window_label_selector_->Show();
570 } else { 682 } else {
571 // Indicate that the label will be drawn onto a transparent background 683 // Indicate that the label will be drawn onto a transparent background
572 // (disables subpixel antialiasing). 684 // (disables subpixel antialiasing).
573 window_label_button_view_->SetBackgroundColorHint(SK_ColorTRANSPARENT); 685 window_label_button_view_->SetBackgroundColorHint(SK_ColorTRANSPARENT);
574 window_label_->SetContentsView(window_label_button_view_); 686 window_label_->SetContentsView(window_label_button_view_);
575 } 687 }
688 first_time_update_ = false;
576 } 689 }
577 690
578 void WindowSelectorItem::UpdateHeaderLayout( 691 void WindowSelectorItem::UpdateHeaderLayout(
579 OverviewAnimationType animation_type) { 692 OverviewAnimationType animation_type) {
580 gfx::Rect transformed_window_bounds = root_window_->ConvertRectFromScreen( 693 gfx::Rect transformed_window_bounds = root_window_->ConvertRectFromScreen(
581 transform_window_.GetTransformedBounds(hide_header())); 694 transform_window_.GetTransformedBounds(hide_header()));
582 695
583 if (ash::MaterialDesignController::IsOverviewMaterial()) { 696 if (ash::MaterialDesignController::IsOverviewMaterial()) {
584 gfx::Rect label_rect(close_button_->GetPreferredSize()); 697 gfx::Rect label_rect(close_button_->GetPreferredSize());
585 label_rect.set_y(-label_rect.height());
586 label_rect.set_width(transformed_window_bounds.width()); 698 label_rect.set_width(transformed_window_bounds.width());
587 699 // For tabbed windows the initial bounds of the caption are set such that it
700 // appears to be "growing" up from the window content area.
701 label_rect.set_y(first_time_update_ ? -transform_window_.GetTopInset()
702 : -label_rect.height());
588 if (!window_label_button_view_->visible()) { 703 if (!window_label_button_view_->visible()) {
589 window_label_button_view_->SetVisible(true); 704 window_label_button_view_->SetVisible(true);
bruthig 2016/09/02 16:00:12 Am I correct that this SetVisible() call invokes a
varkha 2016/09/08 00:09:50 I don't think so. |window_label_button_view_| is j
bruthig 2016/09/08 18:32:49 Acknowledged.
705 if (background_view_) {
706 background_view_->ObserveLayer(window_label_->GetLayer());
707 background_view_->set_color(kLabelBackgroundColor);
708 }
590 SetupFadeInAfterLayout(window_label_.get()); 709 SetupFadeInAfterLayout(window_label_.get());
591 SetupFadeInAfterLayout(window_label_selector_.get());
592 } 710 }
593 WmWindow* window_label_window = 711 WmWindow* window_label_window =
594 WmLookup::Get()->GetWindowForWidget(window_label_.get()); 712 WmLookup::Get()->GetWindowForWidget(window_label_.get());
595 WmWindow* window_label_selector_window =
596 WmLookup::Get()->GetWindowForWidget(window_label_selector_.get());
597 std::unique_ptr<ScopedOverviewAnimationSettings> animation_settings = 713 std::unique_ptr<ScopedOverviewAnimationSettings> animation_settings =
598 ScopedOverviewAnimationSettingsFactory::Get() 714 ScopedOverviewAnimationSettingsFactory::Get()
599 ->CreateOverviewAnimationSettings(animation_type, 715 ->CreateOverviewAnimationSettings(animation_type,
600 window_label_window); 716 window_label_window);
601 std::unique_ptr<ScopedOverviewAnimationSettings>
602 animation_settings_selector =
603 ScopedOverviewAnimationSettingsFactory::Get()
604 ->CreateOverviewAnimationSettings(animation_type,
605 window_label_selector_window);
606 window_label_selector_window->SetBounds(label_rect);
607 // |window_label_window| covers both the transformed window and the header 717 // |window_label_window| covers both the transformed window and the header
608 // as well as the gap between the windows to prevent events from reaching 718 // as well as the gap between the windows to prevent events from reaching
609 // the window including its sizing borders. 719 // the window including its sizing borders.
610 label_rect.set_height(label_rect.height() + 720 if (!first_time_update_) {
611 transformed_window_bounds.height()); 721 label_rect.set_height(close_button_->GetPreferredSize().height() +
612 gfx::Rect shadow_bounds(label_rect.size()); 722 transformed_window_bounds.height());
723 }
613 label_rect.Inset(-kWindowSelectorMargin, -kWindowSelectorMargin); 724 label_rect.Inset(-kWindowSelectorMargin, -kWindowSelectorMargin);
614 window_label_window->SetBounds(label_rect); 725 window_label_window->SetBounds(label_rect);
615 gfx::Transform label_transform; 726 gfx::Transform label_transform;
616 label_transform.Translate(transformed_window_bounds.x(), 727 label_transform.Translate(transformed_window_bounds.x(),
617 transformed_window_bounds.y()); 728 transformed_window_bounds.y());
618 window_label_window->SetTransform(label_transform); 729 window_label_window->SetTransform(label_transform);
619 window_label_selector_window->SetTransform(label_transform);
620 730
621 shadow_bounds.Offset(kWindowSelectorMargin, kWindowSelectorMargin); 731 gfx::Rect shadow_bounds(label_rect.size());
622 shadow_->SetContentBounds(shadow_bounds); 732 shadow_bounds.Inset(kWindowSelectorMargin, kWindowSelectorMargin);
733 if (shadow_)
734 shadow_->SetContentBounds(shadow_bounds);
623 } else { 735 } else {
624 if (!close_button_->visible()) { 736 if (!close_button_->visible()) {
625 close_button_->SetVisible(true); 737 close_button_->SetVisible(true);
626 SetupFadeInAfterLayout(close_button_widget_.get()); 738 SetupFadeInAfterLayout(close_button_widget_.get());
627 } 739 }
628 WmWindow* close_button_widget_window = 740 WmWindow* close_button_widget_window =
629 WmLookup::Get()->GetWindowForWidget(close_button_widget_.get()); 741 WmLookup::Get()->GetWindowForWidget(close_button_widget_.get());
630 std::unique_ptr<ScopedOverviewAnimationSettings> animation_settings = 742 std::unique_ptr<ScopedOverviewAnimationSettings> animation_settings =
631 ScopedOverviewAnimationSettingsFactory::Get() 743 ScopedOverviewAnimationSettingsFactory::Get()
632 ->CreateOverviewAnimationSettings(animation_type, 744 ->CreateOverviewAnimationSettings(animation_type,
633 close_button_widget_window); 745 close_button_widget_window);
634 746
635 gfx::Transform close_button_transform; 747 gfx::Transform close_button_transform;
636 close_button_transform.Translate(transformed_window_bounds.right(), 748 close_button_transform.Translate(transformed_window_bounds.right(),
637 transformed_window_bounds.y()); 749 transformed_window_bounds.y());
638 close_button_widget_window->SetTransform(close_button_transform); 750 close_button_widget_window->SetTransform(close_button_transform);
639 } 751 }
640 } 752 }
641 753
642 void WindowSelectorItem::AnimateOpacity(float opacity, 754 void WindowSelectorItem::AnimateOpacity(float opacity,
643 OverviewAnimationType animation_type) { 755 OverviewAnimationType animation_type) {
644 DCHECK_GE(opacity, 0.f); 756 DCHECK_GE(opacity, 0.f);
645 DCHECK_LE(opacity, 1.f); 757 DCHECK_LE(opacity, 1.f);
646 ScopedTransformOverviewWindow::ScopedAnimationSettings animation_settings; 758 ScopedTransformOverviewWindow::ScopedAnimationSettings animation_settings;
647 transform_window_.BeginScopedAnimation(animation_type, &animation_settings); 759 transform_window_.BeginScopedAnimation(animation_type, &animation_settings);
648 transform_window_.SetOpacity(opacity); 760 transform_window_.SetOpacity(opacity);
649 761
762 const float header_opacity = selected_ ? 0.f : kHeaderOpacity * opacity;
650 WmWindow* window_label_window = 763 WmWindow* window_label_window =
651 WmLookup::Get()->GetWindowForWidget(window_label_.get()); 764 WmLookup::Get()->GetWindowForWidget(window_label_.get());
652 std::unique_ptr<ScopedOverviewAnimationSettings> animation_settings_label = 765 std::unique_ptr<ScopedOverviewAnimationSettings> animation_settings_label =
653 ScopedOverviewAnimationSettingsFactory::Get() 766 ScopedOverviewAnimationSettingsFactory::Get()
654 ->CreateOverviewAnimationSettings(animation_type, 767 ->CreateOverviewAnimationSettings(animation_type,
655 window_label_window); 768 window_label_window);
656 window_label_window->SetOpacity(opacity); 769 window_label_window->SetOpacity(header_opacity);
657
658 WmWindow* window_label_selector_window =
659 WmLookup::Get()->GetWindowForWidget(window_label_selector_.get());
660 std::unique_ptr<ScopedOverviewAnimationSettings> animation_settings_selector =
661 ScopedOverviewAnimationSettingsFactory::Get()
662 ->CreateOverviewAnimationSettings(animation_type,
663 window_label_selector_window);
664 window_label_selector_window->SetOpacity(opacity);
665 } 770 }
666 771
667 void WindowSelectorItem::UpdateCloseButtonAccessibilityName() { 772 void WindowSelectorItem::UpdateCloseButtonAccessibilityName() {
668 close_button_->SetAccessibleName(l10n_util::GetStringFUTF16( 773 close_button_->SetAccessibleName(l10n_util::GetStringFUTF16(
669 IDS_ASH_OVERVIEW_CLOSE_ITEM_BUTTON_ACCESSIBLE_NAME, 774 IDS_ASH_OVERVIEW_CLOSE_ITEM_BUTTON_ACCESSIBLE_NAME,
670 GetWindow()->GetTitle())); 775 GetWindow()->GetTitle()));
671 } 776 }
672 777
778 void WindowSelectorItem::FadeOut(std::unique_ptr<views::Widget> widget) {
779 widget->SetOpacity(1.f);
780
781 // Fade out the widget. This animation continues past the lifetime of |this|.
782 // TODO(varkha): Add a new OverviewAnimationType for this.
783 WmWindow* widget_window = WmLookup::Get()->GetWindowForWidget(widget.get());
784 widget_window->GetLayer()->GetAnimator()->SchedulePauseForProperties(
785 base::TimeDelta::FromMilliseconds(kTransitionMilliseconds / 4),
786 ui::LayerAnimationElement::OPACITY);
787 ui::ScopedLayerAnimationSettings animation_settings(
788 widget_window->GetLayer()->GetAnimator());
789 animation_settings.SetTransitionDuration(
790 base::TimeDelta::FromMilliseconds(kTransitionMilliseconds / 4 * 3));
791 animation_settings.SetTweenType(gfx::Tween::EASE_OUT);
792 animation_settings.SetPreemptionStrategy(
793 ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS);
794 // CleanupAnimationObserver will delete itself (and the widget) when the
795 // opacity animation is complete.
796 // Ownership over the observer is passed to the window_selector_->delegate()
797 // which has longer lifetime so that animations can continue even after the
798 // overview mode is shut down.
799 views::Widget* widget_ptr = widget.get();
800 std::unique_ptr<CleanupAnimationObserver> observer(
801 new CleanupAnimationObserver(std::move(widget)));
802 animation_settings.AddObserver(observer.get());
803 window_selector_->delegate()->AddDelayedAnimationObserver(
804 std::move(observer));
805 widget_ptr->SetOpacity(0.f);
806 }
807
673 } // namespace ash 808 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698