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

Side by Side 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: 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 unified diff | Download patch
« no previous file with comments | « no previous file | ui/app_list/views/apps_grid_view.cc » ('j') | ui/app_list/views/apps_grid_view.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #ifndef UI_APP_LIST_VIEWS_APPS_GRID_VIEW_H_ 5 #ifndef UI_APP_LIST_VIEWS_APPS_GRID_VIEW_H_
6 #define UI_APP_LIST_VIEWS_APPS_GRID_VIEW_H_ 6 #define UI_APP_LIST_VIEWS_APPS_GRID_VIEW_H_
7 7
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 10
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 struct Index { 228 struct Index {
229 Index() : page(-1), slot(-1) {} 229 Index() : page(-1), slot(-1) {}
230 Index(int page, int slot) : page(page), slot(slot) {} 230 Index(int page, int slot) : page(page), slot(slot) {}
231 231
232 bool operator==(const Index& other) const { 232 bool operator==(const Index& other) const {
233 return page == other.page && slot == other.slot; 233 return page == other.page && slot == other.slot;
234 } 234 }
235 bool operator!=(const Index& other) const { 235 bool operator!=(const Index& other) const {
236 return page != other.page || slot != other.slot; 236 return page != other.page || slot != other.slot;
237 } 237 }
238 bool operator<(const Index& other) const {
239 if (page == other.page)
tapted 2014/09/11 08:08:55 optional-nit: This is fine, but I usually write th
calamity 2014/09/15 03:26:11 Done.
240 return slot < other.slot;
241
242 return page < other.page;
243 }
238 244
239 int page; // Which page an item view is on. 245 int page; // Which page an item view is on.
240 int slot; // Which slot in the page an item view is in. 246 int slot; // Which slot in the page an item view is in.
241 }; 247 };
242 248
243 int tiles_per_page() const { return cols_ * rows_per_page_; } 249 int tiles_per_page() const { return cols_ * rows_per_page_; }
244 250
245 // Updates from model. 251 // Updates from model.
246 void Update(); 252 void Update();
247 253
(...skipping 11 matching lines...) Expand all
259 // struct above with page/slot info of where to display the item. 265 // struct above with page/slot info of where to display the item.
260 Index GetIndexFromModelIndex(int model_index) const; 266 Index GetIndexFromModelIndex(int model_index) const;
261 int GetModelIndexFromIndex(const Index& index) const; 267 int GetModelIndexFromIndex(const Index& index) const;
262 268
263 void SetSelectedItemByIndex(const Index& index); 269 void SetSelectedItemByIndex(const Index& index);
264 bool IsValidIndex(const Index& index) const; 270 bool IsValidIndex(const Index& index) const;
265 271
266 Index GetIndexOfView(const views::View* view) const; 272 Index GetIndexOfView(const views::View* view) const;
267 views::View* GetViewAtIndex(const Index& index) const; 273 views::View* GetViewAtIndex(const Index& index) const;
268 274
275 // Gets the index of the AppListItemView in the view model.
tapted 2014/09/11 08:08:55 `in the view model.` -> `at the end of the view mo
calamity 2014/09/15 03:26:11 Done.
276 Index GetLastViewIndex() const;
277
269 void MoveSelected(int page_delta, int slot_x_delta, int slot_y_delta); 278 void MoveSelected(int page_delta, int slot_x_delta, int slot_y_delta);
270 279
271 void CalculateIdealBounds(); 280 void CalculateIdealBounds();
272 void AnimateToIdealBounds(); 281 void AnimateToIdealBounds();
273 282
274 // Invoked when the given |view|'s current bounds and target bounds are on 283 // Invoked when the given |view|'s current bounds and target bounds are on
275 // different rows. To avoid moving diagonally, |view| would be put into a 284 // different rows. To avoid moving diagonally, |view| would be put into a
276 // slot prior |target| and fade in while moving to |target|. In the meanwhile, 285 // slot prior |target| and fade in while moving to |target|. In the meanwhile,
277 // a layer copy of |view| would start at |current| and fade out while moving 286 // a layer copy of |view| would start at |current| and fade out while moving
278 // to succeeding slot of |current|. |animate_current| controls whether to run 287 // to succeeding slot of |current|. |animate_current| controls whether to run
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 // If |hide| is set the view will get hidden, otherwise it gets shown. 392 // If |hide| is set the view will get hidden, otherwise it gets shown.
384 void SetViewHidden(views::View* view, bool hide, bool immediate); 393 void SetViewHidden(views::View* view, bool hide, bool immediate);
385 394
386 // Whether the folder drag-and-drop UI should be enabled. 395 // Whether the folder drag-and-drop UI should be enabled.
387 bool EnableFolderDragDropUI(); 396 bool EnableFolderDragDropUI();
388 397
389 // Whether target specified by |drap_target| can accept more items to be 398 // Whether target specified by |drap_target| can accept more items to be
390 // dropped into it. 399 // dropped into it.
391 bool CanDropIntoTarget(const Index& drop_target); 400 bool CanDropIntoTarget(const Index& drop_target);
392 401
393 // Calculates the visual index of the nearest tile for which |drag_view_|
394 // enters either its re-ordering or folder dropping circle.
395 void CalculateNearestTileForDragView();
396
397 // Calculates |nearest_tile| in which |vertex| of the |drag_view| is
398 // enclosed.
399 // *|nearest_tile| and *|d_min| will be updated based on the calculation.
400 // *|d_min| is the distance between |nearest_tile| and |drag_view_|.
401 void CalculateNearestTileForVertex(
402 const gfx::Point& vertex, Index* nearest_tile, int* d_min);
403
404 // Returns the bounds of the tile in which |point| is enclosed if there
405 // is a valid item sits on the tile.
406 gfx::Rect GetTileBoundsForPoint(const gfx::Point& point, Index* tile_index);
407
408 // Returns the size of the entire tile grid. 402 // Returns the size of the entire tile grid.
409 gfx::Size GetTileGridSize() const; 403 gfx::Size GetTileGridSize() const;
410 404
411 // Gets the expected bounds of a tile located at |row| and |col| on the 405 // Returns the slot number which the given |point| falls into.
tapted 2014/09/11 08:08:55 nit: This comment suggests to me that if |point| i
calamity 2014/09/15 03:26:11 Returns an Index, changed description.
412 // current page. 406 int GetNearestTileSlotForPoint(const gfx::Point& point);
tapted 2014/09/11 08:08:55 nit: declare const?
calamity 2014/09/15 03:26:11 Done.
407
408 // Gets the bounds of the tile located at |slot| on current page.
409 gfx::Rect GetExpectedTileBounds(int slot) const;
tapted 2014/09/11 08:08:55 maybe take an AppsGridView::Index ? looks like it'
calamity 2014/09/15 03:26:11 I think slot is better since using an Index kind o
410
411 // Gets the bounds of the tile located at |row| and |col| on current page.
tapted 2014/09/11 08:08:55 nit: on -> on the
calamity 2014/09/15 03:26:11 Done.
413 gfx::Rect GetExpectedTileBounds(int row, int col) const; 412 gfx::Rect GetExpectedTileBounds(int row, int col) const;
414 413
415 // Returns true if the slot of |index| is the last possible slot to drop
416 // an item, i.e. first empty slot next to the last item on the last page.
417 bool IsLastPossibleDropTarget(const Index& index) const;
418
419 // Gets the item view located at |slot| on the current page. If there is 414 // Gets the item view located at |slot| on the current page. If there is
420 // no item located at |slot|, returns NULL. 415 // no item located at |slot|, returns NULL.
421 views::View* GetViewAtSlotOnCurrentPage(int slot); 416 views::View* GetViewAtSlotOnCurrentPage(int slot);
422 417
423 // Sets state of the view with |target_index| to |is_target_folder| for 418 // Sets state of the view with |target_index| to |is_target_folder| for
424 // dropping |drag_view_|. 419 // dropping |drag_view_|.
425 void SetAsFolderDroppingTarget(const Index& target_index, 420 void SetAsFolderDroppingTarget(const Index& target_index,
426 bool is_target_folder); 421 bool is_target_folder);
427 422
428 // Invoked when |reorder_timer_| fires to show re-order preview UI. 423 // Invoked when |reorder_timer_| fires to show re-order preview UI.
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 #if defined(OS_WIN) 501 #if defined(OS_WIN)
507 // Created when a drag is started (ie: drag exceeds the drag threshold), but 502 // Created when a drag is started (ie: drag exceeds the drag threshold), but
508 // not Run() until supplied with a shortcut path. 503 // not Run() until supplied with a shortcut path.
509 scoped_refptr<SynchronousDrag> synchronous_drag_; 504 scoped_refptr<SynchronousDrag> synchronous_drag_;
510 505
511 // Whether to use SynchronousDrag to support dropping to task bar etc. 506 // Whether to use SynchronousDrag to support dropping to task bar etc.
512 bool use_synchronous_drag_; 507 bool use_synchronous_drag_;
513 #endif 508 #endif
514 509
515 Pointer drag_pointer_; 510 Pointer drag_pointer_;
511
512 // The index where a folder drop is being attempted.
513 Index folder_drop_target_;
514
515 // The index where a reorder is being attempted.
516 Index reorder_drop_target_; 516 Index reorder_drop_target_;
517 Index folder_drop_target_; 517
518 // The index where a reorder's blank placeholder is located.
519 Index reorder_placeholder_;
tapted 2014/09/11 08:08:55 Can you say more about this in the comment - I'm n
calamity 2014/09/15 03:26:11 Done.
520
521 // The type of drop being attempted.
518 DropAttempt drop_attempt_; 522 DropAttempt drop_attempt_;
519 523
520 // Timer for re-ordering the |drop_target_| and |drag_view_|. 524 // Timer for re-ordering the |drop_target_| and |drag_view_|.
521 base::OneShotTimer<AppsGridView> reorder_timer_; 525 base::OneShotTimer<AppsGridView> reorder_timer_;
522 526
523 // Timer for dropping |drag_view_| into the folder containing 527 // Timer for dropping |drag_view_| into the folder containing
524 // the |drop_target_|. 528 // the |drop_target_|.
525 base::OneShotTimer<AppsGridView> folder_dropping_timer_; 529 base::OneShotTimer<AppsGridView> folder_dropping_timer_;
526 530
527 // Timer for dragging a folder item out of folder container ink bubble. 531 // Timer for dragging a folder item out of folder container ink bubble.
(...skipping 30 matching lines...) Expand all
558 562
559 // True if the drag_view_ item is a folder item being dragged for reparenting. 563 // True if the drag_view_ item is a folder item being dragged for reparenting.
560 bool dragging_for_reparent_item_; 564 bool dragging_for_reparent_item_;
561 565
562 DISALLOW_COPY_AND_ASSIGN(AppsGridView); 566 DISALLOW_COPY_AND_ASSIGN(AppsGridView);
563 }; 567 };
564 568
565 } // namespace app_list 569 } // namespace app_list
566 570
567 #endif // UI_APP_LIST_VIEWS_APPS_GRID_VIEW_H_ 571 #endif // UI_APP_LIST_VIEWS_APPS_GRID_VIEW_H_
OLDNEW
« no previous file with comments | « no previous file | ui/app_list/views/apps_grid_view.cc » ('j') | ui/app_list/views/apps_grid_view.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698