Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(275)

Unified Diff: ui/app_list/views/contents_view.cc

Issue 497413003: Refactor app list event handling and prerendering. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reorder in .cc file. Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/app_list/views/contents_view.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/app_list/views/contents_view.cc
diff --git a/ui/app_list/views/contents_view.cc b/ui/app_list/views/contents_view.cc
index e6ae0a847c6114b7700cba88486a2344bf539f39..86f7e7b5e6312c736ef8f588f001b3d9255bdb81 100644
--- a/ui/app_list/views/contents_view.cc
+++ b/ui/app_list/views/contents_view.cc
@@ -25,16 +25,6 @@
namespace app_list {
-namespace {
-
-const int kMinMouseWheelToSwitchPage = 20;
-const int kMinScrollToSwitchPage = 20;
-const int kMinHorizVelocityToSwitchPage = 800;
-
-const double kFinishTransitionThreshold = 0.33;
-
-} // namespace
-
ContentsView::ContentsView(AppListMainView* app_list_main_view)
: search_results_view_(NULL),
start_page_view_(NULL),
@@ -236,9 +226,7 @@ void ContentsView::ShowFolderContent(AppListFolderItem* item) {
}
void ContentsView::Prerender() {
- const int selected_page =
- std::max(0, GetAppsPaginationModel()->selected_page());
- apps_container_view_->apps_grid_view()->Prerender(selected_page);
+ apps_container_view_->apps_grid_view()->Prerender();
}
views::View* ContentsView::GetPageView(int index) {
@@ -303,26 +291,6 @@ bool ContentsView::OnKeyPressed(const ui::KeyEvent& event) {
return view_model_->view_at(GetActivePageIndex())->OnKeyPressed(event);
}
-bool ContentsView::OnMouseWheel(const ui::MouseWheelEvent& event) {
- if (!IsNamedPageActive(NAMED_PAGE_APPS))
- return false;
-
- int offset;
- if (abs(event.x_offset()) > abs(event.y_offset()))
- offset = event.x_offset();
- else
- offset = event.y_offset();
-
- if (abs(offset) > kMinMouseWheelToSwitchPage) {
- if (!GetAppsPaginationModel()->has_transition()) {
- GetAppsPaginationModel()->SelectPageRelative(offset > 0 ? -1 : 1, true);
- }
- return true;
- }
-
- return false;
-}
-
void ContentsView::TotalPagesChanged() {
}
@@ -336,61 +304,4 @@ void ContentsView::TransitionChanged() {
UpdatePageBounds();
}
-void ContentsView::OnGestureEvent(ui::GestureEvent* event) {
- if (!IsNamedPageActive(NAMED_PAGE_APPS))
- return;
-
- switch (event->type()) {
- case ui::ET_GESTURE_SCROLL_BEGIN:
- GetAppsPaginationModel()->StartScroll();
- event->SetHandled();
- return;
- case ui::ET_GESTURE_SCROLL_UPDATE:
- // event->details.scroll_x() > 0 means moving contents to right. That is,
- // transitioning to previous page.
- GetAppsPaginationModel()->UpdateScroll(event->details().scroll_x() /
- GetContentsBounds().width());
- event->SetHandled();
- return;
- case ui::ET_GESTURE_SCROLL_END:
- GetAppsPaginationModel()->EndScroll(
- GetAppsPaginationModel()->transition().progress <
- kFinishTransitionThreshold);
- event->SetHandled();
- return;
- case ui::ET_SCROLL_FLING_START: {
- GetAppsPaginationModel()->EndScroll(true);
- if (fabs(event->details().velocity_x()) > kMinHorizVelocityToSwitchPage) {
- GetAppsPaginationModel()->SelectPageRelative(
- event->details().velocity_x() < 0 ? 1 : -1, true);
- }
- event->SetHandled();
- return;
- }
- default:
- break;
- }
-}
-
-void ContentsView::OnScrollEvent(ui::ScrollEvent* event) {
- if (!IsNamedPageActive(NAMED_PAGE_APPS) ||
- event->type() == ui::ET_SCROLL_FLING_CANCEL) {
- return;
- }
-
- float offset;
- if (std::abs(event->x_offset()) > std::abs(event->y_offset()))
- offset = event->x_offset();
- else
- offset = event->y_offset();
-
- if (std::abs(offset) > kMinScrollToSwitchPage) {
- if (!GetAppsPaginationModel()->has_transition()) {
- GetAppsPaginationModel()->SelectPageRelative(offset > 0 ? -1 : 1, true);
- }
- event->SetHandled();
- event->StopPropagation();
- }
-}
-
} // namespace app_list
« no previous file with comments | « ui/app_list/views/contents_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698