Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / ui / app_list / views / app_list_folder_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_APP_LIST_FOLDER_VIEW_H_
6 #define UI_APP_LIST_VIEWS_APP_LIST_FOLDER_VIEW_H_
7
8 #include <string>
9
10 #include "ui/app_list/app_list_item_list_observer.h"
11 #include "ui/app_list/views/apps_grid_view.h"
12 #include "ui/app_list/views/apps_grid_view_folder_delegate.h"
13 #include "ui/app_list/views/folder_header_view.h"
14 #include "ui/app_list/views/folder_header_view_delegate.h"
15 #include "ui/compositor/layer_animation_observer.h"
16 #include "ui/views/controls/button/button.h"
17 #include "ui/views/view.h"
18
19 namespace views {
20 class ViewModel;
21 }
22
23 namespace app_list {
24
25 class AppsContainerView;
26 class AppsGridView;
27 class AppListFolderItem;
28 class AppListItemView;
29 class AppListMainView;
30 class AppListModel;
31 class FolderHeaderView;
32 class PaginationModel;
33
34 class AppListFolderView : public views::View,
35                           public FolderHeaderViewDelegate,
36                           public AppListModelObserver,
37                           public ui::ImplicitAnimationObserver,
38                           public AppsGridViewFolderDelegate {
39  public:
40   AppListFolderView(AppsContainerView* container_view,
41                     AppListModel* model,
42                     AppListMainView* app_list_main_view);
43   virtual ~AppListFolderView();
44
45   void SetAppListFolderItem(AppListFolderItem* folder);
46
47   // Schedules an animation to show or hide the view.
48   // If |show| is false, the view should be set to invisible after the
49   // animation is done unless |hide_for_reparent| is true.
50   void ScheduleShowHideAnimation(bool show, bool hide_for_reparent);
51
52   // Gets icon image bounds of the item at |index|, relative to
53   // AppListFolderView.
54   gfx::Rect GetItemIconBoundsAt(int index);
55
56   void UpdateFolderNameVisibility(bool visible);
57
58   // Hides the view immediately without animation.
59   void HideViewImmediately();
60
61   // Closes the folder page and goes back the top level page.
62   void CloseFolderPage();
63
64   // views::View
65   virtual gfx::Size GetPreferredSize() OVERRIDE;
66   virtual void Layout() OVERRIDE;
67   virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE;
68
69   // AppListModelObserver
70   virtual void OnAppListItemWillBeDeleted(AppListItem* item) OVERRIDE;
71
72   // ui::ImplicitAnimationObserver
73   virtual void OnImplicitAnimationsCompleted() OVERRIDE;
74
75   AppsGridView* items_grid_view() { return items_grid_view_; }
76
77  private:
78   void CalculateIdealBounds();
79
80   // Starts setting up drag in root level apps grid view for re-parenting a
81   // folder item.
82   // |drag_point_in_root_grid| is in the cooridnates of root level AppsGridView.
83   void StartSetupDragInRootLevelAppsGridView(
84       AppListItemView* original_drag_view,
85       const gfx::Point& drag_point_in_root_grid);
86
87   // Overridden from views::View:
88   virtual void GetAccessibleState(ui::AXViewState* state) OVERRIDE;
89
90   // Overridden from FolderHeaderViewDelegate:
91   virtual void NavigateBack(AppListFolderItem* item,
92                             const ui::Event& event_flags) OVERRIDE;
93   virtual void GiveBackFocusToSearchBox() OVERRIDE;
94   virtual void SetItemName(AppListFolderItem* item,
95                            const std::string& name) OVERRIDE;
96
97   // Overridden from AppsGridViewFolderDelegate:
98   virtual void UpdateFolderViewBackground(bool show_bubble) OVERRIDE;
99   virtual void ReparentItem(AppListItemView* original_drag_view,
100                             const gfx::Point& drag_point_in_folder_grid)
101       OVERRIDE;
102   virtual void DispatchDragEventForReparent(
103       AppsGridView::Pointer pointer,
104       const gfx::Point& drag_point_in_folder_grid) OVERRIDE;
105   virtual void DispatchEndDragEventForReparent(
106       bool events_forwarded_to_drag_drop_host,
107       bool cancel_drag) OVERRIDE;
108   virtual bool IsPointOutsideOfFolderBoundary(const gfx::Point& point) OVERRIDE;
109   virtual bool IsOEMFolder() const OVERRIDE;
110   virtual void SetRootLevelDragViewVisible(bool visible) OVERRIDE;
111
112   AppsContainerView* container_view_;  // Not owned.
113   AppListMainView* app_list_main_view_;   // Not Owned.
114   FolderHeaderView* folder_header_view_;  // Owned by views hierarchy.
115   AppsGridView* items_grid_view_;  // Owned by the views hierarchy.
116
117   scoped_ptr<views::ViewModel> view_model_;
118
119   AppListModel* model_;  // Not owned.
120   AppListFolderItem* folder_item_;  // Not owned.
121
122   scoped_ptr<PaginationModel> pagination_model_;
123
124   bool hide_for_reparent_;
125
126   base::string16 accessible_name_;
127
128   DISALLOW_COPY_AND_ASSIGN(AppListFolderView);
129 };
130
131 }  // namespace app_list
132
133 #endif  // UI_APP_LIST_VIEWS_APP_LIST_FOLDER_VIEW_H_