| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_grid_view.h" | 5 #include "ui/app_list/views/apps_grid_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 755 if (folder_delegate_ && !IsDraggingForReparentInHiddenGridView()) | 755 if (folder_delegate_ && !IsDraggingForReparentInHiddenGridView()) |
| 756 folder_delegate_->UpdateFolderViewBackground(false); | 756 folder_delegate_->UpdateFolderViewBackground(false); |
| 757 } | 757 } |
| 758 | 758 |
| 759 void AppsGridView::StopPageFlipTimer() { | 759 void AppsGridView::StopPageFlipTimer() { |
| 760 page_flip_timer_.Stop(); | 760 page_flip_timer_.Stop(); |
| 761 page_flip_target_ = -1; | 761 page_flip_target_ = -1; |
| 762 } | 762 } |
| 763 | 763 |
| 764 AppListItemView* AppsGridView::GetItemViewAt(int index) const { | 764 AppListItemView* AppsGridView::GetItemViewAt(int index) const { |
| 765 return static_cast<AppListItemView*>(view_model_.view_at(index)); | 765 return view_model_.view_at(index); |
| 766 } | 766 } |
| 767 | 767 |
| 768 void AppsGridView::SetTopItemViewsVisible(bool visible) { | 768 void AppsGridView::SetTopItemViewsVisible(bool visible) { |
| 769 int top_item_count = std::min(static_cast<int>(kNumFolderTopItems), | 769 int top_item_count = std::min(static_cast<int>(kNumFolderTopItems), |
| 770 view_model_.view_size()); | 770 view_model_.view_size()); |
| 771 for (int i = 0; i < top_item_count; ++i) | 771 for (int i = 0; i < top_item_count; ++i) |
| 772 GetItemViewAt(i)->icon()->SetVisible(visible); | 772 GetItemViewAt(i)->icon()->SetVisible(visible); |
| 773 } | 773 } |
| 774 | 774 |
| 775 void AppsGridView::ScheduleShowHideAnimation(bool show) { | 775 void AppsGridView::ScheduleShowHideAnimation(bool show) { |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1050 const int existing_items = item_list_ ? item_list_->item_count() : 0; | 1050 const int existing_items = item_list_ ? item_list_->item_count() : 0; |
| 1051 const int available_slots = | 1051 const int available_slots = |
| 1052 tiles_per_page() - existing_items % tiles_per_page(); | 1052 tiles_per_page() - existing_items % tiles_per_page(); |
| 1053 const int desired = model_->status() == AppListModel::STATUS_SYNCING ? | 1053 const int desired = model_->status() == AppListModel::STATUS_SYNCING ? |
| 1054 available_slots : 0; | 1054 available_slots : 0; |
| 1055 | 1055 |
| 1056 if (pulsing_blocks_model_.view_size() == desired) | 1056 if (pulsing_blocks_model_.view_size() == desired) |
| 1057 return; | 1057 return; |
| 1058 | 1058 |
| 1059 while (pulsing_blocks_model_.view_size() > desired) { | 1059 while (pulsing_blocks_model_.view_size() > desired) { |
| 1060 PulsingBlockView* view = GetPulsingBlockViewAt(0); | 1060 PulsingBlockView* view = pulsing_blocks_model_.view_at(0); |
| 1061 pulsing_blocks_model_.Remove(0); | 1061 pulsing_blocks_model_.Remove(0); |
| 1062 delete view; | 1062 delete view; |
| 1063 } | 1063 } |
| 1064 | 1064 |
| 1065 while (pulsing_blocks_model_.view_size() < desired) { | 1065 while (pulsing_blocks_model_.view_size() < desired) { |
| 1066 PulsingBlockView* view = new PulsingBlockView(GetTotalTileSize(), true); | 1066 PulsingBlockView* view = new PulsingBlockView(GetTotalTileSize(), true); |
| 1067 pulsing_blocks_model_.Add(view, 0); | 1067 pulsing_blocks_model_.Add(view, 0); |
| 1068 AddChildView(view); | 1068 AddChildView(view); |
| 1069 } | 1069 } |
| 1070 } | 1070 } |
| 1071 | 1071 |
| 1072 PulsingBlockView* AppsGridView::GetPulsingBlockViewAt(int index) const { | |
| 1073 return static_cast<PulsingBlockView*>(pulsing_blocks_model_.view_at(index)); | |
| 1074 } | |
| 1075 | |
| 1076 AppListItemView* AppsGridView::CreateViewForItemAtIndex(size_t index) { | 1072 AppListItemView* AppsGridView::CreateViewForItemAtIndex(size_t index) { |
| 1077 // The drag_view_ might be pending for deletion, therefore view_model_ | 1073 // The drag_view_ might be pending for deletion, therefore view_model_ |
| 1078 // may have one more item than item_list_. | 1074 // may have one more item than item_list_. |
| 1079 DCHECK_LE(index, item_list_->item_count()); | 1075 DCHECK_LE(index, item_list_->item_count()); |
| 1080 AppListItemView* view = new AppListItemView(this, | 1076 AppListItemView* view = new AppListItemView(this, |
| 1081 item_list_->item_at(index)); | 1077 item_list_->item_at(index)); |
| 1082 view->SetPaintToLayer(true); | 1078 view->SetPaintToLayer(true); |
| 1083 view->SetFillsBoundsOpaquely(false); | 1079 view->SetFillsBoundsOpaquely(false); |
| 1084 return view; | 1080 return view; |
| 1085 } | 1081 } |
| (...skipping 1065 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2151 | 2147 |
| 2152 void AppsGridView::SetAsFolderDroppingTarget(const Index& target_index, | 2148 void AppsGridView::SetAsFolderDroppingTarget(const Index& target_index, |
| 2153 bool is_target_folder) { | 2149 bool is_target_folder) { |
| 2154 AppListItemView* target_view = | 2150 AppListItemView* target_view = |
| 2155 GetViewDisplayedAtSlotOnCurrentPage(target_index.slot); | 2151 GetViewDisplayedAtSlotOnCurrentPage(target_index.slot); |
| 2156 if (target_view) | 2152 if (target_view) |
| 2157 target_view->SetAsAttemptedFolderTarget(is_target_folder); | 2153 target_view->SetAsAttemptedFolderTarget(is_target_folder); |
| 2158 } | 2154 } |
| 2159 | 2155 |
| 2160 } // namespace app_list | 2156 } // namespace app_list |
| OLD | NEW |