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