OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "ui/app_list/views/contents_view.h" | 5 #include "ui/app_list/views/contents_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 448 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 gfx::Rect search_box_bounds = GetDefaultSearchBoxBounds(); | 459 gfx::Rect search_box_bounds = GetDefaultSearchBoxBounds(); |
460 gfx::Rect default_contents_bounds = GetDefaultContentsBounds(); | 460 gfx::Rect default_contents_bounds = GetDefaultContentsBounds(); |
461 gfx::Vector2d bottom_right = | 461 gfx::Vector2d bottom_right = |
462 search_box_bounds.bottom_right().OffsetFromOrigin(); | 462 search_box_bounds.bottom_right().OffsetFromOrigin(); |
463 bottom_right.SetToMax( | 463 bottom_right.SetToMax( |
464 default_contents_bounds.bottom_right().OffsetFromOrigin()); | 464 default_contents_bounds.bottom_right().OffsetFromOrigin()); |
465 return gfx::Size(bottom_right.x(), bottom_right.y()); | 465 return gfx::Size(bottom_right.x(), bottom_right.y()); |
466 } | 466 } |
467 | 467 |
468 void ContentsView::Layout() { | 468 void ContentsView::Layout() { |
469 // The search box is contained in a widget so set the bounds of the widget | |
470 // rather than the SearchBoxView. In athena, the search box widget will be the | |
471 // same as the app list widget so don't move it. | |
472 views::Widget* search_box_widget = GetSearchBoxView()->GetWidget(); | |
473 if (search_box_widget && search_box_widget != GetWidget()) { | |
474 gfx::Rect search_box_bounds = GetSearchBoxBoundsForState(GetActiveState()); | |
475 search_box_widget->SetBounds(ConvertRectToWidget( | |
476 GetSearchBoxView()->GetViewBoundsForSearchBoxContentsBounds( | |
477 search_box_bounds))); | |
478 } | |
479 | |
480 // Immediately finish all current animations. | 469 // Immediately finish all current animations. |
481 pagination_model_.FinishAnimation(); | 470 pagination_model_.FinishAnimation(); |
482 | 471 |
483 // Move the current view onto the screen, and all other views off screen to | 472 // Move the current view onto the screen, and all other views off screen to |
484 // the left. (Since we are not animating, we don't need to be careful about | 473 // the left. (Since we are not animating, we don't need to be careful about |
485 // which side we place the off-screen views onto.) | 474 // which side we place the off-screen views onto.) |
486 gfx::Rect rect = GetOnscreenPageBounds(GetActivePageIndex()); | 475 gfx::Rect rect = GetOnscreenPageBounds(GetActivePageIndex()); |
487 double progress = | 476 double progress = |
488 IsStateActive(AppListModel::STATE_CUSTOM_LAUNCHER_PAGE) ? 1 : 0; | 477 IsStateActive(AppListModel::STATE_CUSTOM_LAUNCHER_PAGE) ? 1 : 0; |
489 | 478 |
(...skipping 14 matching lines...) Expand all Loading... |
504 ->SetBoundsRect(i == current_page ? rect : offscreen_target); | 493 ->SetBoundsRect(i == current_page ? rect : offscreen_target); |
505 } | 494 } |
506 | 495 |
507 // Custom locations of pages in certain states. | 496 // Custom locations of pages in certain states. |
508 // Within the start page, the custom page is given its collapsed bounds. | 497 // Within the start page, the custom page is given its collapsed bounds. |
509 int start_page_index = GetPageIndexForState(AppListModel::STATE_START); | 498 int start_page_index = GetPageIndexForState(AppListModel::STATE_START); |
510 if (current_page == start_page_index) { | 499 if (current_page == start_page_index) { |
511 if (custom_page_view_) | 500 if (custom_page_view_) |
512 custom_page_view_->SetBoundsRect(GetCustomPageCollapsedBounds()); | 501 custom_page_view_->SetBoundsRect(GetCustomPageCollapsedBounds()); |
513 } | 502 } |
| 503 |
| 504 // The search box is contained in a widget so set the bounds of the widget |
| 505 // rather than the SearchBoxView. In athena, the search box widget will be the |
| 506 // same as the app list widget so don't move it. |
| 507 views::Widget* search_box_widget = GetSearchBoxView()->GetWidget(); |
| 508 if (search_box_widget && search_box_widget != GetWidget()) { |
| 509 gfx::Rect search_box_bounds = GetSearchBoxBoundsForState(GetActiveState()); |
| 510 search_box_widget->SetBounds(ConvertRectToWidget( |
| 511 GetSearchBoxView()->GetViewBoundsForSearchBoxContentsBounds( |
| 512 search_box_bounds))); |
| 513 } |
514 } | 514 } |
515 | 515 |
516 bool ContentsView::OnKeyPressed(const ui::KeyEvent& event) { | 516 bool ContentsView::OnKeyPressed(const ui::KeyEvent& event) { |
517 bool handled = | 517 bool handled = |
518 view_model_->view_at(GetActivePageIndex())->OnKeyPressed(event); | 518 view_model_->view_at(GetActivePageIndex())->OnKeyPressed(event); |
519 | 519 |
520 if (!handled) { | 520 if (!handled) { |
521 if (event.key_code() == ui::VKEY_TAB && event.IsShiftDown()) { | 521 if (event.key_code() == ui::VKEY_TAB && event.IsShiftDown()) { |
522 GetSearchBoxView()->MoveTabFocus(true); | 522 GetSearchBoxView()->MoveTabFocus(true); |
523 handled = true; | 523 handled = true; |
(...skipping 23 matching lines...) Expand all Loading... |
547 } | 547 } |
548 | 548 |
549 void ContentsView::TransitionStarted() { | 549 void ContentsView::TransitionStarted() { |
550 } | 550 } |
551 | 551 |
552 void ContentsView::TransitionChanged() { | 552 void ContentsView::TransitionChanged() { |
553 UpdatePageBounds(); | 553 UpdatePageBounds(); |
554 } | 554 } |
555 | 555 |
556 } // namespace app_list | 556 } // namespace app_list |
OLD | NEW |