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 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/timer/timer.h" | 12 #include "base/timer/timer.h" |
13 #include "ui/app_list/app_list_export.h" | 13 #include "ui/app_list/app_list_export.h" |
14 #include "ui/app_list/app_list_model.h" | 14 #include "ui/app_list/app_list_model.h" |
15 #include "ui/app_list/app_list_model_observer.h" | 15 #include "ui/app_list/app_list_model_observer.h" |
16 #include "ui/app_list/pagination_model_observer.h" | 16 #include "ui/app_list/pagination_model_observer.h" |
17 #include "ui/base/models/list_model_observer.h" | 17 #include "ui/base/models/list_model_observer.h" |
18 #include "ui/compositor/layer_animation_observer.h" | 18 #include "ui/compositor/layer_animation_observer.h" |
| 19 #include "ui/gfx/image/image_skia_operations.h" |
19 #include "ui/views/animation/bounds_animator.h" | 20 #include "ui/views/animation/bounds_animator.h" |
20 #include "ui/views/controls/button/button.h" | 21 #include "ui/views/controls/button/button.h" |
| 22 #include "ui/views/controls/image_view.h" |
21 #include "ui/views/view.h" | 23 #include "ui/views/view.h" |
22 #include "ui/views/view_model.h" | 24 #include "ui/views/view_model.h" |
23 | 25 |
24 #if defined(OS_WIN) | 26 #if defined(OS_WIN) |
25 #include "ui/base/dragdrop/drag_source_win.h" | 27 #include "ui/base/dragdrop/drag_source_win.h" |
26 #endif | 28 #endif |
27 | 29 |
28 namespace content { | 30 namespace content { |
29 class WebContents; | 31 class WebContents; |
30 } | 32 } |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 | 144 |
143 // Returns the item view of the item at |index|. | 145 // Returns the item view of the item at |index|. |
144 AppListItemView* GetItemViewAt(int index) const; | 146 AppListItemView* GetItemViewAt(int index) const; |
145 | 147 |
146 // Show or hide the top item views. | 148 // Show or hide the top item views. |
147 void SetTopItemViewsVisible(bool visible); | 149 void SetTopItemViewsVisible(bool visible); |
148 | 150 |
149 // Schedules an animation to show or hide the view. | 151 // Schedules an animation to show or hide the view. |
150 void ScheduleShowHideAnimation(bool show); | 152 void ScheduleShowHideAnimation(bool show); |
151 | 153 |
| 154 // Called to initiate drag for reparenting a folder item in root level grid |
| 155 // view. |
| 156 // Both |drag_view_rect| and |drag_pint| is in the coordinates of root level |
| 157 // grid view. |
| 158 void InitiateDragFromReparentItemInRootLevelGridView( |
| 159 AppListItemView* original_drag_view, |
| 160 const gfx::Rect& drag_view_rect, |
| 161 const gfx::Point& drag_point); |
| 162 |
| 163 // Updates drag in the root level grid view when receiving the drag event |
| 164 // dispatched from the hidden grid view for reparenting a folder item. |
| 165 void UpdateDragFromReparentItem(Pointer pointer, |
| 166 const ui::LocatedEvent& event); |
| 167 |
| 168 // Dispatches the drag event from hidden grid view to the top level grid view. |
| 169 void DispatchDragEventForReparent(Pointer pointer, |
| 170 const ui::LocatedEvent& event); |
| 171 |
| 172 // Handles EndDrag event dispatched from the hidden folder grid view in the |
| 173 // root level grid view to end reparenting a folder item. |
| 174 // |events_forwarded_to_drag_drop_host|: True if the dragged item is dropped |
| 175 // to the drag_drop_host, eg. dropped on shelf. |
| 176 void EndDragFromReparentItemInRootLevel( |
| 177 bool events_forwarded_to_drag_drop_host); |
| 178 |
| 179 // Handles EndDrag event in the hidden folder grid view to end reparenting |
| 180 // a folder item. |
| 181 void EndDragForReparentInHiddenFolderGridView(); |
| 182 |
| 183 // Called when the folder item associated with the grid view is removed. |
| 184 // The grid view must be inside a folder view. |
| 185 void OnFolderItemRemoved(); |
| 186 |
152 // Return the view model for test purposes. | 187 // Return the view model for test purposes. |
153 const views::ViewModel* view_model_for_test() const { return &view_model_; } | 188 const views::ViewModel* view_model_for_test() const { return &view_model_; } |
154 | 189 |
155 // For test: Return if the drag and drop handler was set. | 190 // For test: Return if the drag and drop handler was set. |
156 bool has_drag_and_drop_host_for_test() { return NULL != drag_and_drop_host_; } | 191 bool has_drag_and_drop_host_for_test() { return NULL != drag_and_drop_host_; } |
157 | 192 |
158 // For test: Return if the drag and drop operation gets dispatched. | 193 // For test: Return if the drag and drop operation gets dispatched. |
159 bool forward_events_to_drag_and_drop_host_for_test() { | 194 bool forward_events_to_drag_and_drop_host_for_test() { |
160 return forward_events_to_drag_and_drop_host_; | 195 return forward_events_to_drag_and_drop_host_; |
161 } | 196 } |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 void OnPageFlipTimer(); | 304 void OnPageFlipTimer(); |
270 | 305 |
271 // Updates |model_| to move item represented by |item_view| to |target| slot. | 306 // Updates |model_| to move item represented by |item_view| to |target| slot. |
272 void MoveItemInModel(views::View* item_view, const Index& target); | 307 void MoveItemInModel(views::View* item_view, const Index& target); |
273 | 308 |
274 // Updates |model_| to move item represented by |item_view| into a folder | 309 // Updates |model_| to move item represented by |item_view| into a folder |
275 // containing item located at |target| slot, also update |view_model_| for | 310 // containing item located at |target| slot, also update |view_model_| for |
276 // the related view changes. | 311 // the related view changes. |
277 void MoveItemToFolder(views::View* item_view, const Index& target); | 312 void MoveItemToFolder(views::View* item_view, const Index& target); |
278 | 313 |
| 314 // Updates both data model and view_model_ for re-parenting a folder item to a |
| 315 // new position in top level item list. |
| 316 void ReparentItemForReorder(views::View* item_view, const Index& target); |
| 317 |
| 318 // Updates both data model and view_model_ for re-parenting a folder item |
| 319 // to anther folder target. |
| 320 void ReparentItemToAnotherFolder(views::View* item_view, const Index& target); |
| 321 |
| 322 // Updates both data model and view_model_ for removing last item from |
| 323 // |source_folder| which is the parent folder of the re-parenting item. |
| 324 void RemoveLastItemFromReparentItemFolder(AppListFolderItem* source_folder); |
| 325 |
| 326 // If user does not drop the re-parenting folder item to any valid target, |
| 327 // cancel the re-parenting action, let the item go back to its original |
| 328 // parent folder with UI animation. |
| 329 void CancelFolderItemReparent(AppListItemView* drag_item_view); |
| 330 |
279 // Cancels any context menus showing for app items on the current page. | 331 // Cancels any context menus showing for app items on the current page. |
280 void CancelContextMenusOnCurrentPage(); | 332 void CancelContextMenusOnCurrentPage(); |
281 | 333 |
282 // Returnes true if |point| lies within the bounds of this grid view plus a | 334 // Returns true if |point| lies within the bounds of this grid view plus a |
283 // buffer area surrounding it. | 335 // buffer area surrounding it. |
284 bool IsPointWithinDragBuffer(const gfx::Point& point) const; | 336 bool IsPointWithinDragBuffer(const gfx::Point& point) const; |
285 | 337 |
286 // Handles start page layout and transition animation. | 338 // Handles start page layout and transition animation. |
287 void LayoutStartPage(); | 339 void LayoutStartPage(); |
288 | 340 |
289 // Overridden from views::ButtonListener: | 341 // Overridden from views::ButtonListener: |
290 virtual void ButtonPressed(views::Button* sender, | 342 virtual void ButtonPressed(views::Button* sender, |
291 const ui::Event& event) OVERRIDE; | 343 const ui::Event& event) OVERRIDE; |
292 | 344 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 views::View* GetViewAtSlotOnCurrentPage(int slot); | 397 views::View* GetViewAtSlotOnCurrentPage(int slot); |
346 | 398 |
347 // Sets state of the view with |target_index| to |is_target_folder| for | 399 // Sets state of the view with |target_index| to |is_target_folder| for |
348 // dropping |drag_view_|. | 400 // dropping |drag_view_|. |
349 void SetAsFolderDroppingTarget(const Index& target_index, | 401 void SetAsFolderDroppingTarget(const Index& target_index, |
350 bool is_target_folder); | 402 bool is_target_folder); |
351 | 403 |
352 // Invoked when |reorder_timer_| fires to show re-order preview UI. | 404 // Invoked when |reorder_timer_| fires to show re-order preview UI. |
353 void OnReorderTimer(); | 405 void OnReorderTimer(); |
354 | 406 |
| 407 // Invoked when |folder_item_reparent_timer_| fires. |
| 408 void OnFolderItemReparentTimer(); |
| 409 |
355 // Invoked when |folder_dropping_timer_| fires to show folder dropping | 410 // Invoked when |folder_dropping_timer_| fires to show folder dropping |
356 // preview UI. | 411 // preview UI. |
357 void OnFolderDroppingTimer(); | 412 void OnFolderDroppingTimer(); |
358 | 413 |
| 414 // Updates drag state for dragging inside a folder's grid view. |
| 415 void UpdateDragStateInsideFolder(Pointer pointer, |
| 416 const ui::LocatedEvent& event); |
| 417 |
| 418 // Returns true if drag event is happening in the root level AppsGridView |
| 419 // for reparenting a folder item. |
| 420 bool IsDraggingForReparentInRootLevelGridView() const; |
| 421 |
| 422 // Returns true if drag event is happening in the hidden AppsGridView of the |
| 423 // folder during reparenting a folder item. |
| 424 bool IsDraggingForReprentInHiddenGridView() const; |
| 425 |
| 426 // Returns the target icon bounds for |drag_item_view| to fly back |
| 427 // to its parent |folder_item_view| in animation. |
| 428 gfx::Rect GetTargetIconRectInFolder(AppListItemView* drag_item_view, |
| 429 AppListItemView* folder_item_view); |
| 430 |
359 AppListModel* model_; // Owned by AppListView. | 431 AppListModel* model_; // Owned by AppListView. |
360 AppListItemList* item_list_; // Not owned. | 432 AppListItemList* item_list_; // Not owned. |
361 AppsGridViewDelegate* delegate_; | 433 AppsGridViewDelegate* delegate_; |
362 PaginationModel* pagination_model_; // Owned by AppListController. | 434 PaginationModel* pagination_model_; // Owned by AppListController. |
363 PageSwitcher* page_switcher_view_; // Owned by views hierarchy. | 435 PageSwitcher* page_switcher_view_; // Owned by views hierarchy. |
364 views::WebView* start_page_view_; // Owned by views hierarchy. | 436 views::WebView* start_page_view_; // Owned by views hierarchy. |
365 | 437 |
366 gfx::Size icon_size_; | 438 gfx::Size icon_size_; |
367 int cols_; | 439 int cols_; |
368 int rows_per_page_; | 440 int rows_per_page_; |
(...skipping 30 matching lines...) Expand all Loading... |
399 Index drop_target_; | 471 Index drop_target_; |
400 DropAttempt drop_attempt_; | 472 DropAttempt drop_attempt_; |
401 | 473 |
402 // Timer for re-ordering the |drop_target_| and |drag_view_|. | 474 // Timer for re-ordering the |drop_target_| and |drag_view_|. |
403 base::OneShotTimer<AppsGridView> reorder_timer_; | 475 base::OneShotTimer<AppsGridView> reorder_timer_; |
404 | 476 |
405 // Timer for dropping |drag_view_| into the folder containing | 477 // Timer for dropping |drag_view_| into the folder containing |
406 // the |drop_target_|. | 478 // the |drop_target_|. |
407 base::OneShotTimer<AppsGridView> folder_dropping_timer_; | 479 base::OneShotTimer<AppsGridView> folder_dropping_timer_; |
408 | 480 |
| 481 // Timer for dragging a folder item out of folder container ink bubble. |
| 482 base::OneShotTimer<AppsGridView> folder_item_reparent_timer_; |
| 483 |
409 // An application target drag and drop host which accepts dnd operations. | 484 // An application target drag and drop host which accepts dnd operations. |
410 ApplicationDragAndDropHost* drag_and_drop_host_; | 485 ApplicationDragAndDropHost* drag_and_drop_host_; |
411 | 486 |
412 // The drag operation is currently inside the dnd host and events get | 487 // The drag operation is currently inside the dnd host and events get |
413 // forwarded. | 488 // forwarded. |
414 bool forward_events_to_drag_and_drop_host_; | 489 bool forward_events_to_drag_and_drop_host_; |
415 | 490 |
416 // Last mouse drag location in this view's coordinates. | 491 // Last mouse drag location in this view's coordinates. |
417 gfx::Point last_drag_point_; | 492 gfx::Point last_drag_point_; |
418 | 493 |
419 // Timer to auto flip page when dragging an item near the left/right edges. | 494 // Timer to auto flip page when dragging an item near the left/right edges. |
420 base::OneShotTimer<AppsGridView> page_flip_timer_; | 495 base::OneShotTimer<AppsGridView> page_flip_timer_; |
421 | 496 |
422 // Target page to switch to when |page_flip_timer_| fires. | 497 // Target page to switch to when |page_flip_timer_| fires. |
423 int page_flip_target_; | 498 int page_flip_target_; |
424 | 499 |
425 // Delay in milliseconds of when |page_flip_timer_| should fire after user | 500 // Delay in milliseconds of when |page_flip_timer_| should fire after user |
426 // drags an item near the edges. | 501 // drags an item near the edges. |
427 int page_flip_delay_in_ms_; | 502 int page_flip_delay_in_ms_; |
428 | 503 |
429 views::BoundsAnimator bounds_animator_; | 504 views::BoundsAnimator bounds_animator_; |
430 | 505 |
431 // If true, AppsGridView is rending items at the root level of the app list. | 506 // If true, AppsGridView is rending items at the root level of the app list. |
432 bool is_root_level_; | 507 bool is_root_level_; |
433 | 508 |
434 // The most recent activated item view. | 509 // The most recent activated item view. |
435 AppListItemView* activated_item_view_; | 510 AppListItemView* activated_item_view_; |
436 | 511 |
| 512 // Tracks if drag_view_ is dragged out of the folder container bubble |
| 513 // when dragging a item inside a folder. |
| 514 bool drag_out_of_folder_container_; |
| 515 |
| 516 // True if the drag_view_ item is a folder item being dragged for reparenting. |
| 517 bool dragging_for_reparent_item_; |
| 518 |
437 DISALLOW_COPY_AND_ASSIGN(AppsGridView); | 519 DISALLOW_COPY_AND_ASSIGN(AppsGridView); |
438 }; | 520 }; |
439 | 521 |
440 } // namespace app_list | 522 } // namespace app_list |
441 | 523 |
442 #endif // UI_APP_LIST_VIEWS_APPS_GRID_VIEW_H_ | 524 #endif // UI_APP_LIST_VIEWS_APPS_GRID_VIEW_H_ |
OLD | NEW |