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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 return it->second; | 176 return it->second; |
177 } | 177 } |
178 | 178 |
179 int ContentsView::NumLauncherPages() const { | 179 int ContentsView::NumLauncherPages() const { |
180 return pagination_model_.total_pages(); | 180 return pagination_model_.total_pages(); |
181 } | 181 } |
182 | 182 |
183 void ContentsView::SetActivePageInternal(int page_index, | 183 void ContentsView::SetActivePageInternal(int page_index, |
184 bool show_search_results, | 184 bool show_search_results, |
185 bool animate) { | 185 bool animate) { |
| 186 if (!GetPageView(page_index)->visible()) |
| 187 return; |
| 188 |
186 if (!show_search_results) | 189 if (!show_search_results) |
187 page_before_search_ = page_index; | 190 page_before_search_ = page_index; |
188 // Start animating to the new page. | 191 // Start animating to the new page. |
189 pagination_model_.SelectPage(page_index, animate); | 192 pagination_model_.SelectPage(page_index, animate); |
190 ActivePageChanged(); | 193 ActivePageChanged(); |
191 | 194 |
192 if (!animate) | 195 if (!animate) |
193 Layout(); | 196 Layout(); |
194 } | 197 } |
195 | 198 |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 return bounds; | 410 return bounds; |
408 } | 411 } |
409 | 412 |
410 gfx::Rect ContentsView::GetCustomPageCollapsedBounds() const { | 413 gfx::Rect ContentsView::GetCustomPageCollapsedBounds() const { |
411 gfx::Rect bounds(GetContentsBounds()); | 414 gfx::Rect bounds(GetContentsBounds()); |
412 int page_height = bounds.height(); | 415 int page_height = bounds.height(); |
413 bounds.set_y(page_height - kCustomPageCollapsedHeight); | 416 bounds.set_y(page_height - kCustomPageCollapsedHeight); |
414 return bounds; | 417 return bounds; |
415 } | 418 } |
416 | 419 |
417 bool ContentsView::ShouldShowCustomPageClickzone() const { | |
418 return custom_page_view_ && IsStateActive(AppListModel::STATE_START) && | |
419 app_list_main_view_->model()->custom_launcher_page_enabled(); | |
420 } | |
421 | |
422 bool ContentsView::Back() { | 420 bool ContentsView::Back() { |
423 AppListModel::State state = view_to_state_[GetActivePageIndex()]; | 421 AppListModel::State state = view_to_state_[GetActivePageIndex()]; |
424 switch (state) { | 422 switch (state) { |
425 case AppListModel::STATE_START: | 423 case AppListModel::STATE_START: |
426 // Close the app list when Back() is called from the start page. | 424 // Close the app list when Back() is called from the start page. |
427 return false; | 425 return false; |
428 case AppListModel::STATE_CUSTOM_LAUNCHER_PAGE: | 426 case AppListModel::STATE_CUSTOM_LAUNCHER_PAGE: |
429 if (app_list_main_view_->model()->PopCustomLauncherPageSubpage()) | 427 if (app_list_main_view_->model()->PopCustomLauncherPageSubpage()) |
430 app_list_main_view_->view_delegate()->CustomLauncherPagePopSubpage(); | 428 app_list_main_view_->view_delegate()->CustomLauncherPagePopSubpage(); |
431 else | 429 else |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 // TODO(mgiuca): This should be generalized so we call a virtual OnShow and | 519 // TODO(mgiuca): This should be generalized so we call a virtual OnShow and |
522 // OnHide method for each page. | 520 // OnHide method for each page. |
523 if (!start_page_view_) | 521 if (!start_page_view_) |
524 return; | 522 return; |
525 | 523 |
526 if (new_selected == GetPageIndexForState(AppListModel::STATE_START)) { | 524 if (new_selected == GetPageIndexForState(AppListModel::STATE_START)) { |
527 start_page_view_->OnShow(); | 525 start_page_view_->OnShow(); |
528 // Show or hide the custom page view, based on whether it is enabled. | 526 // Show or hide the custom page view, based on whether it is enabled. |
529 if (custom_page_view_) { | 527 if (custom_page_view_) { |
530 custom_page_view_->SetVisible( | 528 custom_page_view_->SetVisible( |
531 app_list_main_view_->model()->custom_launcher_page_enabled()); | 529 app_list_main_view_->ShouldShowCustomLauncherPage()); |
532 } | 530 } |
533 } | 531 } |
534 } | 532 } |
535 | 533 |
536 void ContentsView::TransitionStarted() { | 534 void ContentsView::TransitionStarted() { |
537 } | 535 } |
538 | 536 |
539 void ContentsView::TransitionChanged() { | 537 void ContentsView::TransitionChanged() { |
540 UpdatePageBounds(); | 538 UpdatePageBounds(); |
541 } | 539 } |
542 | 540 |
543 } // namespace app_list | 541 } // namespace app_list |
OLD | NEW |