| OLD | NEW |
| 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 Loading... |
| 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; |
| 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 Loading... |
| 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 23 matching lines...) Expand all Loading... |
| 301 WindowSelectorItem::~WindowSelectorItem() { | 321 WindowSelectorItem::~WindowSelectorItem() { |
| 302 GetWindow()->RemoveObserver(this); | 322 GetWindow()->RemoveObserver(this); |
| 303 } | 323 } |
| 304 | 324 |
| 305 WmWindow* WindowSelectorItem::GetWindow() { | 325 WmWindow* WindowSelectorItem::GetWindow() { |
| 306 return transform_window_.window(); | 326 return transform_window_.window(); |
| 307 } | 327 } |
| 308 | 328 |
| 309 void WindowSelectorItem::RestoreWindow() { | 329 void WindowSelectorItem::RestoreWindow() { |
| 310 transform_window_.RestoreWindow(); | 330 transform_window_.RestoreWindow(); |
| 331 UpdateHeaderLayout( |
| 332 OverviewAnimationType::OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS); |
| 333 FadeOut(std::move(window_label_)); |
| 334 if (window_label_selector_) |
| 335 FadeOut(std::move(window_label_selector_)); |
| 311 } | 336 } |
| 312 | 337 |
| 313 void WindowSelectorItem::ShowWindowOnExit() { | 338 void WindowSelectorItem::ShowWindowOnExit() { |
| 314 transform_window_.ShowWindowOnExit(); | 339 transform_window_.ShowWindowOnExit(); |
| 315 } | 340 } |
| 316 | 341 |
| 317 void WindowSelectorItem::PrepareForOverview() { | 342 void WindowSelectorItem::PrepareForOverview() { |
| 318 transform_window_.PrepareForOverview(); | 343 transform_window_.PrepareForOverview(); |
| 319 } | 344 } |
| 320 | 345 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 339 // SetItemBounds is called before UpdateHeaderLayout so the header can | 364 // SetItemBounds is called before UpdateHeaderLayout so the header can |
| 340 // properly use the updated windows bounds. | 365 // properly use the updated windows bounds. |
| 341 UpdateHeaderLayout(animation_type); | 366 UpdateHeaderLayout(animation_type); |
| 342 if (!ash::MaterialDesignController::IsOverviewMaterial()) | 367 if (!ash::MaterialDesignController::IsOverviewMaterial()) |
| 343 UpdateWindowLabel(target_bounds, animation_type); | 368 UpdateWindowLabel(target_bounds, animation_type); |
| 344 } | 369 } |
| 345 | 370 |
| 346 void WindowSelectorItem::SetSelected(bool selected) { | 371 void WindowSelectorItem::SetSelected(bool selected) { |
| 347 if (!ash::MaterialDesignController::IsOverviewMaterial()) | 372 if (!ash::MaterialDesignController::IsOverviewMaterial()) |
| 348 return; | 373 return; |
| 374 selected_ = selected; |
| 349 WmWindow* window = | 375 WmWindow* window = |
| 350 WmLookup::Get()->GetWindowForWidget(window_label_selector_.get()); | 376 WmLookup::Get()->GetWindowForWidget(window_label_selector_.get()); |
| 351 ui::ScopedLayerAnimationSettings animation_settings( | 377 ui::ScopedLayerAnimationSettings animation_settings( |
| 352 window->GetLayer()->GetAnimator()); | 378 window->GetLayer()->GetAnimator()); |
| 353 animation_settings.SetTransitionDuration( | 379 animation_settings.SetTransitionDuration( |
| 354 base::TimeDelta::FromMilliseconds(kSelectorFadeInMilliseconds)); | 380 base::TimeDelta::FromMilliseconds(kSelectorFadeInMilliseconds)); |
| 355 animation_settings.SetTweenType(selected ? gfx::Tween::FAST_OUT_LINEAR_IN | 381 animation_settings.SetTweenType(selected ? gfx::Tween::FAST_OUT_LINEAR_IN |
| 356 : gfx::Tween::LINEAR_OUT_SLOW_IN); | 382 : gfx::Tween::LINEAR_OUT_SLOW_IN); |
| 357 animation_settings.SetPreemptionStrategy( | 383 animation_settings.SetPreemptionStrategy( |
| 358 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | 384 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
| 359 window->SetOpacity(selected ? 0.0f : 1.0f); | 385 window->SetOpacity(selected ? 0.0f : kHeaderOpacity); |
| 360 | 386 |
| 361 ui::ScopedLayerAnimationSettings animation_settings_shadow( | 387 ui::ScopedLayerAnimationSettings animation_settings_shadow( |
| 362 shadow_->shadow_layer()->GetAnimator()); | 388 shadow_->shadow_layer()->GetAnimator()); |
| 363 animation_settings_shadow.SetTransitionDuration( | 389 animation_settings_shadow.SetTransitionDuration( |
| 364 base::TimeDelta::FromMilliseconds(kSelectorFadeInMilliseconds)); | 390 base::TimeDelta::FromMilliseconds(kSelectorFadeInMilliseconds)); |
| 365 animation_settings_shadow.SetTweenType(selected | 391 animation_settings_shadow.SetTweenType(selected |
| 366 ? gfx::Tween::FAST_OUT_LINEAR_IN | 392 ? gfx::Tween::FAST_OUT_LINEAR_IN |
| 367 : gfx::Tween::LINEAR_OUT_SLOW_IN); | 393 : gfx::Tween::LINEAR_OUT_SLOW_IN); |
| 368 animation_settings_shadow.SetPreemptionStrategy( | 394 animation_settings_shadow.SetPreemptionStrategy( |
| 369 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | 395 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 screen_rect, target_bounds, top_view_inset, title_height); | 496 screen_rect, target_bounds, top_view_inset, title_height); |
| 471 gfx::Transform transform = ScopedTransformOverviewWindow::GetTransformForRect( | 497 gfx::Transform transform = ScopedTransformOverviewWindow::GetTransformForRect( |
| 472 screen_rect, selector_item_bounds); | 498 screen_rect, selector_item_bounds); |
| 473 ScopedTransformOverviewWindow::ScopedAnimationSettings animation_settings; | 499 ScopedTransformOverviewWindow::ScopedAnimationSettings animation_settings; |
| 474 transform_window_.BeginScopedAnimation(animation_type, &animation_settings); | 500 transform_window_.BeginScopedAnimation(animation_type, &animation_settings); |
| 475 // Rounded corners are achieved by using a mask layer on the original window | 501 // Rounded corners are achieved by using a mask layer on the original window |
| 476 // before the transform. Dividing by scale factor obtains the corner radius | 502 // before the transform. Dividing by scale factor obtains the corner radius |
| 477 // which when scaled will yield |kLabelBackgroundRadius|. | 503 // which when scaled will yield |kLabelBackgroundRadius|. |
| 478 transform_window_.SetTransform( | 504 transform_window_.SetTransform( |
| 479 root_window_, transform, use_mask_, use_shape_, | 505 root_window_, transform, use_mask_, use_shape_, |
| 480 (kLabelBackgroundRadius / GetItemScale(target_bounds.size()))); | 506 (kLabelBackgroundRadius / GetItemScale(target_bounds.size())), |
| 507 animation_type != OverviewAnimationType::OVERVIEW_ANIMATION_NONE); |
| 481 transform_window_.set_overview_transform(transform); | 508 transform_window_.set_overview_transform(transform); |
| 482 } | 509 } |
| 483 | 510 |
| 484 void WindowSelectorItem::SetOpacity(float opacity) { | 511 void WindowSelectorItem::SetOpacity(float opacity) { |
| 485 window_label_->SetOpacity(opacity); | 512 window_label_->SetOpacity(opacity); |
| 513 if (window_label_selector_) { |
| 514 window_label_selector_->SetOpacity(selected_ ? 0.f |
| 515 : kHeaderOpacity * opacity); |
| 516 } |
| 517 |
| 486 if (!ash::MaterialDesignController::IsOverviewMaterial()) | 518 if (!ash::MaterialDesignController::IsOverviewMaterial()) |
| 487 close_button_widget_->SetOpacity(opacity); | 519 close_button_widget_->SetOpacity(opacity); |
| 488 | 520 |
| 489 transform_window_.SetOpacity(opacity); | 521 transform_window_.SetOpacity(opacity); |
| 490 } | 522 } |
| 491 | 523 |
| 492 void WindowSelectorItem::UpdateWindowLabel( | 524 void WindowSelectorItem::UpdateWindowLabel( |
| 493 const gfx::Rect& window_bounds, | 525 const gfx::Rect& window_bounds, |
| 494 OverviewAnimationType animation_type) { | 526 OverviewAnimationType animation_type) { |
| 495 if (!window_label_->IsVisible()) { | 527 if (!window_label_->IsVisible()) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 506 animation_type, | 538 animation_type, |
| 507 WmLookup::Get()->GetWindowForWidget(window_label_.get())); | 539 WmLookup::Get()->GetWindowForWidget(window_label_.get())); |
| 508 | 540 |
| 509 WmWindow* window_label_window = | 541 WmWindow* window_label_window = |
| 510 WmLookup::Get()->GetWindowForWidget(window_label_.get()); | 542 WmLookup::Get()->GetWindowForWidget(window_label_.get()); |
| 511 window_label_window->SetBounds(label_bounds); | 543 window_label_window->SetBounds(label_bounds); |
| 512 } | 544 } |
| 513 | 545 |
| 514 void WindowSelectorItem::CreateWindowLabel(const base::string16& title) { | 546 void WindowSelectorItem::CreateWindowLabel(const base::string16& title) { |
| 515 const bool material = ash::MaterialDesignController::IsOverviewMaterial(); | 547 const bool material = ash::MaterialDesignController::IsOverviewMaterial(); |
| 516 window_label_.reset(new views::Widget); | |
| 517 views::Widget::InitParams params; | 548 views::Widget::InitParams params; |
| 518 params.type = views::Widget::InitParams::TYPE_POPUP; | 549 params.type = views::Widget::InitParams::TYPE_POPUP; |
| 519 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 550 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 520 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; | 551 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; |
| 521 params.visible_on_all_workspaces = true; | 552 params.visible_on_all_workspaces = true; |
| 522 window_label_->set_focus_on_creation(false); | |
| 523 root_window_->GetRootWindowController() | 553 root_window_->GetRootWindowController() |
| 524 ->ConfigureWidgetInitParamsForContainer( | 554 ->ConfigureWidgetInitParamsForContainer( |
| 525 window_label_.get(), kShellWindowId_StatusContainer, ¶ms); | 555 window_label_.get(), kShellWindowId_StatusContainer, ¶ms); |
| 556 |
| 557 if (material) { |
| 558 views::View* background_view = |
| 559 new RoundedContainerView(kLabelBackgroundRadius, kLabelBackgroundColor); |
| 560 window_label_selector_.reset(new views::Widget); |
| 561 params.activatable = views::Widget::InitParams::Activatable::ACTIVATABLE_NO; |
| 562 params.accept_events = false; |
| 563 window_label_selector_->Init(params); |
| 564 window_label_selector_->set_focus_on_creation(false); |
| 565 window_label_selector_->SetContentsView(background_view); |
| 566 window_label_selector_->Show(); |
| 567 } |
| 568 |
| 569 params.activatable = |
| 570 views::Widget::InitParams::Activatable::ACTIVATABLE_DEFAULT; |
| 571 params.accept_events = true; |
| 572 window_label_.reset(new views::Widget); |
| 573 window_label_->set_focus_on_creation(false); |
| 526 window_label_->Init(params); | 574 window_label_->Init(params); |
| 527 window_label_button_view_ = new OverviewLabelButton(this, title); | 575 window_label_button_view_ = new OverviewLabelButton(this, title); |
| 528 window_label_button_view_->SetBorder(views::Border::NullBorder()); | 576 window_label_button_view_->SetBorder(views::Border::NullBorder()); |
| 529 window_label_button_view_->SetEnabledTextColors(kLabelColor); | 577 window_label_button_view_->SetEnabledTextColors(kLabelColor); |
| 530 window_label_button_view_->set_animate_on_state_change(false); | 578 window_label_button_view_->set_animate_on_state_change(false); |
| 531 if (material) { | 579 if (material) { |
| 532 window_label_button_view_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 580 window_label_button_view_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 533 } else { | 581 } else { |
| 534 window_label_button_view_->SetHorizontalAlignment(gfx::ALIGN_CENTER); | 582 window_label_button_view_->SetHorizontalAlignment(gfx::ALIGN_CENTER); |
| 535 window_label_button_view_->SetTextShadows(gfx::ShadowValues( | 583 window_label_button_view_->SetTextShadows(gfx::ShadowValues( |
| (...skipping 11 matching lines...) Expand all Loading... |
| 547 new CaptionContainerView(window_label_button_view_, close_button_); | 595 new CaptionContainerView(window_label_button_view_, close_button_); |
| 548 window_label_->SetContentsView(caption_container_view_); | 596 window_label_->SetContentsView(caption_container_view_); |
| 549 window_label_button_view_->SetVisible(false); | 597 window_label_button_view_->SetVisible(false); |
| 550 window_label_->Show(); | 598 window_label_->Show(); |
| 551 | 599 |
| 552 shadow_.reset(new ::wm::Shadow()); | 600 shadow_.reset(new ::wm::Shadow()); |
| 553 shadow_->Init(::wm::Shadow::STYLE_INACTIVE); | 601 shadow_->Init(::wm::Shadow::STYLE_INACTIVE); |
| 554 shadow_->layer()->SetVisible(true); | 602 shadow_->layer()->SetVisible(true); |
| 555 window_label_->GetLayer()->Add(shadow_->layer()); | 603 window_label_->GetLayer()->Add(shadow_->layer()); |
| 556 window_label_->GetLayer()->SetMasksToBounds(false); | 604 window_label_->GetLayer()->SetMasksToBounds(false); |
| 557 | 605 UpdateHeaderLayout(OverviewAnimationType::OVERVIEW_ANIMATION_NONE); |
| 558 views::View* background_view = | |
| 559 new RoundedContainerView(kLabelBackgroundRadius, kLabelBackgroundColor); | |
| 560 window_label_selector_.reset(new views::Widget); | |
| 561 params.activatable = views::Widget::InitParams::Activatable::ACTIVATABLE_NO; | |
| 562 params.accept_events = false; | |
| 563 window_label_selector_->Init(params); | |
| 564 window_label_selector_->set_focus_on_creation(false); | |
| 565 window_label_selector_->SetContentsView(background_view); | |
| 566 window_label_selector_->Show(); | |
| 567 } else { | 606 } else { |
| 568 // Indicate that the label will be drawn onto a transparent background | 607 // Indicate that the label will be drawn onto a transparent background |
| 569 // (disables subpixel antialiasing). | 608 // (disables subpixel antialiasing). |
| 570 window_label_button_view_->SetBackgroundColorHint(SK_ColorTRANSPARENT); | 609 window_label_button_view_->SetBackgroundColorHint(SK_ColorTRANSPARENT); |
| 571 window_label_->SetContentsView(window_label_button_view_); | 610 window_label_->SetContentsView(window_label_button_view_); |
| 572 } | 611 } |
| 612 first_time_ = false; |
| 573 } | 613 } |
| 574 | 614 |
| 575 void WindowSelectorItem::UpdateHeaderLayout( | 615 void WindowSelectorItem::UpdateHeaderLayout( |
| 576 OverviewAnimationType animation_type) { | 616 OverviewAnimationType animation_type) { |
| 577 gfx::Rect transformed_window_bounds = root_window_->ConvertRectFromScreen( | 617 gfx::Rect transformed_window_bounds = root_window_->ConvertRectFromScreen( |
| 578 transform_window_.GetTransformedBounds(hide_header())); | 618 transform_window_.GetTransformedBounds(hide_header())); |
| 579 | 619 |
| 580 if (ash::MaterialDesignController::IsOverviewMaterial()) { | 620 if (ash::MaterialDesignController::IsOverviewMaterial()) { |
| 581 gfx::Rect label_rect(close_button_->GetPreferredSize()); | 621 gfx::Rect label_rect(close_button_->GetPreferredSize()); |
| 582 label_rect.set_y(-label_rect.height()); | 622 if (first_time_) { |
| 623 if (transform_window_.GetTopInset() == 0) { |
| 624 label_rect.set_y(0); |
| 625 label_rect.set_height(0); |
| 626 } else { |
| 627 label_rect.set_y(-transform_window_.GetTopInset()); |
| 628 } |
| 629 } else { |
| 630 label_rect.set_y(-label_rect.height()); |
| 631 } |
| 583 label_rect.set_width(transformed_window_bounds.width()); | 632 label_rect.set_width(transformed_window_bounds.width()); |
| 584 | 633 |
| 585 if (!window_label_button_view_->visible()) { | 634 if (!window_label_button_view_->visible()) { |
| 586 window_label_button_view_->SetVisible(true); | 635 window_label_button_view_->SetVisible(true); |
| 587 SetupFadeInAfterLayout(window_label_.get()); | 636 SetupFadeInAfterLayout(window_label_.get()); |
| 588 SetupFadeInAfterLayout(window_label_selector_.get()); | 637 SetupFadeInAfterLayout(window_label_selector_.get()); |
| 638 SetupOpacityAfterLayout(window_label_selector_.get()); |
| 589 } | 639 } |
| 590 WmWindow* window_label_window = | 640 WmWindow* window_label_window = |
| 591 WmLookup::Get()->GetWindowForWidget(window_label_.get()); | 641 WmLookup::Get()->GetWindowForWidget(window_label_.get()); |
| 592 WmWindow* window_label_selector_window = | 642 WmWindow* window_label_selector_window = |
| 593 WmLookup::Get()->GetWindowForWidget(window_label_selector_.get()); | 643 WmLookup::Get()->GetWindowForWidget(window_label_selector_.get()); |
| 594 std::unique_ptr<ScopedOverviewAnimationSettings> animation_settings = | 644 std::unique_ptr<ScopedOverviewAnimationSettings> animation_settings = |
| 595 ScopedOverviewAnimationSettingsFactory::Get() | 645 ScopedOverviewAnimationSettingsFactory::Get() |
| 596 ->CreateOverviewAnimationSettings(animation_type, | 646 ->CreateOverviewAnimationSettings(animation_type, |
| 597 window_label_window); | 647 window_label_window); |
| 598 std::unique_ptr<ScopedOverviewAnimationSettings> | 648 std::unique_ptr<ScopedOverviewAnimationSettings> |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 637 } | 687 } |
| 638 | 688 |
| 639 void WindowSelectorItem::AnimateOpacity(float opacity, | 689 void WindowSelectorItem::AnimateOpacity(float opacity, |
| 640 OverviewAnimationType animation_type) { | 690 OverviewAnimationType animation_type) { |
| 641 DCHECK_GE(opacity, 0.f); | 691 DCHECK_GE(opacity, 0.f); |
| 642 DCHECK_LE(opacity, 1.f); | 692 DCHECK_LE(opacity, 1.f); |
| 643 ScopedTransformOverviewWindow::ScopedAnimationSettings animation_settings; | 693 ScopedTransformOverviewWindow::ScopedAnimationSettings animation_settings; |
| 644 transform_window_.BeginScopedAnimation(animation_type, &animation_settings); | 694 transform_window_.BeginScopedAnimation(animation_type, &animation_settings); |
| 645 transform_window_.SetOpacity(opacity); | 695 transform_window_.SetOpacity(opacity); |
| 646 | 696 |
| 697 const float header_opacity = selected_ ? 0.f : kHeaderOpacity * opacity; |
| 647 WmWindow* window_label_window = | 698 WmWindow* window_label_window = |
| 648 WmLookup::Get()->GetWindowForWidget(window_label_.get()); | 699 WmLookup::Get()->GetWindowForWidget(window_label_.get()); |
| 649 std::unique_ptr<ScopedOverviewAnimationSettings> animation_settings_label = | 700 std::unique_ptr<ScopedOverviewAnimationSettings> animation_settings_label = |
| 650 ScopedOverviewAnimationSettingsFactory::Get() | 701 ScopedOverviewAnimationSettingsFactory::Get() |
| 651 ->CreateOverviewAnimationSettings(animation_type, | 702 ->CreateOverviewAnimationSettings(animation_type, |
| 652 window_label_window); | 703 window_label_window); |
| 653 window_label_window->SetOpacity(opacity); | 704 window_label_window->SetOpacity(header_opacity); |
| 654 | 705 |
| 655 WmWindow* window_label_selector_window = | 706 WmWindow* window_label_selector_window = |
| 656 WmLookup::Get()->GetWindowForWidget(window_label_selector_.get()); | 707 WmLookup::Get()->GetWindowForWidget(window_label_selector_.get()); |
| 657 std::unique_ptr<ScopedOverviewAnimationSettings> animation_settings_selector = | 708 std::unique_ptr<ScopedOverviewAnimationSettings> animation_settings_selector = |
| 658 ScopedOverviewAnimationSettingsFactory::Get() | 709 ScopedOverviewAnimationSettingsFactory::Get() |
| 659 ->CreateOverviewAnimationSettings(animation_type, | 710 ->CreateOverviewAnimationSettings(animation_type, |
| 660 window_label_selector_window); | 711 window_label_selector_window); |
| 661 window_label_selector_window->SetOpacity(opacity); | 712 window_label_selector_window->SetOpacity(header_opacity); |
| 662 } | 713 } |
| 663 | 714 |
| 664 void WindowSelectorItem::UpdateCloseButtonAccessibilityName() { | 715 void WindowSelectorItem::UpdateCloseButtonAccessibilityName() { |
| 665 close_button_->SetAccessibleName(l10n_util::GetStringFUTF16( | 716 close_button_->SetAccessibleName(l10n_util::GetStringFUTF16( |
| 666 IDS_ASH_OVERVIEW_CLOSE_ITEM_BUTTON_ACCESSIBLE_NAME, | 717 IDS_ASH_OVERVIEW_CLOSE_ITEM_BUTTON_ACCESSIBLE_NAME, |
| 667 GetWindow()->GetTitle())); | 718 GetWindow()->GetTitle())); |
| 668 } | 719 } |
| 669 | 720 |
| 721 void WindowSelectorItem::FadeOut(std::unique_ptr<views::Widget> widget) { |
| 722 widget->SetOpacity(1.f); |
| 723 |
| 724 // Fade out the widget. This animation continues past the lifetime of |this|. |
| 725 WmWindow* widget_window = WmLookup::Get()->GetWindowForWidget(widget.get()); |
| 726 ui::ScopedLayerAnimationSettings animation_settings( |
| 727 widget_window->GetLayer()->GetAnimator()); |
| 728 animation_settings.SetTransitionDuration( |
| 729 base::TimeDelta::FromMilliseconds(kTransitionMilliseconds)); |
| 730 animation_settings.SetTweenType(gfx::Tween::EASE_OUT); |
| 731 animation_settings.SetPreemptionStrategy( |
| 732 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
| 733 // CleanupAnimationObserver will delete itself (and the widget) when the |
| 734 // opacity animation is complete. |
| 735 // Ownership over the observer is passed to the window_selector_->delegate() |
| 736 // which has longer lifetime so that animations can continue even after the |
| 737 // overview mode is shut down. |
| 738 views::Widget* widget_ptr = widget.get(); |
| 739 std::unique_ptr<CleanupAnimationObserver> observer( |
| 740 new CleanupAnimationObserver(std::move(widget))); |
| 741 animation_settings.AddObserver(observer.get()); |
| 742 window_selector_->delegate()->AddDelayedAnimationObserver( |
| 743 std::move(observer)); |
| 744 widget_ptr->SetOpacity(0.f); |
| 745 } |
| 746 |
| 670 } // namespace ash | 747 } // namespace ash |
| OLD | NEW |