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

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

Issue 701773002: App list: Added contents view custom animation framework. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed default animator reverse not being set. Oooops. Created 6 years, 1 month 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_animator.h ('k') | ui/app_list/views/contents_view.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/app_list/views/contents_animator.cc
diff --git a/ui/app_list/views/contents_animator.cc b/ui/app_list/views/contents_animator.cc
new file mode 100644
index 0000000000000000000000000000000000000000..895c4a356b9c4ba40d835c9b877dd98a68d3e75d
--- /dev/null
+++ b/ui/app_list/views/contents_animator.cc
@@ -0,0 +1,88 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/app_list/views/contents_animator.h"
+
+#include "ui/app_list/views/contents_view.h"
+#include "ui/gfx/animation/tween.h"
+#include "ui/gfx/geometry/rect.h"
+#include "ui/views/view.h"
+
+namespace app_list {
+
+// ContentsAnimator
+
+ContentsAnimator::ContentsAnimator(ContentsView* contents_view)
+ : contents_view_(contents_view) {
+}
+
+ContentsAnimator::~ContentsAnimator() {
+}
+
+gfx::Rect ContentsAnimator::GetOffscreenPageBounds(int page_index) const {
+ gfx::Rect bounds(contents_view_->GetContentsBounds());
+ // The start page and search page origins are above; all other pages' origins
+ // are below.
+ int page_height = bounds.height();
+ bool origin_above = contents_view_->GetPageIndexForState(
+ AppListModel::STATE_START) == page_index ||
+ contents_view_->GetPageIndexForState(
+ AppListModel::STATE_SEARCH_RESULTS) == page_index;
+ bounds.set_y(origin_above ? -page_height : page_height);
+ return bounds;
+}
+
+// DefaultAnimator
+
+DefaultAnimator::DefaultAnimator(ContentsView* contents_view)
+ : ContentsAnimator(contents_view) {
+}
+
+std::string DefaultAnimator::NameForTests() const {
+ return "DefaultAnimator";
+}
+
+void DefaultAnimator::Update(double progress, int from_page, int to_page) {
+ // Move the from page from 0 to its origin. Move the to page from its origin
+ // to 0.
+ gfx::Rect on_screen(contents_view()->GetDefaultContentsBounds());
+ gfx::Rect from_page_origin(GetOffscreenPageBounds(from_page));
+ gfx::Rect to_page_origin(GetOffscreenPageBounds(to_page));
+ gfx::Rect from_page_rect(
+ gfx::Tween::RectValueBetween(progress, on_screen, from_page_origin));
+ gfx::Rect to_page_rect(
+ gfx::Tween::RectValueBetween(progress, to_page_origin, on_screen));
+
+ contents_view()->GetPageView(from_page)->SetBoundsRect(from_page_rect);
+ contents_view()->GetPageView(to_page)->SetBoundsRect(to_page_rect);
+}
+
+// StartToAppsAnimator
+
+StartToAppsAnimator::StartToAppsAnimator(ContentsView* contents_view)
+ : ContentsAnimator(contents_view) {
+}
+
+std::string StartToAppsAnimator::NameForTests() const {
+ return "StartToAppsAnimator";
+}
+
+void StartToAppsAnimator::Update(double progress,
+ int start_page,
+ int apps_page) {
+ // TODO(mgiuca): This is just a clone of DefaultAnimator's animation. Write a
+ // custom animation for the All Apps button on the Start page.
+ gfx::Rect on_screen(contents_view()->GetDefaultContentsBounds());
+ gfx::Rect from_page_origin(GetOffscreenPageBounds(start_page));
+ gfx::Rect to_page_origin(GetOffscreenPageBounds(apps_page));
+ gfx::Rect from_page_rect(
+ gfx::Tween::RectValueBetween(progress, on_screen, from_page_origin));
+ gfx::Rect to_page_rect(
+ gfx::Tween::RectValueBetween(progress, to_page_origin, on_screen));
+
+ contents_view()->GetPageView(start_page)->SetBoundsRect(from_page_rect);
+ contents_view()->GetPageView(apps_page)->SetBoundsRect(to_page_rect);
+}
+
+} // app_list
« no previous file with comments | « ui/app_list/views/contents_animator.h ('k') | ui/app_list/views/contents_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698