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

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

Issue 2692663002: Gut ash::MaterialDesignController, and remove the about:flags entry. (Closed)
Patch Set: yet another rebase Created 3 years, 10 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') | ash/dip_unittest.cc » ('j') | 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 26 matching lines...) Expand all
37 #include "ui/gfx/color_utils.h" 37 #include "ui/gfx/color_utils.h"
38 #include "ui/gfx/geometry/safe_integer_conversions.h" 38 #include "ui/gfx/geometry/safe_integer_conversions.h"
39 #include "ui/gfx/paint_vector_icon.h" 39 #include "ui/gfx/paint_vector_icon.h"
40 #include "ui/gfx/transform_util.h" 40 #include "ui/gfx/transform_util.h"
41 #include "ui/strings/grit/ui_strings.h" 41 #include "ui/strings/grit/ui_strings.h"
42 #include "ui/views/background.h" 42 #include "ui/views/background.h"
43 #include "ui/views/border.h" 43 #include "ui/views/border.h"
44 #include "ui/views/layout/box_layout.h" 44 #include "ui/views/layout/box_layout.h"
45 #include "ui/views/window/non_client_view.h" 45 #include "ui/views/window/non_client_view.h"
46 #include "ui/wm/core/shadow.h" 46 #include "ui/wm/core/shadow.h"
47 #include "ui/wm/core/shadow_types.h"
48 #include "ui/wm/core/window_util.h" 47 #include "ui/wm/core/window_util.h"
49 48
50 namespace ash { 49 namespace ash {
51 50
52 namespace { 51 namespace {
53 52
54 // In the conceptual overview table, the window margin is the space reserved 53 // In the conceptual overview table, the window margin is the space reserved
55 // around the window within the cell. This margin does not overlap so the 54 // around the window within the cell. This margin does not overlap so the
56 // closest distance between adjacent windows will be twice this amount. 55 // closest distance between adjacent windows will be twice this amount.
57 static const int kWindowMargin = 5; 56 static const int kWindowMargin = 5;
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 SetItemBounds(inset_bounds, animation_type); 492 SetItemBounds(inset_bounds, animation_type);
494 493
495 // SetItemBounds is called before UpdateHeaderLayout so the header can 494 // SetItemBounds is called before UpdateHeaderLayout so the header can
496 // properly use the updated windows bounds. 495 // properly use the updated windows bounds.
497 UpdateHeaderLayout(HeaderFadeInMode::UPDATE, animation_type); 496 UpdateHeaderLayout(HeaderFadeInMode::UPDATE, animation_type);
498 } 497 }
499 498
500 void WindowSelectorItem::SetSelected(bool selected) { 499 void WindowSelectorItem::SetSelected(bool selected) {
501 selected_ = selected; 500 selected_ = selected;
502 background_view_->AnimateBackgroundOpacity(selected ? 0.f : kHeaderOpacity); 501 background_view_->AnimateBackgroundOpacity(selected ? 0.f : kHeaderOpacity);
503
504 if (shadow_) {
505 ui::ScopedLayerAnimationSettings animation_settings_shadow(
506 shadow_->shadow_layer()->GetAnimator());
507 animation_settings_shadow.SetTransitionDuration(
508 base::TimeDelta::FromMilliseconds(kSelectorFadeInMilliseconds));
509 animation_settings_shadow.SetTweenType(
510 selected ? gfx::Tween::FAST_OUT_LINEAR_IN
511 : gfx::Tween::LINEAR_OUT_SLOW_IN);
512 animation_settings_shadow.SetPreemptionStrategy(
513 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
514 shadow_->shadow_layer()->SetOpacity(selected ? 0.0f : 1.0f);
515 }
516 } 502 }
517 503
518 void WindowSelectorItem::SendAccessibleSelectionEvent() { 504 void WindowSelectorItem::SendAccessibleSelectionEvent() {
519 caption_container_view_->listener_button()->NotifyAccessibilityEvent( 505 caption_container_view_->listener_button()->NotifyAccessibilityEvent(
520 ui::AX_EVENT_SELECTION, true); 506 ui::AX_EVENT_SELECTION, true);
521 } 507 }
522 508
523 void WindowSelectorItem::CloseWindow() { 509 void WindowSelectorItem::CloseWindow() {
524 gfx::Rect inset_bounds(target_bounds_); 510 gfx::Rect inset_bounds(target_bounds_);
525 inset_bounds.Inset(target_bounds_.width() * kPreCloseScale, 511 inset_bounds.Inset(target_bounds_.width() * kPreCloseScale,
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 // background color is opaque or transparent to decide whether to use 647 // background color is opaque or transparent to decide whether to use
662 // subpixel rendering. Does not actually set the label's background color. 648 // subpixel rendering. Does not actually set the label's background color.
663 label_view_->SetBackgroundColor(kLabelBackgroundColor); 649 label_view_->SetBackgroundColor(kLabelBackgroundColor);
664 650
665 caption_container_view_ = new CaptionContainerView( 651 caption_container_view_ = new CaptionContainerView(
666 this, label_view_, close_button_, background_view_); 652 this, label_view_, close_button_, background_view_);
667 item_widget_->SetContentsView(caption_container_view_); 653 item_widget_->SetContentsView(caption_container_view_);
668 label_view_->SetVisible(false); 654 label_view_->SetVisible(false);
669 item_widget_->SetOpacity(0); 655 item_widget_->SetOpacity(0);
670 item_widget_->Show(); 656 item_widget_->Show();
671
672 // TODO(varkha): Restore shadows when programmatic shadows exist.
673 // Note: current shadow implementation does not allow proper animation when
674 // the parent layer bounds change during the animation since
675 // Shadow::UpdateLayerBounds() only happens before the animation starts.
676 if (ash::MaterialDesignController::GetMode() ==
677 ash::MaterialDesignController::Mode::MATERIAL_EXPERIMENTAL) {
678 shadow_.reset(new ::wm::Shadow());
679 shadow_->Init(::wm::ShadowElevation::MEDIUM);
680 shadow_->layer()->SetVisible(true);
681 item_widget_->GetLayer()->Add(shadow_->layer());
682 }
683 item_widget_->GetLayer()->SetMasksToBounds(false); 657 item_widget_->GetLayer()->SetMasksToBounds(false);
684 } 658 }
685 659
686 void WindowSelectorItem::UpdateHeaderLayout( 660 void WindowSelectorItem::UpdateHeaderLayout(
687 HeaderFadeInMode mode, 661 HeaderFadeInMode mode,
688 OverviewAnimationType animation_type) { 662 OverviewAnimationType animation_type) {
689 gfx::Rect transformed_window_bounds = root_window_->ConvertRectFromScreen( 663 gfx::Rect transformed_window_bounds = root_window_->ConvertRectFromScreen(
690 transform_window_.GetTransformedBounds()); 664 transform_window_.GetTransformedBounds());
691 665
692 gfx::Rect label_rect(close_button_->GetPreferredSize()); 666 gfx::Rect label_rect(close_button_->GetPreferredSize());
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 if (mode != HeaderFadeInMode::ENTER) { 703 if (mode != HeaderFadeInMode::ENTER) {
730 label_rect.set_height(close_button_->GetPreferredSize().height() + 704 label_rect.set_height(close_button_->GetPreferredSize().height() +
731 transformed_window_bounds.height()); 705 transformed_window_bounds.height());
732 } 706 }
733 label_rect.Inset(-kWindowSelectorMargin, -kWindowSelectorMargin); 707 label_rect.Inset(-kWindowSelectorMargin, -kWindowSelectorMargin);
734 widget_window->SetBounds(label_rect); 708 widget_window->SetBounds(label_rect);
735 gfx::Transform label_transform; 709 gfx::Transform label_transform;
736 label_transform.Translate(transformed_window_bounds.x(), 710 label_transform.Translate(transformed_window_bounds.x(),
737 transformed_window_bounds.y()); 711 transformed_window_bounds.y());
738 widget_window->SetTransform(label_transform); 712 widget_window->SetTransform(label_transform);
739
740 gfx::Rect shadow_bounds(label_rect.size());
741 shadow_bounds.Inset(kWindowSelectorMargin, kWindowSelectorMargin);
742 if (shadow_)
743 shadow_->SetContentBounds(shadow_bounds);
744 } 713 }
745 714
746 void WindowSelectorItem::AnimateOpacity(float opacity, 715 void WindowSelectorItem::AnimateOpacity(float opacity,
747 OverviewAnimationType animation_type) { 716 OverviewAnimationType animation_type) {
748 DCHECK_GE(opacity, 0.f); 717 DCHECK_GE(opacity, 0.f);
749 DCHECK_LE(opacity, 1.f); 718 DCHECK_LE(opacity, 1.f);
750 ScopedTransformOverviewWindow::ScopedAnimationSettings animation_settings; 719 ScopedTransformOverviewWindow::ScopedAnimationSettings animation_settings;
751 transform_window_.BeginScopedAnimation(animation_type, &animation_settings); 720 transform_window_.BeginScopedAnimation(animation_type, &animation_settings);
752 transform_window_.SetOpacity(opacity); 721 transform_window_.SetOpacity(opacity);
753 722
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 761
793 gfx::SlideAnimation* WindowSelectorItem::GetBackgroundViewAnimation() { 762 gfx::SlideAnimation* WindowSelectorItem::GetBackgroundViewAnimation() {
794 return background_view_ ? background_view_->animation() : nullptr; 763 return background_view_ ? background_view_->animation() : nullptr;
795 } 764 }
796 765
797 WmWindow* WindowSelectorItem::GetOverviewWindowForMinimizedStateForTest() { 766 WmWindow* WindowSelectorItem::GetOverviewWindowForMinimizedStateForTest() {
798 return transform_window_.GetOverviewWindowForMinimizedState(); 767 return transform_window_.GetOverviewWindowForMinimizedState();
799 } 768 }
800 769
801 } // namespace ash 770 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/wm/overview/window_selector_item.h ('k') | ash/dip_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698