Roll src/third_party/skia 591a2ca:b3fe1b8
[chromium-blink-merge.git] / ui / app_list / views / apps_container_view.h
blobf7e03d91108a1e27eb88b3957980b9d5b4a5648e
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 <vector>
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"
14 namespace gfx {
15 class Rect;
18 namespace app_list {
20 class AppsGridView;
21 class ApplicationDragAndDropHost;
22 class AppListFolderItem;
23 class AppListFolderView;
24 class AppListMainView;
25 class AppListModel;
26 class ContentsView;
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 {
33 public:
34 AppsContainerView(AppListMainView* app_list_main_view,
35 AppListModel* model);
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 // Called to notify the AppsContainerView that a reparent drag has completed.
64 void ReparentDragEnded();
66 // views::View overrides:
67 gfx::Size GetPreferredSize() const override;
68 void Layout() override;
69 bool OnKeyPressed(const ui::KeyEvent& event) override;
71 // AppListPage overrides:
72 void OnWillBeShown() override;
73 gfx::Rect GetPageBoundsForState(AppListModel::State state) const override;
75 // TopIconAnimationObserver overrides:
76 void OnTopIconAnimationsComplete() override;
78 AppsGridView* apps_grid_view() { return apps_grid_view_; }
79 FolderBackgroundView* folder_background_view() {
80 return folder_background_view_;
82 AppListFolderView* app_list_folder_view() { return app_list_folder_view_; }
84 private:
85 enum ShowState {
86 SHOW_NONE, // initial state
87 SHOW_APPS,
88 SHOW_ACTIVE_FOLDER,
89 SHOW_ITEM_REPARENT,
92 void SetShowState(ShowState show_state, bool show_apps_with_animation);
94 // Calculates the top item icon bounds in the active folder icon. The bounds
95 // is relative to AppsContainerView.
96 // Returns the bounds of top items' icon in sequence of top left, top right,
97 // bottom left, bottom right.
98 std::vector<gfx::Rect> GetTopItemIconBoundsInActiveFolder();
100 // Creates the transitional views for animating the top items in the folder
101 // when opening or closing a folder.
102 void CreateViewsForFolderTopItemsAnimation(
103 AppListFolderItem* active_folder, bool open_folder);
105 void PrepareToShowApps(AppListFolderItem* folder_item);
107 AppListModel* model_;
108 AppsGridView* apps_grid_view_; // Owned by views hierarchy.
109 AppListFolderView* app_list_folder_view_; // Owned by views hierarchy.
110 FolderBackgroundView* folder_background_view_; // Owned by views hierarchy.
111 ShowState show_state_;
113 // The transitional views for animating the top items in folder
114 // when opening or closing a folder.
115 std::vector<views::View*> top_icon_views_;
117 size_t top_icon_animation_pending_count_;
119 DISALLOW_COPY_AND_ASSIGN(AppsContainerView);
122 } // namespace app_list
125 #endif // UI_APP_LIST_VIEWS_APPS_CONTAINER_VIEW_H_