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

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

Issue 555753002: Experimental app list: Change transition animations of top-level pages. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix crash for non-experimental app list and retain old behaviour. Created 6 years, 3 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
« ui/app_list/views/contents_view.h ('K') | « 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 19c9dd93836895343e2c8637f186e69053dbf31e..f0c8dc1aefdc891f8410f4ef27513473e9d8f226 100644
--- a/ui/app_list/views/contents_view.cc
+++ b/ui/app_list/views/contents_view.cc
@@ -118,11 +118,17 @@ int ContentsView::GetActivePageIndex() const {
}
bool ContentsView::IsNamedPageActive(NamedPage named_page) const {
+ return IndexIsNamedPage(GetActivePageIndex(), named_page);
+}
+
+bool ContentsView::IndexIsNamedPage(int page_index,
+ NamedPage named_page) const {
+ // Find the index of the view corresponding to the given named_page.
std::map<NamedPage, int>::const_iterator it =
named_page_to_view_.find(named_page);
if (it == named_page_to_view_.end())
return false;
- return it->second == GetActivePageIndex();
+ return it->second == page_index;
}
int ContentsView::GetPageIndexForNamedPage(NamedPage named_page) const {
@@ -184,6 +190,15 @@ bool ContentsView::IsShowingSearchResults() const {
: IsNamedPageActive(NAMED_PAGE_SEARCH_RESULTS);
}
+int ContentsView::PageOrigin(const gfx::Rect& bounds, int page_index) const {
calamity 2014/09/10 01:56:40 This is cleaner without |bounds| and I don't think
Matt Giuca 2014/09/10 03:15:30 Done.
+ // The start page and search page origins are above; all other pages' origins
+ // are below.
+ int page_height = bounds.height();
+ bool origin_above = IndexIsNamedPage(page_index, NAMED_PAGE_START) ||
+ IndexIsNamedPage(page_index, NAMED_PAGE_SEARCH_RESULTS);
+ return origin_above ? -page_height : page_height;
+}
+
void ContentsView::UpdatePageBounds() {
gfx::Rect rect(GetContentsBounds());
if (rect.IsEmpty())
@@ -203,20 +218,17 @@ void ContentsView::UpdatePageBounds() {
}
}
- gfx::Rect incoming_target(rect);
- gfx::Rect outgoing_target(rect);
- int dir = target_page > current_page ? -1 : 1;
-
- // Pages transition vertically.
- int page_height = rect.height();
- int transition_offset = progress * page_height * dir;
-
- outgoing_target.set_y(transition_offset);
- incoming_target.set_y(dir < 0 ? transition_offset + page_height
- : transition_offset - page_height);
-
- view_model_->view_at(current_page)->SetBoundsRect(outgoing_target);
- view_model_->view_at(target_page)->SetBoundsRect(incoming_target);
+ // Move |current_page| from 0 to its origin. Move |target_page| from its
+ // origin to 0.
+ gfx::Rect current_page_rect(rect);
+ gfx::Rect target_page_rect(rect);
+ int current_page_origin = PageOrigin(rect, current_page);
+ int target_page_origin = PageOrigin(rect, target_page);
+ current_page_rect.set_y(progress * current_page_origin);
+ target_page_rect.set_y((1 - progress) * target_page_origin);
+
+ view_model_->view_at(current_page)->SetBoundsRect(current_page_rect);
+ view_model_->view_at(target_page)->SetBoundsRect(target_page_rect);
}
PaginationModel* ContentsView::GetAppsPaginationModel() {
« ui/app_list/views/contents_view.h ('K') | « 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