OLD | NEW |
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/apps_container_view.h" | 5 #include "ui/app_list/views/apps_container_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 rows = kExperimentalPreferredRows; | 36 rows = kExperimentalPreferredRows; |
37 } | 37 } |
38 apps_grid_view_->SetLayout(kPreferredIconDimension, cols, rows); | 38 apps_grid_view_->SetLayout(kPreferredIconDimension, cols, rows); |
39 AddChildView(apps_grid_view_); | 39 AddChildView(apps_grid_view_); |
40 | 40 |
41 folder_background_view_ = new FolderBackgroundView(); | 41 folder_background_view_ = new FolderBackgroundView(); |
42 AddChildView(folder_background_view_); | 42 AddChildView(folder_background_view_); |
43 | 43 |
44 app_list_folder_view_ = | 44 app_list_folder_view_ = |
45 new AppListFolderView(this, model, app_list_main_view); | 45 new AppListFolderView(this, model, app_list_main_view); |
| 46 // The folder view is initially hidden. |
| 47 app_list_folder_view_->SetVisible(false); |
46 AddChildView(app_list_folder_view_); | 48 AddChildView(app_list_folder_view_); |
47 | 49 |
48 apps_grid_view_->SetModel(model_); | 50 apps_grid_view_->SetModel(model_); |
49 apps_grid_view_->SetItemList(model_->top_level_item_list()); | 51 apps_grid_view_->SetItemList(model_->top_level_item_list()); |
50 SetShowState(SHOW_APPS, | 52 SetShowState(SHOW_APPS, |
51 false); /* show apps without animation */ | 53 false); /* show apps without animation */ |
52 } | 54 } |
53 | 55 |
54 AppsContainerView::~AppsContainerView() { | 56 AppsContainerView::~AppsContainerView() { |
55 } | 57 } |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 | 203 |
202 void AppsContainerView::CreateViewsForFolderTopItemsAnimation( | 204 void AppsContainerView::CreateViewsForFolderTopItemsAnimation( |
203 AppListFolderItem* active_folder, | 205 AppListFolderItem* active_folder, |
204 bool open_folder) { | 206 bool open_folder) { |
205 top_icon_views_.clear(); | 207 top_icon_views_.clear(); |
206 std::vector<gfx::Rect> top_items_bounds = | 208 std::vector<gfx::Rect> top_items_bounds = |
207 GetTopItemIconBoundsInActiveFolder(); | 209 GetTopItemIconBoundsInActiveFolder(); |
208 top_icon_animation_pending_count_ = | 210 top_icon_animation_pending_count_ = |
209 std::min(kNumFolderTopItems, active_folder->item_list()->item_count()); | 211 std::min(kNumFolderTopItems, active_folder->item_list()->item_count()); |
210 for (size_t i = 0; i < top_icon_animation_pending_count_; ++i) { | 212 for (size_t i = 0; i < top_icon_animation_pending_count_; ++i) { |
| 213 if (active_folder->GetTopIcon(i).isNull()) |
| 214 continue; |
| 215 |
211 TopIconAnimationView* icon_view = new TopIconAnimationView( | 216 TopIconAnimationView* icon_view = new TopIconAnimationView( |
212 active_folder->GetTopIcon(i), top_items_bounds[i], open_folder); | 217 active_folder->GetTopIcon(i), top_items_bounds[i], open_folder); |
213 icon_view->AddObserver(this); | 218 icon_view->AddObserver(this); |
214 top_icon_views_.push_back(icon_view); | 219 top_icon_views_.push_back(icon_view); |
215 | 220 |
216 // Add the transitional views into child views, and set its bounds to the | 221 // Add the transitional views into child views, and set its bounds to the |
217 // same location of the item in the folder list view. | 222 // same location of the item in the folder list view. |
218 AddChildView(top_icon_views_[i]); | 223 AddChildView(top_icon_views_[i]); |
219 top_icon_views_[i]->SetBoundsRect( | 224 top_icon_views_[i]->SetBoundsRect( |
220 app_list_folder_view_->ConvertRectToParent( | 225 app_list_folder_view_->ConvertRectToParent( |
221 app_list_folder_view_->GetItemIconBoundsAt(i))); | 226 app_list_folder_view_->GetItemIconBoundsAt(i))); |
222 static_cast<TopIconAnimationView*>(top_icon_views_[i])->TransformView(); | 227 static_cast<TopIconAnimationView*>(top_icon_views_[i])->TransformView(); |
223 } | 228 } |
224 } | 229 } |
225 | 230 |
226 void AppsContainerView::PrepareToShowApps(AppListFolderItem* folder_item) { | 231 void AppsContainerView::PrepareToShowApps(AppListFolderItem* folder_item) { |
227 if (folder_item) | 232 if (folder_item) |
228 CreateViewsForFolderTopItemsAnimation(folder_item, false); | 233 CreateViewsForFolderTopItemsAnimation(folder_item, false); |
229 | 234 |
230 // Hide the active folder item until the animation completes. | 235 // Hide the active folder item until the animation completes. |
231 if (apps_grid_view_->activated_item_view()) | 236 if (apps_grid_view_->activated_item_view()) |
232 apps_grid_view_->activated_item_view()->SetVisible(false); | 237 apps_grid_view_->activated_item_view()->SetVisible(false); |
233 } | 238 } |
234 | 239 |
235 } // namespace app_list | 240 } // namespace app_list |
OLD | NEW |