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"
18 #include "ui/views/view_model.h"
22 class AppsContainerView
;
24 class AppListFolderItem
;
25 class AppListItemView
;
26 class AppListMainView
;
28 class FolderHeaderView
;
30 class AppListFolderView
: public views::View
,
31 public FolderHeaderViewDelegate
,
32 public AppListModelObserver
,
33 public ui::ImplicitAnimationObserver
,
34 public AppsGridViewFolderDelegate
{
36 AppListFolderView(AppsContainerView
* container_view
,
38 AppListMainView
* app_list_main_view
);
39 ~AppListFolderView() override
;
41 void SetAppListFolderItem(AppListFolderItem
* folder
);
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
);
48 // Gets icon image bounds of the item at |index|, relative to
50 gfx::Rect
GetItemIconBoundsAt(int index
);
52 void UpdateFolderNameVisibility(bool visible
);
53 void SetBackButtonLabel(bool folder
);
55 // Hides the view immediately without animation.
56 void HideViewImmediately();
58 // Closes the folder page and goes back the top level page.
59 void CloseFolderPage();
62 gfx::Size
GetPreferredSize() const override
;
63 void Layout() override
;
64 bool OnKeyPressed(const ui::KeyEvent
& event
) override
;
66 // AppListModelObserver
67 void OnAppListItemWillBeDeleted(AppListItem
* item
) override
;
69 // ui::ImplicitAnimationObserver
70 void OnImplicitAnimationsCompleted() override
;
72 AppsGridView
* items_grid_view() { return items_grid_view_
; }
75 void CalculateIdealBounds();
77 // Starts setting up drag in root level apps grid view for re-parenting a
79 // |drag_point_in_root_grid| is in the cooridnates of root level AppsGridView.
80 void StartSetupDragInRootLevelAppsGridView(
81 AppListItemView
* original_drag_view
,
82 const gfx::Point
& drag_point_in_root_grid
,
83 bool has_native_drag
);
85 // Overridden from views::View:
86 void GetAccessibleState(ui::AXViewState
* state
) override
;
88 // Overridden from FolderHeaderViewDelegate:
89 void NavigateBack(AppListFolderItem
* item
,
90 const ui::Event
& event_flags
) override
;
91 void GiveBackFocusToSearchBox() override
;
92 void SetItemName(AppListFolderItem
* item
, const std::string
& name
) override
;
94 // Overridden from AppsGridViewFolderDelegate:
95 void UpdateFolderViewBackground(bool show_bubble
) override
;
96 void ReparentItem(AppListItemView
* original_drag_view
,
97 const gfx::Point
& drag_point_in_folder_grid
,
98 bool has_native_drag
) override
;
99 void DispatchDragEventForReparent(
100 AppsGridView::Pointer pointer
,
101 const gfx::Point
& drag_point_in_folder_grid
) override
;
102 void DispatchEndDragEventForReparent(bool events_forwarded_to_drag_drop_host
,
103 bool cancel_drag
) override
;
104 bool IsPointOutsideOfFolderBoundary(const gfx::Point
& point
) override
;
105 bool IsOEMFolder() const override
;
106 void SetRootLevelDragViewVisible(bool visible
) override
;
108 AppsContainerView
* container_view_
; // Not owned.
109 AppListMainView
* app_list_main_view_
; // Not Owned.
110 FolderHeaderView
* folder_header_view_
; // Owned by views hierarchy.
111 AppsGridView
* items_grid_view_
; // Owned by the views hierarchy.
113 scoped_ptr
<views::ViewModel
> view_model_
;
115 AppListModel
* model_
; // Not owned.
116 AppListFolderItem
* folder_item_
; // Not owned.
118 bool hide_for_reparent_
;
120 base::string16 accessible_name_
;
122 DISALLOW_COPY_AND_ASSIGN(AppListFolderView
);
125 } // namespace app_list
127 #endif // UI_APP_LIST_VIEWS_APP_LIST_FOLDER_VIEW_H_