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

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

Issue 317723005: Refactor app list ContentsView to use page indices, not show states. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed AppListViewTest. 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 e7df7bc0ccbf4b75207aaa04856e5a12c7561ebb..c85f0ef57c4ae4dae1b8943af5e9758d65d3a311 100644
--- a/ui/app_list/views/contents_view.h
+++ b/ui/app_list/views/contents_view.h
@@ -5,6 +5,8 @@
#ifndef UI_APP_LIST_VIEWS_CONTENTS_VIEW_H_
#define UI_APP_LIST_VIEWS_CONTENTS_VIEW_H_
+#include <map>
+
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
@@ -33,13 +35,16 @@ class PaginationModel;
class SearchResultListView;
class StartPageView;
-// A view to manage sub views under the search box (apps grid view + page
-// switcher and search results). The two sets of sub views are mutually
-// exclusive. ContentsView manages a show state to choose one set to show
-// and animates the transition between show states.
+// A view to manage launcher pages within the Launcher (eg. start page, apps
+// grid view, search results). There can be any number of launcher pages, only
+// 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 {
public:
- enum ShowState {
+ // Values of this enum denote special launcher pages that require hard-coding.
+ // Launcher pages are not required to have a NamedPage enum value.
+ enum NamedPage {
SHOW_APPS,
benwells 2014/06/06 06:12:29 Nit: should be NAMED_PAGE_APPS, etc.
Matt Giuca 2014/06/10 04:01:19 Done.
benwells 2014/06/10 08:06:42 There seems to be a new style for enums; as your e
Matt Giuca 2014/06/10 08:45:08 OK, renamed again.
SHOW_SEARCH_RESULTS,
SHOW_START_PAGE,
@@ -61,16 +66,23 @@ class APP_LIST_EXPORT ContentsView : public views::View {
void ShowSearchResults(bool show);
void ShowFolderContent(AppListFolderItem* folder);
- // Sets show state and animates the subviews to match the show state.
- void SetShowState(ShowState show_state);
+ // Sets the active launcher page and animates the pages into place.
+ void SetActivePage(int page_index);
+
+ // The index of the currently active launcher page.
+ int active_page() const { return active_page_; }
benwells 2014/06/06 06:12:29 Nit: active_page -> active_page_index
Matt Giuca 2014/06/10 04:01:19 Done.
+
+ // True if |named_page| is the current active laucher page.
+ bool IsNamedPageActive(NamedPage named_page) const;
+
+ // Gets the index of a launcher page in |view_model_|, by NamedPage.
+ int GetPageIndexForNamedPage(NamedPage named_page) const;
void Prerender();
AppsContainerView* apps_container_view() { return apps_container_view_; }
StartPageView* start_page_view() { return start_page_view_; }
- ShowState show_state() const { return show_state_; }
-
// Overridden from views::View:
virtual gfx::Size GetPreferredSize() const OVERRIDE;
virtual void Layout() OVERRIDE;
@@ -78,12 +90,20 @@ class APP_LIST_EXPORT ContentsView : public views::View {
virtual bool OnMouseWheel(const ui::MouseWheelEvent& event) OVERRIDE;
private:
- // Invoked when show state is changed.
- void ShowStateChanged();
+ // Invoked when active view is changed.
+ void ActivePageChanged();
void CalculateIdealBounds();
void AnimateToIdealBounds();
+ // Adds |view| as a child of the ContentsView. Also adds it to the view model,
+ // having no named page associated with it.
+ void AddLauncherPage(views::View* view);
benwells 2014/06/06 06:12:29 Should these mention that it is added next in the
Matt Giuca 2014/06/10 04:01:19 Not sure what you mean -- the buttons along the bo
benwells 2014/06/10 08:06:42 I mean there is an ordering to the pages, and when
Matt Giuca 2014/06/10 08:45:08 Done.
+
+ // Adds |view| as a child of the ContentsView. Also adds it to the view model,
+ // associating it with |named_page|.
+ void AddLauncherPage(views::View* view, NamedPage named_page);
+
// Gets the PaginationModel owned by the AppsGridView.
PaginationModel* GetAppsPaginationModel();
@@ -91,7 +111,8 @@ class APP_LIST_EXPORT ContentsView : public views::View {
virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE;
virtual void OnScrollEvent(ui::ScrollEvent* event) OVERRIDE;
- ShowState show_state_;
+ // 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_;
@@ -101,6 +122,8 @@ class APP_LIST_EXPORT ContentsView : public views::View {
AppListMainView* app_list_main_view_; // Parent view, owns this.
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_;
DISALLOW_COPY_AND_ASSIGN(ContentsView);

Powered by Google App Engine
This is Rietveld 408576698