Chromium Code Reviews| Index: ui/app_list/views/apps_grid_view.cc |
| diff --git a/ui/app_list/views/apps_grid_view.cc b/ui/app_list/views/apps_grid_view.cc |
| index 4971720fe9d2ef355cfeb7fe8b9bf693b1ff3444..0e0d388e78dc321f3a73f29f5016110d1c1337b2 100644 |
| --- a/ui/app_list/views/apps_grid_view.cc |
| +++ b/ui/app_list/views/apps_grid_view.cc |
| @@ -212,7 +212,7 @@ class ItemMoveAnimationDelegate : public gfx::AnimationDelegate { |
| DISALLOW_COPY_AND_ASSIGN(ItemMoveAnimationDelegate); |
| }; |
| -// Returns true if the |item| is an folder item. |
| +// Returns true if the |item| is a folder item. |
| bool IsFolderItem(AppListItem* item) { |
| return (item->GetItemType() == AppListFolderItem::kItemType); |
| } |
| @@ -1393,20 +1393,39 @@ void AppsGridView::CalculateDropTarget() { |
| bool AppsGridView::CalculateFolderDropTarget(const gfx::Point& point, |
| Index* drop_target) const { |
| + // Folders can't be dropped into other folders. |
| + if (IsFolderItem(drag_view_->item())) |
| + return false; |
| + |
| + // A folder drop shouldn't happen on the reorder placeholder since that would |
| + // be merging an item with itself. |
| Index nearest_tile_index(GetNearestTileIndexForPoint(point)); |
| + if (GetLastViewIndex() < nearest_tile_index || |
|
Matt Giuca
2014/10/02 06:08:59
I don't understand where this condition (GetLastVi
calamity
2014/10/03 03:37:36
Wups. Roundabout way of checking index validity. F
|
| + nearest_tile_index == reorder_placeholder_) { |
| + return false; |
| + } |
| + |
| int distance_to_tile_center = |
| (point - GetExpectedTileBounds(nearest_tile_index.slot).CenterPoint()) |
| .Length(); |
| - if (nearest_tile_index != reorder_placeholder_ && |
| - distance_to_tile_center < kFolderDroppingCircleRadius && |
| - !IsFolderItem(drag_view_->item()) && |
| - CanDropIntoTarget(nearest_tile_index)) { |
| - *drop_target = nearest_tile_index; |
| - DCHECK(IsValidIndex(*drop_target)); |
| - return true; |
| + if (distance_to_tile_center > kFolderDroppingCircleRadius) |
|
Matt Giuca
2014/10/02 06:08:59
FYI, you are slightly changing the behaviour here.
calamity
2014/10/03 03:37:36
I think radii of drop zones should be inclusive of
Matt Giuca
2014/10/09 17:25:18
Acknowledged.
|
| + return false; |
| + |
| + AppListItemView* target_view = |
|
Matt Giuca
2014/10/02 06:08:59
I'm not sure I agree with inlining CanDropIntoTarg
calamity
2014/10/03 03:37:37
It's only used in one place and the logic should b
Matt Giuca
2014/10/09 17:25:18
Acknowledged.
|
| + GetViewDisplayedAtSlotOnCurrentPage(nearest_tile_index.slot); |
|
Matt Giuca
2014/10/02 06:08:59
You removed the NULL-check here?
calamity
2014/10/03 03:37:37
Hmmmmm. I _think_ this can't be NULL. But maybe it
|
| + AppListItem* target_item = target_view->item(); |
| + |
| + // Items can only be dropped into non-folders (which have no children) or |
| + // folders that have fewer than the max allowed items. |
| + // The OEM folder does not allow drag/drop of other items into it. |
| + if (target_item->ChildItemCount() >= kMaxFolderItems || |
| + IsOEMFolderItem(target_item)) { |
| + return false; |
| } |
| - return false; |
| + *drop_target = nearest_tile_index; |
| + DCHECK(IsValidIndex(*drop_target)); |
| + return true; |
| } |
| void AppsGridView::CalculateReorderDropTarget(const gfx::Point& point, |
| @@ -2084,20 +2103,6 @@ bool AppsGridView::EnableFolderDragDropUI() { |
| return model_->folders_enabled() && !folder_delegate_; |
| } |
| -bool AppsGridView::CanDropIntoTarget(const Index& drop_target) const { |
| - AppListItemView* target_view = |
| - GetViewDisplayedAtSlotOnCurrentPage(drop_target.slot); |
| - if (!target_view) |
| - return false; |
| - |
| - AppListItem* target_item = target_view->item(); |
| - // Items can be dropped into non-folders (which have no children) or folders |
| - // that have fewer than the max allowed items. |
| - // OEM folder does not allow to drag/drop other items in it. |
| - return target_item->ChildItemCount() < kMaxFolderItems && |
| - !IsOEMFolderItem(target_item); |
| -} |
| - |
| AppsGridView::Index AppsGridView::GetNearestTileIndexForPoint( |
| const gfx::Point& point) const { |
| gfx::Rect bounds = GetContentsBounds(); |