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 #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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
44 namespace test { | 44 namespace test { |
45 class AppsGridViewTestApi; | 45 class AppsGridViewTestApi; |
46 } | 46 } |
47 | 47 |
48 class ApplicationDragAndDropHost; | 48 class ApplicationDragAndDropHost; |
49 class AppListItemView; | 49 class AppListItemView; |
50 class AppsGridViewDelegate; | 50 class AppsGridViewDelegate; |
51 class AppsGridViewFolderDelegate; | 51 class AppsGridViewFolderDelegate; |
52 class PageSwitcher; | 52 class PageSwitcher; |
53 class PaginationController; | 53 class PaginationController; |
54 class PulsingBlockView; | |
54 | 55 |
55 // AppsGridView displays a grid for AppListItemList sub model. | 56 // AppsGridView displays a grid for AppListItemList sub model. |
56 class APP_LIST_EXPORT AppsGridView : public views::View, | 57 class APP_LIST_EXPORT AppsGridView : public views::View, |
57 public views::ButtonListener, | 58 public views::ButtonListener, |
58 public AppListItemListObserver, | 59 public AppListItemListObserver, |
59 public PaginationModelObserver, | 60 public PaginationModelObserver, |
60 public AppListModelObserver, | 61 public AppListModelObserver, |
61 public ui::ImplicitAnimationObserver { | 62 public ui::ImplicitAnimationObserver { |
62 public: | 63 public: |
63 enum Pointer { | 64 enum Pointer { |
(...skipping 17 matching lines...) Expand all Loading... | |
81 // This resets the grid view to a fresh state for showing the app list. | 82 // This resets the grid view to a fresh state for showing the app list. |
82 void ResetForShowApps(); | 83 void ResetForShowApps(); |
83 | 84 |
84 // Sets |model| to use. Note this does not take ownership of |model|. | 85 // Sets |model| to use. Note this does not take ownership of |model|. |
85 void SetModel(AppListModel* model); | 86 void SetModel(AppListModel* model); |
86 | 87 |
87 // Sets the |item_list| to render. Note this does not take ownership of | 88 // Sets the |item_list| to render. Note this does not take ownership of |
88 // |item_list|. | 89 // |item_list|. |
89 void SetItemList(AppListItemList* item_list); | 90 void SetItemList(AppListItemList* item_list); |
90 | 91 |
91 void SetSelectedView(views::View* view); | 92 void SetSelectedView(AppListItemView* view); |
92 void ClearSelectedView(views::View* view); | 93 void ClearSelectedView(AppListItemView* view); |
93 void ClearAnySelectedView(); | 94 void ClearAnySelectedView(); |
94 bool IsSelectedView(const views::View* view) const; | 95 bool IsSelectedView(const AppListItemView* view) const; |
95 | 96 |
96 // Ensures the view is visible. Note that if there is a running page | 97 // Ensures the view is visible. Note that if there is a running page |
97 // transition, this does nothing. | 98 // transition, this does nothing. |
98 void EnsureViewVisible(const views::View* view); | 99 void EnsureViewVisible(const AppListItemView* view); |
99 | 100 |
100 void InitiateDrag(AppListItemView* view, | 101 void InitiateDrag(AppListItemView* view, |
101 Pointer pointer, | 102 Pointer pointer, |
102 const ui::LocatedEvent& event); | 103 const ui::LocatedEvent& event); |
103 | 104 |
104 // Called from AppListItemView when it receives a drag event. Returns true | 105 // Called from AppListItemView when it receives a drag event. Returns true |
105 // if the drag is still happening. | 106 // if the drag is still happening. |
106 bool UpdateDragFromItem(Pointer pointer, const ui::LocatedEvent& event); | 107 bool UpdateDragFromItem(Pointer pointer, const ui::LocatedEvent& event); |
107 | 108 |
108 // Called when the user is dragging an app. |point| is in grid view | 109 // Called when the user is dragging an app. |point| is in grid view |
109 // coordinates. | 110 // coordinates. |
110 void UpdateDrag(Pointer pointer, const gfx::Point& point); | 111 void UpdateDrag(Pointer pointer, const gfx::Point& point); |
111 void EndDrag(bool cancel); | 112 void EndDrag(bool cancel); |
112 bool IsDraggedView(const views::View* view) const; | 113 bool IsDraggedView(const AppListItemView* view) const; |
113 void ClearDragState(); | 114 void ClearDragState(); |
114 void SetDragViewVisible(bool visible); | 115 void SetDragViewVisible(bool visible); |
115 | 116 |
116 // Set the drag and drop host for application links. | 117 // Set the drag and drop host for application links. |
117 void SetDragAndDropHostOfCurrentAppList( | 118 void SetDragAndDropHostOfCurrentAppList( |
118 ApplicationDragAndDropHost* drag_and_drop_host); | 119 ApplicationDragAndDropHost* drag_and_drop_host); |
119 | 120 |
120 // Prerenders the icons on and around the currently selected page. | 121 // Prerenders the icons on and around the currently selected page. |
121 void Prerender(); | 122 void Prerender(); |
122 | 123 |
123 // Return true if the |bounds_animator_| is animating |view|. | 124 // Return true if the |bounds_animator_| is animating |view|. |
124 bool IsAnimatingView(views::View* view); | 125 bool IsAnimatingView(AppListItemView* view); |
125 | 126 |
126 bool has_dragged_view() const { return drag_view_ != NULL; } | 127 bool has_dragged_view() const { return drag_view_ != NULL; } |
127 bool dragging() const { return drag_pointer_ != NONE; } | 128 bool dragging() const { return drag_pointer_ != NONE; } |
128 | 129 |
129 // Gets the PaginationModel used for the grid view. | 130 // Gets the PaginationModel used for the grid view. |
130 PaginationModel* pagination_model() { return &pagination_model_; } | 131 PaginationModel* pagination_model() { return &pagination_model_; } |
131 | 132 |
132 // Overridden from views::View: | 133 // Overridden from views::View: |
133 virtual gfx::Size GetPreferredSize() const OVERRIDE; | 134 virtual gfx::Size GetPreferredSize() const OVERRIDE; |
134 virtual void Layout() OVERRIDE; | 135 virtual void Layout() OVERRIDE; |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
251 // Updates from model. | 252 // Updates from model. |
252 void Update(); | 253 void Update(); |
253 | 254 |
254 // Updates page splits for item views. | 255 // Updates page splits for item views. |
255 void UpdatePaging(); | 256 void UpdatePaging(); |
256 | 257 |
257 // Updates the number of pulsing block views based on AppListModel status and | 258 // Updates the number of pulsing block views based on AppListModel status and |
258 // number of apps. | 259 // number of apps. |
259 void UpdatePulsingBlockViews(); | 260 void UpdatePulsingBlockViews(); |
260 | 261 |
261 views::View* CreateViewForItemAtIndex(size_t index); | 262 // Returns the pulsing block view of the item at |index| in the pulsing block |
263 // model. | |
264 PulsingBlockView* GetPulsingBlockViewAt(int index) const; | |
265 | |
266 AppListItemView* CreateViewForItemAtIndex(size_t index); | |
262 | 267 |
263 // Convert between the model index and the visual index. The model index | 268 // Convert between the model index and the visual index. The model index |
264 // is the index of the item in AppListModel. The visual index is the Index | 269 // is the index of the item in AppListModel. The visual index is the Index |
265 // struct above with page/slot info of where to display the item. | 270 // struct above with page/slot info of where to display the item. |
266 Index GetIndexFromModelIndex(int model_index) const; | 271 Index GetIndexFromModelIndex(int model_index) const; |
267 int GetModelIndexFromIndex(const Index& index) const; | 272 int GetModelIndexFromIndex(const Index& index) const; |
268 | 273 |
269 void SetSelectedItemByIndex(const Index& index); | 274 void SetSelectedItemByIndex(const Index& index); |
270 bool IsValidIndex(const Index& index) const; | 275 bool IsValidIndex(const Index& index) const; |
271 | 276 |
272 Index GetIndexOfView(const views::View* view) const; | 277 Index GetIndexOfView(const AppListItemView* view) const; |
273 views::View* GetViewAtIndex(const Index& index) const; | 278 AppListItemView* GetViewAtIndex(const Index& index) const; |
274 | 279 |
275 // Gets the index of the AppListItemView at the end of the view model. | 280 // Gets the index of the AppListItemView at the end of the view model. |
276 Index GetLastViewIndex() const; | 281 Index GetLastViewIndex() const; |
277 | 282 |
278 void MoveSelected(int page_delta, int slot_x_delta, int slot_y_delta); | 283 void MoveSelected(int page_delta, int slot_x_delta, int slot_y_delta); |
279 | 284 |
280 void CalculateIdealBounds(); | 285 void CalculateIdealBounds(); |
281 void AnimateToIdealBounds(); | 286 void AnimateToIdealBounds(); |
282 | 287 |
283 // Invoked when the given |view|'s current bounds and target bounds are on | 288 // Invoked when the given |view|'s current bounds and target bounds are on |
284 // different rows. To avoid moving diagonally, |view| would be put into a | 289 // different rows. To avoid moving diagonally, |view| would be put into a |
285 // slot prior |target| and fade in while moving to |target|. In the meanwhile, | 290 // slot prior |target| and fade in while moving to |target|. In the meanwhile, |
286 // a layer copy of |view| would start at |current| and fade out while moving | 291 // a layer copy of |view| would start at |current| and fade out while moving |
287 // to succeeding slot of |current|. |animate_current| controls whether to run | 292 // to succeeding slot of |current|. |animate_current| controls whether to run |
288 // fading out animation from |current|. |animate_target| controls whether to | 293 // fading out animation from |current|. |animate_target| controls whether to |
289 // run fading in animation to |target|. | 294 // run fading in animation to |target|. |
290 void AnimationBetweenRows(views::View* view, | 295 void AnimationBetweenRows(AppListItemView* view, |
291 bool animate_current, | 296 bool animate_current, |
292 const gfx::Rect& current, | 297 const gfx::Rect& current, |
293 bool animate_target, | 298 bool animate_target, |
294 const gfx::Rect& target); | 299 const gfx::Rect& target); |
295 | 300 |
296 // Extracts drag location info from |event| into |drag_point|. | 301 // Extracts drag location info from |event| into |drag_point|. |
297 void ExtractDragLocation(const ui::LocatedEvent& event, | 302 void ExtractDragLocation(const ui::LocatedEvent& event, |
298 gfx::Point* drag_point); | 303 gfx::Point* drag_point); |
299 | 304 |
300 // Updates |reorder_drop_target_|, |folder_drop_target_| and |drop_attempt_| | 305 // Updates |reorder_drop_target_|, |folder_drop_target_| and |drop_attempt_| |
(...skipping 19 matching lines...) Expand all Loading... | |
320 const gfx::Point& location_in_screen_coordinates); | 325 const gfx::Point& location_in_screen_coordinates); |
321 | 326 |
322 // Starts the page flip timer if |drag_point| is in left/right side page flip | 327 // Starts the page flip timer if |drag_point| is in left/right side page flip |
323 // zone or is over page switcher. | 328 // zone or is over page switcher. |
324 void MaybeStartPageFlipTimer(const gfx::Point& drag_point); | 329 void MaybeStartPageFlipTimer(const gfx::Point& drag_point); |
325 | 330 |
326 // Invoked when |page_flip_timer_| fires. | 331 // Invoked when |page_flip_timer_| fires. |
327 void OnPageFlipTimer(); | 332 void OnPageFlipTimer(); |
328 | 333 |
329 // Updates |model_| to move item represented by |item_view| to |target| slot. | 334 // Updates |model_| to move item represented by |item_view| to |target| slot. |
330 void MoveItemInModel(views::View* item_view, const Index& target); | 335 void MoveItemInModel(AppListItemView* item_view, const Index& target); |
331 | 336 |
332 // Updates |model_| to move item represented by |item_view| into a folder | 337 // Updates |model_| to move item represented by |item_view| into a folder |
333 // containing item located at |target| slot, also update |view_model_| for | 338 // containing item located at |target| slot, also update |view_model_| for |
334 // the related view changes. | 339 // the related view changes. |
335 void MoveItemToFolder(views::View* item_view, const Index& target); | 340 void MoveItemToFolder(AppListItemView* item_view, const Index& target); |
336 | 341 |
337 // Updates both data model and view_model_ for re-parenting a folder item to a | 342 // Updates both data model and view_model_ for re-parenting a folder item to a |
338 // new position in top level item list. | 343 // new position in top level item list. |
339 void ReparentItemForReorder(views::View* item_view, const Index& target); | 344 void ReparentItemForReorder(AppListItemView* item_view, const Index& target); |
340 | 345 |
341 // Updates both data model and view_model_ for re-parenting a folder item | 346 // Updates both data model and view_model_ for re-parenting a folder item |
342 // to anther folder target. | 347 // to anther folder target. |
343 void ReparentItemToAnotherFolder(views::View* item_view, const Index& target); | 348 void ReparentItemToAnotherFolder(AppListItemView* item_view, |
349 const Index& target); | |
344 | 350 |
345 // If there is only 1 item left in the source folder after reparenting an item | 351 // If there is only 1 item left in the source folder after reparenting an item |
346 // from it, updates both data model and view_model_ for removing last item | 352 // from it, updates both data model and view_model_ for removing last item |
347 // from the source folder and removes the source folder. | 353 // from the source folder and removes the source folder. |
348 void RemoveLastItemFromReparentItemFolderIfNecessary( | 354 void RemoveLastItemFromReparentItemFolderIfNecessary( |
349 const std::string& source_folder_id); | 355 const std::string& source_folder_id); |
350 | 356 |
351 // If user does not drop the re-parenting folder item to any valid target, | 357 // If user does not drop the re-parenting folder item to any valid target, |
352 // cancel the re-parenting action, let the item go back to its original | 358 // cancel the re-parenting action, let the item go back to its original |
353 // parent folder with UI animation. | 359 // parent folder with UI animation. |
(...skipping 29 matching lines...) Expand all Loading... | |
383 // Overridden from AppListModelObserver: | 389 // Overridden from AppListModelObserver: |
384 virtual void OnAppListModelStatusChanged() OVERRIDE; | 390 virtual void OnAppListModelStatusChanged() OVERRIDE; |
385 | 391 |
386 // ui::ImplicitAnimationObserver overrides: | 392 // ui::ImplicitAnimationObserver overrides: |
387 virtual void OnImplicitAnimationsCompleted() OVERRIDE; | 393 virtual void OnImplicitAnimationsCompleted() OVERRIDE; |
388 | 394 |
389 // Hide a given view temporarily without losing (mouse) events and / or | 395 // Hide a given view temporarily without losing (mouse) events and / or |
390 // changing the size of it. If |immediate| is set the change will be | 396 // changing the size of it. If |immediate| is set the change will be |
391 // immediately applied - otherwise it will change gradually. | 397 // immediately applied - otherwise it will change gradually. |
392 // If |hide| is set the view will get hidden, otherwise it gets shown. | 398 // If |hide| is set the view will get hidden, otherwise it gets shown. |
393 void SetViewHidden(views::View* view, bool hide, bool immediate); | 399 void SetViewHidden(AppListItemView* view, bool hide, bool immediate); |
394 | 400 |
395 // Whether the folder drag-and-drop UI should be enabled. | 401 // Whether the folder drag-and-drop UI should be enabled. |
396 bool EnableFolderDragDropUI(); | 402 bool EnableFolderDragDropUI(); |
397 | 403 |
398 // Whether target specified by |drap_target| can accept more items to be | 404 // Whether target specified by |drap_target| can accept more items to be |
399 // dropped into it. | 405 // dropped into it. |
400 bool CanDropIntoTarget(const Index& drop_target) const; | 406 bool CanDropIntoTarget(const Index& drop_target) const; |
401 | 407 |
402 // Returns the size of the entire tile grid. | 408 // Returns the size of the entire tile grid. |
403 gfx::Size GetTileGridSize() const; | 409 gfx::Size GetTileGridSize() const; |
404 | 410 |
405 // Returns the slot number which the given |point| falls into or the closest | 411 // Returns the slot number which the given |point| falls into or the closest |
406 // slot if |point| is outside the page's bounds. | 412 // slot if |point| is outside the page's bounds. |
407 Index GetNearestTileIndexForPoint(const gfx::Point& point) const; | 413 Index GetNearestTileIndexForPoint(const gfx::Point& point) const; |
408 | 414 |
409 // Gets the bounds of the tile located at |slot| on the current page. | 415 // Gets the bounds of the tile located at |slot| on the current page. |
410 gfx::Rect GetExpectedTileBounds(int slot) const; | 416 gfx::Rect GetExpectedTileBounds(int slot) const; |
411 | 417 |
412 // Gets the bounds of the tile located at |row| and |col| on the current page. | 418 // Gets the bounds of the tile located at |row| and |col| on the current page. |
413 gfx::Rect GetExpectedTileBounds(int row, int col) const; | 419 gfx::Rect GetExpectedTileBounds(int row, int col) const; |
414 | 420 |
415 // Gets the item view located at |slot| on the current page. If there is | 421 // Gets the item view currently displayed at |slot| on the current page. If |
416 // no item located at |slot|, returns NULL. | 422 // there is no item displayed at |slot|, returns NULL. Note that this finds an |
417 views::View* GetViewAtSlotOnCurrentPage(int slot); | 423 // item *displayed* at a slot, which may differ from the item's location in |
424 // the model (as it may have been temporarily moved during a drag operation). | |
calamity
2014/09/30 01:22:23
Noice.
Matt Giuca
2014/09/30 01:32:06
Acknowledged.
| |
425 AppListItemView* GetViewDisplayedAtSlotOnCurrentPage(int slot); | |
418 | 426 |
419 // Sets state of the view with |target_index| to |is_target_folder| for | 427 // Sets state of the view with |target_index| to |is_target_folder| for |
420 // dropping |drag_view_|. | 428 // dropping |drag_view_|. |
421 void SetAsFolderDroppingTarget(const Index& target_index, | 429 void SetAsFolderDroppingTarget(const Index& target_index, |
422 bool is_target_folder); | 430 bool is_target_folder); |
423 | 431 |
424 // Invoked when |reorder_timer_| fires to show re-order preview UI. | 432 // Invoked when |reorder_timer_| fires to show re-order preview UI. |
425 void OnReorderTimer(); | 433 void OnReorderTimer(); |
426 | 434 |
427 // Invoked when |folder_item_reparent_timer_| fires. | 435 // Invoked when |folder_item_reparent_timer_| fires. |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
467 AppsGridViewFolderDelegate* folder_delegate_; | 475 AppsGridViewFolderDelegate* folder_delegate_; |
468 | 476 |
469 PaginationModel pagination_model_; | 477 PaginationModel pagination_model_; |
470 // Must appear after |pagination_model_|. | 478 // Must appear after |pagination_model_|. |
471 scoped_ptr<PaginationController> pagination_controller_; | 479 scoped_ptr<PaginationController> pagination_controller_; |
472 PageSwitcher* page_switcher_view_; // Owned by views hierarchy. | 480 PageSwitcher* page_switcher_view_; // Owned by views hierarchy. |
473 | 481 |
474 int cols_; | 482 int cols_; |
475 int rows_per_page_; | 483 int rows_per_page_; |
476 | 484 |
477 // Tracks app item views. There is a view per item in |model_|. | 485 // List of AppListItemViews. There is a view per item in |model_|. |
478 views::ViewModel view_model_; | 486 views::ViewModel view_model_; |
479 | 487 |
480 // Tracks pulsing block views. | 488 // List of PulsingBlockViews. |
481 views::ViewModel pulsing_blocks_model_; | 489 views::ViewModel pulsing_blocks_model_; |
482 | 490 |
483 views::View* selected_view_; | 491 AppListItemView* selected_view_; |
484 | 492 |
485 AppListItemView* drag_view_; | 493 AppListItemView* drag_view_; |
486 | 494 |
487 // The index of the drag_view_ when the drag starts. | 495 // The index of the drag_view_ when the drag starts. |
488 Index drag_view_init_index_; | 496 Index drag_view_init_index_; |
489 | 497 |
490 // The point where the drag started in AppListItemView coordinates. | 498 // The point where the drag started in AppListItemView coordinates. |
491 gfx::Point drag_view_offset_; | 499 gfx::Point drag_view_offset_; |
492 | 500 |
493 // The point where the drag started in GridView coordinates. | 501 // The point where the drag started in GridView coordinates. |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
564 | 572 |
565 // True if the drag_view_ item is a folder item being dragged for reparenting. | 573 // True if the drag_view_ item is a folder item being dragged for reparenting. |
566 bool dragging_for_reparent_item_; | 574 bool dragging_for_reparent_item_; |
567 | 575 |
568 DISALLOW_COPY_AND_ASSIGN(AppsGridView); | 576 DISALLOW_COPY_AND_ASSIGN(AppsGridView); |
569 }; | 577 }; |
570 | 578 |
571 } // namespace app_list | 579 } // namespace app_list |
572 | 580 |
573 #endif // UI_APP_LIST_VIEWS_APPS_GRID_VIEW_H_ | 581 #endif // UI_APP_LIST_VIEWS_APPS_GRID_VIEW_H_ |
OLD | NEW |