OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/start_page_view.h" | 5 #include "ui/app_list/views/start_page_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 | 195 |
196 // Update the tile item results. | 196 // Update the tile item results. |
197 for (size_t i = 0; i < search_result_tile_views_.size(); ++i) { | 197 for (size_t i = 0; i < search_result_tile_views_.size(); ++i) { |
198 SearchResult* item = nullptr; | 198 SearchResult* item = nullptr; |
199 if (i < display_results.size()) | 199 if (i < display_results.size()) |
200 item = display_results[i]; | 200 item = display_results[i]; |
201 search_result_tile_views_[i]->SetSearchResult(item); | 201 search_result_tile_views_[i]->SetSearchResult(item); |
202 search_result_tile_views_[i]->SetEnabled(true); | 202 search_result_tile_views_[i]->SetEnabled(true); |
203 } | 203 } |
204 | 204 |
205 Layout(); | |
206 parent()->Layout(); | 205 parent()->Layout(); |
207 // Add 1 to the results size to account for the all apps button. | 206 // Add 1 to the results size to account for the all apps button. |
208 return display_results.size() + 1; | 207 return display_results.size() + 1; |
209 } | 208 } |
210 | 209 |
211 void StartPageView::StartPageTilesContainer::UpdateSelectedIndex( | 210 void StartPageView::StartPageTilesContainer::UpdateSelectedIndex( |
212 int old_selected, | 211 int old_selected, |
213 int new_selected) { | 212 int new_selected) { |
214 if (old_selected >= 0 && old_selected < num_results()) | 213 if (old_selected >= 0 && old_selected < num_results()) |
215 GetTileItemView(old_selected)->SetSelected(false); | 214 GetTileItemView(old_selected)->SetSelected(false); |
(...skipping 26 matching lines...) Expand all Loading... |
242 views::ColumnSet* column_set = tiles_layout_manager->AddColumnSet(0); | 241 views::ColumnSet* column_set = tiles_layout_manager->AddColumnSet(0); |
243 column_set->AddPaddingColumn(0, kTilesHorizontalMarginLeft); | 242 column_set->AddPaddingColumn(0, kTilesHorizontalMarginLeft); |
244 for (int col = 0; col < kNumStartPageTilesCols; ++col) { | 243 for (int col = 0; col < kNumStartPageTilesCols; ++col) { |
245 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 0, | 244 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 0, |
246 views::GridLayout::USE_PREF, 0, 0); | 245 views::GridLayout::USE_PREF, 0, 0); |
247 column_set->AddPaddingColumn(0, kTileSpacing); | 246 column_set->AddPaddingColumn(0, kTileSpacing); |
248 } | 247 } |
249 | 248 |
250 // Add SearchResultTileItemViews to the container. | 249 // Add SearchResultTileItemViews to the container. |
251 int i = 0; | 250 int i = 0; |
| 251 search_result_tile_views_.reserve(apps_num); |
252 for (; i < apps_num; ++i) { | 252 for (; i < apps_num; ++i) { |
253 SearchResultTileItemView* tile_item = | 253 SearchResultTileItemView* tile_item = |
254 new SearchResultTileItemView(this, view_delegate_); | 254 new SearchResultTileItemView(this, view_delegate_); |
255 if (i % kNumStartPageTilesCols == 0) | 255 if (i % kNumStartPageTilesCols == 0) |
256 tiles_layout_manager->StartRow(0, 0); | 256 tiles_layout_manager->StartRow(0, 0); |
257 tiles_layout_manager->AddView(tile_item); | 257 tiles_layout_manager->AddView(tile_item); |
258 AddChildView(tile_item); | 258 AddChildView(tile_item); |
259 tile_item->SetParentBackgroundColor(kLabelBackgroundColor); | 259 tile_item->SetParentBackgroundColor(kLabelBackgroundColor); |
260 tile_item->SetHoverStyle(TileItemView::HOVER_STYLE_ANIMATE_SHADOW); | 260 tile_item->SetHoverStyle(TileItemView::HOVER_STYLE_ANIMATE_SHADOW); |
261 search_result_tile_views_.push_back(tile_item); | 261 search_result_tile_views_.emplace_back(tile_item); |
262 } | 262 } |
263 | 263 |
264 // Also add a special "all apps" button to the end of the container. | 264 // Also add a special "all apps" button to the end of the container. |
265 all_apps_button_->UpdateIcon(); | 265 all_apps_button_->UpdateIcon(); |
266 if (i % kNumStartPageTilesCols == 0) | 266 if (i % kNumStartPageTilesCols == 0) |
267 tiles_layout_manager->StartRow(0, 0); | 267 tiles_layout_manager->StartRow(0, 0); |
268 tiles_layout_manager->AddView(all_apps_button_); | 268 tiles_layout_manager->AddView(all_apps_button_); |
269 AddChildView(all_apps_button_); | 269 AddChildView(all_apps_button_); |
270 } | 270 } |
271 | 271 |
(...skipping 15 matching lines...) Expand all Loading... |
287 // The view containing the start page WebContents and SearchBoxSpacerView. | 287 // The view containing the start page WebContents and SearchBoxSpacerView. |
288 InitInstantContainer(); | 288 InitInstantContainer(); |
289 AddChildView(instant_container_); | 289 AddChildView(instant_container_); |
290 | 290 |
291 // The view containing the start page tiles. | 291 // The view containing the start page tiles. |
292 AddChildView(tiles_container_); | 292 AddChildView(tiles_container_); |
293 | 293 |
294 AddChildView(custom_launcher_page_background_); | 294 AddChildView(custom_launcher_page_background_); |
295 | 295 |
296 tiles_container_->SetResults(view_delegate_->GetModel()->results()); | 296 tiles_container_->SetResults(view_delegate_->GetModel()->results()); |
297 Reset(); | |
298 } | 297 } |
299 | 298 |
300 StartPageView::~StartPageView() { | 299 StartPageView::~StartPageView() { |
301 } | 300 } |
302 | 301 |
303 void StartPageView::InitInstantContainer() { | 302 void StartPageView::InitInstantContainer() { |
304 views::BoxLayout* instant_layout_manager = new views::BoxLayout( | 303 views::BoxLayout* instant_layout_manager = new views::BoxLayout( |
305 views::BoxLayout::kVertical, 0, 0, kInstantContainerSpacing); | 304 views::BoxLayout::kVertical, 0, 0, kInstantContainerSpacing); |
306 instant_layout_manager->set_inside_border_insets( | 305 instant_layout_manager->set_inside_border_insets( |
307 gfx::Insets(0, 0, kSearchBoxAndTilesSpacing, 0)); | 306 gfx::Insets(0, 0, kSearchBoxAndTilesSpacing, 0)); |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 // is enabled). | 526 // is enabled). |
528 if (event->type() == ui::ET_SCROLL && event->y_offset() < 0) | 527 if (event->type() == ui::ET_SCROLL && event->y_offset() < 0) |
529 MaybeOpenCustomLauncherPage(); | 528 MaybeOpenCustomLauncherPage(); |
530 } | 529 } |
531 | 530 |
532 TileItemView* StartPageView::GetTileItemView(size_t index) { | 531 TileItemView* StartPageView::GetTileItemView(size_t index) { |
533 return tiles_container_->GetTileItemView(index); | 532 return tiles_container_->GetTileItemView(index); |
534 } | 533 } |
535 | 534 |
536 } // namespace app_list | 535 } // namespace app_list |
OLD | NEW |