| 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/aura/wm_shelf_aura.h" | 8 #include "ash/aura/wm_shelf_aura.h" |
| 9 #include "ash/aura/wm_window_aura.h" | 9 #include "ash/aura/wm_window_aura.h" |
| 10 #include "ash/common/material_design/material_design_controller.h" | 10 #include "ash/common/material_design/material_design_controller.h" |
| 11 #include "ash/common/session/session_state_delegate.h" | 11 #include "ash/common/session/session_state_delegate.h" |
| 12 #include "ash/common/shelf/shelf_constants.h" | 12 #include "ash/common/shelf/shelf_constants.h" |
| 13 #include "ash/common/shelf/shelf_model.h" | 13 #include "ash/common/shelf/shelf_model.h" |
| 14 #include "ash/common/shelf/wm_shelf_util.h" | 14 #include "ash/common/shelf/wm_shelf_util.h" |
| 15 #include "ash/common/shell_window_ids.h" | 15 #include "ash/common/shell_window_ids.h" |
| 16 #include "ash/common/wm_root_window_controller.h" | 16 #include "ash/common/wm_root_window_controller.h" |
| 17 #include "ash/focus_cycler.h" | 17 #include "ash/focus_cycler.h" |
| 18 #include "ash/shelf/shelf_background_animator_delegate.h" |
| 18 #include "ash/shelf/shelf_delegate.h" | 19 #include "ash/shelf/shelf_delegate.h" |
| 19 #include "ash/shelf/shelf_layout_manager.h" | 20 #include "ash/shelf/shelf_layout_manager.h" |
| 20 #include "ash/shelf/shelf_navigator.h" | 21 #include "ash/shelf/shelf_navigator.h" |
| 21 #include "ash/shelf/shelf_util.h" | 22 #include "ash/shelf/shelf_util.h" |
| 22 #include "ash/shelf/shelf_view.h" | 23 #include "ash/shelf/shelf_view.h" |
| 23 #include "ash/shell.h" | 24 #include "ash/shell.h" |
| 24 #include "ash/system/tray/system_tray_delegate.h" | 25 #include "ash/system/tray/system_tray_delegate.h" |
| 25 #include "ash/wm/status_area_layout_manager.h" | 26 #include "ash/wm/status_area_layout_manager.h" |
| 26 #include "ash/wm/window_properties.h" | 27 #include "ash/wm/window_properties.h" |
| 27 #include "ash/wm/workspace_controller.h" | 28 #include "ash/wm/workspace_controller.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 void SetHovered(bool hovered); | 73 void SetHovered(bool hovered); |
| 73 | 74 |
| 74 // Force the dimmer to be undimmed. | 75 // Force the dimmer to be undimmed. |
| 75 void ForceUndimming(bool force); | 76 void ForceUndimming(bool force); |
| 76 | 77 |
| 77 // views::WidgetDelegate overrides: | 78 // views::WidgetDelegate overrides: |
| 78 views::Widget* GetWidget() override { return View::GetWidget(); } | 79 views::Widget* GetWidget() override { return View::GetWidget(); } |
| 79 const views::Widget* GetWidget() const override { return View::GetWidget(); } | 80 const views::Widget* GetWidget() const override { return View::GetWidget(); } |
| 80 | 81 |
| 81 // BackgroundAnimatorDelegate overrides: | 82 // BackgroundAnimatorDelegate overrides: |
| 82 void UpdateBackground(int alpha) override { | 83 void UpdateBackground(BackgroundAnimator* animator, int alpha) override { |
| 83 alpha_ = alpha; | 84 alpha_ = alpha; |
| 84 SchedulePaint(); | 85 SchedulePaint(); |
| 85 } | 86 } |
| 86 | 87 |
| 87 // views::View overrides: | 88 // views::View overrides: |
| 88 void OnPaintBackground(gfx::Canvas* canvas) override; | 89 void OnPaintBackground(gfx::Canvas* canvas) override; |
| 89 | 90 |
| 90 // A function to test the current alpha used. | 91 // A function to test the current alpha used. |
| 91 int get_dimming_alpha_for_test() { return alpha_; } | 92 int get_dimming_alpha_for_test() { return alpha_; } |
| 92 | 93 |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 | 295 |
| 295 DISALLOW_COPY_AND_ASSIGN(ShelfWindowTargeter); | 296 DISALLOW_COPY_AND_ASSIGN(ShelfWindowTargeter); |
| 296 }; | 297 }; |
| 297 | 298 |
| 298 } // namespace | 299 } // namespace |
| 299 | 300 |
| 300 // The contents view of the Shelf. This view contains ShelfView and | 301 // The contents view of the Shelf. This view contains ShelfView and |
| 301 // sizes it to the width of the shelf minus the size of the status area. | 302 // sizes it to the width of the shelf minus the size of the status area. |
| 302 class ShelfWidget::DelegateView : public views::WidgetDelegate, | 303 class ShelfWidget::DelegateView : public views::WidgetDelegate, |
| 303 public views::AccessiblePaneView, | 304 public views::AccessiblePaneView, |
| 304 public BackgroundAnimatorDelegate, | 305 public ShelfBackgroundAnimatorDelegate, |
| 305 public aura::WindowObserver { | 306 public aura::WindowObserver { |
| 306 public: | 307 public: |
| 307 explicit DelegateView(ShelfWidget* shelf); | 308 explicit DelegateView(ShelfWidget* shelf); |
| 308 ~DelegateView() override; | 309 ~DelegateView() override; |
| 309 | 310 |
| 310 void set_focus_cycler(FocusCycler* focus_cycler) { | 311 void set_focus_cycler(FocusCycler* focus_cycler) { |
| 311 focus_cycler_ = focus_cycler; | 312 focus_cycler_ = focus_cycler; |
| 312 } | 313 } |
| 313 FocusCycler* focus_cycler() { return focus_cycler_; } | 314 FocusCycler* focus_cycler() { return focus_cycler_; } |
| 314 | 315 |
| 316 // TODO(bruthig): Remove opaque_background_. |
| 315 ui::Layer* opaque_background() { return &opaque_background_; } | 317 ui::Layer* opaque_background() { return &opaque_background_; } |
| 316 ui::Layer* opaque_foreground() { return &opaque_foreground_; } | 318 ui::Layer* opaque_foreground() { return &opaque_foreground_; } |
| 317 | 319 |
| 318 // Set if the shelf area is dimmed (eg when a window is maximized). | 320 // Set if the shelf area is dimmed (eg when a window is maximized). |
| 319 void SetDimmed(bool dimmed); | 321 void SetDimmed(bool dimmed); |
| 320 bool GetDimmed() const; | 322 bool GetDimmed() const; |
| 321 | 323 |
| 322 void SetParentLayer(ui::Layer* layer); | 324 void SetParentLayer(ui::Layer* layer); |
| 323 | 325 |
| 324 // views::View overrides: | 326 // views::View overrides: |
| (...skipping 10 matching lines...) Expand all Loading... |
| 335 | 337 |
| 336 // aura::WindowObserver overrides: | 338 // aura::WindowObserver overrides: |
| 337 // This will be called when the shelf itself changes its absolute position. | 339 // This will be called when the shelf itself changes its absolute position. |
| 338 // Since the |dimmer_| panel needs to be placed in screen coordinates it needs | 340 // Since the |dimmer_| panel needs to be placed in screen coordinates it needs |
| 339 // to be repositioned. The difference to the OnBoundsChanged call above is | 341 // to be repositioned. The difference to the OnBoundsChanged call above is |
| 340 // that this gets also triggered when the shelf only moves. | 342 // that this gets also triggered when the shelf only moves. |
| 341 void OnWindowBoundsChanged(aura::Window* window, | 343 void OnWindowBoundsChanged(aura::Window* window, |
| 342 const gfx::Rect& old_bounds, | 344 const gfx::Rect& old_bounds, |
| 343 const gfx::Rect& new_bounds) override; | 345 const gfx::Rect& new_bounds) override; |
| 344 | 346 |
| 345 // BackgroundAnimatorDelegate overrides: | 347 // ShelfBackgroundAnimatorDelegate overrides: |
| 346 void UpdateBackground(int alpha) override; | 348 void UpdateBackgroundAlpha(int alpha) override; |
| 347 | 349 |
| 348 // Force the shelf to be presented in an undimmed state. | 350 // Force the shelf to be presented in an undimmed state. |
| 349 void ForceUndimming(bool force); | 351 void ForceUndimming(bool force); |
| 350 | 352 |
| 351 // A function to test the current alpha used by the dimming bar. If there is | 353 // A function to test the current alpha used by the dimming bar. If there is |
| 352 // no dimmer active, the function will return -1. | 354 // no dimmer active, the function will return -1. |
| 353 int GetDimmingAlphaForTest(); | 355 int GetDimmingAlphaForTest(); |
| 354 | 356 |
| 355 // A function to test the bounds of the dimming bar. Returns gfx::Rect() if | 357 // A function to test the bounds of the dimming bar. Returns gfx::Rect() if |
| 356 // the dimmer is inactive. | 358 // the dimmer is inactive. |
| 357 gfx::Rect GetDimmerBoundsForTest(); | 359 gfx::Rect GetDimmerBoundsForTest(); |
| 358 | 360 |
| 359 // Disable dimming animations for running tests. This needs to be called | 361 // Disable dimming animations for running tests. This needs to be called |
| 360 // prior to the creation of of the |dimmer_|. | 362 // prior to the creation of of the |dimmer_|. |
| 361 void disable_dimming_animations_for_test() { | 363 void disable_dimming_animations_for_test() { |
| 362 disable_dimming_animations_for_test_ = true; | 364 disable_dimming_animations_for_test_ = true; |
| 363 } | 365 } |
| 364 | 366 |
| 365 private: | 367 private: |
| 366 ShelfWidget* shelf_; | 368 ShelfWidget* shelf_; |
| 367 std::unique_ptr<views::Widget> dimmer_; | 369 std::unique_ptr<views::Widget> dimmer_; |
| 368 FocusCycler* focus_cycler_; | 370 FocusCycler* focus_cycler_; |
| 369 int alpha_; | 371 int alpha_; |
| 372 // TODO(bruthig): Remove opaque_background_. |
| 370 // A black background layer which is shown when a maximized window is visible. | 373 // A black background layer which is shown when a maximized window is visible. |
| 371 ui::Layer opaque_background_; | 374 ui::Layer opaque_background_; |
| 372 // A black foreground layer which is shown while transitioning between users. | 375 // A black foreground layer which is shown while transitioning between users. |
| 373 // Note: Since the back- and foreground layers have different functions they | 376 // Note: Since the back- and foreground layers have different functions they |
| 374 // can be used simultaneously - so no repurposing possible. | 377 // can be used simultaneously - so no repurposing possible. |
| 375 ui::Layer opaque_foreground_; | 378 ui::Layer opaque_foreground_; |
| 376 | 379 |
| 377 // The view which does the dimming. | 380 // The view which does the dimming. |
| 378 DimmerView* dimmer_view_; | 381 DimmerView* dimmer_view_; |
| 379 | 382 |
| 380 // True if dimming animations should be turned off. | 383 // True if dimming animations should be turned off. |
| 381 bool disable_dimming_animations_for_test_; | 384 bool disable_dimming_animations_for_test_; |
| 382 | 385 |
| 383 DISALLOW_COPY_AND_ASSIGN(DelegateView); | 386 DISALLOW_COPY_AND_ASSIGN(DelegateView); |
| 384 }; | 387 }; |
| 385 | 388 |
| 386 ShelfWidget::DelegateView::DelegateView(ShelfWidget* shelf) | 389 ShelfWidget::DelegateView::DelegateView(ShelfWidget* shelf) |
| 387 : shelf_(shelf), | 390 : shelf_(shelf), |
| 388 focus_cycler_(NULL), | 391 focus_cycler_(NULL), |
| 389 alpha_(0), | 392 alpha_(0), |
| 393 // TODO(bruthig): Remove opaque_background_. |
| 390 opaque_background_(ui::LAYER_SOLID_COLOR), | 394 opaque_background_(ui::LAYER_SOLID_COLOR), |
| 391 opaque_foreground_(ui::LAYER_SOLID_COLOR), | 395 opaque_foreground_(ui::LAYER_SOLID_COLOR), |
| 392 dimmer_view_(NULL), | 396 dimmer_view_(NULL), |
| 393 disable_dimming_animations_for_test_(false) { | 397 disable_dimming_animations_for_test_(false) { |
| 394 SetLayoutManager(new views::FillLayout()); | 398 SetLayoutManager(new views::FillLayout()); |
| 395 set_allow_deactivate_on_esc(true); | 399 set_allow_deactivate_on_esc(true); |
| 400 // TODO(bruthig): Remove opaque_background_. |
| 396 opaque_background_.SetColor(SK_ColorBLACK); | 401 opaque_background_.SetColor(SK_ColorBLACK); |
| 397 opaque_background_.SetBounds(GetLocalBounds()); | 402 opaque_background_.SetBounds(GetLocalBounds()); |
| 398 opaque_background_.SetOpacity(0.0f); | 403 opaque_background_.SetOpacity(0.0f); |
| 399 opaque_foreground_.SetColor(SK_ColorBLACK); | 404 opaque_foreground_.SetColor(SK_ColorBLACK); |
| 400 opaque_foreground_.SetBounds(GetLocalBounds()); | 405 opaque_foreground_.SetBounds(GetLocalBounds()); |
| 401 opaque_foreground_.SetOpacity(0.0f); | 406 opaque_foreground_.SetOpacity(0.0f); |
| 402 } | 407 } |
| 403 | 408 |
| 404 ShelfWidget::DelegateView::~DelegateView() { | 409 ShelfWidget::DelegateView::~DelegateView() { |
| 405 // Make sure that the dimmer goes away since it might have set an observer. | 410 // Make sure that the dimmer goes away since it might have set an observer. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 436 dimmer_view_ = NULL; | 441 dimmer_view_ = NULL; |
| 437 dimmer_.reset(NULL); | 442 dimmer_.reset(NULL); |
| 438 } | 443 } |
| 439 } | 444 } |
| 440 | 445 |
| 441 bool ShelfWidget::DelegateView::GetDimmed() const { | 446 bool ShelfWidget::DelegateView::GetDimmed() const { |
| 442 return dimmer_.get() && dimmer_->IsVisible(); | 447 return dimmer_.get() && dimmer_->IsVisible(); |
| 443 } | 448 } |
| 444 | 449 |
| 445 void ShelfWidget::DelegateView::SetParentLayer(ui::Layer* layer) { | 450 void ShelfWidget::DelegateView::SetParentLayer(ui::Layer* layer) { |
| 451 // TODO(bruthig): Remove opaque_background_. |
| 446 layer->Add(&opaque_background_); | 452 layer->Add(&opaque_background_); |
| 447 layer->Add(&opaque_foreground_); | 453 layer->Add(&opaque_foreground_); |
| 448 ReorderLayers(); | 454 ReorderLayers(); |
| 449 } | 455 } |
| 450 | 456 |
| 451 void ShelfWidget::DelegateView::OnPaintBackground(gfx::Canvas* canvas) { | 457 void ShelfWidget::DelegateView::OnPaintBackground(gfx::Canvas* canvas) { |
| 452 if (MaterialDesignController::IsShelfMaterial()) { | 458 if (MaterialDesignController::IsShelfMaterial()) { |
| 453 canvas->FillRect(bounds(), SkColorSetA(kShelfBaseColor, alpha_)); | 459 canvas->FillRect(bounds(), SkColorSetA(kShelfBaseColor, alpha_)); |
| 454 } else { | 460 } else { |
| 455 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); | 461 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 514 return true; | 520 return true; |
| 515 // Allow to activate from the focus cycler. | 521 // Allow to activate from the focus cycler. |
| 516 if (focus_cycler_ && focus_cycler_->widget_activating() == GetWidget()) | 522 if (focus_cycler_ && focus_cycler_->widget_activating() == GetWidget()) |
| 517 return true; | 523 return true; |
| 518 // Disallow activating in other cases, especially when using mouse. | 524 // Disallow activating in other cases, especially when using mouse. |
| 519 return false; | 525 return false; |
| 520 } | 526 } |
| 521 | 527 |
| 522 void ShelfWidget::DelegateView::ReorderChildLayers(ui::Layer* parent_layer) { | 528 void ShelfWidget::DelegateView::ReorderChildLayers(ui::Layer* parent_layer) { |
| 523 views::View::ReorderChildLayers(parent_layer); | 529 views::View::ReorderChildLayers(parent_layer); |
| 530 // TODO(bruthig): Remove opaque_background_. |
| 524 parent_layer->StackAtBottom(&opaque_background_); | 531 parent_layer->StackAtBottom(&opaque_background_); |
| 525 parent_layer->StackAtTop(&opaque_foreground_); | 532 parent_layer->StackAtTop(&opaque_foreground_); |
| 526 } | 533 } |
| 527 | 534 |
| 528 void ShelfWidget::DelegateView::OnBoundsChanged(const gfx::Rect& old_bounds) { | 535 void ShelfWidget::DelegateView::OnBoundsChanged(const gfx::Rect& old_bounds) { |
| 536 // TODO(bruthig): Remove opaque_background_. |
| 529 opaque_background_.SetBounds(GetLocalBounds()); | 537 opaque_background_.SetBounds(GetLocalBounds()); |
| 530 opaque_foreground_.SetBounds(GetLocalBounds()); | 538 opaque_foreground_.SetBounds(GetLocalBounds()); |
| 531 if (dimmer_) | 539 if (dimmer_) |
| 532 dimmer_->SetBounds(GetBoundsInScreen()); | 540 dimmer_->SetBounds(GetBoundsInScreen()); |
| 533 } | 541 } |
| 534 | 542 |
| 535 void ShelfWidget::DelegateView::OnWindowBoundsChanged( | 543 void ShelfWidget::DelegateView::OnWindowBoundsChanged( |
| 536 aura::Window* window, | 544 aura::Window* window, |
| 537 const gfx::Rect& old_bounds, | 545 const gfx::Rect& old_bounds, |
| 538 const gfx::Rect& new_bounds) { | 546 const gfx::Rect& new_bounds) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 552 return dimmer_view_->get_dimming_alpha_for_test(); | 560 return dimmer_view_->get_dimming_alpha_for_test(); |
| 553 return -1; | 561 return -1; |
| 554 } | 562 } |
| 555 | 563 |
| 556 gfx::Rect ShelfWidget::DelegateView::GetDimmerBoundsForTest() { | 564 gfx::Rect ShelfWidget::DelegateView::GetDimmerBoundsForTest() { |
| 557 if (GetDimmed()) | 565 if (GetDimmed()) |
| 558 return dimmer_view_->GetBoundsInScreen(); | 566 return dimmer_view_->GetBoundsInScreen(); |
| 559 return gfx::Rect(); | 567 return gfx::Rect(); |
| 560 } | 568 } |
| 561 | 569 |
| 562 void ShelfWidget::DelegateView::UpdateBackground(int alpha) { | 570 void ShelfWidget::DelegateView::UpdateBackgroundAlpha(int alpha) { |
| 563 alpha_ = alpha; | 571 alpha_ = alpha; |
| 564 SchedulePaint(); | 572 SchedulePaint(); |
| 565 } | 573 } |
| 566 | 574 |
| 567 ShelfWidget::ShelfWidget(WmWindow* wm_shelf_container, | 575 ShelfWidget::ShelfWidget(WmWindow* wm_shelf_container, |
| 568 WmWindow* wm_status_container, | 576 WmWindow* wm_status_container, |
| 569 WorkspaceController* workspace_controller) | 577 WorkspaceController* workspace_controller) |
| 570 : delegate_view_(new DelegateView(this)), | 578 : delegate_view_(new DelegateView(this)), |
| 571 background_animator_( | |
| 572 delegate_view_, 0, GetShelfConstant(SHELF_BACKGROUND_ALPHA)), | |
| 573 activating_as_fallback_(false) { | 579 activating_as_fallback_(false) { |
| 574 views::Widget::InitParams params( | 580 views::Widget::InitParams params( |
| 575 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); | 581 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); |
| 576 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; | 582 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; |
| 577 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 583 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 578 params.delegate = delegate_view_; | 584 params.delegate = delegate_view_; |
| 579 wm_shelf_container->GetRootWindowController() | 585 wm_shelf_container->GetRootWindowController() |
| 580 ->ConfigureWidgetInitParamsForContainer( | 586 ->ConfigureWidgetInitParamsForContainer( |
| 581 this, wm_shelf_container->GetShellWindowId(), ¶ms); | 587 this, wm_shelf_container->GetShellWindowId(), ¶ms); |
| 582 Init(params); | 588 Init(params); |
| 583 | 589 |
| 584 // The shelf should not take focus when initially shown. | 590 // The shelf should not take focus when initially shown. |
| 585 set_focus_on_creation(false); | 591 set_focus_on_creation(false); |
| 586 SetContentsView(delegate_view_); | 592 SetContentsView(delegate_view_); |
| 587 delegate_view_->SetParentLayer(GetLayer()); | 593 delegate_view_->SetParentLayer(GetLayer()); |
| 588 | 594 |
| 589 shelf_layout_manager_ = new ShelfLayoutManager(this); | 595 shelf_layout_manager_ = new ShelfLayoutManager(this); |
| 590 shelf_layout_manager_->AddObserver(this); | 596 shelf_layout_manager_->AddObserver(this); |
| 591 aura::Window* shelf_container = | 597 aura::Window* shelf_container = |
| 592 WmWindowAura::GetAuraWindow(wm_shelf_container); | 598 WmWindowAura::GetAuraWindow(wm_shelf_container); |
| 593 shelf_container->SetLayoutManager(shelf_layout_manager_); | 599 shelf_container->SetLayoutManager(shelf_layout_manager_); |
| 594 shelf_layout_manager_->set_workspace_controller(workspace_controller); | 600 shelf_layout_manager_->set_workspace_controller(workspace_controller); |
| 595 workspace_controller->SetShelf(shelf_layout_manager_); | 601 workspace_controller->SetShelf(shelf_layout_manager_); |
| 596 | 602 |
| 603 background_animator_.PaintBackground(SHELF_BACKGROUND_DEFAULT, |
| 604 BACKGROUND_CHANGE_IMMEDIATE); |
| 605 background_animator_.AddShelfBackgroundDelegate(delegate_view_); |
| 606 shelf_layout_manager_->AddObserver(&background_animator_); |
| 607 |
| 597 status_area_widget_ = new StatusAreaWidget(wm_status_container, this); | 608 status_area_widget_ = new StatusAreaWidget(wm_status_container, this); |
| 598 status_area_widget_->CreateTrayViews(); | 609 status_area_widget_->CreateTrayViews(); |
| 599 if (Shell::GetInstance()->session_state_delegate()-> | 610 if (Shell::GetInstance()->session_state_delegate()-> |
| 600 IsActiveUserSessionStarted()) { | 611 IsActiveUserSessionStarted()) { |
| 601 status_area_widget_->Show(); | 612 status_area_widget_->Show(); |
| 602 } | 613 } |
| 603 Shell::GetInstance()->focus_cycler()->AddWidget(status_area_widget_); | 614 Shell::GetInstance()->focus_cycler()->AddWidget(status_area_widget_); |
| 604 | 615 |
| 605 aura::Window* status_container = | 616 aura::Window* status_container = |
| 606 WmWindowAura::GetAuraWindow(wm_status_container); | 617 WmWindowAura::GetAuraWindow(wm_status_container); |
| 607 status_container->SetLayoutManager( | 618 status_container->SetLayoutManager( |
| 608 new StatusAreaLayoutManager(status_container, this)); | 619 new StatusAreaLayoutManager(status_container, this)); |
| 609 | 620 |
| 610 shelf_container->SetEventTargeter(std::unique_ptr<ui::EventTargeter>( | 621 shelf_container->SetEventTargeter(std::unique_ptr<ui::EventTargeter>( |
| 611 new ShelfWindowTargeter(shelf_container, shelf_layout_manager_))); | 622 new ShelfWindowTargeter(shelf_container, shelf_layout_manager_))); |
| 612 status_container->SetEventTargeter(std::unique_ptr<ui::EventTargeter>( | 623 status_container->SetEventTargeter(std::unique_ptr<ui::EventTargeter>( |
| 613 new ShelfWindowTargeter(status_container, shelf_layout_manager_))); | 624 new ShelfWindowTargeter(status_container, shelf_layout_manager_))); |
| 614 | 625 |
| 615 views::Widget::AddObserver(this); | 626 views::Widget::AddObserver(this); |
| 616 } | 627 } |
| 617 | 628 |
| 618 ShelfWidget::~ShelfWidget() { | 629 ShelfWidget::~ShelfWidget() { |
| 619 // Must call Shutdown() before destruction. | 630 // Must call Shutdown() before destruction. |
| 620 DCHECK(!status_area_widget_); | 631 DCHECK(!status_area_widget_); |
| 621 Shell::GetInstance()->focus_cycler()->RemoveWidget(this); | 632 Shell::GetInstance()->focus_cycler()->RemoveWidget(this); |
| 622 SetFocusCycler(nullptr); | 633 SetFocusCycler(nullptr); |
| 623 RemoveObserver(this); | 634 RemoveObserver(this); |
| 624 } | 635 } |
| 625 | 636 |
| 637 // TODO(bruthig): Remove opaque_background_ => This entire method. |
| 626 void ShelfWidget::SetPaintsBackground( | 638 void ShelfWidget::SetPaintsBackground( |
| 627 ShelfBackgroundType background_type, | 639 ShelfBackgroundType background_type, |
| 628 BackgroundAnimatorChangeType change_type) { | 640 BackgroundAnimatorChangeType change_type) { |
| 629 ui::Layer* opaque_background = delegate_view_->opaque_background(); | 641 ui::Layer* opaque_background = delegate_view_->opaque_background(); |
| 630 float target_opacity = | 642 float target_opacity = |
| 631 (background_type == SHELF_BACKGROUND_MAXIMIZED) ? 1.0f : 0.0f; | 643 (background_type == SHELF_BACKGROUND_MAXIMIZED) ? 1.0f : 0.0f; |
| 632 std::unique_ptr<ui::ScopedLayerAnimationSettings> opaque_background_animation; | 644 std::unique_ptr<ui::ScopedLayerAnimationSettings> opaque_background_animation; |
| 633 if (change_type != BACKGROUND_CHANGE_IMMEDIATE) { | 645 if (change_type != BACKGROUND_CHANGE_IMMEDIATE) { |
| 634 opaque_background_animation.reset(new ui::ScopedLayerAnimationSettings( | 646 opaque_background_animation.reset(new ui::ScopedLayerAnimationSettings( |
| 635 opaque_background->GetAnimator())); | 647 opaque_background->GetAnimator())); |
| 636 opaque_background_animation->SetTransitionDuration( | 648 opaque_background_animation->SetTransitionDuration( |
| 637 base::TimeDelta::FromMilliseconds(kTimeToSwitchBackgroundMs)); | 649 base::TimeDelta::FromMilliseconds(kTimeToSwitchBackgroundMs)); |
| 638 } | 650 } |
| 639 opaque_background->SetOpacity(target_opacity); | 651 opaque_background->SetOpacity(target_opacity); |
| 640 | 652 |
| 641 // TODO(mukai): use ui::Layer on both opaque_background and normal background | 653 // TODO(mukai): use ui::Layer on both opaque_background and normal background |
| 642 // retire background_animator_ at all. It would be simpler. | 654 // retire background_animator_ at all. It would be simpler. |
| 643 // See also DockedBackgroundWidget::SetPaintsBackground. | 655 // See also DockedBackgroundWidget::SetPaintsBackground. |
| 644 background_animator_.SetPaintsBackground( | 656 background_animator_.PaintBackground(background_type, change_type); |
| 645 background_type != SHELF_BACKGROUND_DEFAULT, change_type); | |
| 646 } | 657 } |
| 647 | 658 |
| 648 ShelfBackgroundType ShelfWidget::GetBackgroundType() const { | 659 ShelfBackgroundType ShelfWidget::GetBackgroundType() const { |
| 649 if (delegate_view_->opaque_background()->GetTargetOpacity() == 1.0f) | 660 return background_animator_.target_background_type(); |
| 650 return SHELF_BACKGROUND_MAXIMIZED; | |
| 651 if (background_animator_.paints_background()) | |
| 652 return SHELF_BACKGROUND_OVERLAP; | |
| 653 | |
| 654 return SHELF_BACKGROUND_DEFAULT; | |
| 655 } | 661 } |
| 656 | 662 |
| 657 void ShelfWidget::HideShelfBehindBlackBar(bool hide, int animation_time_ms) { | 663 void ShelfWidget::HideShelfBehindBlackBar(bool hide, int animation_time_ms) { |
| 658 if (IsShelfHiddenBehindBlackBar() == hide) | 664 if (IsShelfHiddenBehindBlackBar() == hide) |
| 659 return; | 665 return; |
| 660 | 666 |
| 661 ui::Layer* opaque_foreground = delegate_view_->opaque_foreground(); | 667 ui::Layer* opaque_foreground = delegate_view_->opaque_foreground(); |
| 662 float target_opacity = hide ? 1.0f : 0.0f; | 668 float target_opacity = hide ? 1.0f : 0.0f; |
| 663 std::unique_ptr<ui::ScopedLayerAnimationSettings> opaque_foreground_animation; | 669 std::unique_ptr<ui::ScopedLayerAnimationSettings> opaque_foreground_animation; |
| 664 opaque_foreground_animation.reset(new ui::ScopedLayerAnimationSettings( | 670 opaque_foreground_animation.reset(new ui::ScopedLayerAnimationSettings( |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 806 return delegate_view_->GetDimmerBoundsForTest(); | 812 return delegate_view_->GetDimmerBoundsForTest(); |
| 807 return gfx::Rect(); | 813 return gfx::Rect(); |
| 808 } | 814 } |
| 809 | 815 |
| 810 void ShelfWidget::DisableDimmingAnimationsForTest() { | 816 void ShelfWidget::DisableDimmingAnimationsForTest() { |
| 811 DCHECK(delegate_view_); | 817 DCHECK(delegate_view_); |
| 812 return delegate_view_->disable_dimming_animations_for_test(); | 818 return delegate_view_->disable_dimming_animations_for_test(); |
| 813 } | 819 } |
| 814 | 820 |
| 815 void ShelfWidget::WillDeleteShelfLayoutManager() { | 821 void ShelfWidget::WillDeleteShelfLayoutManager() { |
| 822 shelf_layout_manager_->RemoveObserver(&background_animator_); |
| 816 shelf_layout_manager_->RemoveObserver(this); | 823 shelf_layout_manager_->RemoveObserver(this); |
| 817 shelf_layout_manager_ = NULL; | 824 shelf_layout_manager_ = NULL; |
| 818 } | 825 } |
| 819 | 826 |
| 820 void ShelfWidget::OnMouseEvent(ui::MouseEvent* event) { | 827 void ShelfWidget::OnMouseEvent(ui::MouseEvent* event) { |
| 821 Widget::OnMouseEvent(event); | 828 Widget::OnMouseEvent(event); |
| 822 if (Shell::GetInstance()->in_mus() && shelf_layout_manager_) | 829 if (Shell::GetInstance()->in_mus() && shelf_layout_manager_) |
| 823 shelf_layout_manager_->UpdateAutoHideForMouseEvent(event); | 830 shelf_layout_manager_->UpdateAutoHideForMouseEvent(event); |
| 824 } | 831 } |
| 825 | 832 |
| 826 void ShelfWidget::OnGestureEvent(ui::GestureEvent* event) { | 833 void ShelfWidget::OnGestureEvent(ui::GestureEvent* event) { |
| 827 Widget::OnGestureEvent(event); | 834 Widget::OnGestureEvent(event); |
| 828 if (Shell::GetInstance()->in_mus() && shelf_layout_manager_) | 835 if (Shell::GetInstance()->in_mus() && shelf_layout_manager_) |
| 829 shelf_layout_manager_->UpdateAutoHideForGestureEvent(event); | 836 shelf_layout_manager_->UpdateAutoHideForGestureEvent(event); |
| 830 } | 837 } |
| 831 | 838 |
| 832 } // namespace ash | 839 } // namespace ash |
| OLD | NEW |