| 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" |
| 11 #include "ui/app_list/app_list_constants.h" | 11 #include "ui/app_list/app_list_constants.h" |
| 12 #include "ui/app_list/app_list_folder_item.h" | 12 #include "ui/app_list/app_list_folder_item.h" |
| 13 #include "ui/app_list/app_list_switches.h" | 13 #include "ui/app_list/app_list_switches.h" |
| 14 #include "ui/app_list/pagination_model.h" | 14 #include "ui/app_list/pagination_model.h" |
| 15 #include "ui/app_list/views/app_list_folder_view.h" | 15 #include "ui/app_list/views/app_list_folder_view.h" |
| 16 #include "ui/app_list/views/app_list_item_view.h" | 16 #include "ui/app_list/views/app_list_item_view.h" |
| 17 #include "ui/app_list/views/app_list_main_view.h" | 17 #include "ui/app_list/views/app_list_main_view.h" |
| 18 #include "ui/app_list/views/apps_grid_view.h" | 18 #include "ui/app_list/views/apps_grid_view.h" |
| 19 #include "ui/app_list/views/folder_background_view.h" | 19 #include "ui/app_list/views/folder_background_view.h" |
| 20 #include "ui/events/event.h" | 20 #include "ui/events/event.h" |
| 21 | 21 |
| 22 namespace app_list { | 22 namespace app_list { |
| 23 | 23 |
| 24 AppsContainerView::AppsContainerView(AppListMainView* app_list_main_view, | 24 AppsContainerView::AppsContainerView(AppListMainView* app_list_main_view, |
| 25 PaginationModel* pagination_model, | 25 PaginationModel* pagination_model, |
| 26 AppListModel* model, | 26 AppListModel* model, |
| 27 content::WebContents* start_page_contents) | 27 content::WebContents* start_page_contents) |
| 28 : model_(model), | 28 : model_(model), |
| 29 show_state_(SHOW_APPS), | 29 show_state_(SHOW_APPS), |
| 30 activated_folder_view_(NULL), |
| 30 top_icon_animation_pending_count_(0) { | 31 top_icon_animation_pending_count_(0) { |
| 31 apps_grid_view_ = new AppsGridView( | 32 apps_grid_view_ = new AppsGridView( |
| 32 app_list_main_view, pagination_model, start_page_contents); | 33 app_list_main_view, pagination_model, start_page_contents); |
| 33 int cols = kPreferredCols; | 34 int cols = kPreferredCols; |
| 34 int rows = kPreferredRows; | 35 int rows = kPreferredRows; |
| 35 if (CommandLine::ForCurrentProcess()->HasSwitch( | 36 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 36 app_list::switches::kEnableExperimentalAppList)) { | 37 app_list::switches::kEnableExperimentalAppList)) { |
| 37 cols = kExperimentalPreferredCols; | 38 cols = kExperimentalPreferredCols; |
| 38 rows = kExperimentalPreferredRows; | 39 rows = kExperimentalPreferredRows; |
| 39 } | 40 } |
| 40 apps_grid_view_->SetLayout(kPreferredIconDimension, cols, rows); | 41 apps_grid_view_->SetLayout(kPreferredIconDimension, cols, rows); |
| 41 AddChildView(apps_grid_view_); | 42 AddChildView(apps_grid_view_); |
| 42 | 43 |
| 43 folder_background_view_ = new FolderBackgroundView(); | 44 folder_background_view_ = new FolderBackgroundView(); |
| 44 AddChildView(folder_background_view_); | 45 AddChildView(folder_background_view_); |
| 45 | 46 |
| 46 app_list_folder_view_ = new AppListFolderView( | 47 app_list_folder_view_ = new AppListFolderView( |
| 47 this, | 48 this, |
| 48 model, | 49 model, |
| 49 app_list_main_view, | 50 app_list_main_view, |
| 50 start_page_contents); | 51 start_page_contents); |
| 51 AddChildView(app_list_folder_view_); | 52 AddChildView(app_list_folder_view_); |
| 52 | 53 |
| 53 apps_grid_view_->SetModel(model_); | 54 apps_grid_view_->SetModel(model_); |
| 54 apps_grid_view_->SetItemList(model_->item_list()); | 55 apps_grid_view_->SetItemList(model_->item_list()); |
| 55 SetShowState(SHOW_APPS, | 56 ResetForShow(); |
| 56 false); /* show apps without animation */ | |
| 57 } | 57 } |
| 58 | 58 |
| 59 AppsContainerView::~AppsContainerView() { | 59 AppsContainerView::~AppsContainerView() { |
| 60 } | 60 } |
| 61 | 61 |
| 62 void AppsContainerView::ShowActiveFolder(AppListFolderItem* folder_item) { | 62 void AppsContainerView::ShowActiveFolder(AppListFolderItem* folder_item) { |
| 63 if (activated_folder_view_) |
| 64 return; |
| 65 |
| 63 app_list_folder_view_->SetAppListFolderItem(folder_item); | 66 app_list_folder_view_->SetAppListFolderItem(folder_item); |
| 64 SetShowState(SHOW_ACTIVE_FOLDER, false); | 67 SetShowState(SHOW_ACTIVE_FOLDER, false); |
| 65 | 68 |
| 66 CreateViewsForFolderTopItemsAnimation(folder_item, true); | 69 CreateViewsForFolderTopItemsAnimation(folder_item, true); |
| 67 } | 70 } |
| 68 | 71 |
| 69 void AppsContainerView::ShowApps(AppListFolderItem* folder_item) { | 72 void AppsContainerView::ShowApps(AppListFolderItem* folder_item) { |
| 70 PrepareToShowApps(folder_item); | 73 PrepareToShowApps(folder_item); |
| 71 SetShowState(SHOW_APPS, | 74 SetShowState(SHOW_APPS, |
| 72 true); /* show apps with animation */ | 75 true); /* show apps with animation */ |
| 73 } | 76 } |
| 74 | 77 |
| 78 void AppsContainerView::ResetForShow() { |
| 79 SetShowState(SHOW_APPS, false /* show apps without animation */); |
| 80 } |
| 81 |
| 75 void AppsContainerView::SetDragAndDropHostOfCurrentAppList( | 82 void AppsContainerView::SetDragAndDropHostOfCurrentAppList( |
| 76 ApplicationDragAndDropHost* drag_and_drop_host) { | 83 ApplicationDragAndDropHost* drag_and_drop_host) { |
| 77 apps_grid_view()->SetDragAndDropHostOfCurrentAppList(drag_and_drop_host); | 84 apps_grid_view()->SetDragAndDropHostOfCurrentAppList(drag_and_drop_host); |
| 78 app_list_folder_view()->items_grid_view()-> | 85 app_list_folder_view()->items_grid_view()-> |
| 79 SetDragAndDropHostOfCurrentAppList(drag_and_drop_host); | 86 SetDragAndDropHostOfCurrentAppList(drag_and_drop_host); |
| 80 } | 87 } |
| 81 | 88 |
| 82 void AppsContainerView::ReparentFolderItemTransit( | 89 void AppsContainerView::ReparentFolderItemTransit( |
| 83 AppListFolderItem* folder_item) { | 90 AppListFolderItem* folder_item) { |
| 84 PrepareToShowApps(folder_item); | 91 PrepareToShowApps(folder_item); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 | 130 |
| 124 void AppsContainerView::OnTopIconAnimationsComplete() { | 131 void AppsContainerView::OnTopIconAnimationsComplete() { |
| 125 --top_icon_animation_pending_count_; | 132 --top_icon_animation_pending_count_; |
| 126 | 133 |
| 127 if (!top_icon_animation_pending_count_) { | 134 if (!top_icon_animation_pending_count_) { |
| 128 // Clean up the transitional views used for top item icon animation. | 135 // Clean up the transitional views used for top item icon animation. |
| 129 top_icon_views_.clear(); | 136 top_icon_views_.clear(); |
| 130 | 137 |
| 131 // Show the folder icon when closing the folder. | 138 // Show the folder icon when closing the folder. |
| 132 if ((show_state_ == SHOW_APPS || show_state_ == SHOW_ITEM_REPARENT) && | 139 if ((show_state_ == SHOW_APPS || show_state_ == SHOW_ITEM_REPARENT) && |
| 133 apps_grid_view_->activated_item_view()) { | 140 activated_folder_view_) { |
| 134 apps_grid_view_->activated_item_view()->SetVisible(true); | 141 activated_folder_view_->SetVisible(true); |
| 142 activated_folder_view_ = NULL; |
| 135 } | 143 } |
| 136 } | 144 } |
| 137 } | 145 } |
| 138 | 146 |
| 139 void AppsContainerView::SetShowState(ShowState show_state, | 147 void AppsContainerView::SetShowState(ShowState show_state, |
| 140 bool show_apps_with_animation) { | 148 bool show_apps_with_animation) { |
| 141 if (show_state_ == show_state) | 149 if (show_state_ == show_state) |
| 142 return; | 150 return; |
| 143 | 151 |
| 144 show_state_ = show_state; | 152 show_state_ = show_state; |
| 145 | 153 |
| 146 switch (show_state_) { | 154 switch (show_state_) { |
| 147 case SHOW_APPS: | 155 case SHOW_APPS: |
| 148 folder_background_view_->SetVisible(false); | 156 folder_background_view_->SetVisible(false); |
| 149 if (show_apps_with_animation) { | 157 if (show_apps_with_animation) { |
| 150 app_list_folder_view_->ScheduleShowHideAnimation(false, false); | 158 app_list_folder_view_->ScheduleShowHideAnimation(false, false); |
| 151 apps_grid_view_->ScheduleShowHideAnimation(true); | 159 apps_grid_view_->ScheduleShowHideAnimation(true); |
| 152 } else { | 160 } else { |
| 161 if (activated_folder_view_) { |
| 162 activated_folder_view_->SetVisible(true); |
| 163 activated_folder_view_ = NULL; |
| 164 } |
| 153 app_list_folder_view_->HideViewImmediately(); | 165 app_list_folder_view_->HideViewImmediately(); |
| 166 apps_grid_view_->layer()->SetOpacity(1.0f); |
| 154 apps_grid_view_->SetVisible(true); | 167 apps_grid_view_->SetVisible(true); |
| 155 } | 168 } |
| 156 break; | 169 break; |
| 157 case SHOW_ACTIVE_FOLDER: | 170 case SHOW_ACTIVE_FOLDER: |
| 158 folder_background_view_->SetVisible(true); | 171 folder_background_view_->SetVisible(true); |
| 159 apps_grid_view_->ScheduleShowHideAnimation(false); | 172 apps_grid_view_->ScheduleShowHideAnimation(false); |
| 160 app_list_folder_view_->ScheduleShowHideAnimation(true, false); | 173 app_list_folder_view_->ScheduleShowHideAnimation(true, false); |
| 161 break; | 174 break; |
| 162 case SHOW_ITEM_REPARENT: | 175 case SHOW_ITEM_REPARENT: |
| 163 folder_background_view_->SetVisible(false); | 176 folder_background_view_->SetVisible(false); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 app_list_folder_view_->GetItemIconBoundsAt(i))); | 218 app_list_folder_view_->GetItemIconBoundsAt(i))); |
| 206 static_cast<TopIconAnimationView*>(top_icon_views_[i])->TransformView(); | 219 static_cast<TopIconAnimationView*>(top_icon_views_[i])->TransformView(); |
| 207 } | 220 } |
| 208 } | 221 } |
| 209 | 222 |
| 210 void AppsContainerView::PrepareToShowApps(AppListFolderItem* folder_item) { | 223 void AppsContainerView::PrepareToShowApps(AppListFolderItem* folder_item) { |
| 211 if (folder_item) | 224 if (folder_item) |
| 212 CreateViewsForFolderTopItemsAnimation(folder_item, false); | 225 CreateViewsForFolderTopItemsAnimation(folder_item, false); |
| 213 | 226 |
| 214 // Hide the active folder item until the animation completes. | 227 // Hide the active folder item until the animation completes. |
| 215 if (apps_grid_view_->activated_item_view()) | 228 if (apps_grid_view_->activated_item_view()) { |
| 216 apps_grid_view_->activated_item_view()->SetVisible(false); | 229 activated_folder_view_ = apps_grid_view_->activated_item_view(); |
| 230 activated_folder_view_->SetVisible(false); |
| 231 } |
| 217 } | 232 } |
| 218 | 233 |
| 219 } // namespace app_list | 234 } // namespace app_list |
| OLD | NEW |