Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / ui / app_list / views / apps_container_view.h
blob3278385fdbda56a2d40d2a683bd569bbc4e733c7
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/top_icon_animation_view.h"
12 #include "ui/views/view.h"
14 namespace app_list {
16 class AppsGridView;
17 class ApplicationDragAndDropHost;
18 class AppListFolderItem;
19 class AppListFolderView;
20 class AppListMainView;
21 class AppListModel;
22 class ContentsView;
23 class FolderBackgroundView;
25 // AppsContainerView contains a root level AppsGridView to render the root level
26 // app items, and a AppListFolderView to render the app items inside the
27 // active folder. Only one if them is visible to user at any time.
28 class AppsContainerView : public views::View,
29 public TopIconAnimationObserver {
30 public:
31 AppsContainerView(AppListMainView* app_list_main_view,
32 AppListModel* model);
33 virtual ~AppsContainerView();
35 // Shows the active folder content specified by |folder_item|.
36 void ShowActiveFolder(AppListFolderItem* folder_item);
38 // Shows the root level apps list. This is called when UI navigate back from
39 // a folder view with |folder_item|. If |folder_item| is NULL skips animation.
40 void ShowApps(AppListFolderItem* folder_item);
42 // Resets the app list to a state where it shows the main grid view. This is
43 // called when the user opens the launcher for the first time or when the user
44 // hides and then shows it. This is necessary because we only hide and show
45 // the launcher on Windows and Linux so we need to reset to a fresh state.
46 void ResetForShowApps();
48 // Sets |drag_and_drop_host_| for the current app list in both
49 // app_list_folder_view_ and root level apps_grid_view_.
50 void SetDragAndDropHostOfCurrentAppList(
51 ApplicationDragAndDropHost* drag_and_drop_host);
53 // Transits the UI from folder view to root lelve apps grid view when
54 // re-parenting a child item of |folder_item|.
55 void ReparentFolderItemTransit(AppListFolderItem* folder_item);
57 // Returns true if it is currently showing an active folder page.
58 bool IsInFolderView() const;
60 // views::View overrides:
61 virtual gfx::Size GetPreferredSize() const OVERRIDE;
62 virtual void Layout() OVERRIDE;
63 virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE;
65 // TopIconAnimationObserver overrides:
66 virtual void OnTopIconAnimationsComplete() OVERRIDE;
68 AppsGridView* apps_grid_view() { return apps_grid_view_; }
69 FolderBackgroundView* folder_background_view() {
70 return folder_background_view_;
72 AppListFolderView* app_list_folder_view() { return app_list_folder_view_; }
74 private:
75 enum ShowState {
76 SHOW_NONE, // initial state
77 SHOW_APPS,
78 SHOW_ACTIVE_FOLDER,
79 SHOW_ITEM_REPARENT,
82 void SetShowState(ShowState show_state, bool show_apps_with_animation);
84 // Calculates the top item icon bounds in the active folder icon. The bounds
85 // is relative to AppsContainerView.
86 // Returns the bounds of top items' icon in sequence of top left, top right,
87 // bottom left, bottom right.
88 Rects GetTopItemIconBoundsInActiveFolder();
90 // Creates the transitional views for animating the top items in the folder
91 // when opening or closing a folder.
92 void CreateViewsForFolderTopItemsAnimation(
93 AppListFolderItem* active_folder, bool open_folder);
95 void PrepareToShowApps(AppListFolderItem* folder_item);
97 AppListModel* model_;
98 AppsGridView* apps_grid_view_; // Owned by views hierarchy.
99 AppListFolderView* app_list_folder_view_; // Owned by views hierarchy.
100 FolderBackgroundView* folder_background_view_; // Owned by views hierarchy.
101 ShowState show_state_;
103 // The transitional views for animating the top items in folder
104 // when opening or closing a folder.
105 std::vector<views::View*> top_icon_views_;
107 size_t top_icon_animation_pending_count_;
109 DISALLOW_COPY_AND_ASSIGN(AppsContainerView);
112 } // namespace app_list
115 #endif // UI_APP_LIST_VIEWS_APPS_CONTAINER_VIEW_H_