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_
8 #include "ui/app_list/app_list_folder_item.h"
9 #include "ui/views/view.h"
18 class AppListFolderItem
;
19 class AppListFolderView
;
20 class AppListMainView
;
23 class PaginationModel
;
25 class TopIconAnimationObserver
{
27 // Called when top icon animation completes.
28 virtual void OnTopIconAnimationsComplete(views::View
* icon_view
) {}
31 TopIconAnimationObserver() {}
32 virtual ~TopIconAnimationObserver() {}
35 DISALLOW_COPY_AND_ASSIGN(TopIconAnimationObserver
);
38 // AppsContainerView contains a root level AppsGridView to render the root level
39 // 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.
41 class AppsContainerView
: public views::View
,
42 public TopIconAnimationObserver
{
44 AppsContainerView(AppListMainView
* app_list_main_view
,
45 PaginationModel
* pagination_model
,
47 content::WebContents
* start_page_contents
);
48 virtual ~AppsContainerView();
50 // Shows the active folder content specified by |folder_item|.
51 void ShowActiveFolder(AppListFolderItem
* folder_item
);
53 // 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.
55 void ShowApps(AppListFolderItem
* folder_item
);
57 // Overridden from views::View:
58 virtual gfx::Size
GetPreferredSize() OVERRIDE
;
59 virtual void Layout() OVERRIDE
;
60 virtual bool OnKeyPressed(const ui::KeyEvent
& event
) OVERRIDE
;
62 // Overridden from TopIconAnimationObserver.
63 virtual void OnTopIconAnimationsComplete(views::View
* icon_view
) OVERRIDE
;
65 AppsGridView
* apps_grid_view() { return apps_grid_view_
; }
73 void SetShowState(ShowState show_state
);
75 // Calculates the top item icon bounds in the active folder icon. The bounds
76 // is relative to AppsContainerView.
77 // Returns the bounds of top items' icon in sequence of top left, top right,
78 // bottom left, bottom right.
79 Rects
GetTopItemIconBoundsInActiveFolder();
81 // Creates the transitional views for animating the top items in the folder
82 // when opening or closing a folder.
83 void CreateViewsForFolderTopItemsAnimation(
84 AppListFolderItem
* active_folder
, bool open_folder
);
87 AppsGridView
* apps_grid_view_
; // Owned by views hierarchy.
88 AppListFolderView
* app_list_folder_view_
; // Owned by views hierarchy.
89 ShowState show_state_
;
91 // The transitional views for animating the top items in folder
92 // when opening or closing a folder.
93 std::vector
<views::View
*> top_icon_views_
;
95 DISALLOW_COPY_AND_ASSIGN(AppsContainerView
);
98 } // namespace app_list
101 #endif // UI_APP_LIST_VIEWS_APPS_CONTAINER_VIEW_H_