| 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 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 pagination_model_.RemoveObserver(this); | 380 pagination_model_.RemoveObserver(this); |
| 381 | 381 |
| 382 if (item_list_) | 382 if (item_list_) |
| 383 item_list_->RemoveObserver(this); | 383 item_list_->RemoveObserver(this); |
| 384 | 384 |
| 385 // Make sure |page_switcher_view_| is deleted before |pagination_model_|. | 385 // Make sure |page_switcher_view_| is deleted before |pagination_model_|. |
| 386 view_model_.Clear(); | 386 view_model_.Clear(); |
| 387 RemoveAllChildViews(true); | 387 RemoveAllChildViews(true); |
| 388 } | 388 } |
| 389 | 389 |
| 390 void AppsGridView::SetLayout(int icon_size, int cols, int rows_per_page) { | 390 void AppsGridView::SetLayout(int cols, int rows_per_page) { |
| 391 icon_size_.SetSize(icon_size, icon_size); | |
| 392 cols_ = cols; | 391 cols_ = cols; |
| 393 rows_per_page_ = rows_per_page; | 392 rows_per_page_ = rows_per_page; |
| 394 | 393 |
| 395 SetBorder(views::Border::CreateEmptyBorder( | 394 SetBorder(views::Border::CreateEmptyBorder( |
| 396 kTopPadding, kLeftRightPadding, 0, kLeftRightPadding)); | 395 kTopPadding, kLeftRightPadding, 0, kLeftRightPadding)); |
| 397 } | 396 } |
| 398 | 397 |
| 399 void AppsGridView::ResetForShowApps() { | 398 void AppsGridView::ResetForShowApps() { |
| 400 activated_folder_item_view_ = NULL; | 399 activated_folder_item_view_ = NULL; |
| 401 ClearDragState(); | 400 ClearDragState(); |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 775 | 774 |
| 776 // Create a new AppListItemView to duplicate the original_drag_view in the | 775 // Create a new AppListItemView to duplicate the original_drag_view in the |
| 777 // folder's grid view. | 776 // folder's grid view. |
| 778 AppListItemView* view = new AppListItemView(this, original_drag_view->item()); | 777 AppListItemView* view = new AppListItemView(this, original_drag_view->item()); |
| 779 AddChildView(view); | 778 AddChildView(view); |
| 780 drag_view_ = view; | 779 drag_view_ = view; |
| 781 drag_view_->SetPaintToLayer(true); | 780 drag_view_->SetPaintToLayer(true); |
| 782 // Note: For testing purpose, SetFillsBoundsOpaquely can be set to true to | 781 // Note: For testing purpose, SetFillsBoundsOpaquely can be set to true to |
| 783 // show the gray background. | 782 // show the gray background. |
| 784 drag_view_->SetFillsBoundsOpaquely(false); | 783 drag_view_->SetFillsBoundsOpaquely(false); |
| 785 drag_view_->SetIconSize(icon_size_); | |
| 786 drag_view_->SetBoundsRect(drag_view_rect); | 784 drag_view_->SetBoundsRect(drag_view_rect); |
| 787 drag_view_->SetDragUIState(); // Hide the title of the drag_view_. | 785 drag_view_->SetDragUIState(); // Hide the title of the drag_view_. |
| 788 | 786 |
| 789 // Hide the drag_view_ for drag icon proxy. | 787 // Hide the drag_view_ for drag icon proxy. |
| 790 SetViewHidden(drag_view_, | 788 SetViewHidden(drag_view_, |
| 791 true /* hide */, | 789 true /* hide */, |
| 792 true /* no animate */); | 790 true /* no animate */); |
| 793 | 791 |
| 794 // Add drag_view_ to the end of the view_model_. | 792 // Add drag_view_ to the end of the view_model_. |
| 795 view_model_.Add(drag_view_, view_model_.view_size()); | 793 view_model_.Add(drag_view_, view_model_.view_size()); |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1020 AddChildView(view); | 1018 AddChildView(view); |
| 1021 } | 1019 } |
| 1022 } | 1020 } |
| 1023 | 1021 |
| 1024 views::View* AppsGridView::CreateViewForItemAtIndex(size_t index) { | 1022 views::View* AppsGridView::CreateViewForItemAtIndex(size_t index) { |
| 1025 // The drag_view_ might be pending for deletion, therefore view_model_ | 1023 // The drag_view_ might be pending for deletion, therefore view_model_ |
| 1026 // may have one more item than item_list_. | 1024 // may have one more item than item_list_. |
| 1027 DCHECK_LE(index, item_list_->item_count()); | 1025 DCHECK_LE(index, item_list_->item_count()); |
| 1028 AppListItemView* view = new AppListItemView(this, | 1026 AppListItemView* view = new AppListItemView(this, |
| 1029 item_list_->item_at(index)); | 1027 item_list_->item_at(index)); |
| 1030 view->SetIconSize(icon_size_); | |
| 1031 view->SetPaintToLayer(true); | 1028 view->SetPaintToLayer(true); |
| 1032 view->SetFillsBoundsOpaquely(false); | 1029 view->SetFillsBoundsOpaquely(false); |
| 1033 return view; | 1030 return view; |
| 1034 } | 1031 } |
| 1035 | 1032 |
| 1036 AppsGridView::Index AppsGridView::GetIndexFromModelIndex( | 1033 AppsGridView::Index AppsGridView::GetIndexFromModelIndex( |
| 1037 int model_index) const { | 1034 int model_index) const { |
| 1038 return Index(model_index / tiles_per_page(), model_index % tiles_per_page()); | 1035 return Index(model_index / tiles_per_page(), model_index % tiles_per_page()); |
| 1039 } | 1036 } |
| 1040 | 1037 |
| (...skipping 1134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2175 void AppsGridView::SetAsFolderDroppingTarget(const Index& target_index, | 2172 void AppsGridView::SetAsFolderDroppingTarget(const Index& target_index, |
| 2176 bool is_target_folder) { | 2173 bool is_target_folder) { |
| 2177 AppListItemView* target_view = | 2174 AppListItemView* target_view = |
| 2178 static_cast<AppListItemView*>( | 2175 static_cast<AppListItemView*>( |
| 2179 GetViewAtSlotOnCurrentPage(target_index.slot)); | 2176 GetViewAtSlotOnCurrentPage(target_index.slot)); |
| 2180 if (target_view) | 2177 if (target_view) |
| 2181 target_view->SetAsAttemptedFolderTarget(is_target_folder); | 2178 target_view->SetAsAttemptedFolderTarget(is_target_folder); |
| 2182 } | 2179 } |
| 2183 | 2180 |
| 2184 } // namespace app_list | 2181 } // namespace app_list |
| OLD | NEW |