OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_APP_LIST_FOLDER_VIEW_H_ | 5 #ifndef UI_APP_LIST_VIEWS_APP_LIST_FOLDER_VIEW_H_ |
6 #define UI_APP_LIST_VIEWS_APP_LIST_FOLDER_VIEW_H_ | 6 #define UI_APP_LIST_VIEWS_APP_LIST_FOLDER_VIEW_H_ |
7 | 7 |
8 #include "ui/app_list/app_list_item_list_observer.h" | 8 #include "ui/app_list/app_list_item_list_observer.h" |
| 9 #include "ui/app_list/views/apps_grid_view.h" |
9 #include "ui/app_list/views/folder_header_view.h" | 10 #include "ui/app_list/views/folder_header_view.h" |
10 #include "ui/app_list/views/folder_header_view_delegate.h" | 11 #include "ui/app_list/views/folder_header_view_delegate.h" |
11 #include "ui/compositor/layer_animation_observer.h" | 12 #include "ui/compositor/layer_animation_observer.h" |
12 #include "ui/views/controls/button/button.h" | 13 #include "ui/views/controls/button/button.h" |
13 #include "ui/views/view.h" | 14 #include "ui/views/view.h" |
14 | 15 |
15 namespace content { | 16 namespace content { |
16 class WebContents; | 17 class WebContents; |
17 } | 18 } |
18 | 19 |
19 namespace views { | 20 namespace views { |
20 class ViewModel; | 21 class ViewModel; |
21 } | 22 } |
22 | 23 |
23 namespace app_list { | 24 namespace app_list { |
24 | 25 |
25 class AppsContainerView; | 26 class AppsContainerView; |
26 class AppsGridView; | 27 class AppsGridView; |
27 class AppListFolderItem; | 28 class AppListFolderItem; |
| 29 class AppListItemView; |
28 class AppListMainView; | 30 class AppListMainView; |
29 class AppListModel; | 31 class AppListModel; |
30 class FolderHeaderView; | 32 class FolderHeaderView; |
31 class PaginationModel; | 33 class PaginationModel; |
32 | 34 |
33 class AppListFolderView : public views::View, | 35 class AppListFolderView : public views::View, |
34 public FolderHeaderViewDelegate, | 36 public FolderHeaderViewDelegate, |
35 public AppListItemListObserver, | 37 public AppListItemListObserver, |
36 public ui::ImplicitAnimationObserver { | 38 public ui::ImplicitAnimationObserver { |
37 public: | 39 public: |
38 AppListFolderView(AppsContainerView* container_view, | 40 AppListFolderView(AppsContainerView* container_view, |
39 AppListModel* model, | 41 AppListModel* model, |
40 AppListMainView* app_list_main_view, | 42 AppListMainView* app_list_main_view, |
41 content::WebContents* start_page_contents); | 43 content::WebContents* start_page_contents); |
42 virtual ~AppListFolderView(); | 44 virtual ~AppListFolderView(); |
43 | 45 |
44 void SetAppListFolderItem(AppListFolderItem* folder); | 46 void SetAppListFolderItem(AppListFolderItem* folder); |
45 | 47 |
46 // Schedules an animation to show or hide the view. | 48 // Schedules an animation to show or hide the view. |
47 void ScheduleShowHideAnimation(bool show); | 49 // If |show| is false, the view should be set to invisible after the |
| 50 // animation is done unless |hide_for_reparent| is true. |
| 51 void ScheduleShowHideAnimation(bool show, bool hide_for_reparent); |
48 | 52 |
49 // Gets icon image bounds of the item at |index|, relative to | 53 // Gets icon image bounds of the item at |index|, relative to |
50 // AppListFolderView. | 54 // AppListFolderView. |
51 gfx::Rect GetItemIconBoundsAt(int index); | 55 gfx::Rect GetItemIconBoundsAt(int index); |
52 | 56 |
| 57 // Updates the folder view background to show or hide folder container ink |
| 58 // bubble. |
| 59 void UpdateFolderViewBackground(bool show_bubble); |
| 60 |
| 61 void UpdateFolderNameVisibility(bool visible); |
| 62 |
| 63 // Returns true if |point| falls outside of the folder container ink bubble. |
| 64 bool IsPointOutsideOfFolderBoundray(const gfx::Point& point); |
| 65 |
| 66 // Called when a folder item is dragged out of the folder to be re-parented. |
| 67 // |original_drag_view| is the |drag_view_| inside the folder's grid view. |
| 68 // |drag_point_in_folder_grid| is the last drag point in coordinate of the |
| 69 // AppsGridView inside the folder. |
| 70 void ReparentItem(AppListItemView* original_drag_view, |
| 71 const gfx::Point& drag_point_in_folder_grid); |
| 72 |
| 73 // Dispatches drag event from the hidden grid view to the root level grid view |
| 74 // for re-parenting a folder item. |
| 75 void DispatchDragEventForReparent(AppsGridView::Pointer pointer, |
| 76 const ui::LocatedEvent& event); |
| 77 |
| 78 // Dispatches EndDrag event from the hidden grid view to the root level grid |
| 79 // view for reparenting a folder item. |
| 80 // |events_forwarded_to_drag_drop_host|: True if the dragged item is dropped |
| 81 // to the drag_drop_host, eg. dropped on shelf. |
| 82 void DispatchEndDragEventForReparent(bool events_forwarded_to_drag_drop_host); |
| 83 |
53 // views::View overrides: | 84 // views::View overrides: |
54 virtual gfx::Size GetPreferredSize() OVERRIDE; | 85 virtual gfx::Size GetPreferredSize() OVERRIDE; |
55 virtual void Layout() OVERRIDE; | 86 virtual void Layout() OVERRIDE; |
56 virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE; | 87 virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE; |
57 | 88 |
58 // Overridden from AppListItemListObserver: | 89 // Overridden from AppListItemListObserver: |
59 virtual void OnListItemRemoved(size_t index, AppListItem* item) OVERRIDE; | 90 virtual void OnListItemRemoved(size_t index, AppListItem* item) OVERRIDE; |
60 | 91 |
61 // ui::ImplicitAnimationObserver overrides: | 92 // ui::ImplicitAnimationObserver overrides: |
62 virtual void OnImplicitAnimationsCompleted() OVERRIDE; | 93 virtual void OnImplicitAnimationsCompleted() OVERRIDE; |
63 | 94 |
| 95 AppsGridView* items_grid_view() { return items_grid_view_; } |
| 96 bool hide_for_reparent() const { return hide_for_reparent_; } |
| 97 |
64 private: | 98 private: |
65 void CalculateIdealBounds(); | 99 void CalculateIdealBounds(); |
66 | 100 |
| 101 // Starts setting up drag in root level apps grid view for re-parenting a |
| 102 // folder item. |
| 103 // |drag_point_in_root_grid| is in the cooridnates of root level AppsGridView. |
| 104 void StartSetupDragInRootLevelAppsGridView( |
| 105 AppListItemView* original_drag_view, |
| 106 const gfx::Point& drag_point_in_root_grid); |
| 107 |
67 // Overridden from FolderHeaderViewDelegate: | 108 // Overridden from FolderHeaderViewDelegate: |
68 virtual void NavigateBack(AppListFolderItem* item, | 109 virtual void NavigateBack(AppListFolderItem* item, |
69 const ui::Event& event_flags) OVERRIDE; | 110 const ui::Event& event_flags) OVERRIDE; |
70 | 111 |
71 AppsContainerView* container_view_; // Not owned. | 112 AppsContainerView* container_view_; // Not owned. |
72 FolderHeaderView* folder_header_view_; // Owned by views hierarchy. | 113 FolderHeaderView* folder_header_view_; // Owned by views hierarchy. |
73 AppsGridView* items_grid_view_; // Owned by the views hierarchy. | 114 AppsGridView* items_grid_view_; // Owned by the views hierarchy. |
74 | 115 |
75 scoped_ptr<views::ViewModel> view_model_; | 116 scoped_ptr<views::ViewModel> view_model_; |
76 | 117 |
77 AppListModel* model_; // Not owned. | 118 AppListModel* model_; // Not owned. |
78 AppListFolderItem* folder_item_; // Not owned. | 119 AppListFolderItem* folder_item_; // Not owned. |
79 | 120 |
80 scoped_ptr<PaginationModel> pagination_model_; | 121 scoped_ptr<PaginationModel> pagination_model_; |
81 | 122 |
| 123 bool hide_for_reparent_; |
| 124 |
82 DISALLOW_COPY_AND_ASSIGN(AppListFolderView); | 125 DISALLOW_COPY_AND_ASSIGN(AppListFolderView); |
83 }; | 126 }; |
84 | 127 |
85 } // namespace app_list | 128 } // namespace app_list |
86 | 129 |
87 #endif // UI_APP_LIST_VIEWS_APP_LIST_FOLDER_VIEW_H_ | 130 #endif // UI_APP_LIST_VIEWS_APP_LIST_FOLDER_VIEW_H_ |
OLD | NEW |