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

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

Issue 2203793003: [ash-md] Properly scales windows with transient parents in overview (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2785
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/common/wm/overview/window_selector_item.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #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"
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 // Opacity for fading out during closing a window. 94 // Opacity for fading out during closing a window.
95 static const float kClosingItemOpacity = 0.8f; 95 static const float kClosingItemOpacity = 0.8f;
96 96
97 // Duration of background opacity transition for the selected label. 97 // Duration of background opacity transition for the selected label.
98 static const int kSelectorFadeInMilliseconds = 350; 98 static const int kSelectorFadeInMilliseconds = 350;
99 99
100 // Before closing a window animate both the window and the caption to shrink by 100 // Before closing a window animate both the window and the caption to shrink by
101 // this fraction of size. 101 // this fraction of size.
102 static const float kPreCloseScale = 0.02f; 102 static const float kPreCloseScale = 0.02f;
103 103
104 // Calculates the |window| bounds after being transformed to the selector's
105 // space. The returned Rect is in virtual screen coordinates.
106 gfx::Rect GetTransformedBounds(WmWindow* window, bool hide_header) {
107 gfx::RectF bounds(
108 window->GetRootWindow()->ConvertRectToScreen(window->GetTargetBounds()));
109 gfx::Transform new_transform = TransformAboutPivot(
110 gfx::Point(bounds.x(), bounds.y()), window->GetTargetTransform());
111 new_transform.TransformRect(&bounds);
112
113 // With Material Design the preview title is shown above the preview window.
114 // Hide the window header for apps or browser windows with no tabs (web apps)
115 // to avoid showing both the window header and the preview title.
116 if (ash::MaterialDesignController::IsOverviewMaterial() && hide_header) {
117 gfx::RectF header_bounds(bounds);
118 header_bounds.set_height(
119 window->GetIntProperty(WmWindowProperty::TOP_VIEW_INSET));
120 new_transform.TransformRect(&header_bounds);
121 bounds.Inset(0, gfx::ToCeiledInt(header_bounds.height()), 0, 0);
122 }
123 return ToEnclosingRect(bounds);
124 }
125
126 // Convenience method to fade in a Window with predefined animation settings. 104 // Convenience method to fade in a Window with predefined animation settings.
127 // Note: The fade in animation will occur after a delay where the delay is how 105 // Note: The fade in animation will occur after a delay where the delay is how
128 // long the lay out animations take. 106 // long the lay out animations take.
129 void SetupFadeInAfterLayout(views::Widget* widget) { 107 void SetupFadeInAfterLayout(views::Widget* widget) {
130 WmWindow* window = WmLookup::Get()->GetWindowForWidget(widget); 108 WmWindow* window = WmLookup::Get()->GetWindowForWidget(widget);
131 window->SetOpacity(0.0f); 109 window->SetOpacity(0.0f);
132 std::unique_ptr<ScopedOverviewAnimationSettings> 110 std::unique_ptr<ScopedOverviewAnimationSettings>
133 scoped_overview_animation_settings = 111 scoped_overview_animation_settings =
134 ScopedOverviewAnimationSettingsFactory::Get() 112 ScopedOverviewAnimationSettingsFactory::Get()
135 ->CreateOverviewAnimationSettings( 113 ->CreateOverviewAnimationSettings(
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 413
436 void WindowSelectorItem::OnWindowTitleChanged(WmWindow* window) { 414 void WindowSelectorItem::OnWindowTitleChanged(WmWindow* window) {
437 // TODO(flackr): Maybe add the new title to a vector of titles so that we can 415 // TODO(flackr): Maybe add the new title to a vector of titles so that we can
438 // filter any of the titles the window had while in the overview session. 416 // filter any of the titles the window had while in the overview session.
439 window_label_button_view_->SetText(window->GetTitle()); 417 window_label_button_view_->SetText(window->GetTitle());
440 UpdateCloseButtonAccessibilityName(); 418 UpdateCloseButtonAccessibilityName();
441 } 419 }
442 420
443 float WindowSelectorItem::GetItemScale(const gfx::Size& size) { 421 float WindowSelectorItem::GetItemScale(const gfx::Size& size) {
444 gfx::Size inset_size(size.width(), size.height() - 2 * kWindowMarginMD); 422 gfx::Size inset_size(size.width(), size.height() - 2 * kWindowMarginMD);
445 const int header_inset =
446 hide_header()
447 ? GetWindow()->GetIntProperty(WmWindowProperty::TOP_VIEW_INSET)
448 : 0;
449 return ScopedTransformOverviewWindow::GetItemScale( 423 return ScopedTransformOverviewWindow::GetItemScale(
450 GetWindow()->GetTargetBounds().size(), inset_size, header_inset, 424 transform_window_.GetTargetBoundsInScreen().size(), inset_size,
425 hide_header() ? transform_window_.GetTopInset() : 0,
451 close_button_->GetPreferredSize().height()); 426 close_button_->GetPreferredSize().height());
452 } 427 }
453 428
429 gfx::Rect WindowSelectorItem::GetTargetBoundsInScreen() const {
430 return transform_window_.GetTargetBoundsInScreen();
431 }
432
454 void WindowSelectorItem::SetItemBounds(const gfx::Rect& target_bounds, 433 void WindowSelectorItem::SetItemBounds(const gfx::Rect& target_bounds,
455 OverviewAnimationType animation_type) { 434 OverviewAnimationType animation_type) {
456 DCHECK(root_window_ == GetWindow()->GetRootWindow()); 435 DCHECK(root_window_ == GetWindow()->GetRootWindow());
457 gfx::Rect screen_rect = transform_window_.GetTargetBoundsInScreen(); 436 gfx::Rect screen_rect = transform_window_.GetTargetBoundsInScreen();
458 437
459 // Avoid division by zero by ensuring screen bounds is not empty. 438 // Avoid division by zero by ensuring screen bounds is not empty.
460 gfx::Size screen_size(screen_rect.size()); 439 gfx::Size screen_size(screen_rect.size());
461 screen_size.SetToMax(gfx::Size(1, 1)); 440 screen_size.SetToMax(gfx::Size(1, 1));
462 screen_rect.set_size(screen_size); 441 screen_rect.set_size(screen_size);
463 442
464 int top_view_inset = 0; 443 int top_view_inset = 0;
465 int title_height = 0; 444 int title_height = 0;
466 if (ash::MaterialDesignController::IsOverviewMaterial()) { 445 if (ash::MaterialDesignController::IsOverviewMaterial()) {
467 if (hide_header()) { 446 if (hide_header())
468 top_view_inset = 447 top_view_inset = transform_window_.GetTopInset();
469 GetWindow()->GetIntProperty(WmWindowProperty::TOP_VIEW_INSET);
470 }
471 title_height = close_button_->GetPreferredSize().height(); 448 title_height = close_button_->GetPreferredSize().height();
472 } 449 }
473 gfx::Rect selector_item_bounds = 450 gfx::Rect selector_item_bounds =
474 ScopedTransformOverviewWindow::ShrinkRectToFitPreservingAspectRatio( 451 ScopedTransformOverviewWindow::ShrinkRectToFitPreservingAspectRatio(
475 screen_rect, target_bounds, top_view_inset, title_height); 452 screen_rect, target_bounds, top_view_inset, title_height);
476 gfx::Transform transform = ScopedTransformOverviewWindow::GetTransformForRect( 453 gfx::Transform transform = ScopedTransformOverviewWindow::GetTransformForRect(
477 screen_rect, selector_item_bounds); 454 screen_rect, selector_item_bounds);
478 ScopedTransformOverviewWindow::ScopedAnimationSettings animation_settings; 455 ScopedTransformOverviewWindow::ScopedAnimationSettings animation_settings;
479 transform_window_.BeginScopedAnimation(animation_type, &animation_settings); 456 transform_window_.BeginScopedAnimation(animation_type, &animation_settings);
480 // Rounded corners are achieved by using a mask layer on the original window 457 // Rounded corners are achieved by using a mask layer on the original window
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 // Indicate that the label will be drawn onto a transparent background 544 // Indicate that the label will be drawn onto a transparent background
568 // (disables subpixel antialiasing). 545 // (disables subpixel antialiasing).
569 window_label_button_view_->SetBackgroundColorHint(SK_ColorTRANSPARENT); 546 window_label_button_view_->SetBackgroundColorHint(SK_ColorTRANSPARENT);
570 window_label_->SetContentsView(window_label_button_view_); 547 window_label_->SetContentsView(window_label_button_view_);
571 } 548 }
572 } 549 }
573 550
574 void WindowSelectorItem::UpdateHeaderLayout( 551 void WindowSelectorItem::UpdateHeaderLayout(
575 OverviewAnimationType animation_type) { 552 OverviewAnimationType animation_type) {
576 gfx::Rect transformed_window_bounds = root_window_->ConvertRectFromScreen( 553 gfx::Rect transformed_window_bounds = root_window_->ConvertRectFromScreen(
577 GetTransformedBounds(GetWindow(), hide_header())); 554 transform_window_.GetTransformedBounds(hide_header()));
578 555
579 if (ash::MaterialDesignController::IsOverviewMaterial()) { 556 if (ash::MaterialDesignController::IsOverviewMaterial()) {
580 gfx::Rect label_rect(close_button_->GetPreferredSize()); 557 gfx::Rect label_rect(close_button_->GetPreferredSize());
581 label_rect.set_y(-label_rect.height()); 558 label_rect.set_y(-label_rect.height());
582 label_rect.set_width(transformed_window_bounds.width()); 559 label_rect.set_width(transformed_window_bounds.width());
583 560
584 if (!window_label_button_view_->visible()) { 561 if (!window_label_button_view_->visible()) {
585 window_label_button_view_->SetVisible(true); 562 window_label_button_view_->SetVisible(true);
586 SetupFadeInAfterLayout(window_label_.get()); 563 SetupFadeInAfterLayout(window_label_.get());
587 SetupFadeInAfterLayout(window_label_selector_.get()); 564 SetupFadeInAfterLayout(window_label_selector_.get());
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 window_label_selector_window->SetOpacity(opacity); 633 window_label_selector_window->SetOpacity(opacity);
657 } 634 }
658 635
659 void WindowSelectorItem::UpdateCloseButtonAccessibilityName() { 636 void WindowSelectorItem::UpdateCloseButtonAccessibilityName() {
660 close_button_->SetAccessibleName(l10n_util::GetStringFUTF16( 637 close_button_->SetAccessibleName(l10n_util::GetStringFUTF16(
661 IDS_ASH_OVERVIEW_CLOSE_ITEM_BUTTON_ACCESSIBLE_NAME, 638 IDS_ASH_OVERVIEW_CLOSE_ITEM_BUTTON_ACCESSIBLE_NAME,
662 GetWindow()->GetTitle())); 639 GetWindow()->GetTitle()));
663 } 640 }
664 641
665 } // namespace ash 642 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/wm/overview/window_selector_item.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698