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_APP_LIST_FOLDER_VIEW_H_
6 #define UI_APP_LIST_VIEWS_APP_LIST_FOLDER_VIEW_H_
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"
25 class AppsContainerView
;
27 class AppListFolderItem
;
28 class AppListItemView
;
29 class AppListMainView
;
31 class FolderHeaderView
;
32 class PaginationModel
;
34 class AppListFolderView
: public views::View
,
35 public FolderHeaderViewDelegate
,
36 public AppListModelObserver
,
37 public ui::ImplicitAnimationObserver
,
38 public AppsGridViewFolderDelegate
{
40 AppListFolderView(AppsContainerView
* container_view
,
42 AppListMainView
* app_list_main_view
);
43 virtual ~AppListFolderView();
45 void SetAppListFolderItem(AppListFolderItem
* folder
);
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
);
52 // Gets icon image bounds of the item at |index|, relative to
54 gfx::Rect
GetItemIconBoundsAt(int index
);
56 void UpdateFolderNameVisibility(bool visible
);
58 // Hides the view immediately without animation.
59 void HideViewImmediately();
61 // Closes the folder page and goes back the top level page.
62 void CloseFolderPage();
65 virtual gfx::Size
GetPreferredSize() const OVERRIDE
;
66 virtual void Layout() OVERRIDE
;
67 virtual bool OnKeyPressed(const ui::KeyEvent
& event
) OVERRIDE
;
69 // AppListModelObserver
70 virtual void OnAppListItemWillBeDeleted(AppListItem
* item
) OVERRIDE
;
72 // ui::ImplicitAnimationObserver
73 virtual void OnImplicitAnimationsCompleted() OVERRIDE
;
75 AppsGridView
* items_grid_view() { return items_grid_view_
; }
78 void CalculateIdealBounds();
80 // Starts setting up drag in root level apps grid view for re-parenting a
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
);
87 // Overridden from views::View:
88 virtual void GetAccessibleState(ui::AXViewState
* state
) OVERRIDE
;
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
;
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
)
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
;
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.
117 scoped_ptr
<views::ViewModel
> view_model_
;
119 AppListModel
* model_
; // Not owned.
120 AppListFolderItem
* folder_item_
; // Not owned.
122 scoped_ptr
<PaginationModel
> pagination_model_
;
124 bool hide_for_reparent_
;
126 base::string16 accessible_name_
;
128 DISALLOW_COPY_AND_ASSIGN(AppListFolderView
);
131 } // namespace app_list
133 #endif // UI_APP_LIST_VIEWS_APP_LIST_FOLDER_VIEW_H_