| Index: ash/shelf/shelf_widget.cc
|
| diff --git a/ash/shelf/shelf_widget.cc b/ash/shelf/shelf_widget.cc
|
| index 37f63de6e639c1fbca81d84c3cf3b236684d8469..35c360e0f0b4ea43e73c9bef31b2185a009f7521 100644
|
| --- a/ash/shelf/shelf_widget.cc
|
| +++ b/ash/shelf/shelf_widget.cc
|
| @@ -15,6 +15,7 @@
|
| #include "ash/common/shell_window_ids.h"
|
| #include "ash/common/wm_root_window_controller.h"
|
| #include "ash/focus_cycler.h"
|
| +#include "ash/shelf/shelf_background_animator_delegate.h"
|
| #include "ash/shelf/shelf_delegate.h"
|
| #include "ash/shelf/shelf_layout_manager.h"
|
| #include "ash/shelf/shelf_navigator.h"
|
| @@ -79,7 +80,7 @@ class DimmerView : public views::View,
|
| const views::Widget* GetWidget() const override { return View::GetWidget(); }
|
|
|
| // BackgroundAnimatorDelegate overrides:
|
| - void UpdateBackground(int alpha) override {
|
| + void UpdateBackground(BackgroundAnimator* animator, int alpha) override {
|
| alpha_ = alpha;
|
| SchedulePaint();
|
| }
|
| @@ -301,7 +302,7 @@ class ShelfWindowTargeter : public ::wm::EasyResizeWindowTargeter,
|
| // sizes it to the width of the shelf minus the size of the status area.
|
| class ShelfWidget::DelegateView : public views::WidgetDelegate,
|
| public views::AccessiblePaneView,
|
| - public BackgroundAnimatorDelegate,
|
| + public ShelfBackgroundAnimatorDelegate,
|
| public aura::WindowObserver {
|
| public:
|
| explicit DelegateView(ShelfWidget* shelf);
|
| @@ -312,6 +313,7 @@ class ShelfWidget::DelegateView : public views::WidgetDelegate,
|
| }
|
| FocusCycler* focus_cycler() { return focus_cycler_; }
|
|
|
| + // TODO(bruthig): Remove opaque_background_.
|
| ui::Layer* opaque_background() { return &opaque_background_; }
|
| ui::Layer* opaque_foreground() { return &opaque_foreground_; }
|
|
|
| @@ -342,8 +344,8 @@ class ShelfWidget::DelegateView : public views::WidgetDelegate,
|
| const gfx::Rect& old_bounds,
|
| const gfx::Rect& new_bounds) override;
|
|
|
| - // BackgroundAnimatorDelegate overrides:
|
| - void UpdateBackground(int alpha) override;
|
| + // ShelfBackgroundAnimatorDelegate overrides:
|
| + void UpdateBackgroundAlpha(int alpha) override;
|
|
|
| // Force the shelf to be presented in an undimmed state.
|
| void ForceUndimming(bool force);
|
| @@ -367,6 +369,7 @@ class ShelfWidget::DelegateView : public views::WidgetDelegate,
|
| std::unique_ptr<views::Widget> dimmer_;
|
| FocusCycler* focus_cycler_;
|
| int alpha_;
|
| + // TODO(bruthig): Remove opaque_background_.
|
| // A black background layer which is shown when a maximized window is visible.
|
| ui::Layer opaque_background_;
|
| // A black foreground layer which is shown while transitioning between users.
|
| @@ -387,12 +390,14 @@ ShelfWidget::DelegateView::DelegateView(ShelfWidget* shelf)
|
| : shelf_(shelf),
|
| focus_cycler_(NULL),
|
| alpha_(0),
|
| + // TODO(bruthig): Remove opaque_background_.
|
| opaque_background_(ui::LAYER_SOLID_COLOR),
|
| opaque_foreground_(ui::LAYER_SOLID_COLOR),
|
| dimmer_view_(NULL),
|
| disable_dimming_animations_for_test_(false) {
|
| SetLayoutManager(new views::FillLayout());
|
| set_allow_deactivate_on_esc(true);
|
| + // TODO(bruthig): Remove opaque_background_.
|
| opaque_background_.SetColor(SK_ColorBLACK);
|
| opaque_background_.SetBounds(GetLocalBounds());
|
| opaque_background_.SetOpacity(0.0f);
|
| @@ -443,6 +448,7 @@ bool ShelfWidget::DelegateView::GetDimmed() const {
|
| }
|
|
|
| void ShelfWidget::DelegateView::SetParentLayer(ui::Layer* layer) {
|
| + // TODO(bruthig): Remove opaque_background_.
|
| layer->Add(&opaque_background_);
|
| layer->Add(&opaque_foreground_);
|
| ReorderLayers();
|
| @@ -521,11 +527,13 @@ bool ShelfWidget::DelegateView::CanActivate() const {
|
|
|
| void ShelfWidget::DelegateView::ReorderChildLayers(ui::Layer* parent_layer) {
|
| views::View::ReorderChildLayers(parent_layer);
|
| + // TODO(bruthig): Remove opaque_background_.
|
| parent_layer->StackAtBottom(&opaque_background_);
|
| parent_layer->StackAtTop(&opaque_foreground_);
|
| }
|
|
|
| void ShelfWidget::DelegateView::OnBoundsChanged(const gfx::Rect& old_bounds) {
|
| + // TODO(bruthig): Remove opaque_background_.
|
| opaque_background_.SetBounds(GetLocalBounds());
|
| opaque_foreground_.SetBounds(GetLocalBounds());
|
| if (dimmer_)
|
| @@ -559,7 +567,7 @@ gfx::Rect ShelfWidget::DelegateView::GetDimmerBoundsForTest() {
|
| return gfx::Rect();
|
| }
|
|
|
| -void ShelfWidget::DelegateView::UpdateBackground(int alpha) {
|
| +void ShelfWidget::DelegateView::UpdateBackgroundAlpha(int alpha) {
|
| alpha_ = alpha;
|
| SchedulePaint();
|
| }
|
| @@ -568,8 +576,6 @@ ShelfWidget::ShelfWidget(WmWindow* wm_shelf_container,
|
| WmWindow* wm_status_container,
|
| WorkspaceController* workspace_controller)
|
| : delegate_view_(new DelegateView(this)),
|
| - background_animator_(
|
| - delegate_view_, 0, GetShelfConstant(SHELF_BACKGROUND_ALPHA)),
|
| activating_as_fallback_(false) {
|
| views::Widget::InitParams params(
|
| views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
|
| @@ -594,6 +600,11 @@ ShelfWidget::ShelfWidget(WmWindow* wm_shelf_container,
|
| shelf_layout_manager_->set_workspace_controller(workspace_controller);
|
| workspace_controller->SetShelf(shelf_layout_manager_);
|
|
|
| + background_animator_.PaintBackground(SHELF_BACKGROUND_DEFAULT,
|
| + BACKGROUND_CHANGE_IMMEDIATE);
|
| + background_animator_.AddShelfBackgroundDelegate(delegate_view_);
|
| + shelf_layout_manager_->AddObserver(&background_animator_);
|
| +
|
| status_area_widget_ = new StatusAreaWidget(wm_status_container, this);
|
| status_area_widget_->CreateTrayViews();
|
| if (Shell::GetInstance()->session_state_delegate()->
|
| @@ -623,6 +634,7 @@ ShelfWidget::~ShelfWidget() {
|
| RemoveObserver(this);
|
| }
|
|
|
| +// TODO(bruthig): Remove opaque_background_ => This entire method.
|
| void ShelfWidget::SetPaintsBackground(
|
| ShelfBackgroundType background_type,
|
| BackgroundAnimatorChangeType change_type) {
|
| @@ -641,17 +653,11 @@ void ShelfWidget::SetPaintsBackground(
|
| // TODO(mukai): use ui::Layer on both opaque_background and normal background
|
| // retire background_animator_ at all. It would be simpler.
|
| // See also DockedBackgroundWidget::SetPaintsBackground.
|
| - background_animator_.SetPaintsBackground(
|
| - background_type != SHELF_BACKGROUND_DEFAULT, change_type);
|
| + background_animator_.PaintBackground(background_type, change_type);
|
| }
|
|
|
| ShelfBackgroundType ShelfWidget::GetBackgroundType() const {
|
| - if (delegate_view_->opaque_background()->GetTargetOpacity() == 1.0f)
|
| - return SHELF_BACKGROUND_MAXIMIZED;
|
| - if (background_animator_.paints_background())
|
| - return SHELF_BACKGROUND_OVERLAP;
|
| -
|
| - return SHELF_BACKGROUND_DEFAULT;
|
| + return background_animator_.target_background_type();
|
| }
|
|
|
| void ShelfWidget::HideShelfBehindBlackBar(bool hide, int animation_time_ms) {
|
| @@ -813,6 +819,7 @@ void ShelfWidget::DisableDimmingAnimationsForTest() {
|
| }
|
|
|
| void ShelfWidget::WillDeleteShelfLayoutManager() {
|
| + shelf_layout_manager_->RemoveObserver(&background_animator_);
|
| shelf_layout_manager_->RemoveObserver(this);
|
| shelf_layout_manager_ = NULL;
|
| }
|
|
|