| 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/wm/overview/window_selector_item.h" | 5 #include "ash/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/metrics/user_metrics_action.h" | 10 #include "ash/metrics/user_metrics_action.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 #include "ui/gfx/canvas.h" | 33 #include "ui/gfx/canvas.h" |
| 34 #include "ui/gfx/color_utils.h" | 34 #include "ui/gfx/color_utils.h" |
| 35 #include "ui/gfx/geometry/safe_integer_conversions.h" | 35 #include "ui/gfx/geometry/safe_integer_conversions.h" |
| 36 #include "ui/gfx/paint_vector_icon.h" | 36 #include "ui/gfx/paint_vector_icon.h" |
| 37 #include "ui/gfx/transform_util.h" | 37 #include "ui/gfx/transform_util.h" |
| 38 #include "ui/strings/grit/ui_strings.h" | 38 #include "ui/strings/grit/ui_strings.h" |
| 39 #include "ui/views/background.h" | 39 #include "ui/views/background.h" |
| 40 #include "ui/views/border.h" | 40 #include "ui/views/border.h" |
| 41 #include "ui/views/layout/box_layout.h" | 41 #include "ui/views/layout/box_layout.h" |
| 42 #include "ui/views/window/non_client_view.h" | 42 #include "ui/views/window/non_client_view.h" |
| 43 #include "ui/wm/core/coordinate_conversion.h" |
| 43 #include "ui/wm/core/shadow.h" | 44 #include "ui/wm/core/shadow.h" |
| 44 #include "ui/wm/core/window_util.h" | 45 #include "ui/wm/core/window_util.h" |
| 45 | 46 |
| 46 namespace ash { | 47 namespace ash { |
| 47 | 48 |
| 48 namespace { | 49 namespace { |
| 49 | 50 |
| 50 // In the conceptual overview table, the window margin is the space reserved | 51 // In the conceptual overview table, the window margin is the space reserved |
| 51 // around the window within the cell. This margin does not overlap so the | 52 // around the window within the cell. This margin does not overlap so the |
| 52 // closest distance between adjacent windows will be twice this amount. | 53 // closest distance between adjacent windows will be twice this amount. |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 static const int kExitFadeInMilliseconds = 30; | 100 static const int kExitFadeInMilliseconds = 30; |
| 100 | 101 |
| 101 // Before closing a window animate both the window and the caption to shrink by | 102 // Before closing a window animate both the window and the caption to shrink by |
| 102 // this fraction of size. | 103 // this fraction of size. |
| 103 static const float kPreCloseScale = 0.02f; | 104 static const float kPreCloseScale = 0.02f; |
| 104 | 105 |
| 105 // Convenience method to fade in a Window with predefined animation settings. | 106 // Convenience method to fade in a Window with predefined animation settings. |
| 106 // Note: The fade in animation will occur after a delay where the delay is how | 107 // Note: The fade in animation will occur after a delay where the delay is how |
| 107 // long the lay out animations take. | 108 // long the lay out animations take. |
| 108 void SetupFadeInAfterLayout(views::Widget* widget) { | 109 void SetupFadeInAfterLayout(views::Widget* widget) { |
| 109 WmWindow* window = WmWindow::Get(widget->GetNativeWindow()); | 110 aura::Window* window = widget->GetNativeWindow(); |
| 110 window->SetOpacity(0.0f); | 111 window->layer()->SetOpacity(0.0f); |
| 111 std::unique_ptr<ScopedOverviewAnimationSettings> | 112 std::unique_ptr<ScopedOverviewAnimationSettings> |
| 112 scoped_overview_animation_settings = | 113 scoped_overview_animation_settings = |
| 113 ScopedOverviewAnimationSettingsFactory::Get() | 114 ScopedOverviewAnimationSettingsFactory::Get() |
| 114 ->CreateOverviewAnimationSettings( | 115 ->CreateOverviewAnimationSettings( |
| 115 OverviewAnimationType:: | 116 OverviewAnimationType:: |
| 116 OVERVIEW_ANIMATION_ENTER_OVERVIEW_MODE_FADE_IN, | 117 OVERVIEW_ANIMATION_ENTER_OVERVIEW_MODE_FADE_IN, |
| 117 window); | 118 window); |
| 118 window->SetOpacity(1.0f); | 119 window->layer()->SetOpacity(1.0f); |
| 119 } | 120 } |
| 120 | 121 |
| 121 // A Button that has a listener and listens to mouse clicks on the visible part | 122 // A Button that has a listener and listens to mouse clicks on the visible part |
| 122 // of an overview window. | 123 // of an overview window. |
| 123 class ShieldButton : public views::CustomButton { | 124 class ShieldButton : public views::CustomButton { |
| 124 public: | 125 public: |
| 125 ShieldButton(views::ButtonListener* listener, const base::string16& name) | 126 ShieldButton(views::ButtonListener* listener, const base::string16& name) |
| 126 : views::CustomButton(listener) { | 127 : views::CustomButton(listener) { |
| 127 SetAccessibleName(name); | 128 SetAccessibleName(name); |
| 128 } | 129 } |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 // original window's header to semi-transparent color of the overview mode | 171 // original window's header to semi-transparent color of the overview mode |
| 171 // header (on entry to overview). It is also used on exit from overview to | 172 // header (on entry to overview). It is also used on exit from overview to |
| 172 // quickly change the color to a close opaque color in parallel with an | 173 // quickly change the color to a close opaque color in parallel with an |
| 173 // opacity transition to mask the original header reappearing. | 174 // opacity transition to mask the original header reappearing. |
| 174 class WindowSelectorItem::RoundedContainerView | 175 class WindowSelectorItem::RoundedContainerView |
| 175 : public views::View, | 176 : public views::View, |
| 176 public gfx::AnimationDelegate, | 177 public gfx::AnimationDelegate, |
| 177 public ui::LayerAnimationObserver { | 178 public ui::LayerAnimationObserver { |
| 178 public: | 179 public: |
| 179 RoundedContainerView(WindowSelectorItem* item, | 180 RoundedContainerView(WindowSelectorItem* item, |
| 180 WmWindow* item_window, | 181 aura::Window* item_window, |
| 181 int corner_radius, | 182 int corner_radius, |
| 182 SkColor background) | 183 SkColor background) |
| 183 : item_(item), | 184 : item_(item), |
| 184 item_window_(item_window), | 185 item_window_(item_window), |
| 185 corner_radius_(corner_radius), | 186 corner_radius_(corner_radius), |
| 186 initial_color_(background), | 187 initial_color_(background), |
| 187 target_color_(background), | 188 target_color_(background), |
| 188 current_value_(0), | 189 current_value_(0), |
| 189 layer_(nullptr), | 190 layer_(nullptr), |
| 190 animation_(new gfx::SlideAnimation(this)) { | 191 animation_(new gfx::SlideAnimation(this)) { |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 const char* GetClassName() const override { return "RoundedContainerView"; } | 279 const char* GetClassName() const override { return "RoundedContainerView"; } |
| 279 | 280 |
| 280 private: | 281 private: |
| 281 // gfx::AnimationDelegate: | 282 // gfx::AnimationDelegate: |
| 282 void AnimationEnded(const gfx::Animation* animation) override { | 283 void AnimationEnded(const gfx::Animation* animation) override { |
| 283 initial_color_ = target_color_; | 284 initial_color_ = target_color_; |
| 284 // Tabbed browser windows show the overview mode header behind the window | 285 // Tabbed browser windows show the overview mode header behind the window |
| 285 // during the initial animation. Once the initial fade-in completes and the | 286 // during the initial animation. Once the initial fade-in completes and the |
| 286 // overview header is fully exposed update stacking to keep the label above | 287 // overview header is fully exposed update stacking to keep the label above |
| 287 // the item which prevents input events from reaching the window. | 288 // the item which prevents input events from reaching the window. |
| 288 WmWindow* widget_window = WmWindow::Get(GetWidget()->GetNativeWindow()); | 289 aura::Window* widget_window = GetWidget()->GetNativeWindow(); |
| 289 if (widget_window && item_window_) | 290 if (widget_window && item_window_) |
| 290 widget_window->GetParent()->StackChildAbove(widget_window, item_window_); | 291 widget_window->parent()->StackChildAbove(widget_window, item_window_); |
| 291 item_window_ = nullptr; | 292 item_window_ = nullptr; |
| 292 } | 293 } |
| 293 | 294 |
| 294 void AnimationProgressed(const gfx::Animation* animation) override { | 295 void AnimationProgressed(const gfx::Animation* animation) override { |
| 295 current_value_ = animation_->CurrentValueBetween(0, 255); | 296 current_value_ = animation_->CurrentValueBetween(0, 255); |
| 296 SchedulePaint(); | 297 SchedulePaint(); |
| 297 } | 298 } |
| 298 | 299 |
| 299 void AnimationCanceled(const gfx::Animation* animation) override { | 300 void AnimationCanceled(const gfx::Animation* animation) override { |
| 300 item_window_ = nullptr; | 301 item_window_ = nullptr; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 318 if (0 != (sequence->properties() & | 319 if (0 != (sequence->properties() & |
| 319 ui::LayerAnimationElement::AnimatableProperty::OPACITY)) { | 320 ui::LayerAnimationElement::AnimatableProperty::OPACITY)) { |
| 320 StopObservingLayerAnimations(); | 321 StopObservingLayerAnimations(); |
| 321 } | 322 } |
| 322 } | 323 } |
| 323 | 324 |
| 324 void OnLayerAnimationScheduled( | 325 void OnLayerAnimationScheduled( |
| 325 ui::LayerAnimationSequence* sequence) override {} | 326 ui::LayerAnimationSequence* sequence) override {} |
| 326 | 327 |
| 327 WindowSelectorItem* item_; | 328 WindowSelectorItem* item_; |
| 328 WmWindow* item_window_; | 329 aura::Window* item_window_; |
| 329 int corner_radius_; | 330 int corner_radius_; |
| 330 SkColor initial_color_; | 331 SkColor initial_color_; |
| 331 SkColor target_color_; | 332 SkColor target_color_; |
| 332 int current_value_; | 333 int current_value_; |
| 333 ui::Layer* layer_; | 334 ui::Layer* layer_; |
| 334 std::unique_ptr<gfx::SlideAnimation> animation_; | 335 std::unique_ptr<gfx::SlideAnimation> animation_; |
| 335 | 336 |
| 336 DISALLOW_COPY_AND_ASSIGN(RoundedContainerView); | 337 DISALLOW_COPY_AND_ASSIGN(RoundedContainerView); |
| 337 }; | 338 }; |
| 338 | 339 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 | 395 |
| 395 private: | 396 private: |
| 396 ShieldButton* listener_button_; | 397 ShieldButton* listener_button_; |
| 397 WindowSelectorItem::RoundedContainerView* background_; | 398 WindowSelectorItem::RoundedContainerView* background_; |
| 398 views::Label* label_; | 399 views::Label* label_; |
| 399 views::ImageButton* close_button_; | 400 views::ImageButton* close_button_; |
| 400 | 401 |
| 401 DISALLOW_COPY_AND_ASSIGN(CaptionContainerView); | 402 DISALLOW_COPY_AND_ASSIGN(CaptionContainerView); |
| 402 }; | 403 }; |
| 403 | 404 |
| 404 WindowSelectorItem::WindowSelectorItem(WmWindow* window, | 405 WindowSelectorItem::WindowSelectorItem(aura::Window* window, |
| 405 WindowSelector* window_selector) | 406 WindowSelector* window_selector) |
| 406 : dimmed_(false), | 407 : dimmed_(false), |
| 407 root_window_(window->GetRootWindow()), | 408 root_window_(window->GetRootWindow()), |
| 408 transform_window_(window), | 409 transform_window_(window), |
| 409 in_bounds_update_(false), | 410 in_bounds_update_(false), |
| 410 selected_(false), | 411 selected_(false), |
| 411 caption_container_view_(nullptr), | 412 caption_container_view_(nullptr), |
| 412 label_view_(nullptr), | 413 label_view_(nullptr), |
| 413 close_button_(new OverviewCloseButton(this)), | 414 close_button_(new OverviewCloseButton(this)), |
| 414 window_selector_(window_selector), | 415 window_selector_(window_selector), |
| 415 background_view_(nullptr) { | 416 background_view_(nullptr) { |
| 416 CreateWindowLabel(window->aura_window()->GetTitle()); | 417 CreateWindowLabel(window->GetTitle()); |
| 417 GetWindow()->aura_window()->AddObserver(this); | 418 GetWindow()->AddObserver(this); |
| 418 } | 419 } |
| 419 | 420 |
| 420 WindowSelectorItem::~WindowSelectorItem() { | 421 WindowSelectorItem::~WindowSelectorItem() { |
| 421 GetWindow()->aura_window()->RemoveObserver(this); | 422 GetWindow()->RemoveObserver(this); |
| 422 } | 423 } |
| 423 | 424 |
| 424 WmWindow* WindowSelectorItem::GetWindow() { | 425 aura::Window* WindowSelectorItem::GetWindow() { |
| 425 return transform_window_.window(); | 426 return transform_window_.window(); |
| 426 } | 427 } |
| 427 | 428 |
| 428 void WindowSelectorItem::RestoreWindow() { | 429 void WindowSelectorItem::RestoreWindow() { |
| 429 caption_container_view_->listener_button()->ResetListener(); | 430 caption_container_view_->listener_button()->ResetListener(); |
| 430 close_button_->ResetListener(); | 431 close_button_->ResetListener(); |
| 431 transform_window_.RestoreWindow(); | 432 transform_window_.RestoreWindow(); |
| 432 if (background_view_) { | 433 if (background_view_) { |
| 433 background_view_->OnItemRestored(); | 434 background_view_->OnItemRestored(); |
| 434 background_view_ = nullptr; | 435 background_view_ = nullptr; |
| 435 } | 436 } |
| 436 UpdateHeaderLayout( | 437 UpdateHeaderLayout( |
| 437 HeaderFadeInMode::EXIT, | 438 HeaderFadeInMode::EXIT, |
| 438 OverviewAnimationType::OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS); | 439 OverviewAnimationType::OVERVIEW_ANIMATION_LAY_OUT_SELECTOR_ITEMS); |
| 439 } | 440 } |
| 440 | 441 |
| 441 void WindowSelectorItem::EnsureVisible() { | 442 void WindowSelectorItem::EnsureVisible() { |
| 442 transform_window_.EnsureVisible(); | 443 transform_window_.EnsureVisible(); |
| 443 } | 444 } |
| 444 | 445 |
| 445 void WindowSelectorItem::Shutdown() { | 446 void WindowSelectorItem::Shutdown() { |
| 446 if (transform_window_.GetTopInset()) { | 447 if (transform_window_.GetTopInset()) { |
| 447 // Activating a window (even when it is the window that was active before | 448 // Activating a window (even when it is the window that was active before |
| 448 // overview) results in stacking it at the top. Maintain the label window | 449 // overview) results in stacking it at the top. Maintain the label window |
| 449 // stacking position above the item to make the header transformation more | 450 // stacking position above the item to make the header transformation more |
| 450 // gradual upon exiting the overview mode. | 451 // gradual upon exiting the overview mode. |
| 451 WmWindow* widget_window = WmWindow::Get(item_widget_->GetNativeWindow()); | 452 aura::Window* widget_window = item_widget_->GetNativeWindow(); |
| 452 | 453 |
| 453 // |widget_window| was originally created in the same container as the | 454 // |widget_window| was originally created in the same container as the |
| 454 // |transform_window_| but when closing overview the |transform_window_| | 455 // |transform_window_| but when closing overview the |transform_window_| |
| 455 // could have been reparented if a drag was active. Only change stacking | 456 // could have been reparented if a drag was active. Only change stacking |
| 456 // if the windows still belong to the same container. | 457 // if the windows still belong to the same container. |
| 457 if (widget_window->GetParent() == transform_window_.window()->GetParent()) { | 458 if (widget_window->parent() == transform_window_.window()->parent()) { |
| 458 widget_window->GetParent()->StackChildAbove(widget_window, | 459 widget_window->parent()->StackChildAbove(widget_window, |
| 459 transform_window_.window()); | 460 transform_window_.window()); |
| 460 } | 461 } |
| 461 } | 462 } |
| 462 if (background_view_) { | 463 if (background_view_) { |
| 463 background_view_->OnItemRestored(); | 464 background_view_->OnItemRestored(); |
| 464 background_view_ = nullptr; | 465 background_view_ = nullptr; |
| 465 } | 466 } |
| 466 FadeOut(std::move(item_widget_)); | 467 FadeOut(std::move(item_widget_)); |
| 467 } | 468 } |
| 468 | 469 |
| 469 void WindowSelectorItem::PrepareForOverview() { | 470 void WindowSelectorItem::PrepareForOverview() { |
| 470 transform_window_.PrepareForOverview(); | 471 transform_window_.PrepareForOverview(); |
| 471 UpdateHeaderLayout(HeaderFadeInMode::ENTER, | 472 UpdateHeaderLayout(HeaderFadeInMode::ENTER, |
| 472 OverviewAnimationType::OVERVIEW_ANIMATION_NONE); | 473 OverviewAnimationType::OVERVIEW_ANIMATION_NONE); |
| 473 } | 474 } |
| 474 | 475 |
| 475 bool WindowSelectorItem::Contains(const WmWindow* target) const { | 476 bool WindowSelectorItem::Contains(const aura::Window* target) const { |
| 476 return transform_window_.Contains(target); | 477 return transform_window_.Contains(target); |
| 477 } | 478 } |
| 478 | 479 |
| 479 void WindowSelectorItem::SetBounds(const gfx::Rect& target_bounds, | 480 void WindowSelectorItem::SetBounds(const gfx::Rect& target_bounds, |
| 480 OverviewAnimationType animation_type) { | 481 OverviewAnimationType animation_type) { |
| 481 if (in_bounds_update_) | 482 if (in_bounds_update_) |
| 482 return; | 483 return; |
| 483 base::AutoReset<bool> auto_reset_in_bounds_update(&in_bounds_update_, true); | 484 base::AutoReset<bool> auto_reset_in_bounds_update(&in_bounds_update_, true); |
| 484 target_bounds_ = target_bounds; | 485 target_bounds_ = target_bounds; |
| 485 | 486 |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 608 params_label.type = views::Widget::InitParams::TYPE_POPUP; | 609 params_label.type = views::Widget::InitParams::TYPE_POPUP; |
| 609 params_label.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 610 params_label.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 610 params_label.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; | 611 params_label.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; |
| 611 params_label.visible_on_all_workspaces = true; | 612 params_label.visible_on_all_workspaces = true; |
| 612 params_label.layer_type = ui::LAYER_NOT_DRAWN; | 613 params_label.layer_type = ui::LAYER_NOT_DRAWN; |
| 613 params_label.name = "OverviewModeLabel"; | 614 params_label.name = "OverviewModeLabel"; |
| 614 params_label.activatable = | 615 params_label.activatable = |
| 615 views::Widget::InitParams::Activatable::ACTIVATABLE_DEFAULT; | 616 views::Widget::InitParams::Activatable::ACTIVATABLE_DEFAULT; |
| 616 params_label.accept_events = true; | 617 params_label.accept_events = true; |
| 617 item_widget_.reset(new views::Widget); | 618 item_widget_.reset(new views::Widget); |
| 618 root_window_->GetRootWindowController() | 619 RootWindowController::ForWindow(root_window_) |
| 619 ->ConfigureWidgetInitParamsForContainer( | 620 ->ConfigureWidgetInitParamsForContainer( |
| 620 item_widget_.get(), | 621 item_widget_.get(), transform_window_.window()->parent()->id(), |
| 621 transform_window_.window()->GetParent()->aura_window()->id(), | |
| 622 ¶ms_label); | 622 ¶ms_label); |
| 623 item_widget_->set_focus_on_creation(false); | 623 item_widget_->set_focus_on_creation(false); |
| 624 item_widget_->Init(params_label); | 624 item_widget_->Init(params_label); |
| 625 WmWindow* widget_window = WmWindow::Get(item_widget_->GetNativeWindow()); | 625 aura::Window* widget_window = item_widget_->GetNativeWindow(); |
| 626 if (transform_window_.GetTopInset()) { | 626 if (transform_window_.GetTopInset()) { |
| 627 // For windows with headers the overview header fades in above the | 627 // For windows with headers the overview header fades in above the |
| 628 // original window header. | 628 // original window header. |
| 629 widget_window->GetParent()->StackChildAbove(widget_window, | 629 widget_window->parent()->StackChildAbove(widget_window, |
| 630 transform_window_.window()); | 630 transform_window_.window()); |
| 631 } else { | 631 } else { |
| 632 // For tabbed windows the overview header slides from behind. The stacking | 632 // For tabbed windows the overview header slides from behind. The stacking |
| 633 // is then corrected when the animation completes. | 633 // is then corrected when the animation completes. |
| 634 widget_window->GetParent()->StackChildBelow(widget_window, | 634 widget_window->parent()->StackChildBelow(widget_window, |
| 635 transform_window_.window()); | 635 transform_window_.window()); |
| 636 } | 636 } |
| 637 label_view_ = new views::Label(title); | 637 label_view_ = new views::Label(title); |
| 638 label_view_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 638 label_view_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 639 label_view_->SetAutoColorReadabilityEnabled(false); | 639 label_view_->SetAutoColorReadabilityEnabled(false); |
| 640 label_view_->SetEnabledColor(kLabelColor); | 640 label_view_->SetEnabledColor(kLabelColor); |
| 641 // Tell the label what color it will be drawn onto. It will use whether the | 641 // Tell the label what color it will be drawn onto. It will use whether the |
| 642 // background color is opaque or transparent to decide whether to use | 642 // background color is opaque or transparent to decide whether to use |
| 643 // subpixel rendering. Does not actually set the label's background color. | 643 // subpixel rendering. Does not actually set the label's background color. |
| 644 label_view_->SetBackgroundColor(kLabelBackgroundColor); | 644 label_view_->SetBackgroundColor(kLabelBackgroundColor); |
| 645 | 645 |
| 646 caption_container_view_ = new CaptionContainerView( | 646 caption_container_view_ = new CaptionContainerView( |
| 647 this, label_view_, close_button_, background_view_); | 647 this, label_view_, close_button_, background_view_); |
| 648 item_widget_->SetContentsView(caption_container_view_); | 648 item_widget_->SetContentsView(caption_container_view_); |
| 649 label_view_->SetVisible(false); | 649 label_view_->SetVisible(false); |
| 650 item_widget_->SetOpacity(0); | 650 item_widget_->SetOpacity(0); |
| 651 item_widget_->Show(); | 651 item_widget_->Show(); |
| 652 item_widget_->GetLayer()->SetMasksToBounds(false); | 652 item_widget_->GetLayer()->SetMasksToBounds(false); |
| 653 } | 653 } |
| 654 | 654 |
| 655 void WindowSelectorItem::UpdateHeaderLayout( | 655 void WindowSelectorItem::UpdateHeaderLayout( |
| 656 HeaderFadeInMode mode, | 656 HeaderFadeInMode mode, |
| 657 OverviewAnimationType animation_type) { | 657 OverviewAnimationType animation_type) { |
| 658 gfx::Rect transformed_window_bounds = root_window_->ConvertRectFromScreen( | 658 gfx::Rect transformed_window_bounds(transform_window_.GetTransformedBounds()); |
| 659 transform_window_.GetTransformedBounds()); | 659 ::wm::ConvertRectFromScreen(root_window_, &transformed_window_bounds); |
| 660 | 660 |
| 661 gfx::Rect label_rect(close_button_->GetPreferredSize()); | 661 gfx::Rect label_rect(close_button_->GetPreferredSize()); |
| 662 label_rect.set_width(transformed_window_bounds.width()); | 662 label_rect.set_width(transformed_window_bounds.width()); |
| 663 // For tabbed windows the initial bounds of the caption are set such that it | 663 // For tabbed windows the initial bounds of the caption are set such that it |
| 664 // appears to be "growing" up from the window content area. | 664 // appears to be "growing" up from the window content area. |
| 665 label_rect.set_y( | 665 label_rect.set_y( |
| 666 (mode != HeaderFadeInMode::ENTER || transform_window_.GetTopInset()) | 666 (mode != HeaderFadeInMode::ENTER || transform_window_.GetTopInset()) |
| 667 ? -label_rect.height() | 667 ? -label_rect.height() |
| 668 : 0); | 668 : 0); |
| 669 if (background_view_) { | 669 if (background_view_) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 680 // the Shutdown() is called. | 680 // the Shutdown() is called. |
| 681 background_view_->AnimateColor(gfx::Tween::EASE_OUT, | 681 background_view_->AnimateColor(gfx::Tween::EASE_OUT, |
| 682 kExitFadeInMilliseconds); | 682 kExitFadeInMilliseconds); |
| 683 background_view_->set_color(kLabelExitColor); | 683 background_view_->set_color(kLabelExitColor); |
| 684 } | 684 } |
| 685 } | 685 } |
| 686 if (!label_view_->visible()) { | 686 if (!label_view_->visible()) { |
| 687 label_view_->SetVisible(true); | 687 label_view_->SetVisible(true); |
| 688 SetupFadeInAfterLayout(item_widget_.get()); | 688 SetupFadeInAfterLayout(item_widget_.get()); |
| 689 } | 689 } |
| 690 WmWindow* widget_window = WmWindow::Get(item_widget_->GetNativeWindow()); | 690 aura::Window* widget_window = item_widget_->GetNativeWindow(); |
| 691 std::unique_ptr<ScopedOverviewAnimationSettings> animation_settings = | 691 std::unique_ptr<ScopedOverviewAnimationSettings> animation_settings = |
| 692 ScopedOverviewAnimationSettingsFactory::Get() | 692 ScopedOverviewAnimationSettingsFactory::Get() |
| 693 ->CreateOverviewAnimationSettings(animation_type, widget_window); | 693 ->CreateOverviewAnimationSettings(animation_type, widget_window); |
| 694 // |widget_window| covers both the transformed window and the header | 694 // |widget_window| covers both the transformed window and the header |
| 695 // as well as the gap between the windows to prevent events from reaching | 695 // as well as the gap between the windows to prevent events from reaching |
| 696 // the window including its sizing borders. | 696 // the window including its sizing borders. |
| 697 if (mode != HeaderFadeInMode::ENTER) { | 697 if (mode != HeaderFadeInMode::ENTER) { |
| 698 label_rect.set_height(close_button_->GetPreferredSize().height() + | 698 label_rect.set_height(close_button_->GetPreferredSize().height() + |
| 699 transformed_window_bounds.height()); | 699 transformed_window_bounds.height()); |
| 700 } | 700 } |
| 701 label_rect.Inset(-kWindowSelectorMargin, -kWindowSelectorMargin); | 701 label_rect.Inset(-kWindowSelectorMargin, -kWindowSelectorMargin); |
| 702 widget_window->SetBounds(label_rect); | 702 widget_window->SetBounds(label_rect); |
| 703 gfx::Transform label_transform; | 703 gfx::Transform label_transform; |
| 704 label_transform.Translate(transformed_window_bounds.x(), | 704 label_transform.Translate(transformed_window_bounds.x(), |
| 705 transformed_window_bounds.y()); | 705 transformed_window_bounds.y()); |
| 706 widget_window->SetTransform(label_transform); | 706 widget_window->SetTransform(label_transform); |
| 707 } | 707 } |
| 708 | 708 |
| 709 void WindowSelectorItem::AnimateOpacity(float opacity, | 709 void WindowSelectorItem::AnimateOpacity(float opacity, |
| 710 OverviewAnimationType animation_type) { | 710 OverviewAnimationType animation_type) { |
| 711 DCHECK_GE(opacity, 0.f); | 711 DCHECK_GE(opacity, 0.f); |
| 712 DCHECK_LE(opacity, 1.f); | 712 DCHECK_LE(opacity, 1.f); |
| 713 ScopedTransformOverviewWindow::ScopedAnimationSettings animation_settings; | 713 ScopedTransformOverviewWindow::ScopedAnimationSettings animation_settings; |
| 714 transform_window_.BeginScopedAnimation(animation_type, &animation_settings); | 714 transform_window_.BeginScopedAnimation(animation_type, &animation_settings); |
| 715 transform_window_.SetOpacity(opacity); | 715 transform_window_.SetOpacity(opacity); |
| 716 | 716 |
| 717 const float header_opacity = selected_ ? 0.f : kHeaderOpacity * opacity; | 717 const float header_opacity = selected_ ? 0.f : kHeaderOpacity * opacity; |
| 718 WmWindow* widget_window = WmWindow::Get(item_widget_->GetNativeWindow()); | 718 aura::Window* widget_window = item_widget_->GetNativeWindow(); |
| 719 std::unique_ptr<ScopedOverviewAnimationSettings> animation_settings_label = | 719 std::unique_ptr<ScopedOverviewAnimationSettings> animation_settings_label = |
| 720 ScopedOverviewAnimationSettingsFactory::Get() | 720 ScopedOverviewAnimationSettingsFactory::Get() |
| 721 ->CreateOverviewAnimationSettings(animation_type, widget_window); | 721 ->CreateOverviewAnimationSettings(animation_type, widget_window); |
| 722 widget_window->SetOpacity(header_opacity); | 722 widget_window->layer()->SetOpacity(header_opacity); |
| 723 } | 723 } |
| 724 | 724 |
| 725 void WindowSelectorItem::UpdateAccessibilityName() { | 725 void WindowSelectorItem::UpdateAccessibilityName() { |
| 726 caption_container_view_->listener_button()->SetAccessibleName( | 726 caption_container_view_->listener_button()->SetAccessibleName( |
| 727 GetWindow()->aura_window()->GetTitle()); | 727 GetWindow()->GetTitle()); |
| 728 } | 728 } |
| 729 | 729 |
| 730 void WindowSelectorItem::FadeOut(std::unique_ptr<views::Widget> widget) { | 730 void WindowSelectorItem::FadeOut(std::unique_ptr<views::Widget> widget) { |
| 731 widget->SetOpacity(1.f); | 731 widget->SetOpacity(1.f); |
| 732 | 732 |
| 733 // Fade out the widget. This animation continues past the lifetime of |this|. | 733 // Fade out the widget. This animation continues past the lifetime of |this|. |
| 734 WmWindow* widget_window = WmWindow::Get(widget->GetNativeWindow()); | 734 aura::Window* widget_window = widget->GetNativeWindow(); |
| 735 std::unique_ptr<ScopedOverviewAnimationSettings> animation_settings = | 735 std::unique_ptr<ScopedOverviewAnimationSettings> animation_settings = |
| 736 ScopedOverviewAnimationSettingsFactory::Get() | 736 ScopedOverviewAnimationSettingsFactory::Get() |
| 737 ->CreateOverviewAnimationSettings( | 737 ->CreateOverviewAnimationSettings( |
| 738 OverviewAnimationType:: | 738 OverviewAnimationType:: |
| 739 OVERVIEW_ANIMATION_EXIT_OVERVIEW_MODE_FADE_OUT, | 739 OVERVIEW_ANIMATION_EXIT_OVERVIEW_MODE_FADE_OUT, |
| 740 widget_window); | 740 widget_window); |
| 741 // CleanupAnimationObserver will delete itself (and the widget) when the | 741 // CleanupAnimationObserver will delete itself (and the widget) when the |
| 742 // opacity animation is complete. | 742 // opacity animation is complete. |
| 743 // Ownership over the observer is passed to the window_selector_->delegate() | 743 // Ownership over the observer is passed to the window_selector_->delegate() |
| 744 // which has longer lifetime so that animations can continue even after the | 744 // which has longer lifetime so that animations can continue even after the |
| 745 // overview mode is shut down. | 745 // overview mode is shut down. |
| 746 views::Widget* widget_ptr = widget.get(); | 746 views::Widget* widget_ptr = widget.get(); |
| 747 std::unique_ptr<CleanupAnimationObserver> observer( | 747 std::unique_ptr<CleanupAnimationObserver> observer( |
| 748 new CleanupAnimationObserver(std::move(widget))); | 748 new CleanupAnimationObserver(std::move(widget))); |
| 749 animation_settings->AddObserver(observer.get()); | 749 animation_settings->AddObserver(observer.get()); |
| 750 window_selector_->delegate()->AddDelayedAnimationObserver( | 750 window_selector_->delegate()->AddDelayedAnimationObserver( |
| 751 std::move(observer)); | 751 std::move(observer)); |
| 752 widget_ptr->SetOpacity(0.f); | 752 widget_ptr->SetOpacity(0.f); |
| 753 } | 753 } |
| 754 | 754 |
| 755 gfx::SlideAnimation* WindowSelectorItem::GetBackgroundViewAnimation() { | 755 gfx::SlideAnimation* WindowSelectorItem::GetBackgroundViewAnimation() { |
| 756 return background_view_ ? background_view_->animation() : nullptr; | 756 return background_view_ ? background_view_->animation() : nullptr; |
| 757 } | 757 } |
| 758 | 758 |
| 759 WmWindow* WindowSelectorItem::GetOverviewWindowForMinimizedStateForTest() { | 759 aura::Window* WindowSelectorItem::GetOverviewWindowForMinimizedStateForTest() { |
| 760 return transform_window_.GetOverviewWindowForMinimizedState(); | 760 return transform_window_.GetOverviewWindowForMinimizedState(); |
| 761 } | 761 } |
| 762 | 762 |
| 763 } // namespace ash | 763 } // namespace ash |
| OLD | NEW |