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

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"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 static const int kWindowSelectorMargin = kWindowMarginMD * 2; 62 static const int kWindowSelectorMargin = kWindowMarginMD * 2;
62 63
63 // Foreground label color. 64 // Foreground label color.
64 static const SkColor kLabelColor = SK_ColorWHITE; 65 static const SkColor kLabelColor = SK_ColorWHITE;
65 66
66 // TODO(tdanderson): Move this to a central location. 67 // TODO(tdanderson): Move this to a central location.
67 static const SkColor kCloseButtonColor = SK_ColorWHITE; 68 static const SkColor kCloseButtonColor = SK_ColorWHITE;
68 69
69 // Label background color used with Material Design. 70 // Label background color used with Material Design.
70 // TODO(varkha): Make background color conform to window header. 71 // TODO(varkha): Make background color conform to window header.
71 static const SkColor kLabelBackgroundColor = SkColorSetARGB(25, 255, 255, 255); 72 static const SkColor kLabelBackgroundColor = SkColorSetARGB(254, 225, 225, 225);
72 73
73 // Corner radius for the selection tiles used with Material Design. 74 // Corner radius for the selection tiles used with Material Design.
74 static int kLabelBackgroundRadius = 2; 75 static int kLabelBackgroundRadius = 2;
75 76
76 // Label shadow color. 77 // Label shadow color.
77 static const SkColor kLabelShadow = SkColorSetARGB(176, 0, 0, 0); 78 static const SkColor kLabelShadow = SkColorSetARGB(176, 0, 0, 0);
78 79
79 // Vertical padding for the label, on top of it. 80 // Vertical padding for the label, on top of it.
80 static const int kVerticalLabelPadding = 20; 81 static const int kVerticalLabelPadding = 20;
81 82
82 // Horizontal padding for the label, on both sides. Used with Material Design. 83 // Horizontal padding for the label, on both sides. Used with Material Design.
83 static const int kHorizontalLabelPaddingMD = 8; 84 static const int kHorizontalLabelPaddingMD = 8;
84 85
85 // Solid shadow length from the label 86 // Solid shadow length from the label
86 static const int kVerticalShadowOffset = 1; 87 static const int kVerticalShadowOffset = 1;
87 88
88 // Amount of blur applied to the label shadow 89 // Amount of blur applied to the label shadow
89 static const int kShadowBlur = 10; 90 static const int kShadowBlur = 10;
90 91
91 // Height of an item header in Material Design. 92 // Height of an item header in Material Design.
92 static const int kHeaderHeight = 32; 93 static const int kHeaderHeight = 32;
93 94
94 // Opacity for dimmed items. 95 // Opacity for dimmed items.
95 static const float kDimmedItemOpacity = 0.5f; 96 static const float kDimmedItemOpacity = 0.5f;
96 97
97 // Opacity for fading out during closing a window. 98 // Opacity for fading out during closing a window.
98 static const float kClosingItemOpacity = 0.8f; 99 static const float kClosingItemOpacity = 0.8f;
99 100
101 // Opacity for the item header.
102 static const float kHeaderOpacity = 0.2f;
103
100 // Duration of background opacity transition for the selected label. 104 // Duration of background opacity transition for the selected label.
101 static const int kSelectorFadeInMilliseconds = 350; 105 static const int kSelectorFadeInMilliseconds = 350;
102 106
107 // The time duration for fade out animations when exiting overview mode.
108 const int kTransitionMilliseconds = 300;
bruthig 2016/08/30 17:57:33 Should this have 'static' just like the rest of th
varkha 2016/09/02 11:22:51 Done.
109
103 // Before closing a window animate both the window and the caption to shrink by 110 // Before closing a window animate both the window and the caption to shrink by
104 // this fraction of size. 111 // this fraction of size.
105 static const float kPreCloseScale = 0.02f; 112 static const float kPreCloseScale = 0.02f;
106 113
107 // Convenience method to fade in a Window with predefined animation settings. 114 // 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 115 // Note: The fade in animation will occur after a delay where the delay is how
109 // long the lay out animations take. 116 // long the lay out animations take.
110 void SetupFadeInAfterLayout(views::Widget* widget) { 117 void SetupFadeInAfterLayout(views::Widget* widget) {
111 WmWindow* window = WmLookup::Get()->GetWindowForWidget(widget); 118 WmWindow* window = WmLookup::Get()->GetWindowForWidget(widget);
112 window->SetOpacity(0.0f); 119 window->SetOpacity(0.0f);
113 std::unique_ptr<ScopedOverviewAnimationSettings> 120 std::unique_ptr<ScopedOverviewAnimationSettings>
114 scoped_overview_animation_settings = 121 scoped_overview_animation_settings =
115 ScopedOverviewAnimationSettingsFactory::Get() 122 ScopedOverviewAnimationSettingsFactory::Get()
116 ->CreateOverviewAnimationSettings( 123 ->CreateOverviewAnimationSettings(
117 OverviewAnimationType:: 124 OverviewAnimationType::
118 OVERVIEW_ANIMATION_ENTER_OVERVIEW_MODE_FADE_IN, 125 OVERVIEW_ANIMATION_ENTER_OVERVIEW_MODE_FADE_IN,
119 window); 126 window);
120 window->SetOpacity(1.0f); 127 window->SetOpacity(1.0f);
121 } 128 }
122 129
130 void SetupOpacityAfterLayout(views::Widget* widget) {
131 WmWindow* window = WmLookup::Get()->GetWindowForWidget(widget);
132 std::unique_ptr<ScopedOverviewAnimationSettings>
133 scoped_overview_animation_settings =
134 ScopedOverviewAnimationSettingsFactory::Get()
135 ->CreateOverviewAnimationSettings(
136 OverviewAnimationType::OVERVIEW_ANIMATION_FADE_IN_HEADER,
137 window);
138 window->SetOpacity(kHeaderOpacity);
139 }
140
123 // An image button with a close window icon. 141 // An image button with a close window icon.
124 class OverviewCloseButton : public views::ImageButton { 142 class OverviewCloseButton : public views::ImageButton {
125 public: 143 public:
126 explicit OverviewCloseButton(views::ButtonListener* listener); 144 explicit OverviewCloseButton(views::ButtonListener* listener);
127 ~OverviewCloseButton() override; 145 ~OverviewCloseButton() override;
128 146
129 private: 147 private:
130 gfx::ImageSkia icon_image_; 148 gfx::ImageSkia icon_image_;
131 149
132 DISALLOW_COPY_AND_ASSIGN(OverviewCloseButton); 150 DISALLOW_COPY_AND_ASSIGN(OverviewCloseButton);
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 276
259 DISALLOW_COPY_AND_ASSIGN(CaptionContainerView); 277 DISALLOW_COPY_AND_ASSIGN(CaptionContainerView);
260 }; 278 };
261 279
262 WindowSelectorItem::WindowSelectorItem(WmWindow* window, 280 WindowSelectorItem::WindowSelectorItem(WmWindow* window,
263 WindowSelector* window_selector) 281 WindowSelector* window_selector)
264 : dimmed_(false), 282 : dimmed_(false),
265 root_window_(window->GetRootWindow()), 283 root_window_(window->GetRootWindow()),
266 transform_window_(window), 284 transform_window_(window),
267 in_bounds_update_(false), 285 in_bounds_update_(false),
286 selected_(false),
287 first_time_(true),
268 caption_container_view_(nullptr), 288 caption_container_view_(nullptr),
269 window_label_button_view_(nullptr), 289 window_label_button_view_(nullptr),
270 close_button_(new OverviewCloseButton(this)), 290 close_button_(new OverviewCloseButton(this)),
271 window_selector_(window_selector) { 291 window_selector_(window_selector) {
272 CreateWindowLabel(window->GetTitle()); 292 CreateWindowLabel(window->GetTitle());
273 if (!ash::MaterialDesignController::IsOverviewMaterial()) { 293 if (!ash::MaterialDesignController::IsOverviewMaterial()) {
274 views::Widget::InitParams params; 294 views::Widget::InitParams params;
275 params.type = views::Widget::InitParams::TYPE_POPUP; 295 params.type = views::Widget::InitParams::TYPE_POPUP;
276 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 296 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
277 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; 297 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
(...skipping 24 matching lines...) Expand all
302 WindowSelectorItem::~WindowSelectorItem() { 322 WindowSelectorItem::~WindowSelectorItem() {
303 GetWindow()->RemoveObserver(this); 323 GetWindow()->RemoveObserver(this);
304 } 324 }
305 325
306 WmWindow* WindowSelectorItem::GetWindow() { 326 WmWindow* WindowSelectorItem::GetWindow() {
307 return transform_window_.window(); 327 return transform_window_.window();
308 } 328 }
309 329
310 void WindowSelectorItem::RestoreWindow() { 330 void WindowSelectorItem::RestoreWindow() {
311 transform_window_.RestoreWindow(); 331 transform_window_.RestoreWindow();
332 UpdateHeaderLayout(
333 OverviewAnimationType::OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS);
334 FadeOut(std::move(window_label_));
335 if (window_label_selector_)
336 FadeOut(std::move(window_label_selector_));
312 } 337 }
313 338
314 void WindowSelectorItem::ShowWindowOnExit() { 339 void WindowSelectorItem::ShowWindowOnExit() {
315 transform_window_.ShowWindowOnExit(); 340 transform_window_.ShowWindowOnExit();
316 } 341 }
317 342
318 void WindowSelectorItem::PrepareForOverview() { 343 void WindowSelectorItem::PrepareForOverview() {
319 transform_window_.PrepareForOverview(); 344 transform_window_.PrepareForOverview();
320 } 345 }
321 346
(...skipping 18 matching lines...) Expand all
340 // SetItemBounds is called before UpdateHeaderLayout so the header can 365 // SetItemBounds is called before UpdateHeaderLayout so the header can
341 // properly use the updated windows bounds. 366 // properly use the updated windows bounds.
342 UpdateHeaderLayout(animation_type); 367 UpdateHeaderLayout(animation_type);
343 if (!ash::MaterialDesignController::IsOverviewMaterial()) 368 if (!ash::MaterialDesignController::IsOverviewMaterial())
344 UpdateWindowLabel(target_bounds, animation_type); 369 UpdateWindowLabel(target_bounds, animation_type);
345 } 370 }
346 371
347 void WindowSelectorItem::SetSelected(bool selected) { 372 void WindowSelectorItem::SetSelected(bool selected) {
348 if (!ash::MaterialDesignController::IsOverviewMaterial()) 373 if (!ash::MaterialDesignController::IsOverviewMaterial())
349 return; 374 return;
375 selected_ = selected;
350 WmWindow* window = 376 WmWindow* window =
351 WmLookup::Get()->GetWindowForWidget(window_label_selector_.get()); 377 WmLookup::Get()->GetWindowForWidget(window_label_selector_.get());
352 ui::ScopedLayerAnimationSettings animation_settings( 378 ui::ScopedLayerAnimationSettings animation_settings(
353 window->GetLayer()->GetAnimator()); 379 window->GetLayer()->GetAnimator());
354 animation_settings.SetTransitionDuration( 380 animation_settings.SetTransitionDuration(
355 base::TimeDelta::FromMilliseconds(kSelectorFadeInMilliseconds)); 381 base::TimeDelta::FromMilliseconds(kSelectorFadeInMilliseconds));
356 animation_settings.SetTweenType(selected ? gfx::Tween::FAST_OUT_LINEAR_IN 382 animation_settings.SetTweenType(selected ? gfx::Tween::FAST_OUT_LINEAR_IN
357 : gfx::Tween::LINEAR_OUT_SLOW_IN); 383 : gfx::Tween::LINEAR_OUT_SLOW_IN);
358 animation_settings.SetPreemptionStrategy( 384 animation_settings.SetPreemptionStrategy(
359 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); 385 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
360 window->SetOpacity(selected ? 0.0f : 1.0f); 386 window->SetOpacity(selected ? 0.0f : kHeaderOpacity);
361 387
362 ui::ScopedLayerAnimationSettings animation_settings_shadow( 388 ui::ScopedLayerAnimationSettings animation_settings_shadow(
363 shadow_->shadow_layer()->GetAnimator()); 389 shadow_->shadow_layer()->GetAnimator());
364 animation_settings_shadow.SetTransitionDuration( 390 animation_settings_shadow.SetTransitionDuration(
365 base::TimeDelta::FromMilliseconds(kSelectorFadeInMilliseconds)); 391 base::TimeDelta::FromMilliseconds(kSelectorFadeInMilliseconds));
366 animation_settings_shadow.SetTweenType(selected 392 animation_settings_shadow.SetTweenType(selected
367 ? gfx::Tween::FAST_OUT_LINEAR_IN 393 ? gfx::Tween::FAST_OUT_LINEAR_IN
368 : gfx::Tween::LINEAR_OUT_SLOW_IN); 394 : gfx::Tween::LINEAR_OUT_SLOW_IN);
369 animation_settings_shadow.SetPreemptionStrategy( 395 animation_settings_shadow.SetPreemptionStrategy(
370 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); 396 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 screen_rect, target_bounds, top_view_inset, title_height); 497 screen_rect, target_bounds, top_view_inset, title_height);
472 gfx::Transform transform = ScopedTransformOverviewWindow::GetTransformForRect( 498 gfx::Transform transform = ScopedTransformOverviewWindow::GetTransformForRect(
473 screen_rect, selector_item_bounds); 499 screen_rect, selector_item_bounds);
474 ScopedTransformOverviewWindow::ScopedAnimationSettings animation_settings; 500 ScopedTransformOverviewWindow::ScopedAnimationSettings animation_settings;
475 transform_window_.BeginScopedAnimation(animation_type, &animation_settings); 501 transform_window_.BeginScopedAnimation(animation_type, &animation_settings);
476 // Rounded corners are achieved by using a mask layer on the original window 502 // Rounded corners are achieved by using a mask layer on the original window
477 // before the transform. Dividing by scale factor obtains the corner radius 503 // before the transform. Dividing by scale factor obtains the corner radius
478 // which when scaled will yield |kLabelBackgroundRadius|. 504 // which when scaled will yield |kLabelBackgroundRadius|.
479 transform_window_.SetTransform( 505 transform_window_.SetTransform(
480 root_window_, transform, use_mask_, use_shape_, 506 root_window_, transform, use_mask_, use_shape_,
481 (kLabelBackgroundRadius / GetItemScale(target_bounds.size()))); 507 (kLabelBackgroundRadius / GetItemScale(target_bounds.size())),
508 animation_type != OverviewAnimationType::OVERVIEW_ANIMATION_NONE);
482 transform_window_.set_overview_transform(transform); 509 transform_window_.set_overview_transform(transform);
483 } 510 }
484 511
485 void WindowSelectorItem::SetOpacity(float opacity) { 512 void WindowSelectorItem::SetOpacity(float opacity) {
486 window_label_->SetOpacity(opacity); 513 window_label_->SetOpacity(opacity);
514 if (window_label_selector_) {
515 window_label_selector_->SetOpacity(selected_ ? 0.f
516 : kHeaderOpacity * opacity);
517 }
518
487 if (!ash::MaterialDesignController::IsOverviewMaterial()) 519 if (!ash::MaterialDesignController::IsOverviewMaterial())
488 close_button_widget_->SetOpacity(opacity); 520 close_button_widget_->SetOpacity(opacity);
489 521
490 transform_window_.SetOpacity(opacity); 522 transform_window_.SetOpacity(opacity);
491 } 523 }
492 524
493 void WindowSelectorItem::UpdateWindowLabel( 525 void WindowSelectorItem::UpdateWindowLabel(
494 const gfx::Rect& window_bounds, 526 const gfx::Rect& window_bounds,
495 OverviewAnimationType animation_type) { 527 OverviewAnimationType animation_type) {
496 if (!window_label_->IsVisible()) { 528 if (!window_label_->IsVisible()) {
(...skipping 10 matching lines...) Expand all
507 animation_type, 539 animation_type,
508 WmLookup::Get()->GetWindowForWidget(window_label_.get())); 540 WmLookup::Get()->GetWindowForWidget(window_label_.get()));
509 541
510 WmWindow* window_label_window = 542 WmWindow* window_label_window =
511 WmLookup::Get()->GetWindowForWidget(window_label_.get()); 543 WmLookup::Get()->GetWindowForWidget(window_label_.get());
512 window_label_window->SetBounds(label_bounds); 544 window_label_window->SetBounds(label_bounds);
513 } 545 }
514 546
515 void WindowSelectorItem::CreateWindowLabel(const base::string16& title) { 547 void WindowSelectorItem::CreateWindowLabel(const base::string16& title) {
516 const bool material = ash::MaterialDesignController::IsOverviewMaterial(); 548 const bool material = ash::MaterialDesignController::IsOverviewMaterial();
517 window_label_.reset(new views::Widget);
518 views::Widget::InitParams params; 549 views::Widget::InitParams params;
519 params.type = views::Widget::InitParams::TYPE_POPUP; 550 params.type = views::Widget::InitParams::TYPE_POPUP;
520 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 551 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
521 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; 552 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
522 params.visible_on_all_workspaces = true; 553 params.visible_on_all_workspaces = true;
523 params.name = "OverviewModeLabel"; 554 params.name = "OverviewModeLabel";
524 window_label_->set_focus_on_creation(false);
525 root_window_->GetRootWindowController() 555 root_window_->GetRootWindowController()
526 ->ConfigureWidgetInitParamsForContainer( 556 ->ConfigureWidgetInitParamsForContainer(
527 window_label_.get(), kShellWindowId_StatusContainer, &params); 557 window_label_.get(), kShellWindowId_StatusContainer, &params);
558
559 if (material) {
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;
bruthig 2016/08/30 17:57:33 I feel like re-using |params| like this creates mo
varkha 2016/09/02 11:22:51 I've managed to kill the second widget with some r
564 params.accept_events = false;
565 window_label_selector_->Init(params);
566 window_label_selector_->set_focus_on_creation(false);
567 window_label_selector_->SetContentsView(background_view);
568 window_label_selector_->Show();
569 }
570
571 params.activatable =
572 views::Widget::InitParams::Activatable::ACTIVATABLE_DEFAULT;
573 params.accept_events = true;
574 params.name = "OverviewModeLabelSelector";
575 window_label_.reset(new views::Widget);
576 window_label_->set_focus_on_creation(false);
528 window_label_->Init(params); 577 window_label_->Init(params);
529 window_label_button_view_ = new OverviewLabelButton(this, title); 578 window_label_button_view_ = new OverviewLabelButton(this, title);
530 window_label_button_view_->SetBorder(views::Border::NullBorder()); 579 window_label_button_view_->SetBorder(views::Border::NullBorder());
531 window_label_button_view_->SetEnabledTextColors(kLabelColor); 580 window_label_button_view_->SetEnabledTextColors(kLabelColor);
532 window_label_button_view_->set_animate_on_state_change(false); 581 window_label_button_view_->set_animate_on_state_change(false);
533 if (material) { 582 if (material) {
534 window_label_button_view_->SetHorizontalAlignment(gfx::ALIGN_LEFT); 583 window_label_button_view_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
535 } else { 584 } else {
536 window_label_button_view_->SetHorizontalAlignment(gfx::ALIGN_CENTER); 585 window_label_button_view_->SetHorizontalAlignment(gfx::ALIGN_CENTER);
537 window_label_button_view_->SetTextShadows(gfx::ShadowValues( 586 window_label_button_view_->SetTextShadows(gfx::ShadowValues(
(...skipping 11 matching lines...) Expand all
549 new CaptionContainerView(window_label_button_view_, close_button_); 598 new CaptionContainerView(window_label_button_view_, close_button_);
550 window_label_->SetContentsView(caption_container_view_); 599 window_label_->SetContentsView(caption_container_view_);
551 window_label_button_view_->SetVisible(false); 600 window_label_button_view_->SetVisible(false);
552 window_label_->Show(); 601 window_label_->Show();
553 602
554 shadow_.reset(new ::wm::Shadow()); 603 shadow_.reset(new ::wm::Shadow());
555 shadow_->Init(::wm::Shadow::STYLE_INACTIVE); 604 shadow_->Init(::wm::Shadow::STYLE_INACTIVE);
556 shadow_->layer()->SetVisible(true); 605 shadow_->layer()->SetVisible(true);
557 window_label_->GetLayer()->Add(shadow_->layer()); 606 window_label_->GetLayer()->Add(shadow_->layer());
558 window_label_->GetLayer()->SetMasksToBounds(false); 607 window_label_->GetLayer()->SetMasksToBounds(false);
559 608 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 { 609 } else {
571 // Indicate that the label will be drawn onto a transparent background 610 // Indicate that the label will be drawn onto a transparent background
572 // (disables subpixel antialiasing). 611 // (disables subpixel antialiasing).
573 window_label_button_view_->SetBackgroundColorHint(SK_ColorTRANSPARENT); 612 window_label_button_view_->SetBackgroundColorHint(SK_ColorTRANSPARENT);
574 window_label_->SetContentsView(window_label_button_view_); 613 window_label_->SetContentsView(window_label_button_view_);
575 } 614 }
615 first_time_ = false;
576 } 616 }
577 617
578 void WindowSelectorItem::UpdateHeaderLayout( 618 void WindowSelectorItem::UpdateHeaderLayout(
579 OverviewAnimationType animation_type) { 619 OverviewAnimationType animation_type) {
580 gfx::Rect transformed_window_bounds = root_window_->ConvertRectFromScreen( 620 gfx::Rect transformed_window_bounds = root_window_->ConvertRectFromScreen(
581 transform_window_.GetTransformedBounds(hide_header())); 621 transform_window_.GetTransformedBounds(hide_header()));
582 622
583 if (ash::MaterialDesignController::IsOverviewMaterial()) { 623 if (ash::MaterialDesignController::IsOverviewMaterial()) {
584 gfx::Rect label_rect(close_button_->GetPreferredSize()); 624 gfx::Rect label_rect(close_button_->GetPreferredSize());
585 label_rect.set_y(-label_rect.height()); 625 if (first_time_) {
626 if (transform_window_.GetTopInset() == 0) {
627 label_rect.set_y(0);
628 label_rect.set_height(0);
629 } else {
630 label_rect.set_y(-transform_window_.GetTopInset());
631 }
632 } else {
633 label_rect.set_y(-label_rect.height());
634 }
586 label_rect.set_width(transformed_window_bounds.width()); 635 label_rect.set_width(transformed_window_bounds.width());
587 636
588 if (!window_label_button_view_->visible()) { 637 if (!window_label_button_view_->visible()) {
589 window_label_button_view_->SetVisible(true); 638 window_label_button_view_->SetVisible(true);
590 SetupFadeInAfterLayout(window_label_.get()); 639 SetupFadeInAfterLayout(window_label_.get());
591 SetupFadeInAfterLayout(window_label_selector_.get()); 640 SetupFadeInAfterLayout(window_label_selector_.get());
641 SetupOpacityAfterLayout(window_label_selector_.get());
592 } 642 }
593 WmWindow* window_label_window = 643 WmWindow* window_label_window =
594 WmLookup::Get()->GetWindowForWidget(window_label_.get()); 644 WmLookup::Get()->GetWindowForWidget(window_label_.get());
595 WmWindow* window_label_selector_window = 645 WmWindow* window_label_selector_window =
596 WmLookup::Get()->GetWindowForWidget(window_label_selector_.get()); 646 WmLookup::Get()->GetWindowForWidget(window_label_selector_.get());
597 std::unique_ptr<ScopedOverviewAnimationSettings> animation_settings = 647 std::unique_ptr<ScopedOverviewAnimationSettings> animation_settings =
598 ScopedOverviewAnimationSettingsFactory::Get() 648 ScopedOverviewAnimationSettingsFactory::Get()
599 ->CreateOverviewAnimationSettings(animation_type, 649 ->CreateOverviewAnimationSettings(animation_type,
600 window_label_window); 650 window_label_window);
601 std::unique_ptr<ScopedOverviewAnimationSettings> 651 std::unique_ptr<ScopedOverviewAnimationSettings>
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 } 690 }
641 691
642 void WindowSelectorItem::AnimateOpacity(float opacity, 692 void WindowSelectorItem::AnimateOpacity(float opacity,
643 OverviewAnimationType animation_type) { 693 OverviewAnimationType animation_type) {
644 DCHECK_GE(opacity, 0.f); 694 DCHECK_GE(opacity, 0.f);
645 DCHECK_LE(opacity, 1.f); 695 DCHECK_LE(opacity, 1.f);
646 ScopedTransformOverviewWindow::ScopedAnimationSettings animation_settings; 696 ScopedTransformOverviewWindow::ScopedAnimationSettings animation_settings;
647 transform_window_.BeginScopedAnimation(animation_type, &animation_settings); 697 transform_window_.BeginScopedAnimation(animation_type, &animation_settings);
648 transform_window_.SetOpacity(opacity); 698 transform_window_.SetOpacity(opacity);
649 699
700 const float header_opacity = selected_ ? 0.f : kHeaderOpacity * opacity;
650 WmWindow* window_label_window = 701 WmWindow* window_label_window =
651 WmLookup::Get()->GetWindowForWidget(window_label_.get()); 702 WmLookup::Get()->GetWindowForWidget(window_label_.get());
652 std::unique_ptr<ScopedOverviewAnimationSettings> animation_settings_label = 703 std::unique_ptr<ScopedOverviewAnimationSettings> animation_settings_label =
653 ScopedOverviewAnimationSettingsFactory::Get() 704 ScopedOverviewAnimationSettingsFactory::Get()
654 ->CreateOverviewAnimationSettings(animation_type, 705 ->CreateOverviewAnimationSettings(animation_type,
655 window_label_window); 706 window_label_window);
656 window_label_window->SetOpacity(opacity); 707 window_label_window->SetOpacity(header_opacity);
657 708
658 WmWindow* window_label_selector_window = 709 WmWindow* window_label_selector_window =
659 WmLookup::Get()->GetWindowForWidget(window_label_selector_.get()); 710 WmLookup::Get()->GetWindowForWidget(window_label_selector_.get());
660 std::unique_ptr<ScopedOverviewAnimationSettings> animation_settings_selector = 711 std::unique_ptr<ScopedOverviewAnimationSettings> animation_settings_selector =
661 ScopedOverviewAnimationSettingsFactory::Get() 712 ScopedOverviewAnimationSettingsFactory::Get()
662 ->CreateOverviewAnimationSettings(animation_type, 713 ->CreateOverviewAnimationSettings(animation_type,
663 window_label_selector_window); 714 window_label_selector_window);
664 window_label_selector_window->SetOpacity(opacity); 715 window_label_selector_window->SetOpacity(header_opacity);
665 } 716 }
666 717
667 void WindowSelectorItem::UpdateCloseButtonAccessibilityName() { 718 void WindowSelectorItem::UpdateCloseButtonAccessibilityName() {
668 close_button_->SetAccessibleName(l10n_util::GetStringFUTF16( 719 close_button_->SetAccessibleName(l10n_util::GetStringFUTF16(
669 IDS_ASH_OVERVIEW_CLOSE_ITEM_BUTTON_ACCESSIBLE_NAME, 720 IDS_ASH_OVERVIEW_CLOSE_ITEM_BUTTON_ACCESSIBLE_NAME,
670 GetWindow()->GetTitle())); 721 GetWindow()->GetTitle()));
671 } 722 }
672 723
724 void WindowSelectorItem::FadeOut(std::unique_ptr<views::Widget> widget) {
725 widget->SetOpacity(1.f);
726
727 // Fade out the widget. This animation continues past the lifetime of |this|.
728 WmWindow* widget_window = WmLookup::Get()->GetWindowForWidget(widget.get());
729 ui::ScopedLayerAnimationSettings animation_settings(
bruthig 2016/08/30 17:57:33 For consistency, would it make more sense to add a
varkha 2016/09/02 11:22:51 Yes, will do.
730 widget_window->GetLayer()->GetAnimator());
731 animation_settings.SetTransitionDuration(
732 base::TimeDelta::FromMilliseconds(kTransitionMilliseconds));
733 animation_settings.SetTweenType(gfx::Tween::EASE_OUT);
734 animation_settings.SetPreemptionStrategy(
735 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
736 // CleanupAnimationObserver will delete itself (and the widget) when the
737 // opacity animation is complete.
738 // Ownership over the observer is passed to the window_selector_->delegate()
739 // which has longer lifetime so that animations can continue even after the
740 // overview mode is shut down.
741 views::Widget* widget_ptr = widget.get();
742 std::unique_ptr<CleanupAnimationObserver> observer(
743 new CleanupAnimationObserver(std::move(widget)));
744 animation_settings.AddObserver(observer.get());
745 window_selector_->delegate()->AddDelayedAnimationObserver(
746 std::move(observer));
747 widget_ptr->SetOpacity(0.f);
748 }
749
673 } // namespace ash 750 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698