apps_container_view.h revision 5d1f7b1de12d16ceb2c938c56701a3e8bfa558f7
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_APPS_CONTAINER_VIEW_H_ 6#define UI_APP_LIST_VIEWS_APPS_CONTAINER_VIEW_H_ 7 8#include "ui/app_list/app_list_folder_item.h" 9#include "ui/app_list/views/top_icon_animation_view.h" 10#include "ui/views/view.h" 11 12namespace content { 13class WebContents; 14} 15 16namespace app_list { 17 18class AppsGridView; 19class ApplicationDragAndDropHost; 20class AppListFolderItem; 21class AppListFolderView; 22class AppListMainView; 23class AppListModel; 24class ContentsView; 25class FolderBackgroundView; 26class PaginationModel; 27 28// AppsContainerView contains a root level AppsGridView to render the root level 29// app items, and a AppListFolderView to render the app items inside the 30// active folder. Only one if them is visible to user at any time. 31class AppsContainerView : public views::View, 32 public TopIconAnimationObserver { 33 public: 34 AppsContainerView(AppListMainView* app_list_main_view, 35 PaginationModel* pagination_model, 36 AppListModel* model, 37 content::WebContents* start_page_contents); 38 virtual ~AppsContainerView(); 39 40 // Shows the active folder content specified by |folder_item|. 41 void ShowActiveFolder(AppListFolderItem* folder_item); 42 43 // Shows the root level apps list. This is called when UI navigate back from 44 // a folder view with |folder_item|. If |folder_item| is NULL skips animation. 45 void ShowApps(AppListFolderItem* folder_item); 46 47 // Sets |drag_and_drop_host_| for the current app list in both 48 // app_list_folder_view_ and root level apps_grid_view_. 49 void SetDragAndDropHostOfCurrentAppList( 50 ApplicationDragAndDropHost* drag_and_drop_host); 51 52 // Transits the UI from folder view to root lelve apps grid view when 53 // re-parenting a child item of |folder_item|. 54 void ReparentFolderItemTransit(AppListFolderItem* folder_item); 55 56 // views::View overrides: 57 virtual gfx::Size GetPreferredSize() OVERRIDE; 58 virtual void Layout() OVERRIDE; 59 virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE; 60 61 // TopIconAnimationObserver overrides: 62 virtual void OnTopIconAnimationsComplete() OVERRIDE; 63 64 AppsGridView* apps_grid_view() { return apps_grid_view_; } 65 FolderBackgroundView* folder_background_view() { 66 return folder_background_view_; 67 } 68 AppListFolderView* app_list_folder_view() { return app_list_folder_view_; } 69 70 private: 71 enum ShowState { 72 SHOW_APPS, 73 SHOW_ACTIVE_FOLDER, 74 SHOW_ITEM_REPARENT, 75 }; 76 77 void SetShowState(ShowState show_state, bool show_apps_with_animation); 78 79 // Calculates the top item icon bounds in the active folder icon. The bounds 80 // is relative to AppsContainerView. 81 // Returns the bounds of top items' icon in sequence of top left, top right, 82 // bottom left, bottom right. 83 Rects GetTopItemIconBoundsInActiveFolder(); 84 85 // Creates the transitional views for animating the top items in the folder 86 // when opening or closing a folder. 87 void CreateViewsForFolderTopItemsAnimation( 88 AppListFolderItem* active_folder, bool open_folder); 89 90 void PrepareToShowApps(AppListFolderItem* folder_item); 91 92 AppListModel* model_; 93 AppsGridView* apps_grid_view_; // Owned by views hierarchy. 94 AppListFolderView* app_list_folder_view_; // Owned by views hierarchy. 95 FolderBackgroundView* folder_background_view_; // Owned by views hierarchy. 96 ShowState show_state_; 97 98 // The transitional views for animating the top items in folder 99 // when opening or closing a folder. 100 std::vector<views::View*> top_icon_views_; 101 102 size_t top_icon_animation_pending_count_; 103 104 DISALLOW_COPY_AND_ASSIGN(AppsContainerView); 105}; 106 107} // namespace app_list 108 109 110#endif // UI_APP_LIST_VIEWS_APPS_CONTAINER_VIEW_H_ 111