| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/shelf/shelf_widget.h" | 5 #include "ash/shelf/shelf_widget.h" |
| 6 | 6 |
| 7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
| 8 #include "ash/focus_cycler.h" | 8 #include "ash/focus_cycler.h" |
| 9 #include "ash/root_window_controller.h" | 9 #include "ash/root_window_controller.h" |
| 10 #include "ash/session/session_state_delegate.h" | 10 #include "ash/session/session_state_delegate.h" |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 // True if someone forces us not to be dimmed (e.g. a menu is open). | 120 // True if someone forces us not to be dimmed (e.g. a menu is open). |
| 121 bool force_hovered_; | 121 bool force_hovered_; |
| 122 | 122 |
| 123 // True if animations should be suppressed for a test. | 123 // True if animations should be suppressed for a test. |
| 124 bool disable_dimming_animations_for_test_; | 124 bool disable_dimming_animations_for_test_; |
| 125 | 125 |
| 126 // The animator for the background transitions. | 126 // The animator for the background transitions. |
| 127 ash::BackgroundAnimator background_animator_; | 127 ash::BackgroundAnimator background_animator_; |
| 128 | 128 |
| 129 // Notification of entering / exiting of the shelf area by mouse. | 129 // Notification of entering / exiting of the shelf area by mouse. |
| 130 scoped_ptr<DimmerEventFilter> event_filter_; | 130 std::unique_ptr<DimmerEventFilter> event_filter_; |
| 131 | 131 |
| 132 DISALLOW_COPY_AND_ASSIGN(DimmerView); | 132 DISALLOW_COPY_AND_ASSIGN(DimmerView); |
| 133 }; | 133 }; |
| 134 | 134 |
| 135 DimmerView::DimmerView(ash::ShelfWidget* shelf_widget, | 135 DimmerView::DimmerView(ash::ShelfWidget* shelf_widget, |
| 136 bool disable_dimming_animations_for_test) | 136 bool disable_dimming_animations_for_test) |
| 137 : shelf_(shelf_widget), | 137 : shelf_(shelf_widget), |
| 138 alpha_(kDimAlpha), | 138 alpha_(kDimAlpha), |
| 139 is_hovered_(false), | 139 is_hovered_(false), |
| 140 force_hovered_(false), | 140 force_hovered_(false), |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 gfx::Rect GetDimmerBoundsForTest(); | 372 gfx::Rect GetDimmerBoundsForTest(); |
| 373 | 373 |
| 374 // Disable dimming animations for running tests. This needs to be called | 374 // Disable dimming animations for running tests. This needs to be called |
| 375 // prior to the creation of of the |dimmer_|. | 375 // prior to the creation of of the |dimmer_|. |
| 376 void disable_dimming_animations_for_test() { | 376 void disable_dimming_animations_for_test() { |
| 377 disable_dimming_animations_for_test_ = true; | 377 disable_dimming_animations_for_test_ = true; |
| 378 } | 378 } |
| 379 | 379 |
| 380 private: | 380 private: |
| 381 ShelfWidget* shelf_; | 381 ShelfWidget* shelf_; |
| 382 scoped_ptr<views::Widget> dimmer_; | 382 std::unique_ptr<views::Widget> dimmer_; |
| 383 FocusCycler* focus_cycler_; | 383 FocusCycler* focus_cycler_; |
| 384 int alpha_; | 384 int alpha_; |
| 385 // A black background layer which is shown when a maximized window is visible. | 385 // A black background layer which is shown when a maximized window is visible. |
| 386 ui::Layer opaque_background_; | 386 ui::Layer opaque_background_; |
| 387 // A black foreground layer which is shown while transitioning between users. | 387 // A black foreground layer which is shown while transitioning between users. |
| 388 // Note: Since the back- and foreground layers have different functions they | 388 // Note: Since the back- and foreground layers have different functions they |
| 389 // can be used simultaneously - so no repurposing possible. | 389 // can be used simultaneously - so no repurposing possible. |
| 390 ui::Layer opaque_foreground_; | 390 ui::Layer opaque_foreground_; |
| 391 | 391 |
| 392 // The view which does the dimming. | 392 // The view which does the dimming. |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 624 status_area_widget_->CreateTrayViews(); | 624 status_area_widget_->CreateTrayViews(); |
| 625 if (Shell::GetInstance()->session_state_delegate()-> | 625 if (Shell::GetInstance()->session_state_delegate()-> |
| 626 IsActiveUserSessionStarted()) { | 626 IsActiveUserSessionStarted()) { |
| 627 status_area_widget_->Show(); | 627 status_area_widget_->Show(); |
| 628 } | 628 } |
| 629 Shell::GetInstance()->focus_cycler()->AddWidget(status_area_widget_); | 629 Shell::GetInstance()->focus_cycler()->AddWidget(status_area_widget_); |
| 630 | 630 |
| 631 status_container->SetLayoutManager( | 631 status_container->SetLayoutManager( |
| 632 new StatusAreaLayoutManager(status_container, this)); | 632 new StatusAreaLayoutManager(status_container, this)); |
| 633 | 633 |
| 634 shelf_container->SetEventTargeter(scoped_ptr<ui::EventTargeter>(new | 634 shelf_container->SetEventTargeter(std::unique_ptr<ui::EventTargeter>( |
| 635 ShelfWindowTargeter(shelf_container, shelf_layout_manager_))); | 635 new ShelfWindowTargeter(shelf_container, shelf_layout_manager_))); |
| 636 status_container->SetEventTargeter(scoped_ptr<ui::EventTargeter>(new | 636 status_container->SetEventTargeter(std::unique_ptr<ui::EventTargeter>( |
| 637 ShelfWindowTargeter(status_container, shelf_layout_manager_))); | 637 new ShelfWindowTargeter(status_container, shelf_layout_manager_))); |
| 638 | 638 |
| 639 views::Widget::AddObserver(this); | 639 views::Widget::AddObserver(this); |
| 640 } | 640 } |
| 641 | 641 |
| 642 ShelfWidget::~ShelfWidget() { | 642 ShelfWidget::~ShelfWidget() { |
| 643 Shell::GetInstance()->focus_cycler()->RemoveWidget(this); | 643 Shell::GetInstance()->focus_cycler()->RemoveWidget(this); |
| 644 SetFocusCycler(nullptr); | 644 SetFocusCycler(nullptr); |
| 645 RemoveObserver(this); | 645 RemoveObserver(this); |
| 646 } | 646 } |
| 647 | 647 |
| 648 void ShelfWidget::SetPaintsBackground( | 648 void ShelfWidget::SetPaintsBackground( |
| 649 ShelfBackgroundType background_type, | 649 ShelfBackgroundType background_type, |
| 650 BackgroundAnimatorChangeType change_type) { | 650 BackgroundAnimatorChangeType change_type) { |
| 651 ui::Layer* opaque_background = delegate_view_->opaque_background(); | 651 ui::Layer* opaque_background = delegate_view_->opaque_background(); |
| 652 float target_opacity = | 652 float target_opacity = |
| 653 (background_type == SHELF_BACKGROUND_MAXIMIZED) ? 1.0f : 0.0f; | 653 (background_type == SHELF_BACKGROUND_MAXIMIZED) ? 1.0f : 0.0f; |
| 654 scoped_ptr<ui::ScopedLayerAnimationSettings> opaque_background_animation; | 654 std::unique_ptr<ui::ScopedLayerAnimationSettings> opaque_background_animation; |
| 655 if (change_type != BACKGROUND_CHANGE_IMMEDIATE) { | 655 if (change_type != BACKGROUND_CHANGE_IMMEDIATE) { |
| 656 opaque_background_animation.reset(new ui::ScopedLayerAnimationSettings( | 656 opaque_background_animation.reset(new ui::ScopedLayerAnimationSettings( |
| 657 opaque_background->GetAnimator())); | 657 opaque_background->GetAnimator())); |
| 658 opaque_background_animation->SetTransitionDuration( | 658 opaque_background_animation->SetTransitionDuration( |
| 659 base::TimeDelta::FromMilliseconds(kTimeToSwitchBackgroundMs)); | 659 base::TimeDelta::FromMilliseconds(kTimeToSwitchBackgroundMs)); |
| 660 } | 660 } |
| 661 opaque_background->SetOpacity(target_opacity); | 661 opaque_background->SetOpacity(target_opacity); |
| 662 | 662 |
| 663 // TODO(mukai): use ui::Layer on both opaque_background and normal background | 663 // TODO(mukai): use ui::Layer on both opaque_background and normal background |
| 664 // retire background_animator_ at all. It would be simpler. | 664 // retire background_animator_ at all. It would be simpler. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 677 | 677 |
| 678 return SHELF_BACKGROUND_DEFAULT; | 678 return SHELF_BACKGROUND_DEFAULT; |
| 679 } | 679 } |
| 680 | 680 |
| 681 void ShelfWidget::HideShelfBehindBlackBar(bool hide, int animation_time_ms) { | 681 void ShelfWidget::HideShelfBehindBlackBar(bool hide, int animation_time_ms) { |
| 682 if (IsShelfHiddenBehindBlackBar() == hide) | 682 if (IsShelfHiddenBehindBlackBar() == hide) |
| 683 return; | 683 return; |
| 684 | 684 |
| 685 ui::Layer* opaque_foreground = delegate_view_->opaque_foreground(); | 685 ui::Layer* opaque_foreground = delegate_view_->opaque_foreground(); |
| 686 float target_opacity = hide ? 1.0f : 0.0f; | 686 float target_opacity = hide ? 1.0f : 0.0f; |
| 687 scoped_ptr<ui::ScopedLayerAnimationSettings> opaque_foreground_animation; | 687 std::unique_ptr<ui::ScopedLayerAnimationSettings> opaque_foreground_animation; |
| 688 opaque_foreground_animation.reset(new ui::ScopedLayerAnimationSettings( | 688 opaque_foreground_animation.reset(new ui::ScopedLayerAnimationSettings( |
| 689 opaque_foreground->GetAnimator())); | 689 opaque_foreground->GetAnimator())); |
| 690 opaque_foreground_animation->SetTransitionDuration( | 690 opaque_foreground_animation->SetTransitionDuration( |
| 691 base::TimeDelta::FromMilliseconds(animation_time_ms)); | 691 base::TimeDelta::FromMilliseconds(animation_time_ms)); |
| 692 opaque_foreground_animation->SetPreemptionStrategy( | 692 opaque_foreground_animation->SetPreemptionStrategy( |
| 693 ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); | 693 ui::LayerAnimator::REPLACE_QUEUED_ANIMATIONS); |
| 694 | 694 |
| 695 opaque_foreground->SetOpacity(target_opacity); | 695 opaque_foreground->SetOpacity(target_opacity); |
| 696 } | 696 } |
| 697 | 697 |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 826 DCHECK(delegate_view_); | 826 DCHECK(delegate_view_); |
| 827 return delegate_view_->disable_dimming_animations_for_test(); | 827 return delegate_view_->disable_dimming_animations_for_test(); |
| 828 } | 828 } |
| 829 | 829 |
| 830 void ShelfWidget::WillDeleteShelf() { | 830 void ShelfWidget::WillDeleteShelf() { |
| 831 shelf_layout_manager_->RemoveObserver(this); | 831 shelf_layout_manager_->RemoveObserver(this); |
| 832 shelf_layout_manager_ = NULL; | 832 shelf_layout_manager_ = NULL; |
| 833 } | 833 } |
| 834 | 834 |
| 835 } // namespace ash | 835 } // namespace ash |
| OLD | NEW |