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