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/top_icon_animation_view.h"
12 #include "ui/views/view.h"
21 class ApplicationDragAndDropHost
;
22 class AppListFolderItem
;
23 class AppListFolderView
;
24 class AppListMainView
;
27 class FolderBackgroundView
;
28 class PaginationModel
;
30 // AppsContainerView contains a root level AppsGridView to render the root level
31 // app items, and a AppListFolderView to render the app items inside the
32 // active folder. Only one if them is visible to user at any time.
33 class AppsContainerView
: public views::View
,
34 public TopIconAnimationObserver
{
36 AppsContainerView(AppListMainView
* app_list_main_view
,
37 PaginationModel
* pagination_model
,
39 virtual ~AppsContainerView();
41 // Shows the active folder content specified by |folder_item|.
42 void ShowActiveFolder(AppListFolderItem
* folder_item
);
44 // Shows the root level apps list. This is called when UI navigate back from
45 // a folder view with |folder_item|. If |folder_item| is NULL skips animation.
46 void ShowApps(AppListFolderItem
* folder_item
);
48 // Resets the app list to a state where it shows the main grid view. This is
49 // called when the user opens the launcher for the first time or when the user
50 // hides and then shows it. This is necessary because we only hide and show
51 // the launcher on Windows and Linux so we need to reset to a fresh state.
52 void ResetForShowApps();
54 // Sets |drag_and_drop_host_| for the current app list in both
55 // app_list_folder_view_ and root level apps_grid_view_.
56 void SetDragAndDropHostOfCurrentAppList(
57 ApplicationDragAndDropHost
* drag_and_drop_host
);
59 // Transits the UI from folder view to root lelve apps grid view when
60 // re-parenting a child item of |folder_item|.
61 void ReparentFolderItemTransit(AppListFolderItem
* folder_item
);
63 // Returns true if it is currently showing an active folder page.
64 bool IsInFolderView() const;
66 // views::View overrides:
67 virtual gfx::Size
GetPreferredSize() const OVERRIDE
;
68 virtual void Layout() OVERRIDE
;
69 virtual bool OnKeyPressed(const ui::KeyEvent
& event
) OVERRIDE
;
71 // TopIconAnimationObserver overrides:
72 virtual void OnTopIconAnimationsComplete() OVERRIDE
;
74 AppsGridView
* apps_grid_view() { return apps_grid_view_
; }
75 FolderBackgroundView
* folder_background_view() {
76 return folder_background_view_
;
78 AppListFolderView
* app_list_folder_view() { return app_list_folder_view_
; }
82 SHOW_NONE
, // initial state
88 void SetShowState(ShowState show_state
, bool show_apps_with_animation
);
90 // Calculates the top item icon bounds in the active folder icon. The bounds
91 // is relative to AppsContainerView.
92 // Returns the bounds of top items' icon in sequence of top left, top right,
93 // bottom left, bottom right.
94 Rects
GetTopItemIconBoundsInActiveFolder();
96 // Creates the transitional views for animating the top items in the folder
97 // when opening or closing a folder.
98 void CreateViewsForFolderTopItemsAnimation(
99 AppListFolderItem
* active_folder
, bool open_folder
);
101 void PrepareToShowApps(AppListFolderItem
* folder_item
);
103 AppListModel
* model_
;
104 AppsGridView
* apps_grid_view_
; // Owned by views hierarchy.
105 AppListFolderView
* app_list_folder_view_
; // Owned by views hierarchy.
106 FolderBackgroundView
* folder_background_view_
; // Owned by views hierarchy.
107 ShowState show_state_
;
109 // The transitional views for animating the top items in folder
110 // when opening or closing a folder.
111 std::vector
<views::View
*> top_icon_views_
;
113 size_t top_icon_animation_pending_count_
;
115 DISALLOW_COPY_AND_ASSIGN(AppsContainerView
);
118 } // namespace app_list
121 #endif // UI_APP_LIST_VIEWS_APPS_CONTAINER_VIEW_H_