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

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

Issue 293563002: GetScaleFactorForNativeView should return scale factor in float (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « content/public/browser/web_ui.h ('k') | ui/base/layout.h » ('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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/app_list_main_view.h" 5 #include "ui/app_list/views/app_list_main_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 void AppListMainView::SetDragAndDropHostOfCurrentAppList( 181 void AppListMainView::SetDragAndDropHostOfCurrentAppList(
182 ApplicationDragAndDropHost* drag_and_drop_host) { 182 ApplicationDragAndDropHost* drag_and_drop_host) {
183 contents_view_->SetDragAndDropHostOfCurrentAppList(drag_and_drop_host); 183 contents_view_->SetDragAndDropHostOfCurrentAppList(drag_and_drop_host);
184 } 184 }
185 185
186 bool AppListMainView::ShouldCenterWindow() const { 186 bool AppListMainView::ShouldCenterWindow() const {
187 return delegate_->ShouldCenterWindow(); 187 return delegate_->ShouldCenterWindow();
188 } 188 }
189 189
190 void AppListMainView::PreloadIcons(gfx::NativeView parent) { 190 void AppListMainView::PreloadIcons(gfx::NativeView parent) {
191 ui::ScaleFactor scale_factor = ui::SCALE_FACTOR_100P; 191 float scale_factor = 1.0f;
192 if (parent) 192 if (parent)
193 scale_factor = ui::GetScaleFactorForNativeView(parent); 193 scale_factor = ui::GetScaleFactorForNativeView(parent);
194 194
195 float scale = ui::GetImageScale(scale_factor);
196 // |pagination_model| could have -1 as the initial selected page and 195 // |pagination_model| could have -1 as the initial selected page and
197 // assumes first page (i.e. index 0) will be used in this case. 196 // assumes first page (i.e. index 0) will be used in this case.
198 const int selected_page = std::max(0, pagination_model_->selected_page()); 197 const int selected_page = std::max(0, pagination_model_->selected_page());
199 198
200 const int tiles_per_page = kPreferredCols * kPreferredRows; 199 const int tiles_per_page = kPreferredCols * kPreferredRows;
201 const int start_model_index = selected_page * tiles_per_page; 200 const int start_model_index = selected_page * tiles_per_page;
202 const int end_model_index = 201 const int end_model_index =
203 std::min(static_cast<int>(model_->top_level_item_list()->item_count()), 202 std::min(static_cast<int>(model_->top_level_item_list()->item_count()),
204 start_model_index + tiles_per_page); 203 start_model_index + tiles_per_page);
205 204
206 pending_icon_loaders_.clear(); 205 pending_icon_loaders_.clear();
207 for (int i = start_model_index; i < end_model_index; ++i) { 206 for (int i = start_model_index; i < end_model_index; ++i) {
208 AppListItem* item = model_->top_level_item_list()->item_at(i); 207 AppListItem* item = model_->top_level_item_list()->item_at(i);
209 if (item->icon().HasRepresentation(scale)) 208 if (item->icon().HasRepresentation(scale_factor))
210 continue; 209 continue;
211 210
212 pending_icon_loaders_.push_back(new IconLoader(this, item, scale)); 211 pending_icon_loaders_.push_back(new IconLoader(this, item, scale_factor));
213 } 212 }
214 } 213 }
215 214
216 void AppListMainView::OnIconLoadingWaitTimer() { 215 void AppListMainView::OnIconLoadingWaitTimer() {
217 GetWidget()->Show(); 216 GetWidget()->Show();
218 } 217 }
219 218
220 void AppListMainView::OnItemIconLoaded(IconLoader* loader) { 219 void AppListMainView::OnItemIconLoaded(IconLoader* loader) {
221 ScopedVector<IconLoader>::iterator it = std::find( 220 ScopedVector<IconLoader>::iterator it = std::find(
222 pending_icon_loaders_.begin(), pending_icon_loaders_.end(), loader); 221 pending_icon_loaders_.begin(), pending_icon_loaders_.end(), loader);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 // Resubmit the query via a posted task so that all observers for the 271 // Resubmit the query via a posted task so that all observers for the
273 // uninstall notification are notified. 272 // uninstall notification are notified.
274 base::MessageLoop::current()->PostTask( 273 base::MessageLoop::current()->PostTask(
275 FROM_HERE, 274 FROM_HERE,
276 base::Bind(&AppListMainView::QueryChanged, 275 base::Bind(&AppListMainView::QueryChanged,
277 weak_ptr_factory_.GetWeakPtr(), 276 weak_ptr_factory_.GetWeakPtr(),
278 search_box_view_)); 277 search_box_view_));
279 } 278 }
280 279
281 } // namespace app_list 280 } // namespace app_list
OLDNEW
« no previous file with comments | « content/public/browser/web_ui.h ('k') | ui/base/layout.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698