Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(574)

Unified Diff: ui/app_list/views/apps_grid_view.h

Issue 553753003: Rework app list item drag zones. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@fasdaj
Patch Set: fix test Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/app_list/views/app_list_main_view_unittest.cc ('k') | ui/app_list/views/apps_grid_view.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/app_list/views/apps_grid_view.h
diff --git a/ui/app_list/views/apps_grid_view.h b/ui/app_list/views/apps_grid_view.h
index f98843bd92d8f95f33abaaf5f35695544fea7341..fefa9f23d2f437ea80ecaed85e2202af5f5d0ecf 100644
--- a/ui/app_list/views/apps_grid_view.h
+++ b/ui/app_list/views/apps_grid_view.h
@@ -235,6 +235,12 @@ class APP_LIST_EXPORT AppsGridView : public views::View,
bool operator!=(const Index& other) const {
return page != other.page || slot != other.slot;
}
+ bool operator<(const Index& other) const {
+ if (page != other.page)
+ return page < other.page;
+
+ return slot < other.slot;
+ }
int page; // Which page an item view is on.
int slot; // Which slot in the page an item view is in.
@@ -266,6 +272,9 @@ class APP_LIST_EXPORT AppsGridView : public views::View,
Index GetIndexOfView(const views::View* view) const;
views::View* GetViewAtIndex(const Index& index) const;
+ // Gets the index of the AppListItemView at the end of the view model.
+ Index GetLastViewIndex() const;
+
void MoveSelected(int page_delta, int slot_x_delta, int slot_y_delta);
void CalculateIdealBounds();
@@ -288,19 +297,19 @@ class APP_LIST_EXPORT AppsGridView : public views::View,
void ExtractDragLocation(const ui::LocatedEvent& event,
gfx::Point* drag_point);
- // Calculates reorder and folder drop targets based on |drag_point|.
- // |drag_point| is in the grid view's coordinates. When
- // |use_page_button_hovering| is true and |drag_point| is hovering on a page
- // button, use the last slot on that page as drop target.
- void CalculateDropTarget(const gfx::Point& drag_point,
- bool use_page_button_hovering);
+ // Updates |reorder_drop_target_|, |folder_drop_target_| and |drop_attempt_|
+ // based on |drag_view_|'s position.
+ void CalculateDropTarget();
- // Same as CalculateDropTarget, but with folder UI enabled. The drop target
- // can be either a target for re-ordering, or a target folder to move the
- // dragged item into if |drag_view_| enters its re-ordering or folder
- // dropping circle.
- void CalculateDropTargetWithFolderEnabled(const gfx::Point& drag_point,
- bool use_page_button_hovering);
+ // If |point| is a valid folder drop target, returns true and sets
+ // |drop_target| to the index of the view to do a folder drop for.
+ bool CalculateFolderDropTarget(const gfx::Point& point,
+ Index* drop_target) const;
+
+ // Calculates the reorder target |point| and sets |drop_target| to the index
+ // of the view to reorder.
+ void CalculateReorderDropTarget(const gfx::Point& point,
+ Index* drop_target) const;
// Prepares |drag_and_drop_host_| for dragging. |grid_location| contains
// the drag point in this grid view's coordinates.
@@ -388,33 +397,20 @@ class APP_LIST_EXPORT AppsGridView : public views::View,
// Whether target specified by |drap_target| can accept more items to be
// dropped into it.
- bool CanDropIntoTarget(const Index& drop_target);
-
- // Calculates the visual index of the nearest tile for which |drag_view_|
- // enters either its re-ordering or folder dropping circle.
- void CalculateNearestTileForDragView();
-
- // Calculates |nearest_tile| in which |vertex| of the |drag_view| is
- // enclosed.
- // *|nearest_tile| and *|d_min| will be updated based on the calculation.
- // *|d_min| is the distance between |nearest_tile| and |drag_view_|.
- void CalculateNearestTileForVertex(
- const gfx::Point& vertex, Index* nearest_tile, int* d_min);
-
- // Returns the bounds of the tile in which |point| is enclosed if there
- // is a valid item sits on the tile.
- gfx::Rect GetTileBoundsForPoint(const gfx::Point& point, Index* tile_index);
+ bool CanDropIntoTarget(const Index& drop_target) const;
// Returns the size of the entire tile grid.
gfx::Size GetTileGridSize() const;
- // Gets the expected bounds of a tile located at |row| and |col| on the
- // current page.
- gfx::Rect GetExpectedTileBounds(int row, int col) const;
+ // Returns the slot number which the given |point| falls into or the closest
+ // slot if |point| is outside the page's bounds.
+ Index GetNearestTileIndexForPoint(const gfx::Point& point) const;
- // Returns true if the slot of |index| is the last possible slot to drop
- // an item, i.e. first empty slot next to the last item on the last page.
- bool IsLastPossibleDropTarget(const Index& index) const;
+ // Gets the bounds of the tile located at |slot| on the current page.
+ gfx::Rect GetExpectedTileBounds(int slot) const;
+
+ // Gets the bounds of the tile located at |row| and |col| on the current page.
+ gfx::Rect GetExpectedTileBounds(int row, int col) const;
// Gets the item view located at |slot| on the current page. If there is
// no item located at |slot|, returns NULL.
@@ -520,6 +516,10 @@ class APP_LIST_EXPORT AppsGridView : public views::View,
// The most recent folder drop target.
Index folder_drop_target_;
+ // The index where an empty slot has been left as a placeholder for the
+ // reorder drop target. This updates when the reorder animation triggers.
+ Index reorder_placeholder_;
+
// The current action that ending a drag will perform.
DropAttempt drop_attempt_;
« no previous file with comments | « ui/app_list/views/app_list_main_view_unittest.cc ('k') | ui/app_list/views/apps_grid_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698