Commit b5067414 authored by Kevin Strohbehn's avatar Kevin Strohbehn Committed by Commit Bot

Refactors drop_target to reference regions, not intentions

Bug: 885232
Change-Id: I08943ff79a7dfae036acb8842bc67e8fe90c2999
Reviewed-on: https://chromium-review.googlesource.com/1253073Reviewed-by: default avatarWeidong Guo <weidongg@chromium.org>
Commit-Queue: Kevin Strohbehn <ginko@google.com>
Cr-Commit-Position: refs/heads/master@{#595613}
parent f6c57c76
This diff is collapsed.
...@@ -299,10 +299,11 @@ class APP_LIST_EXPORT AppsGridView : public views::View, ...@@ -299,10 +299,11 @@ class APP_LIST_EXPORT AppsGridView : public views::View,
friend class test::AppsGridViewTestApi; friend class test::AppsGridViewTestApi;
friend class PagedViewStructure; friend class PagedViewStructure;
enum DropAttempt { enum DropTargetRegion {
DROP_FOR_NONE, NO_TARGET,
DROP_FOR_REORDER, ON_ITEM,
DROP_FOR_FOLDER, NEAR_ITEM,
BETWEEN_ITEMS,
}; };
// Updates suggestions from app list model. // Updates suggestions from app list model.
...@@ -359,20 +360,21 @@ class APP_LIST_EXPORT AppsGridView : public views::View, ...@@ -359,20 +360,21 @@ class APP_LIST_EXPORT AppsGridView : public views::View,
void ExtractDragLocation(const gfx::Point& root_location, void ExtractDragLocation(const gfx::Point& root_location,
gfx::Point* drag_point); gfx::Point* drag_point);
// Updates |reorder_drop_target_|, |folder_drop_target_| and |drop_attempt_| // Updates |drop_target_| and |drop_target_region_|
// based on |drag_view_|'s position. // based on |drag_view_|'s position.
void CalculateDropTarget(); void UpdateDropTargetRegion();
// If |point| is a valid folder drop target, returns true and sets bool DropTargetIsValidFolder();
// |drop_target| to the index of the view to do a folder drop for.
bool CalculateFolderDropTarget(const gfx::Point& point,
GridIndex* drop_target) const;
// Calculates the reorder target |point| and sets |drop_target| to the index // Updates |drop_target_| as a location for potential reordering after the
// of the view to reorder. Returns true if |drop_target| is calculated // currently dragged item is released.
// successfully. void UpdateDropTargetForReorder(const gfx::Point& point);
bool CalculateReorderDropTarget(const gfx::Point& point,
GridIndex* drop_target) const; // Returns true if the current drag is occurring within a certain range of the
// nearest item.
bool DragIsCloseToItem();
bool DragPointIsOverItem(const gfx::Point& point);
// Prepares |drag_and_drop_host_| for dragging. |grid_location| contains // Prepares |drag_and_drop_host_| for dragging. |grid_location| contains
// the drag point in this grid view's coordinates. // the drag point in this grid view's coordinates.
...@@ -466,8 +468,9 @@ class APP_LIST_EXPORT AppsGridView : public views::View, ...@@ -466,8 +468,9 @@ class APP_LIST_EXPORT AppsGridView : public views::View,
// If |hide| is set the view will get hidden, otherwise it gets shown. // If |hide| is set the view will get hidden, otherwise it gets shown.
void SetViewHidden(AppListItemView* view, bool hide, bool immediate); void SetViewHidden(AppListItemView* view, bool hide, bool immediate);
// Whether the folder drag-and-drop UI should be enabled. // Returns true if the dragged item isn't a folder, the drag is not
bool EnableFolderDragDropUI(); // occurring inside a folder, and |drop_target_| is a valid index.
bool DraggedItemCanEnterFolder();
// Returns the size of the entire tile grid. // Returns the size of the entire tile grid.
gfx::Size GetTileGridSize() const; gfx::Size GetTileGridSize() const;
...@@ -663,7 +666,7 @@ class APP_LIST_EXPORT AppsGridView : public views::View, ...@@ -663,7 +666,7 @@ class APP_LIST_EXPORT AppsGridView : public views::View,
Pointer drag_pointer_ = NONE; Pointer drag_pointer_ = NONE;
// The most recent reorder drop target. // The most recent reorder drop target.
GridIndex reorder_drop_target_; GridIndex drop_target_;
// The most recent folder drop target. // The most recent folder drop target.
GridIndex folder_drop_target_; GridIndex folder_drop_target_;
...@@ -673,12 +676,12 @@ class APP_LIST_EXPORT AppsGridView : public views::View, ...@@ -673,12 +676,12 @@ class APP_LIST_EXPORT AppsGridView : public views::View,
GridIndex reorder_placeholder_; GridIndex reorder_placeholder_;
// The current action that ending a drag will perform. // The current action that ending a drag will perform.
DropAttempt drop_attempt_ = DROP_FOR_NONE; DropTargetRegion drop_target_region_ = NO_TARGET;
// Timer for re-ordering the |drop_target_| and |drag_view_|. // Timer for re-ordering the |drop_target_region_| and |drag_view_|.
base::OneShotTimer reorder_timer_; base::OneShotTimer reorder_timer_;
// Timer for dropping |drag_view_| into the folder containing // Timer for dropping |drag_view_| into the folder represented by
// the |drop_target_|. // the |drop_target_|.
base::OneShotTimer folder_dropping_timer_; base::OneShotTimer folder_dropping_timer_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment