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

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

Issue 316393002: App list uses PaginationModel to transition between pages. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 6 years, 6 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
Index: ui/app_list/views/contents_view.h
diff --git a/ui/app_list/views/contents_view.h b/ui/app_list/views/contents_view.h
index 0a7bfc5cca48011abd644264cb2801597a2fb4af..751079a7f3c3731e570bf56442e471ee7d9eb8a6 100644
--- a/ui/app_list/views/contents_view.h
+++ b/ui/app_list/views/contents_view.h
@@ -11,6 +11,8 @@
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
#include "ui/app_list/app_list_export.h"
+#include "ui/app_list/pagination_model.h"
+#include "ui/app_list/pagination_model_observer.h"
#include "ui/views/view.h"
namespace content {
@@ -18,7 +20,6 @@ class WebContents;
}
namespace views {
-class BoundsAnimator;
class ViewModel;
}
@@ -40,7 +41,8 @@ class StartPageView;
// one of which can be active at a given time. ContentsView provides the user
// interface for switching between launcher pages, and animates the transition
// between them.
-class APP_LIST_EXPORT ContentsView : public views::View {
+class APP_LIST_EXPORT ContentsView : public views::View,
+ public PaginationModelObserver {
public:
// Values of this enum denote special launcher pages that require hard-coding.
// Launcher pages are not required to have a NamedPage enum value.
@@ -70,7 +72,7 @@ class APP_LIST_EXPORT ContentsView : public views::View {
void SetActivePage(int page_index);
// The index of the currently active launcher page.
- int active_page_index() const { return active_page_; }
+ int GetActivePageIndex() const;
// True if |named_page| is the current active laucher page.
bool IsNamedPageActive(NamedPage named_page) const;
@@ -83,18 +85,30 @@ class APP_LIST_EXPORT ContentsView : public views::View {
AppsContainerView* apps_container_view() { return apps_container_view_; }
StartPageView* start_page_view() { return start_page_view_; }
+ // Ends the current animation abruptly (for use in tests).
+ void FinishCurrentAnimationForTests();
+
// Overridden from views::View:
virtual gfx::Size GetPreferredSize() const OVERRIDE;
virtual void Layout() OVERRIDE;
virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE;
virtual bool OnMouseWheel(const ui::MouseWheelEvent& event) OVERRIDE;
+ // Overridden from PaginationModelObserver:
+ virtual void TotalPagesChanged() OVERRIDE;
+ virtual void SelectedPageChanged(int old_selected, int new_selected) OVERRIDE;
+ virtual void TransitionStarted() OVERRIDE;
+ virtual void TransitionChanged() OVERRIDE;
+
private:
// Invoked when active view is changed.
void ActivePageChanged();
- void CalculateIdealBounds();
- void AnimateToIdealBounds();
+ // Calculates and sets the bounds for the subviews. If |ideal| is true, this
+ // calculates the ideal bounds (for after the current animation completes),
+ // which will be used when Layout() is called; otherwise, calculates the
+ // actual bounds (potentially mid-animation) and directly moves the views.
+ void CalculateAndSetBounds(bool ideal);
calamity 2014/06/12 03:05:08 Doesn't the ideal=true case go against the method
Matt Giuca 2014/06/16 00:59:05 The implication was that "SetBounds" was non-speci
Matt Giuca 2014/06/16 07:20:28 OK as discussed, no more ideal bounds. This method
// Adds |view| as a new page to the end of the list of launcher pages. The
// view is inserted as a child of the ContentsView. There is no name
@@ -107,15 +121,14 @@ class APP_LIST_EXPORT ContentsView : public views::View {
int AddLauncherPage(views::View* view, NamedPage named_page);
// Gets the PaginationModel owned by the AppsGridView.
+ // Note: This is different to |pagination_model_|, which manages top-level
+ // launcher-page pagination.
PaginationModel* GetAppsPaginationModel();
// Overridden from ui::EventHandler:
virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE;
virtual void OnScrollEvent(ui::ScrollEvent* event) OVERRIDE;
- // Index into |view_model_| of the currently active page.
- int active_page_;
-
// Special sub views of the ContentsView. All owned by the views hierarchy.
AppsContainerView* apps_container_view_;
SearchResultListView* search_results_view_;
@@ -126,7 +139,9 @@ class APP_LIST_EXPORT ContentsView : public views::View {
scoped_ptr<views::ViewModel> view_model_;
// Maps NamedPage onto |view_model_| indices.
std::map<NamedPage, int> named_page_to_view_;
- scoped_ptr<views::BoundsAnimator> bounds_animator_;
+
+ // Manages the pagination for the launcher pages.
+ PaginationModel pagination_model_;
DISALLOW_COPY_AND_ASSIGN(ContentsView);
};

Powered by Google App Engine
This is Rietveld 408576698