Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / ui / app_list / views / apps_container_view.h
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.
4
5 #ifndef UI_APP_LIST_VIEWS_APPS_CONTAINER_VIEW_H_
6 #define UI_APP_LIST_VIEWS_APPS_CONTAINER_VIEW_H_
7
8 #include <vector>
9
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"
13
14 namespace content {
15 class WebContents;
16 }
17
18 namespace app_list {
19
20 class AppsGridView;
21 class ApplicationDragAndDropHost;
22 class AppListFolderItem;
23 class AppListFolderView;
24 class AppListMainView;
25 class AppListModel;
26 class ContentsView;
27 class FolderBackgroundView;
28 class PaginationModel;
29
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 {
35  public:
36   AppsContainerView(AppListMainView* app_list_main_view,
37                     PaginationModel* pagination_model,
38                     AppListModel* model);
39   virtual ~AppsContainerView();
40
41   // Shows the active folder content specified by |folder_item|.
42   void ShowActiveFolder(AppListFolderItem* folder_item);
43
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);
47
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();
53
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);
58
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);
62
63   // Returns true if it is currently showing an active folder page.
64   bool IsInFolderView() const;
65
66   // views::View overrides:
67   virtual gfx::Size GetPreferredSize() OVERRIDE;
68   virtual void Layout() OVERRIDE;
69   virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE;
70
71   // TopIconAnimationObserver overrides:
72   virtual void OnTopIconAnimationsComplete() OVERRIDE;
73
74   AppsGridView* apps_grid_view() { return apps_grid_view_; }
75   FolderBackgroundView* folder_background_view() {
76      return folder_background_view_;
77   }
78   AppListFolderView* app_list_folder_view() { return app_list_folder_view_; }
79
80  private:
81   enum ShowState {
82     SHOW_NONE,  // initial state
83     SHOW_APPS,
84     SHOW_ACTIVE_FOLDER,
85     SHOW_ITEM_REPARENT,
86   };
87
88   void SetShowState(ShowState show_state, bool show_apps_with_animation);
89
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();
95
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);
100
101   void PrepareToShowApps(AppListFolderItem* folder_item);
102
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_;
108
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_;
112
113   size_t top_icon_animation_pending_count_;
114
115   DISALLOW_COPY_AND_ASSIGN(AppsContainerView);
116 };
117
118 }  // namespace app_list
119
120
121 #endif  // UI_APP_LIST_VIEWS_APPS_CONTAINER_VIEW_H_