| 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/common/shelf/shelf_widget.h" | 5 #include "ash/common/shelf/shelf_widget.h" |
| 6 | 6 |
| 7 #include "ash/common/focus_cycler.h" | 7 #include "ash/common/focus_cycler.h" |
| 8 #include "ash/common/material_design/material_design_controller.h" | 8 #include "ash/common/material_design/material_design_controller.h" |
| 9 #include "ash/common/session/session_state_delegate.h" | 9 #include "ash/common/session/session_state_delegate.h" |
| 10 #include "ash/common/shelf/app_list_button.h" | 10 #include "ash/common/shelf/app_list_button.h" |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 GetContentsView()->AddChildView(shelf_view_); | 324 GetContentsView()->AddChildView(shelf_view_); |
| 325 return shelf_view_; | 325 return shelf_view_; |
| 326 } | 326 } |
| 327 | 327 |
| 328 void ShelfWidget::PostCreateShelf() { | 328 void ShelfWidget::PostCreateShelf() { |
| 329 SetFocusCycler(WmShell::Get()->focus_cycler()); | 329 SetFocusCycler(WmShell::Get()->focus_cycler()); |
| 330 | 330 |
| 331 // Ensure the newly created |shelf_| gets current values. | 331 // Ensure the newly created |shelf_| gets current values. |
| 332 background_animator_.Initialize(this); | 332 background_animator_.Initialize(this); |
| 333 | 333 |
| 334 // TODO(jamescook): The IsActiveUserSessionStarted() check may not be needed | |
| 335 // because the shelf is only created after the first user session is active. | |
| 336 // The ShelfView seems to always be visible after login. At the lock screen | |
| 337 // the shelf is hidden because its container is hidden. During auto-hide it is | |
| 338 // hidden because ShelfWidget is transparent. Some of the ShelfView visibility | |
| 339 // code could be simplified. http://crbug.com/674773 | |
| 340 shelf_view_->SetVisible( | 334 shelf_view_->SetVisible( |
| 341 WmShell::Get()->GetSessionStateDelegate()->IsActiveUserSessionStarted()); | 335 WmShell::Get()->GetSessionStateDelegate()->IsActiveUserSessionStarted()); |
| 342 shelf_layout_manager_->LayoutShelf(); | 336 shelf_layout_manager_->LayoutShelf(); |
| 343 shelf_layout_manager_->UpdateAutoHideState(); | 337 shelf_layout_manager_->UpdateAutoHideState(); |
| 344 Show(); | 338 Show(); |
| 345 } | 339 } |
| 346 | 340 |
| 347 bool ShelfWidget::IsShelfVisible() const { | 341 bool ShelfWidget::IsShelfVisible() const { |
| 348 return shelf_view_ && shelf_view_->visible(); | 342 return shelf_view_ && shelf_view_->visible(); |
| 349 } | 343 } |
| 350 | 344 |
| 345 void ShelfWidget::SetShelfVisibility(bool visible) { |
| 346 if (shelf_view_) |
| 347 shelf_view_->SetVisible(visible); |
| 348 } |
| 349 |
| 351 bool ShelfWidget::IsShowingAppList() const { | 350 bool ShelfWidget::IsShowingAppList() const { |
| 352 return GetAppListButton() && GetAppListButton()->is_showing_app_list(); | 351 return GetAppListButton() && GetAppListButton()->is_showing_app_list(); |
| 353 } | 352 } |
| 354 | 353 |
| 355 bool ShelfWidget::IsShowingContextMenu() const { | 354 bool ShelfWidget::IsShowingContextMenu() const { |
| 356 return shelf_view_ && shelf_view_->IsShowingMenu(); | 355 return shelf_view_ && shelf_view_->IsShowingMenu(); |
| 357 } | 356 } |
| 358 | 357 |
| 359 bool ShelfWidget::IsShowingOverflowBubble() const { | 358 bool ShelfWidget::IsShowingOverflowBubble() const { |
| 360 return shelf_view_ && shelf_view_->IsShowingOverflowBubble(); | 359 return shelf_view_ && shelf_view_->IsShowingOverflowBubble(); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 382 background_animator_.RemoveObserver(status_area_widget_); | 381 background_animator_.RemoveObserver(status_area_widget_); |
| 383 WmShell::Get()->focus_cycler()->RemoveWidget(status_area_widget_); | 382 WmShell::Get()->focus_cycler()->RemoveWidget(status_area_widget_); |
| 384 status_area_widget_->Shutdown(); | 383 status_area_widget_->Shutdown(); |
| 385 status_area_widget_ = nullptr; | 384 status_area_widget_ = nullptr; |
| 386 } | 385 } |
| 387 | 386 |
| 388 CloseNow(); | 387 CloseNow(); |
| 389 } | 388 } |
| 390 | 389 |
| 391 void ShelfWidget::UpdateIconPositionForPanel(WmWindow* panel) { | 390 void ShelfWidget::UpdateIconPositionForPanel(WmWindow* panel) { |
| 392 if (!shelf_view_) | |
| 393 return; | |
| 394 | |
| 395 WmWindow* shelf_window = WmLookup::Get()->GetWindowForWidget(this); | 391 WmWindow* shelf_window = WmLookup::Get()->GetWindowForWidget(this); |
| 396 shelf_view_->UpdatePanelIconPosition( | 392 shelf_view_->UpdatePanelIconPosition( |
| 397 panel->GetIntProperty(WmWindowProperty::SHELF_ID), | 393 panel->GetIntProperty(WmWindowProperty::SHELF_ID), |
| 398 shelf_window->ConvertRectFromScreen(panel->GetBoundsInScreen()) | 394 shelf_window->ConvertRectFromScreen(panel->GetBoundsInScreen()) |
| 399 .CenterPoint()); | 395 .CenterPoint()); |
| 400 } | 396 } |
| 401 | 397 |
| 402 gfx::Rect ShelfWidget::GetScreenBoundsOfItemIconForWindow(WmWindow* window) { | 398 gfx::Rect ShelfWidget::GetScreenBoundsOfItemIconForWindow(WmWindow* window) { |
| 403 // Window animations can be triggered during session restore before the shelf | |
| 404 // view is created. In that case, return default empty bounds. | |
| 405 if (!shelf_view_) | |
| 406 return gfx::Rect(); | |
| 407 | |
| 408 ShelfID id = window->GetIntProperty(WmWindowProperty::SHELF_ID); | 399 ShelfID id = window->GetIntProperty(WmWindowProperty::SHELF_ID); |
| 409 gfx::Rect bounds(shelf_view_->GetIdealBoundsOfItemIcon(id)); | 400 gfx::Rect bounds(shelf_view_->GetIdealBoundsOfItemIcon(id)); |
| 410 gfx::Point screen_origin; | 401 gfx::Point screen_origin; |
| 411 views::View::ConvertPointToScreen(shelf_view_, &screen_origin); | 402 views::View::ConvertPointToScreen(shelf_view_, &screen_origin); |
| 412 return gfx::Rect(screen_origin.x() + bounds.x(), | 403 return gfx::Rect(screen_origin.x() + bounds.x(), |
| 413 screen_origin.y() + bounds.y(), bounds.width(), | 404 screen_origin.y() + bounds.y(), bounds.width(), |
| 414 bounds.height()); | 405 bounds.height()); |
| 415 } | 406 } |
| 416 | 407 |
| 417 AppListButton* ShelfWidget::GetAppListButton() const { | 408 AppListButton* ShelfWidget::GetAppListButton() const { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 436 if (shelf_view_) | 427 if (shelf_view_) |
| 437 shelf_view_->UpdateShelfItemBackground(alpha); | 428 shelf_view_->UpdateShelfItemBackground(alpha); |
| 438 } | 429 } |
| 439 | 430 |
| 440 void ShelfWidget::WillDeleteShelfLayoutManager() { | 431 void ShelfWidget::WillDeleteShelfLayoutManager() { |
| 441 shelf_layout_manager_->RemoveObserver(this); | 432 shelf_layout_manager_->RemoveObserver(this); |
| 442 shelf_layout_manager_ = nullptr; | 433 shelf_layout_manager_ = nullptr; |
| 443 } | 434 } |
| 444 | 435 |
| 445 } // namespace ash | 436 } // namespace ash |
| OLD | NEW |