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

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

Issue 889403005: Make start page fill app list bounds. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@new_apps_grid_paddings
Patch Set: address_comment Created 5 years, 10 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') | ui/app_list/views/start_page_view.cc » ('j') | 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 #include <vector> 8 #include <vector>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 bool success = 345 bool success =
346 state_to_view_.insert(std::make_pair(state, page_index)).second; 346 state_to_view_.insert(std::make_pair(state, page_index)).second;
347 success = success && 347 success = success &&
348 view_to_state_.insert(std::make_pair(page_index, state)).second; 348 view_to_state_.insert(std::make_pair(page_index, state)).second;
349 349
350 // There shouldn't be duplicates in either map. 350 // There shouldn't be duplicates in either map.
351 DCHECK(success); 351 DCHECK(success);
352 return page_index; 352 return page_index;
353 } 353 }
354 354
355 gfx::Rect ContentsView::GetOnscreenPageBounds(int page_index) const {
356 AppListModel::State state = GetStateForPageIndex(page_index);
357 bool fills_contents_view =
358 state == AppListModel::STATE_CUSTOM_LAUNCHER_PAGE ||
359 state == AppListModel::STATE_START;
360 return fills_contents_view ? GetContentsBounds() : GetDefaultContentsBounds();
361 }
362
363 gfx::Rect ContentsView::GetOffscreenPageBounds(int page_index) const {
364 AppListModel::State state = GetStateForPageIndex(page_index);
365 gfx::Rect bounds(GetOnscreenPageBounds(page_index));
366 // The start page and search page origins are above; all other pages' origins
367 // are below.
368 bool origin_above = state == AppListModel::STATE_START ||
369 state == AppListModel::STATE_SEARCH_RESULTS;
370 bounds.set_y(origin_above ? -bounds.height()
371 : GetContentsBounds().height() + bounds.y());
372 return bounds;
373 }
374
355 gfx::Rect ContentsView::GetDefaultSearchBoxBounds() const { 375 gfx::Rect ContentsView::GetDefaultSearchBoxBounds() const {
356 gfx::Rect search_box_bounds(0, 0, GetDefaultContentsSize().width(), 376 gfx::Rect search_box_bounds(0, 0, GetDefaultContentsSize().width(),
357 GetSearchBoxView()->GetPreferredSize().height()); 377 GetSearchBoxView()->GetPreferredSize().height());
358 if (switches::IsExperimentalAppListEnabled()) { 378 if (switches::IsExperimentalAppListEnabled()) {
359 search_box_bounds.set_y(kExperimentalSearchBoxPadding); 379 search_box_bounds.set_y(kExperimentalSearchBoxPadding);
360 search_box_bounds.Inset(kExperimentalSearchBoxPadding, 0); 380 search_box_bounds.Inset(kExperimentalSearchBoxPadding, 0);
361 } 381 }
362 return search_box_bounds; 382 return search_box_bounds;
363 } 383 }
364 384
365 gfx::Rect ContentsView::GetSearchBoxBoundsForState( 385 gfx::Rect ContentsView::GetSearchBoxBoundsForState(
366 AppListModel::State state) const { 386 AppListModel::State state) const {
367 // On the start page, the search box is in a different location. 387 // On the start page, the search box is in a different location.
368 if (state == AppListModel::STATE_START) { 388 if (state == AppListModel::STATE_START) {
369 DCHECK(start_page_view_); 389 DCHECK(start_page_view_);
370 // Convert to ContentsView space, assuming that the StartPageView is in the 390 // Convert to ContentsView space, assuming that the StartPageView is in the
371 // ContentsView's default bounds. 391 // ContentsView's default bounds.
372 return start_page_view_->GetSearchBoxBounds() + 392 return start_page_view_->GetSearchBoxBounds() +
373 GetDefaultContentsBounds().OffsetFromOrigin(); 393 GetOnscreenPageBounds(GetPageIndexForState(state))
394 .OffsetFromOrigin();
374 } 395 }
375 396
376 return GetDefaultSearchBoxBounds(); 397 return GetDefaultSearchBoxBounds();
377 } 398 }
378 399
379 gfx::Rect ContentsView::GetSearchBoxBoundsForPageIndex(int index) const { 400 gfx::Rect ContentsView::GetSearchBoxBoundsForPageIndex(int index) const {
380 return GetSearchBoxBoundsForState(GetStateForPageIndex(index)); 401 return GetSearchBoxBoundsForState(GetStateForPageIndex(index));
381 } 402 }
382 403
383 gfx::Rect ContentsView::GetDefaultContentsBounds() const { 404 gfx::Rect ContentsView::GetDefaultContentsBounds() const {
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 GetSearchBoxView()->GetViewBoundsForSearchBoxContentsBounds( 473 GetSearchBoxView()->GetViewBoundsForSearchBoxContentsBounds(
453 search_box_bounds))); 474 search_box_bounds)));
454 } 475 }
455 476
456 // Immediately finish all current animations. 477 // Immediately finish all current animations.
457 pagination_model_.FinishAnimation(); 478 pagination_model_.FinishAnimation();
458 479
459 // Move the current view onto the screen, and all other views off screen to 480 // Move the current view onto the screen, and all other views off screen to
460 // the left. (Since we are not animating, we don't need to be careful about 481 // the left. (Since we are not animating, we don't need to be careful about
461 // which side we place the off-screen views onto.) 482 // which side we place the off-screen views onto.)
462 gfx::Rect rect(GetDefaultContentsBounds()); 483 gfx::Rect rect = GetOnscreenPageBounds(GetActivePageIndex());
463 // Custom pages are aligned to the top of the window, not under the search 484 double progress =
464 // box. 485 IsStateActive(AppListModel::STATE_CUSTOM_LAUNCHER_PAGE) ? 1 : 0;
465 double progress = 0;
466 if (IsStateActive(AppListModel::STATE_CUSTOM_LAUNCHER_PAGE)) {
467 rect = GetContentsBounds();
468 progress = 1;
469 }
470 486
471 // Notify the custom launcher page that the active page has changed. 487 // Notify the custom launcher page that the active page has changed.
472 app_list_main_view_->view_delegate()->CustomLauncherPageAnimationChanged( 488 app_list_main_view_->view_delegate()->CustomLauncherPageAnimationChanged(
473 progress); 489 progress);
474 490
475 if (rect.IsEmpty()) 491 if (rect.IsEmpty())
476 return; 492 return;
477 493
478 gfx::Rect offscreen_target(rect); 494 gfx::Rect offscreen_target(rect);
479 offscreen_target.set_x(-rect.width()); 495 offscreen_target.set_x(-rect.width());
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 } 530 }
515 531
516 void ContentsView::TransitionStarted() { 532 void ContentsView::TransitionStarted() {
517 } 533 }
518 534
519 void ContentsView::TransitionChanged() { 535 void ContentsView::TransitionChanged() {
520 UpdatePageBounds(); 536 UpdatePageBounds();
521 } 537 }
522 538
523 } // namespace app_list 539 } // namespace app_list
OLDNEW
« no previous file with comments | « ui/app_list/views/contents_view.h ('k') | ui/app_list/views/start_page_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698