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
3 // found in the LICENSE file.
5 #ifndef UI_APP_LIST_VIEWS_APPS_CONTAINER_VIEW_H_
6 #define UI_APP_LIST_VIEWS_APPS_CONTAINER_VIEW_H_
10 #include "ui/app_list/app_list_folder_item.h"
11 #include "ui/app_list/views/app_list_page.h"
12 #include "ui/app_list/views/top_icon_animation_view.h"
21 class ApplicationDragAndDropHost
;
22 class AppListFolderItem
;
23 class AppListFolderView
;
24 class AppListMainView
;
27 class FolderBackgroundView
;
29 // AppsContainerView contains a root level AppsGridView to render the root level
30 // app items, and a AppListFolderView to render the app items inside the
31 // active folder. Only one if them is visible to user at any time.
32 class AppsContainerView
: public AppListPage
, public TopIconAnimationObserver
{
34 AppsContainerView(AppListMainView
* app_list_main_view
,
36 ~AppsContainerView() override
;
38 // Shows the active folder content specified by |folder_item|.
39 void ShowActiveFolder(AppListFolderItem
* folder_item
);
41 // Shows the root level apps list. This is called when UI navigate back from
42 // a folder view with |folder_item|. If |folder_item| is NULL skips animation.
43 void ShowApps(AppListFolderItem
* folder_item
);
45 // Resets the app list to a state where it shows the main grid view. This is
46 // called when the user opens the launcher for the first time or when the user
47 // hides and then shows it. This is necessary because we only hide and show
48 // the launcher on Windows and Linux so we need to reset to a fresh state.
49 void ResetForShowApps();
51 // Sets |drag_and_drop_host_| for the current app list in both
52 // app_list_folder_view_ and root level apps_grid_view_.
53 void SetDragAndDropHostOfCurrentAppList(
54 ApplicationDragAndDropHost
* drag_and_drop_host
);
56 // Transits the UI from folder view to root lelve apps grid view when
57 // re-parenting a child item of |folder_item|.
58 void ReparentFolderItemTransit(AppListFolderItem
* folder_item
);
60 // Returns true if it is currently showing an active folder page.
61 bool IsInFolderView() const;
63 // views::View overrides:
64 gfx::Size
GetPreferredSize() const override
;
65 void Layout() override
;
66 bool OnKeyPressed(const ui::KeyEvent
& event
) override
;
68 // AppListPage overrides:
69 void OnWillBeShown() override
;
70 gfx::Rect
GetPageBoundsForState(AppListModel::State state
) const override
;
72 // TopIconAnimationObserver overrides:
73 void OnTopIconAnimationsComplete() override
;
75 AppsGridView
* apps_grid_view() { return apps_grid_view_
; }
76 FolderBackgroundView
* folder_background_view() {
77 return folder_background_view_
;
79 AppListFolderView
* app_list_folder_view() { return app_list_folder_view_
; }
83 SHOW_NONE
, // initial state
89 void SetShowState(ShowState show_state
, bool show_apps_with_animation
);
91 // Calculates the top item icon bounds in the active folder icon. The bounds
92 // is relative to AppsContainerView.
93 // Returns the bounds of top items' icon in sequence of top left, top right,
94 // bottom left, bottom right.
95 std::vector
<gfx::Rect
> GetTopItemIconBoundsInActiveFolder();
97 // Creates the transitional views for animating the top items in the folder
98 // when opening or closing a folder.
99 void CreateViewsForFolderTopItemsAnimation(
100 AppListFolderItem
* active_folder
, bool open_folder
);
102 void PrepareToShowApps(AppListFolderItem
* folder_item
);
104 AppListModel
* model_
;
105 AppsGridView
* apps_grid_view_
; // Owned by views hierarchy.
106 AppListFolderView
* app_list_folder_view_
; // Owned by views hierarchy.
107 FolderBackgroundView
* folder_background_view_
; // Owned by views hierarchy.
108 ShowState show_state_
;
110 // The transitional views for animating the top items in folder
111 // when opening or closing a folder.
112 std::vector
<views::View
*> top_icon_views_
;
114 size_t top_icon_animation_pending_count_
;
116 DISALLOW_COPY_AND_ASSIGN(AppsContainerView
);
119 } // namespace app_list
122 #endif // UI_APP_LIST_VIEWS_APPS_CONTAINER_VIEW_H_