Commit 31c74925 authored by mgiuca@chromium.org's avatar mgiuca@chromium.org

App Launcher: Preload the correct number of icons (don't assume 4x4).

Previously, there would be a brief moment where the last two icons of
the centered app list (--enable-centered-app-list) were not visible.
Use the correct number of cols/rows instead of assuming 4x4.

BUG=380015
TEST=With --enable-centered-app-list, click the app launcher button
*immediately* after logging in. Should not be able to see missing icons
(pay attention to the last two icons).

Review URL: https://codereview.chromium.org/311753002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@274496 0039d316-1c4b-4281-b951-d872f2087c98
parent b049288f
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "ui/app_list/search_box_model.h" #include "ui/app_list/search_box_model.h"
#include "ui/app_list/views/app_list_item_view.h" #include "ui/app_list/views/app_list_item_view.h"
#include "ui/app_list/views/apps_container_view.h" #include "ui/app_list/views/apps_container_view.h"
#include "ui/app_list/views/apps_grid_view.h"
#include "ui/app_list/views/contents_switcher_view.h" #include "ui/app_list/views/contents_switcher_view.h"
#include "ui/app_list/views/contents_view.h" #include "ui/app_list/views/contents_view.h"
#include "ui/app_list/views/search_box_view.h" #include "ui/app_list/views/search_box_view.h"
...@@ -91,9 +92,6 @@ AppListMainView::AppListMainView(AppListViewDelegate* delegate, ...@@ -91,9 +92,6 @@ AppListMainView::AppListMainView(AppListViewDelegate* delegate,
search_box_view_(NULL), search_box_view_(NULL),
contents_view_(NULL), contents_view_(NULL),
weak_ptr_factory_(this) { weak_ptr_factory_(this) {
// Starts icon loading early.
PreloadIcons(parent);
SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical,
kInnerPadding, kInnerPadding,
kInnerPadding, kInnerPadding,
...@@ -104,6 +102,9 @@ AppListMainView::AppListMainView(AppListViewDelegate* delegate, ...@@ -104,6 +102,9 @@ AppListMainView::AppListMainView(AppListViewDelegate* delegate,
AddContentsView(); AddContentsView();
if (app_list::switches::IsExperimentalAppListEnabled()) if (app_list::switches::IsExperimentalAppListEnabled())
AddChildView(new ContentsSwitcherView(contents_view_)); AddChildView(new ContentsSwitcherView(contents_view_));
// Starts icon loading early.
PreloadIcons(parent);
} }
void AppListMainView::AddContentsView() { void AppListMainView::AddContentsView() {
...@@ -196,7 +197,11 @@ void AppListMainView::PreloadIcons(gfx::NativeView parent) { ...@@ -196,7 +197,11 @@ void AppListMainView::PreloadIcons(gfx::NativeView parent) {
// assumes first page (i.e. index 0) will be used in this case. // assumes first page (i.e. index 0) will be used in this case.
const int selected_page = std::max(0, pagination_model_->selected_page()); const int selected_page = std::max(0, pagination_model_->selected_page());
const int tiles_per_page = kPreferredCols * kPreferredRows; const AppsGridView* const apps_grid_view =
contents_view_->apps_container_view()->apps_grid_view();
const int tiles_per_page =
apps_grid_view->cols() * apps_grid_view->rows_per_page();
const int start_model_index = selected_page * tiles_per_page; const int start_model_index = selected_page * tiles_per_page;
const int end_model_index = const int end_model_index =
std::min(static_cast<int>(model_->top_level_item_list()->item_count()), std::min(static_cast<int>(model_->top_level_item_list()->item_count()),
......
...@@ -80,8 +80,8 @@ class APP_LIST_EXPORT AppsGridView : public views::View, ...@@ -80,8 +80,8 @@ class APP_LIST_EXPORT AppsGridView : public views::View,
// is no longer called to dynamically choosing those layout params. // is no longer called to dynamically choosing those layout params.
void SetLayout(int icon_size, int cols, int rows_per_page); void SetLayout(int icon_size, int cols, int rows_per_page);
int cols() { return cols_; } int cols() const { return cols_; }
int rows_per_page() { return rows_per_page_; } int rows_per_page() const { return rows_per_page_; }
// This resets the grid view to a fresh state for showing the app list. // This resets the grid view to a fresh state for showing the app list.
void ResetForShowApps(); void ResetForShowApps();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment