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

Side by Side Diff: ui/app_list/views/contents_view.cc

Issue 380613002: Experimental app list: Added a current page indicator to the launcher. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed static initializer. Created 6 years, 5 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 unified diff | Download patch
« no previous file with comments | « ui/app_list/views/contents_view.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/app_list/views/contents_view.h" 5 #include "ui/app_list/views/contents_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "grit/ui_resources.h" 10 #include "grit/ui_resources.h"
(...skipping 28 matching lines...) Expand all
39 : search_results_view_(NULL), 39 : search_results_view_(NULL),
40 start_page_view_(NULL), 40 start_page_view_(NULL),
41 app_list_main_view_(app_list_main_view), 41 app_list_main_view_(app_list_main_view),
42 contents_switcher_view_(NULL), 42 contents_switcher_view_(NULL),
43 view_model_(new views::ViewModel) { 43 view_model_(new views::ViewModel) {
44 pagination_model_.AddObserver(this); 44 pagination_model_.AddObserver(this);
45 } 45 }
46 46
47 ContentsView::~ContentsView() { 47 ContentsView::~ContentsView() {
48 pagination_model_.RemoveObserver(this); 48 pagination_model_.RemoveObserver(this);
49 if (contents_switcher_view_)
50 pagination_model_.RemoveObserver(contents_switcher_view_);
49 } 51 }
50 52
51 void ContentsView::InitNamedPages(AppListModel* model, 53 void ContentsView::InitNamedPages(AppListModel* model,
52 AppListViewDelegate* view_delegate) { 54 AppListViewDelegate* view_delegate) {
53 DCHECK(model); 55 DCHECK(model);
54 56
55 if (app_list::switches::IsExperimentalAppListEnabled()) { 57 if (app_list::switches::IsExperimentalAppListEnabled()) {
56 views::View* custom_page_view = 58 views::View* custom_page_view =
57 view_delegate->CreateCustomPageWebView(GetLocalBounds().size()); 59 view_delegate->CreateCustomPageWebView(GetLocalBounds().size());
58 if (custom_page_view) 60 if (custom_page_view)
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 apps_container_view_->app_list_folder_view()->items_grid_view()->EndDrag( 92 apps_container_view_->app_list_folder_view()->items_grid_view()->EndDrag(
91 true); 93 true);
92 } 94 }
93 } 95 }
94 96
95 void ContentsView::SetDragAndDropHostOfCurrentAppList( 97 void ContentsView::SetDragAndDropHostOfCurrentAppList(
96 ApplicationDragAndDropHost* drag_and_drop_host) { 98 ApplicationDragAndDropHost* drag_and_drop_host) {
97 apps_container_view_->SetDragAndDropHostOfCurrentAppList(drag_and_drop_host); 99 apps_container_view_->SetDragAndDropHostOfCurrentAppList(drag_and_drop_host);
98 } 100 }
99 101
102 void ContentsView::SetContentsSwitcherView(
103 ContentsSwitcherView* contents_switcher_view) {
104 DCHECK(!contents_switcher_view_);
105 contents_switcher_view_ = contents_switcher_view;
106 if (contents_switcher_view_)
107 pagination_model_.AddObserver(contents_switcher_view_);
108 }
109
100 void ContentsView::SetActivePage(int page_index) { 110 void ContentsView::SetActivePage(int page_index) {
101 if (GetActivePageIndex() == page_index) 111 if (GetActivePageIndex() == page_index)
102 return; 112 return;
103 113
104 SetActivePageInternal(page_index, false); 114 SetActivePageInternal(page_index, false);
105 } 115 }
106 116
107 int ContentsView::GetActivePageIndex() const { 117 int ContentsView::GetActivePageIndex() const {
108 // The active page is changed at the beginning of an animation, not the end. 118 // The active page is changed at the beginning of an animation, not the end.
109 return pagination_model_.SelectedTargetPage(); 119 return pagination_model_.SelectedTargetPage();
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 } 247 }
238 248
239 void ContentsView::AddBlankPageForTesting() { 249 void ContentsView::AddBlankPageForTesting() {
240 AddLauncherPage(new views::View, 0); 250 AddLauncherPage(new views::View, 0);
241 } 251 }
242 252
243 int ContentsView::AddLauncherPage(views::View* view, int resource_id) { 253 int ContentsView::AddLauncherPage(views::View* view, int resource_id) {
244 int page_index = view_model_->view_size(); 254 int page_index = view_model_->view_size();
245 AddChildView(view); 255 AddChildView(view);
246 view_model_->Add(view, page_index); 256 view_model_->Add(view, page_index);
247 pagination_model_.SetTotalPages(view_model_->view_size());
248 if (contents_switcher_view_) 257 if (contents_switcher_view_)
249 contents_switcher_view_->AddSwitcherButton(resource_id, page_index); 258 contents_switcher_view_->AddSwitcherButton(resource_id, page_index);
259 pagination_model_.SetTotalPages(view_model_->view_size());
250 return page_index; 260 return page_index;
251 } 261 }
252 262
253 int ContentsView::AddLauncherPage(views::View* view, 263 int ContentsView::AddLauncherPage(views::View* view,
254 int resource_id, 264 int resource_id,
255 NamedPage named_page) { 265 NamedPage named_page) {
256 int page_index = AddLauncherPage(view, resource_id); 266 int page_index = AddLauncherPage(view, resource_id);
257 named_page_to_view_.insert(std::pair<NamedPage, int>(named_page, page_index)); 267 named_page_to_view_.insert(std::pair<NamedPage, int>(named_page, page_index));
258 return page_index; 268 return page_index;
259 } 269 }
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 if (std::abs(offset) > kMinScrollToSwitchPage) { 388 if (std::abs(offset) > kMinScrollToSwitchPage) {
379 if (!GetAppsPaginationModel()->has_transition()) { 389 if (!GetAppsPaginationModel()->has_transition()) {
380 GetAppsPaginationModel()->SelectPageRelative(offset > 0 ? -1 : 1, true); 390 GetAppsPaginationModel()->SelectPageRelative(offset > 0 ? -1 : 1, true);
381 } 391 }
382 event->SetHandled(); 392 event->SetHandled();
383 event->StopPropagation(); 393 event->StopPropagation();
384 } 394 }
385 } 395 }
386 396
387 } // namespace app_list 397 } // namespace app_list
OLDNEW
« no previous file with comments | « 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