| 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/aura/wm_shelf_aura.h" | 7 #include "ash/aura/wm_shelf_aura.h" |
| 8 #include "ash/common/focus_cycler.h" | 8 #include "ash/common/focus_cycler.h" |
| 9 #include "ash/common/material_design/material_design_controller.h" | 9 #include "ash/common/material_design/material_design_controller.h" |
| 10 #include "ash/common/session/session_state_delegate.h" | 10 #include "ash/common/session/session_state_delegate.h" |
| 11 #include "ash/common/shelf/shelf_background_animator_observer.h" | 11 #include "ash/common/shelf/shelf_background_animator_observer.h" |
| 12 #include "ash/common/shelf/shelf_constants.h" | 12 #include "ash/common/shelf/shelf_constants.h" |
| 13 #include "ash/common/shelf/shelf_delegate.h" | 13 #include "ash/common/shelf/shelf_delegate.h" |
| 14 #include "ash/common/shelf/wm_dimmer_view.h" | 14 #include "ash/common/shelf/wm_dimmer_view.h" |
| 15 #include "ash/common/shelf/wm_shelf.h" | 15 #include "ash/common/shelf/wm_shelf.h" |
| 16 #include "ash/common/shelf/wm_shelf_util.h" | 16 #include "ash/common/shelf/wm_shelf_util.h" |
| 17 #include "ash/common/system/status_area_widget.h" | 17 #include "ash/common/system/status_area_widget.h" |
| 18 #include "ash/common/system/tray/system_tray_delegate.h" | 18 #include "ash/common/system/tray/system_tray_delegate.h" |
| 19 #include "ash/common/wm_root_window_controller.h" | 19 #include "ash/common/wm_root_window_controller.h" |
| 20 #include "ash/common/wm_shell.h" | 20 #include "ash/common/wm_shell.h" |
| 21 #include "ash/common/wm_window.h" | 21 #include "ash/common/wm_window.h" |
| 22 #include "ash/shelf/shelf.h" | 22 #include "ash/shelf/shelf.h" |
| 23 #include "ash/shelf/shelf_layout_manager.h" | 23 #include "ash/shelf/shelf_layout_manager.h" |
| 24 #include "ash/wm/status_area_layout_manager.h" | 24 #include "ash/wm/status_area_layout_manager.h" |
| 25 #include "ash/wm/workspace_controller.h" | |
| 26 #include "base/memory/ptr_util.h" | 25 #include "base/memory/ptr_util.h" |
| 27 #include "grit/ash_resources.h" | 26 #include "grit/ash_resources.h" |
| 28 #include "ui/base/resource/resource_bundle.h" | 27 #include "ui/base/resource/resource_bundle.h" |
| 29 #include "ui/compositor/layer.h" | 28 #include "ui/compositor/layer.h" |
| 30 #include "ui/compositor/scoped_layer_animation_settings.h" | 29 #include "ui/compositor/scoped_layer_animation_settings.h" |
| 31 #include "ui/gfx/canvas.h" | 30 #include "ui/gfx/canvas.h" |
| 32 #include "ui/gfx/image/image.h" | 31 #include "ui/gfx/image/image.h" |
| 33 #include "ui/gfx/image/image_skia_operations.h" | 32 #include "ui/gfx/image/image_skia_operations.h" |
| 34 #include "ui/gfx/skbitmap_operations.h" | 33 #include "ui/gfx/skbitmap_operations.h" |
| 35 #include "ui/views/accessible_pane_view.h" | 34 #include "ui/views/accessible_pane_view.h" |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 opaque_background_.SetOpacity(alpha / kMaxAlpha); | 278 opaque_background_.SetOpacity(alpha / kMaxAlpha); |
| 280 } | 279 } |
| 281 | 280 |
| 282 void ShelfWidget::DelegateView::UpdateShelfAssetBackground(int alpha) { | 281 void ShelfWidget::DelegateView::UpdateShelfAssetBackground(int alpha) { |
| 283 asset_background_alpha_ = alpha; | 282 asset_background_alpha_ = alpha; |
| 284 SchedulePaint(); | 283 SchedulePaint(); |
| 285 } | 284 } |
| 286 | 285 |
| 287 ShelfWidget::ShelfWidget(WmWindow* shelf_container, | 286 ShelfWidget::ShelfWidget(WmWindow* shelf_container, |
| 288 WmWindow* status_container, | 287 WmWindow* status_container, |
| 289 WmShelfAura* wm_shelf_aura, | 288 WmShelfAura* wm_shelf_aura) |
| 290 WorkspaceController* workspace_controller) | |
| 291 : wm_shelf_aura_(wm_shelf_aura), | 289 : wm_shelf_aura_(wm_shelf_aura), |
| 292 delegate_view_(new DelegateView(this)), | 290 delegate_view_(new DelegateView(this)), |
| 293 background_animator_(SHELF_BACKGROUND_DEFAULT, wm_shelf_aura_), | 291 background_animator_(SHELF_BACKGROUND_DEFAULT, wm_shelf_aura_), |
| 294 activating_as_fallback_(false) { | 292 activating_as_fallback_(false) { |
| 295 background_animator_.AddObserver(this); | 293 background_animator_.AddObserver(this); |
| 296 background_animator_.AddObserver(delegate_view_); | 294 background_animator_.AddObserver(delegate_view_); |
| 297 | 295 |
| 298 views::Widget::InitParams params( | 296 views::Widget::InitParams params( |
| 299 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); | 297 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS); |
| 300 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; | 298 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; |
| 301 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 299 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 302 params.delegate = delegate_view_; | 300 params.delegate = delegate_view_; |
| 303 shelf_container->GetRootWindowController() | 301 shelf_container->GetRootWindowController() |
| 304 ->ConfigureWidgetInitParamsForContainer( | 302 ->ConfigureWidgetInitParamsForContainer( |
| 305 this, shelf_container->GetShellWindowId(), ¶ms); | 303 this, shelf_container->GetShellWindowId(), ¶ms); |
| 306 Init(params); | 304 Init(params); |
| 307 | 305 |
| 308 // The shelf should not take focus when initially shown. | 306 // The shelf should not take focus when initially shown. |
| 309 set_focus_on_creation(false); | 307 set_focus_on_creation(false); |
| 310 SetContentsView(delegate_view_); | 308 SetContentsView(delegate_view_); |
| 311 delegate_view_->SetParentLayer(GetLayer()); | 309 delegate_view_->SetParentLayer(GetLayer()); |
| 312 | 310 |
| 313 shelf_layout_manager_ = new ShelfLayoutManager(this); | 311 shelf_layout_manager_ = new ShelfLayoutManager(this); |
| 314 shelf_layout_manager_->AddObserver(this); | 312 shelf_layout_manager_->AddObserver(this); |
| 315 shelf_container->SetLayoutManager(base::WrapUnique(shelf_layout_manager_)); | 313 shelf_container->SetLayoutManager(base::WrapUnique(shelf_layout_manager_)); |
| 316 shelf_layout_manager_->set_workspace_controller(workspace_controller); | |
| 317 workspace_controller->SetShelf(shelf_layout_manager_); | |
| 318 background_animator_.PaintBackground( | 314 background_animator_.PaintBackground( |
| 319 shelf_layout_manager_->GetShelfBackgroundType(), | 315 shelf_layout_manager_->GetShelfBackgroundType(), |
| 320 BACKGROUND_CHANGE_IMMEDIATE); | 316 BACKGROUND_CHANGE_IMMEDIATE); |
| 321 wm_shelf_aura_->SetShelfLayoutManager(shelf_layout_manager_); | 317 wm_shelf_aura_->SetShelfLayoutManager(shelf_layout_manager_); |
| 322 | 318 |
| 323 // TODO(jamescook): Move ownership to RootWindowController. | 319 // TODO(jamescook): Move ownership to RootWindowController. |
| 324 status_area_widget_ = new StatusAreaWidget(status_container, wm_shelf_aura_); | 320 status_area_widget_ = new StatusAreaWidget(status_container, wm_shelf_aura_); |
| 325 status_area_widget_->CreateTrayViews(); | 321 status_area_widget_->CreateTrayViews(); |
| 326 if (WmShell::Get()->GetSessionStateDelegate()->IsActiveUserSessionStarted()) | 322 if (WmShell::Get()->GetSessionStateDelegate()->IsActiveUserSessionStarted()) |
| 327 status_area_widget_->Show(); | 323 status_area_widget_->Show(); |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 if (shelf_) | 516 if (shelf_) |
| 521 shelf_->UpdateShelfItemBackground(alpha); | 517 shelf_->UpdateShelfItemBackground(alpha); |
| 522 } | 518 } |
| 523 | 519 |
| 524 void ShelfWidget::WillDeleteShelfLayoutManager() { | 520 void ShelfWidget::WillDeleteShelfLayoutManager() { |
| 525 shelf_layout_manager_->RemoveObserver(this); | 521 shelf_layout_manager_->RemoveObserver(this); |
| 526 shelf_layout_manager_ = nullptr; | 522 shelf_layout_manager_ = nullptr; |
| 527 } | 523 } |
| 528 | 524 |
| 529 } // namespace ash | 525 } // namespace ash |
| OLD | NEW |