Chromium Code Reviews| 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 c9ea27655c55962d62d45ed9a73f2db58491bcb9..424c003002a3be0874ce32571e361151ea6da4ee 100644 |
| --- a/ui/app_list/views/contents_view.cc |
| +++ b/ui/app_list/views/contents_view.cc |
| @@ -15,12 +15,12 @@ |
| #include "ui/app_list/views/app_list_main_view.h" |
| #include "ui/app_list/views/apps_container_view.h" |
| #include "ui/app_list/views/apps_grid_view.h" |
| +#include "ui/app_list/views/contents_animator.h" |
| #include "ui/app_list/views/contents_switcher_view.h" |
| #include "ui/app_list/views/search_box_view.h" |
| #include "ui/app_list/views/search_result_list_view.h" |
| #include "ui/app_list/views/start_page_view.h" |
| #include "ui/events/event.h" |
| -#include "ui/gfx/animation/tween.h" |
| #include "ui/resources/grit/ui_resources.h" |
| #include "ui/views/view_model.h" |
| #include "ui/views/view_model_utils.h" |
| @@ -82,7 +82,14 @@ void ContentsView::Init(AppListModel* model, |
| page_before_search_ = initial_page_index; |
| pagination_model_.SelectPage(initial_page_index, false); |
| + |
| ActivePageChanged(false); |
| + |
| + // Populate the contents animators. |
| + AddAnimator(GetPageIndexForState(AppListModel::STATE_START), |
| + GetPageIndexForState(AppListModel::STATE_APPS), |
| + new StartToAppsAnimator(this)); |
| + default_animator_.reset(new DefaultAnimator(this)); |
| } |
| void ContentsView::CancelDrag() { |
| @@ -199,18 +206,6 @@ bool ContentsView::IsShowingSearchResults() const { |
| : IsStateActive(AppListModel::STATE_SEARCH_RESULTS); |
| } |
| -gfx::Rect ContentsView::GetOffscreenPageBounds(int page_index) const { |
| - gfx::Rect bounds(GetContentsBounds()); |
| - // The start page and search page origins are above; all other pages' origins |
| - // are below. |
| - int page_height = bounds.height(); |
| - bool origin_above = |
| - GetPageIndexForState(AppListModel::STATE_START) == page_index || |
| - GetPageIndexForState(AppListModel::STATE_SEARCH_RESULTS) == page_index; |
| - bounds.set_y(origin_above ? -page_height : page_height); |
| - return bounds; |
| -} |
| - |
| void ContentsView::UpdatePageBounds() { |
| // The bounds calculations will potentially be mid-transition (depending on |
| // the state of the PaginationModel). |
| @@ -226,24 +221,46 @@ void ContentsView::UpdatePageBounds() { |
| } |
| } |
| - // Move |current_page| from 0 to its origin. Move |target_page| from its |
| - // origin to 0. |
| - gfx::Rect on_screen(GetDefaultContentsBounds()); |
| - gfx::Rect current_page_origin(GetOffscreenPageBounds(current_page)); |
| - gfx::Rect target_page_origin(GetOffscreenPageBounds(target_page)); |
| - gfx::Rect current_page_rect( |
| - gfx::Tween::RectValueBetween(progress, on_screen, current_page_origin)); |
| - gfx::Rect target_page_rect( |
| - gfx::Tween::RectValueBetween(progress, target_page_origin, on_screen)); |
| + bool reverse; |
| + ContentsAnimator* animator = |
| + GetAnimatorForTransition(current_page, target_page, &reverse); |
| - view_model_->view_at(current_page)->SetBoundsRect(current_page_rect); |
| - view_model_->view_at(target_page)->SetBoundsRect(target_page_rect); |
| + if (reverse) |
|
calamity
2014/11/05 06:29:07
Mention that easing is handled by pagination_model
Matt Giuca
2014/11/06 00:32:59
Done.
|
| + animator->Update(1 - progress, target_page, current_page); |
| + else |
| + animator->Update(progress, current_page, target_page); |
| } |
| PaginationModel* ContentsView::GetAppsPaginationModel() { |
| return apps_container_view_->apps_grid_view()->pagination_model(); |
| } |
| +void ContentsView::AddAnimator(int from_page, |
| + int to_page, |
| + ContentsAnimator* animator) { |
| + contents_animators_.insert( |
| + std::make_pair(std::make_pair(from_page, to_page), |
| + linked_ptr<ContentsAnimator>(animator))); |
| +} |
| + |
| +ContentsAnimator* ContentsView::GetAnimatorForTransition(int from_page, |
| + int to_page, |
| + bool* reverse) const { |
|
calamity
2014/11/05 06:29:07
Having this out var locks us into symmetrical anim
Matt Giuca
2014/11/06 00:32:59
As discussed, I think this is a good idea if we ne
calamity
2014/11/06 05:34:47
Acknowledged.
|
| + auto it = contents_animators_.find(std::make_pair(from_page, to_page)); |
| + if (it != contents_animators_.end()) { |
| + *reverse = false; |
| + return it->second.get(); |
| + } |
| + |
| + it = contents_animators_.find(std::make_pair(to_page, from_page)); |
| + if (it != contents_animators_.end()) { |
| + *reverse = true; |
| + return it->second.get(); |
| + } |
| + |
| + return default_animator_.get(); |
| +} |
| + |
| void ContentsView::ShowFolderContent(AppListFolderItem* item) { |
| apps_container_view_->ShowActiveFolder(item); |
| } |