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