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

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

Issue 683703002: Notify launcher page with onTransitionChanged event (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@launcher_page_api_show_state_notify
Patch Set: address tapted@'s comments 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 unified diff | Download patch
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 #include <vector> 8 #include <vector>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 27 matching lines...) Expand all
38 kOverscrollPageTransitionDurationMs); 38 kOverscrollPageTransitionDurationMs);
39 pagination_model_.AddObserver(this); 39 pagination_model_.AddObserver(this);
40 } 40 }
41 41
42 ContentsView::~ContentsView() { 42 ContentsView::~ContentsView() {
43 pagination_model_.RemoveObserver(this); 43 pagination_model_.RemoveObserver(this);
44 if (contents_switcher_view_) 44 if (contents_switcher_view_)
45 pagination_model_.RemoveObserver(contents_switcher_view_); 45 pagination_model_.RemoveObserver(contents_switcher_view_);
46 } 46 }
47 47
48 void ContentsView::Init(AppListModel* model, 48 void ContentsView::Init(AppListModel* model) {
49 AppListViewDelegate* view_delegate) {
50 DCHECK(model); 49 DCHECK(model);
51 50
51 AppListViewDelegate* view_delegate = app_list_main_view_->view_delegate();
52
52 if (app_list::switches::IsExperimentalAppListEnabled()) { 53 if (app_list::switches::IsExperimentalAppListEnabled()) {
53 std::vector<views::View*> custom_page_views = 54 std::vector<views::View*> custom_page_views =
54 view_delegate->CreateCustomPageWebViews(GetLocalBounds().size()); 55 view_delegate->CreateCustomPageWebViews(GetLocalBounds().size());
55 for (std::vector<views::View*>::const_iterator it = 56 for (std::vector<views::View*>::const_iterator it =
56 custom_page_views.begin(); 57 custom_page_views.begin();
57 it != custom_page_views.end(); 58 it != custom_page_views.end();
58 ++it) { 59 ++it) {
59 AddLauncherPage(*it, IDR_APP_LIST_NOTIFICATIONS_ICON); 60 // Only the first launcher page is considered to represent
61 // STATE_CUSTOM_LAUNCHER_PAGE.
62 if (it == custom_page_views.begin()) {
63 AddLauncherPage(*it, IDR_APP_LIST_NOTIFICATIONS_ICON,
64 AppListModel::STATE_CUSTOM_LAUNCHER_PAGE);
65 } else {
66 AddLauncherPage(*it, IDR_APP_LIST_NOTIFICATIONS_ICON);
67 }
60 } 68 }
61 69
62 start_page_view_ = new StartPageView(app_list_main_view_, view_delegate); 70 start_page_view_ = new StartPageView(app_list_main_view_, view_delegate);
63 AddLauncherPage( 71 AddLauncherPage(
64 start_page_view_, IDR_APP_LIST_SEARCH_ICON, AppListModel::STATE_START); 72 start_page_view_, IDR_APP_LIST_SEARCH_ICON, AppListModel::STATE_START);
65 } else { 73 } else {
66 search_results_view_ = 74 search_results_view_ =
67 new SearchResultListView(app_list_main_view_, view_delegate); 75 new SearchResultListView(app_list_main_view_, view_delegate);
68 AddLauncherPage( 76 AddLauncherPage(
69 search_results_view_, 0, AppListModel::STATE_SEARCH_RESULTS); 77 search_results_view_, 0, AppListModel::STATE_SEARCH_RESULTS);
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 // The start page and search page origins are above; all other pages' origins 212 // The start page and search page origins are above; all other pages' origins
205 // are below. 213 // are below.
206 int page_height = bounds.height(); 214 int page_height = bounds.height();
207 bool origin_above = 215 bool origin_above =
208 GetPageIndexForState(AppListModel::STATE_START) == page_index || 216 GetPageIndexForState(AppListModel::STATE_START) == page_index ||
209 GetPageIndexForState(AppListModel::STATE_SEARCH_RESULTS) == page_index; 217 GetPageIndexForState(AppListModel::STATE_SEARCH_RESULTS) == page_index;
210 bounds.set_y(origin_above ? -page_height : page_height); 218 bounds.set_y(origin_above ? -page_height : page_height);
211 return bounds; 219 return bounds;
212 } 220 }
213 221
222 void ContentsView::NotifyCustomLauncherPageAnimationChanged(double progress,
223 int current_page,
224 int target_page) {
225 int custom_launcher_page_index =
226 GetPageIndexForState(AppListModel::STATE_CUSTOM_LAUNCHER_PAGE);
227 if (custom_launcher_page_index == target_page) {
228 app_list_main_view_->view_delegate()->CustomLauncherPageAnimationChanged(
229 progress);
230 } else if (custom_launcher_page_index == current_page) {
231 app_list_main_view_->view_delegate()->CustomLauncherPageAnimationChanged(
232 1 - progress);
233 }
234 }
235
214 void ContentsView::UpdatePageBounds() { 236 void ContentsView::UpdatePageBounds() {
Matt Giuca 2014/11/07 06:46:29 I'm confused... I thought you were moving Paginati
calamity 2014/11/10 03:38:30 Avoided for now. This doesn't support observing an
215 // The bounds calculations will potentially be mid-transition (depending on 237 // The bounds calculations will potentially be mid-transition (depending on
216 // the state of the PaginationModel). 238 // the state of the PaginationModel).
217 int current_page = std::max(0, pagination_model_.selected_page()); 239 int current_page = std::max(0, pagination_model_.selected_page());
218 int target_page = current_page; 240 int target_page = current_page;
219 double progress = 1; 241 double progress = 1;
220 if (pagination_model_.has_transition()) { 242 if (pagination_model_.has_transition()) {
221 const PaginationModel::Transition& transition = 243 const PaginationModel::Transition& transition =
222 pagination_model_.transition(); 244 pagination_model_.transition();
223 if (pagination_model_.is_valid_page(transition.target_page)) { 245 if (pagination_model_.is_valid_page(transition.target_page)) {
224 target_page = transition.target_page; 246 target_page = transition.target_page;
225 progress = transition.progress; 247 progress = transition.progress;
226 } 248 }
227 } 249 }
228 250
251 NotifyCustomLauncherPageAnimationChanged(progress, current_page, target_page);
252
229 // Move |current_page| from 0 to its origin. Move |target_page| from its 253 // Move |current_page| from 0 to its origin. Move |target_page| from its
230 // origin to 0. 254 // origin to 0.
231 gfx::Rect on_screen(GetDefaultContentsBounds()); 255 gfx::Rect on_screen(GetDefaultContentsBounds());
232 gfx::Rect current_page_origin(GetOffscreenPageBounds(current_page)); 256 gfx::Rect current_page_origin(GetOffscreenPageBounds(current_page));
233 gfx::Rect target_page_origin(GetOffscreenPageBounds(target_page)); 257 gfx::Rect target_page_origin(GetOffscreenPageBounds(target_page));
234 gfx::Rect current_page_rect( 258 gfx::Rect current_page_rect(
235 gfx::Tween::RectValueBetween(progress, on_screen, current_page_origin)); 259 gfx::Tween::RectValueBetween(progress, on_screen, current_page_origin));
236 gfx::Rect target_page_rect( 260 gfx::Rect target_page_rect(
237 gfx::Tween::RectValueBetween(progress, target_page_origin, on_screen)); 261 gfx::Tween::RectValueBetween(progress, target_page_origin, on_screen));
238 262
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 } 380 }
357 381
358 void ContentsView::TransitionStarted() { 382 void ContentsView::TransitionStarted() {
359 } 383 }
360 384
361 void ContentsView::TransitionChanged() { 385 void ContentsView::TransitionChanged() {
362 UpdatePageBounds(); 386 UpdatePageBounds();
363 } 387 }
364 388
365 } // namespace app_list 389 } // namespace app_list
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698