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_APPS_CONTAINER_VIEW_H_ | 5 #ifndef UI_APP_LIST_VIEWS_APPS_CONTAINER_VIEW_H_ |
6 #define UI_APP_LIST_VIEWS_APPS_CONTAINER_VIEW_H_ | 6 #define UI_APP_LIST_VIEWS_APPS_CONTAINER_VIEW_H_ |
7 | 7 |
8 #include "ui/app_list/app_list_folder_item.h" | 8 #include "ui/app_list/app_list_folder_item.h" |
| 9 #include "ui/app_list/views/top_icon_animation_view.h" |
9 #include "ui/views/view.h" | 10 #include "ui/views/view.h" |
10 | 11 |
11 namespace content { | 12 namespace content { |
12 class WebContents; | 13 class WebContents; |
13 } | 14 } |
14 | 15 |
15 namespace app_list { | 16 namespace app_list { |
16 | 17 |
17 class AppsGridView; | 18 class AppsGridView; |
| 19 class ApplicationDragAndDropHost; |
18 class AppListFolderItem; | 20 class AppListFolderItem; |
19 class AppListFolderView; | 21 class AppListFolderView; |
20 class AppListMainView; | 22 class AppListMainView; |
21 class AppListModel; | 23 class AppListModel; |
22 class ContentsView; | 24 class ContentsView; |
| 25 class FolderBackgroundView; |
23 class PaginationModel; | 26 class PaginationModel; |
24 | 27 |
25 class TopIconAnimationObserver { | |
26 public: | |
27 // Called when top icon animation completes. | |
28 virtual void OnTopIconAnimationsComplete(views::View* icon_view) {} | |
29 | |
30 protected: | |
31 TopIconAnimationObserver() {} | |
32 virtual ~TopIconAnimationObserver() {} | |
33 | |
34 private: | |
35 DISALLOW_COPY_AND_ASSIGN(TopIconAnimationObserver); | |
36 }; | |
37 | |
38 // AppsContainerView contains a root level AppsGridView to render the root level | 28 // AppsContainerView contains a root level AppsGridView to render the root level |
39 // app items, and a AppListFolderView to render the app items inside the | 29 // app items, and a AppListFolderView to render the app items inside the |
40 // active folder. Only one if them is visible to user at any time. | 30 // active folder. Only one if them is visible to user at any time. |
41 class AppsContainerView : public views::View, | 31 class AppsContainerView : public views::View, |
42 public TopIconAnimationObserver { | 32 public TopIconAnimationObserver { |
43 public: | 33 public: |
44 AppsContainerView(AppListMainView* app_list_main_view, | 34 AppsContainerView(AppListMainView* app_list_main_view, |
45 PaginationModel* pagination_model, | 35 PaginationModel* pagination_model, |
46 AppListModel* model, | 36 AppListModel* model, |
47 content::WebContents* start_page_contents); | 37 content::WebContents* start_page_contents); |
48 virtual ~AppsContainerView(); | 38 virtual ~AppsContainerView(); |
49 | 39 |
50 // Shows the active folder content specified by |folder_item|. | 40 // Shows the active folder content specified by |folder_item|. |
51 void ShowActiveFolder(AppListFolderItem* folder_item); | 41 void ShowActiveFolder(AppListFolderItem* folder_item); |
52 | 42 |
53 // Shows the root level apps list. This is called when UI navigate back from | 43 // Shows the root level apps list. This is called when UI navigate back from |
54 // a folder view with |folder_item|. If |folder_item| is NULL skips animation. | 44 // a folder view with |folder_item|. If |folder_item| is NULL skips animation. |
55 void ShowApps(AppListFolderItem* folder_item); | 45 void ShowApps(AppListFolderItem* folder_item); |
56 | 46 |
57 // Overridden from views::View: | 47 // Sets |drag_and_drop_host_| for the current app list in both |
| 48 // app_list_folder_view_ and root level apps_grid_view_. |
| 49 void SetDragAndDropHostOfCurrentAppList( |
| 50 ApplicationDragAndDropHost* drag_and_drop_host); |
| 51 |
| 52 // Transits the UI from folder view to root lelve apps grid view when |
| 53 // re-parenting a child item of |folder_item|. |
| 54 void ReparentFolderItemTransit(AppListFolderItem* folder_item); |
| 55 |
| 56 // views::View overrides: |
58 virtual gfx::Size GetPreferredSize() OVERRIDE; | 57 virtual gfx::Size GetPreferredSize() OVERRIDE; |
59 virtual void Layout() OVERRIDE; | 58 virtual void Layout() OVERRIDE; |
60 virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE; | 59 virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE; |
61 | 60 |
62 // Overridden from TopIconAnimationObserver. | 61 // TopIconAnimationObserver overrides: |
63 virtual void OnTopIconAnimationsComplete(views::View* icon_view) OVERRIDE; | 62 virtual void OnTopIconAnimationsComplete() OVERRIDE; |
64 | 63 |
65 AppsGridView* apps_grid_view() { return apps_grid_view_; } | 64 AppsGridView* apps_grid_view() { return apps_grid_view_; } |
| 65 FolderBackgroundView* folder_background_view() { |
| 66 return folder_background_view_; |
| 67 } |
| 68 AppListFolderView* app_list_folder_view() { return app_list_folder_view_; } |
66 | 69 |
67 private: | 70 private: |
68 enum ShowState { | 71 enum ShowState { |
69 SHOW_APPS, | 72 SHOW_APPS, |
70 SHOW_ACTIVE_FOLDER, | 73 SHOW_ACTIVE_FOLDER, |
| 74 SHOW_ITEM_REPARENT, |
71 }; | 75 }; |
72 | 76 |
73 void SetShowState(ShowState show_state); | 77 void SetShowState(ShowState show_state); |
74 | 78 |
75 // Calculates the top item icon bounds in the active folder icon. The bounds | 79 // Calculates the top item icon bounds in the active folder icon. The bounds |
76 // is relative to AppsContainerView. | 80 // is relative to AppsContainerView. |
77 // Returns the bounds of top items' icon in sequence of top left, top right, | 81 // Returns the bounds of top items' icon in sequence of top left, top right, |
78 // bottom left, bottom right. | 82 // bottom left, bottom right. |
79 Rects GetTopItemIconBoundsInActiveFolder(); | 83 Rects GetTopItemIconBoundsInActiveFolder(); |
80 | 84 |
81 // Creates the transitional views for animating the top items in the folder | 85 // Creates the transitional views for animating the top items in the folder |
82 // when opening or closing a folder. | 86 // when opening or closing a folder. |
83 void CreateViewsForFolderTopItemsAnimation( | 87 void CreateViewsForFolderTopItemsAnimation( |
84 AppListFolderItem* active_folder, bool open_folder); | 88 AppListFolderItem* active_folder, bool open_folder); |
85 | 89 |
| 90 void PrepareToShowApps(AppListFolderItem* folder_item); |
| 91 |
86 AppListModel* model_; | 92 AppListModel* model_; |
87 AppsGridView* apps_grid_view_; // Owned by views hierarchy. | 93 AppsGridView* apps_grid_view_; // Owned by views hierarchy. |
88 AppListFolderView* app_list_folder_view_; // Owned by views hierarchy. | 94 AppListFolderView* app_list_folder_view_; // Owned by views hierarchy. |
| 95 FolderBackgroundView* folder_background_view_; // Owned by views hierarchy. |
89 ShowState show_state_; | 96 ShowState show_state_; |
90 | 97 |
91 // The transitional views for animating the top items in folder | 98 // The transitional views for animating the top items in folder |
92 // when opening or closing a folder. | 99 // when opening or closing a folder. |
93 std::vector<views::View*> top_icon_views_; | 100 std::vector<views::View*> top_icon_views_; |
94 | 101 |
| 102 size_t top_icon_animation_pending_count_; |
| 103 |
95 DISALLOW_COPY_AND_ASSIGN(AppsContainerView); | 104 DISALLOW_COPY_AND_ASSIGN(AppsContainerView); |
96 }; | 105 }; |
97 | 106 |
98 } // namespace app_list | 107 } // namespace app_list |
99 | 108 |
100 | 109 |
101 #endif // UI_APP_LIST_VIEWS_APPS_CONTAINER_VIEW_H_ | 110 #endif // UI_APP_LIST_VIEWS_APPS_CONTAINER_VIEW_H_ |
OLD | NEW |