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/app_list/views/top_icon_animation_view.h"
10 #include "ui/views/view.h"
19 class ApplicationDragAndDropHost;
20 class AppListFolderItem;
21 class AppListFolderView;
22 class AppListMainView;
25 class FolderBackgroundView;
26 class PaginationModel;
28 // AppsContainerView contains a root level AppsGridView to render the root level
29 // app items, and a AppListFolderView to render the app items inside the
30 // active folder. Only one if them is visible to user at any time.
31 class AppsContainerView : public views::View,
32 public TopIconAnimationObserver {
34 AppsContainerView(AppListMainView* app_list_main_view,
35 PaginationModel* pagination_model,
37 content::WebContents* start_page_contents);
38 virtual ~AppsContainerView();
40 // Shows the active folder content specified by |folder_item|.
41 void ShowActiveFolder(AppListFolderItem* folder_item);
43 // Shows the root level apps list. This is called when UI navigate back from
44 // a folder view with |folder_item|. If |folder_item| is NULL skips animation.
45 void ShowApps(AppListFolderItem* folder_item);
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);
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);
56 // views::View overrides:
57 virtual gfx::Size GetPreferredSize() OVERRIDE;
58 virtual void Layout() OVERRIDE;
59 virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE;
61 // TopIconAnimationObserver overrides:
62 virtual void OnTopIconAnimationsComplete() OVERRIDE;
64 AppsGridView* apps_grid_view() { return apps_grid_view_; }
65 FolderBackgroundView* folder_background_view() {
66 return folder_background_view_;
68 AppListFolderView* app_list_folder_view() { return app_list_folder_view_; }
77 void SetShowState(ShowState show_state, bool show_apps_with_animation);
79 // Calculates the top item icon bounds in the active folder icon. The bounds
80 // is relative to AppsContainerView.
81 // Returns the bounds of top items' icon in sequence of top left, top right,
82 // bottom left, bottom right.
83 Rects GetTopItemIconBoundsInActiveFolder();
85 // Creates the transitional views for animating the top items in the folder
86 // when opening or closing a folder.
87 void CreateViewsForFolderTopItemsAnimation(
88 AppListFolderItem* active_folder, bool open_folder);
90 void PrepareToShowApps(AppListFolderItem* folder_item);
93 AppsGridView* apps_grid_view_; // Owned by views hierarchy.
94 AppListFolderView* app_list_folder_view_; // Owned by views hierarchy.
95 FolderBackgroundView* folder_background_view_; // Owned by views hierarchy.
96 ShowState show_state_;
98 // The transitional views for animating the top items in folder
99 // when opening or closing a folder.
100 std::vector<views::View*> top_icon_views_;
102 size_t top_icon_animation_pending_count_;
104 DISALLOW_COPY_AND_ASSIGN(AppsContainerView);
107 } // namespace app_list
110 #endif // UI_APP_LIST_VIEWS_APPS_CONTAINER_VIEW_H_