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

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

Issue 2150823002: [ash-md] Implements a shadow over overview items and selector (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: [ash-md] Implements a shadow over overview items and selector (nits) Created 4 years, 5 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') | ui/wm/core/shadow.h » ('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 24 matching lines...) Expand all
35 #include "ui/gfx/geometry/vector2d.h" 35 #include "ui/gfx/geometry/vector2d.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/gfx/vector_icons.h" 38 #include "ui/gfx/vector_icons.h"
39 #include "ui/strings/grit/ui_strings.h" 39 #include "ui/strings/grit/ui_strings.h"
40 #include "ui/views/background.h" 40 #include "ui/views/background.h"
41 #include "ui/views/border.h" 41 #include "ui/views/border.h"
42 #include "ui/views/controls/button/image_button.h" 42 #include "ui/views/controls/button/image_button.h"
43 #include "ui/views/layout/box_layout.h" 43 #include "ui/views/layout/box_layout.h"
44 #include "ui/views/window/non_client_view.h" 44 #include "ui/views/window/non_client_view.h"
45 #include "ui/wm/core/shadow.h"
45 #include "ui/wm/core/window_util.h" 46 #include "ui/wm/core/window_util.h"
46 47
47 namespace ash { 48 namespace ash {
48 49
49 namespace { 50 namespace {
50 51
51 // In the conceptual overview table, the window margin is the space reserved 52 // In the conceptual overview table, the window margin is the space reserved
52 // around the window within the cell. This margin does not overlap so the 53 // around the window within the cell. This margin does not overlap so the
53 // closest distance between adjacent windows will be twice this amount. 54 // closest distance between adjacent windows will be twice this amount.
54 static const int kWindowMargin = 30; 55 static const int kWindowMargin = 30;
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 WmLookup::Get()->GetWindowForWidget(window_label_selector_.get()); 366 WmLookup::Get()->GetWindowForWidget(window_label_selector_.get());
366 ui::ScopedLayerAnimationSettings animation_settings( 367 ui::ScopedLayerAnimationSettings animation_settings(
367 window->GetLayer()->GetAnimator()); 368 window->GetLayer()->GetAnimator());
368 animation_settings.SetTransitionDuration( 369 animation_settings.SetTransitionDuration(
369 base::TimeDelta::FromMilliseconds(kSelectorFadeInMilliseconds)); 370 base::TimeDelta::FromMilliseconds(kSelectorFadeInMilliseconds));
370 animation_settings.SetTweenType(selected ? gfx::Tween::FAST_OUT_LINEAR_IN 371 animation_settings.SetTweenType(selected ? gfx::Tween::FAST_OUT_LINEAR_IN
371 : gfx::Tween::LINEAR_OUT_SLOW_IN); 372 : gfx::Tween::LINEAR_OUT_SLOW_IN);
372 animation_settings.SetPreemptionStrategy( 373 animation_settings.SetPreemptionStrategy(
373 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); 374 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
374 window->SetOpacity(selected ? 0.0f : 1.0f); 375 window->SetOpacity(selected ? 0.0f : 1.0f);
376
377 ui::ScopedLayerAnimationSettings animation_settings_shadow(
378 shadow_->shadow_layer()->GetAnimator());
379 animation_settings_shadow.SetTransitionDuration(
380 base::TimeDelta::FromMilliseconds(kSelectorFadeInMilliseconds));
381 animation_settings_shadow.SetTweenType(selected
382 ? gfx::Tween::FAST_OUT_LINEAR_IN
383 : gfx::Tween::LINEAR_OUT_SLOW_IN);
384 animation_settings_shadow.SetPreemptionStrategy(
385 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET);
386 shadow_->shadow_layer()->SetOpacity(selected ? 0.0f : 1.0f);
375 } 387 }
376 388
377 void WindowSelectorItem::RecomputeWindowTransforms() { 389 void WindowSelectorItem::RecomputeWindowTransforms() {
378 if (in_bounds_update_ || target_bounds_.IsEmpty()) 390 if (in_bounds_update_ || target_bounds_.IsEmpty())
379 return; 391 return;
380 base::AutoReset<bool> auto_reset_in_bounds_update(&in_bounds_update_, true); 392 base::AutoReset<bool> auto_reset_in_bounds_update(&in_bounds_update_, true);
381 gfx::Rect inset_bounds(target_bounds_); 393 gfx::Rect inset_bounds(target_bounds_);
382 if (ash::MaterialDesignController::IsOverviewMaterial()) 394 if (ash::MaterialDesignController::IsOverviewMaterial())
383 inset_bounds.Inset(kWindowMarginMD, kWindowMarginMD); 395 inset_bounds.Inset(kWindowMarginMD, kWindowMarginMD);
384 else 396 else
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); 551 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
540 window_label_button_view_->SetFontList(bundle.GetFontList( 552 window_label_button_view_->SetFontList(bundle.GetFontList(
541 material ? ui::ResourceBundle::BaseFont : ui::ResourceBundle::BoldFont)); 553 material ? ui::ResourceBundle::BaseFont : ui::ResourceBundle::BoldFont));
542 if (material) { 554 if (material) {
543 caption_container_view_ = 555 caption_container_view_ =
544 new CaptionContainerView(window_label_button_view_, close_button_); 556 new CaptionContainerView(window_label_button_view_, close_button_);
545 window_label_->SetContentsView(caption_container_view_); 557 window_label_->SetContentsView(caption_container_view_);
546 window_label_button_view_->SetVisible(false); 558 window_label_button_view_->SetVisible(false);
547 window_label_->Show(); 559 window_label_->Show();
548 560
561 shadow_.reset(new ::wm::Shadow());
562 shadow_->Init(::wm::Shadow::STYLE_INACTIVE);
563 shadow_->layer()->SetVisible(true);
564 window_label_->GetLayer()->Add(shadow_->layer());
565 window_label_->GetLayer()->SetMasksToBounds(false);
566
549 views::View* background_view = 567 views::View* background_view =
550 new RoundedContainerView(kLabelBackgroundRadius, kLabelBackgroundColor); 568 new RoundedContainerView(kLabelBackgroundRadius, kLabelBackgroundColor);
551 window_label_selector_.reset(new views::Widget); 569 window_label_selector_.reset(new views::Widget);
552 params.activatable = views::Widget::InitParams::Activatable::ACTIVATABLE_NO; 570 params.activatable = views::Widget::InitParams::Activatable::ACTIVATABLE_NO;
553 params.accept_events = false; 571 params.accept_events = false;
554 window_label_selector_->Init(params); 572 window_label_selector_->Init(params);
555 window_label_selector_->set_focus_on_creation(false); 573 window_label_selector_->set_focus_on_creation(false);
556 window_label_selector_->SetContentsView(background_view); 574 window_label_selector_->SetContentsView(background_view);
557 window_label_selector_->Show(); 575 window_label_selector_->Show();
558 } else { 576 } else {
(...skipping 28 matching lines...) Expand all
587 animation_settings_selector = 605 animation_settings_selector =
588 ScopedOverviewAnimationSettingsFactory::Get() 606 ScopedOverviewAnimationSettingsFactory::Get()
589 ->CreateOverviewAnimationSettings(animation_type, 607 ->CreateOverviewAnimationSettings(animation_type,
590 window_label_selector_window); 608 window_label_selector_window);
591 window_label_selector_window->SetBounds(label_rect); 609 window_label_selector_window->SetBounds(label_rect);
592 // |window_label_window| covers both the transformed window and the header 610 // |window_label_window| covers both the transformed window and the header
593 // as well as the gap between the windows to prevent events from reaching 611 // as well as the gap between the windows to prevent events from reaching
594 // the window including its sizing borders. 612 // the window including its sizing borders.
595 label_rect.set_height(label_rect.height() + 613 label_rect.set_height(label_rect.height() +
596 transformed_window_bounds.height()); 614 transformed_window_bounds.height());
615 gfx::Rect shadow_bounds(label_rect.size());
597 label_rect.Inset(-kWindowSelectorMargin, -kWindowSelectorMargin); 616 label_rect.Inset(-kWindowSelectorMargin, -kWindowSelectorMargin);
598 window_label_window->SetBounds(label_rect); 617 window_label_window->SetBounds(label_rect);
599 gfx::Transform label_transform; 618 gfx::Transform label_transform;
600 label_transform.Translate(transformed_window_bounds.x(), 619 label_transform.Translate(transformed_window_bounds.x(),
601 transformed_window_bounds.y()); 620 transformed_window_bounds.y());
602 window_label_window->SetTransform(label_transform); 621 window_label_window->SetTransform(label_transform);
603 window_label_selector_window->SetTransform(label_transform); 622 window_label_selector_window->SetTransform(label_transform);
623
624 shadow_bounds.Offset(kWindowSelectorMargin, kWindowSelectorMargin);
625 shadow_->SetContentBounds(shadow_bounds);
604 } else { 626 } else {
605 if (!close_button_->visible()) { 627 if (!close_button_->visible()) {
606 close_button_->SetVisible(true); 628 close_button_->SetVisible(true);
607 SetupFadeInAfterLayout(close_button_widget_.get()); 629 SetupFadeInAfterLayout(close_button_widget_.get());
608 } 630 }
609 WmWindow* close_button_widget_window = 631 WmWindow* close_button_widget_window =
610 WmLookup::Get()->GetWindowForWidget(close_button_widget_.get()); 632 WmLookup::Get()->GetWindowForWidget(close_button_widget_.get());
611 std::unique_ptr<ScopedOverviewAnimationSettings> animation_settings = 633 std::unique_ptr<ScopedOverviewAnimationSettings> animation_settings =
612 ScopedOverviewAnimationSettingsFactory::Get() 634 ScopedOverviewAnimationSettingsFactory::Get()
613 ->CreateOverviewAnimationSettings(animation_type, 635 ->CreateOverviewAnimationSettings(animation_type,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
645 window_label_selector_window->SetOpacity(opacity); 667 window_label_selector_window->SetOpacity(opacity);
646 } 668 }
647 669
648 void WindowSelectorItem::UpdateCloseButtonAccessibilityName() { 670 void WindowSelectorItem::UpdateCloseButtonAccessibilityName() {
649 close_button_->SetAccessibleName(l10n_util::GetStringFUTF16( 671 close_button_->SetAccessibleName(l10n_util::GetStringFUTF16(
650 IDS_ASH_OVERVIEW_CLOSE_ITEM_BUTTON_ACCESSIBLE_NAME, 672 IDS_ASH_OVERVIEW_CLOSE_ITEM_BUTTON_ACCESSIBLE_NAME,
651 GetWindow()->GetTitle())); 673 GetWindow()->GetTitle()));
652 } 674 }
653 675
654 } // namespace ash 676 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/wm/overview/window_selector_item.h ('k') | ui/wm/core/shadow.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698