Chromium Code Reviews| 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 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "grit/ui_resources.h" | 10 #include "grit/ui_resources.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 69 } | 69 } |
| 70 | 70 |
| 71 apps_container_view_ = new AppsContainerView(app_list_main_view_, model); | 71 apps_container_view_ = new AppsContainerView(app_list_main_view_, model); |
| 72 | 72 |
| 73 int initial_page_index = AddLauncherPage( | 73 int initial_page_index = AddLauncherPage( |
| 74 apps_container_view_, IDR_APP_LIST_APPS_ICON, NAMED_PAGE_APPS); | 74 apps_container_view_, IDR_APP_LIST_APPS_ICON, NAMED_PAGE_APPS); |
| 75 if (app_list::switches::IsExperimentalAppListEnabled()) | 75 if (app_list::switches::IsExperimentalAppListEnabled()) |
| 76 initial_page_index = GetPageIndexForNamedPage(NAMED_PAGE_START); | 76 initial_page_index = GetPageIndexForNamedPage(NAMED_PAGE_START); |
| 77 | 77 |
| 78 pagination_model_.SelectPage(initial_page_index, false); | 78 pagination_model_.SelectPage(initial_page_index, false); |
| 79 if (contents_switcher_view_) | |
| 80 contents_switcher_view_->SelectedPageChanged(-1, initial_page_index); | |
| 79 | 81 |
| 80 // Needed to update the main search box visibility. | 82 // Needed to update the main search box visibility. |
| 81 ActivePageChanged(false); | 83 ActivePageChanged(false); |
| 82 } | 84 } |
| 83 | 85 |
| 84 void ContentsView::CancelDrag() { | 86 void ContentsView::CancelDrag() { |
| 85 if (apps_container_view_->apps_grid_view()->has_dragged_view()) | 87 if (apps_container_view_->apps_grid_view()->has_dragged_view()) |
| 86 apps_container_view_->apps_grid_view()->EndDrag(true); | 88 apps_container_view_->apps_grid_view()->EndDrag(true); |
| 87 if (apps_container_view_->app_list_folder_view() | 89 if (apps_container_view_->app_list_folder_view() |
| 88 ->items_grid_view() | 90 ->items_grid_view() |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 239 void ContentsView::AddBlankPageForTesting() { | 241 void ContentsView::AddBlankPageForTesting() { |
| 240 AddLauncherPage(new views::View, 0); | 242 AddLauncherPage(new views::View, 0); |
| 241 } | 243 } |
| 242 | 244 |
| 243 int ContentsView::AddLauncherPage(views::View* view, int resource_id) { | 245 int ContentsView::AddLauncherPage(views::View* view, int resource_id) { |
| 244 int page_index = view_model_->view_size(); | 246 int page_index = view_model_->view_size(); |
| 245 AddChildView(view); | 247 AddChildView(view); |
| 246 view_model_->Add(view, page_index); | 248 view_model_->Add(view, page_index); |
| 247 pagination_model_.SetTotalPages(view_model_->view_size()); | 249 pagination_model_.SetTotalPages(view_model_->view_size()); |
| 248 if (contents_switcher_view_) | 250 if (contents_switcher_view_) |
| 249 contents_switcher_view_->AddSwitcherButton(resource_id, page_index); | 251 contents_switcher_view_->AddSwitcherButton(resource_id, page_index); |
|
calamity
2014/07/09 08:02:54
Lines 79-80 can be removed if you move this above
kcarattini
2014/07/10 03:33:27
Done.
| |
| 250 return page_index; | 252 return page_index; |
| 251 } | 253 } |
| 252 | 254 |
| 253 int ContentsView::AddLauncherPage(views::View* view, | 255 int ContentsView::AddLauncherPage(views::View* view, |
| 254 int resource_id, | 256 int resource_id, |
| 255 NamedPage named_page) { | 257 NamedPage named_page) { |
| 256 int page_index = AddLauncherPage(view, resource_id); | 258 int page_index = AddLauncherPage(view, resource_id); |
| 257 named_page_to_view_.insert(std::pair<NamedPage, int>(named_page, page_index)); | 259 named_page_to_view_.insert(std::pair<NamedPage, int>(named_page, page_index)); |
| 258 return page_index; | 260 return page_index; |
| 259 } | 261 } |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 311 return true; | 313 return true; |
| 312 } | 314 } |
| 313 | 315 |
| 314 return false; | 316 return false; |
| 315 } | 317 } |
| 316 | 318 |
| 317 void ContentsView::TotalPagesChanged() { | 319 void ContentsView::TotalPagesChanged() { |
| 318 } | 320 } |
| 319 | 321 |
| 320 void ContentsView::SelectedPageChanged(int old_selected, int new_selected) { | 322 void ContentsView::SelectedPageChanged(int old_selected, int new_selected) { |
| 323 if (contents_switcher_view_) | |
| 324 contents_switcher_view_->SelectedPageChanged(old_selected, new_selected); | |
| 321 } | 325 } |
| 322 | 326 |
| 323 void ContentsView::TransitionStarted() { | 327 void ContentsView::TransitionStarted() { |
| 324 } | 328 } |
| 325 | 329 |
| 326 void ContentsView::TransitionChanged() { | 330 void ContentsView::TransitionChanged() { |
| 327 UpdatePageBounds(); | 331 UpdatePageBounds(); |
| 328 } | 332 } |
| 329 | 333 |
| 330 void ContentsView::OnGestureEvent(ui::GestureEvent* event) { | 334 void ContentsView::OnGestureEvent(ui::GestureEvent* event) { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 378 if (std::abs(offset) > kMinScrollToSwitchPage) { | 382 if (std::abs(offset) > kMinScrollToSwitchPage) { |
| 379 if (!GetAppsPaginationModel()->has_transition()) { | 383 if (!GetAppsPaginationModel()->has_transition()) { |
| 380 GetAppsPaginationModel()->SelectPageRelative(offset > 0 ? -1 : 1, true); | 384 GetAppsPaginationModel()->SelectPageRelative(offset > 0 ? -1 : 1, true); |
| 381 } | 385 } |
| 382 event->SetHandled(); | 386 event->SetHandled(); |
| 383 event->StopPropagation(); | 387 event->StopPropagation(); |
| 384 } | 388 } |
| 385 } | 389 } |
| 386 | 390 |
| 387 } // namespace app_list | 391 } // namespace app_list |
| OLD | NEW |