11e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved. 21e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 31e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)// found in the LICENSE file. 41e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 51e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#ifndef UI_APP_LIST_VIEWS_APP_LIST_FOLDER_VIEW_H_ 61e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#define UI_APP_LIST_VIEWS_APP_LIST_FOLDER_VIEW_H_ 71e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 8010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)#include <string> 9010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) 105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ui/app_list/app_list_item_list_observer.h" 115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ui/app_list/views/apps_grid_view.h" 12effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch#include "ui/app_list/views/apps_grid_view_folder_delegate.h" 131e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#include "ui/app_list/views/folder_header_view.h" 141e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#include "ui/app_list/views/folder_header_view_delegate.h" 155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ui/compositor/layer_animation_observer.h" 161e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#include "ui/views/controls/button/button.h" 171e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#include "ui/views/view.h" 181e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 191e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)namespace views { 201e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)class ViewModel; 211e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)} 221e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 231e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)namespace app_list { 241e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 251e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)class AppsContainerView; 261e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)class AppsGridView; 271e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)class AppListFolderItem; 285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class AppListItemView; 291e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)class AppListMainView; 301e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)class AppListModel; 311e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)class FolderHeaderView; 321e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 331e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)class AppListFolderView : public views::View, 345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) public FolderHeaderViewDelegate, 35a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) public AppListModelObserver, 36effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch public ui::ImplicitAnimationObserver, 37effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch public AppsGridViewFolderDelegate { 381e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) public: 391e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) AppListFolderView(AppsContainerView* container_view, 401e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) AppListModel* model, 41effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch AppListMainView* app_list_main_view); 421e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) virtual ~AppListFolderView(); 431e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 441e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) void SetAppListFolderItem(AppListFolderItem* folder); 451e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Schedules an animation to show or hide the view. 475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // If |show| is false, the view should be set to invisible after the 485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // animation is done unless |hide_for_reparent| is true. 495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void ScheduleShowHideAnimation(bool show, bool hide_for_reparent); 505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 515d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Gets icon image bounds of the item at |index|, relative to 525d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // AppListFolderView. 535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) gfx::Rect GetItemIconBoundsAt(int index); 545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void UpdateFolderNameVisibility(bool visible); 565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Hides the view immediately without animation. 585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void HideViewImmediately(); 595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 60e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch // Closes the folder page and goes back the top level page. 61e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch void CloseFolderPage(); 62e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch 63a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // views::View 64cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles) virtual gfx::Size GetPreferredSize() const OVERRIDE; 651e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) virtual void Layout() OVERRIDE; 66f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE; 671e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 68a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // AppListModelObserver 69a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) virtual void OnAppListItemWillBeDeleted(AppListItem* item) OVERRIDE; 705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 71a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) // ui::ImplicitAnimationObserver 725d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual void OnImplicitAnimationsCompleted() OVERRIDE; 735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 745d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) AppsGridView* items_grid_view() { return items_grid_view_; } 755d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 761e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) private: 771e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) void CalculateIdealBounds(); 781e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 795d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Starts setting up drag in root level apps grid view for re-parenting a 805d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // folder item. 815d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // |drag_point_in_root_grid| is in the cooridnates of root level AppsGridView. 825d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) void StartSetupDragInRootLevelAppsGridView( 835d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) AppListItemView* original_drag_view, 845d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) const gfx::Point& drag_point_in_root_grid); 855d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 86c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch // Overridden from views::View: 87c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch virtual void GetAccessibleState(ui::AXViewState* state) OVERRIDE; 88c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch 891e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) // Overridden from FolderHeaderViewDelegate: 901e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) virtual void NavigateBack(AppListFolderItem* item, 911e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) const ui::Event& event_flags) OVERRIDE; 92a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) virtual void GiveBackFocusToSearchBox() OVERRIDE; 93a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) virtual void SetItemName(AppListFolderItem* item, 94a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) const std::string& name) OVERRIDE; 951e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 96effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch // Overridden from AppsGridViewFolderDelegate: 97effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch virtual void UpdateFolderViewBackground(bool show_bubble) OVERRIDE; 98effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch virtual void ReparentItem(AppListItemView* original_drag_view, 99effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch const gfx::Point& drag_point_in_folder_grid) 100effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch OVERRIDE; 1014ad1aa43a48567659193a298fad74f55e00b3dd9Ben Murdoch virtual void DispatchDragEventForReparent( 1024ad1aa43a48567659193a298fad74f55e00b3dd9Ben Murdoch AppsGridView::Pointer pointer, 1034ad1aa43a48567659193a298fad74f55e00b3dd9Ben Murdoch const gfx::Point& drag_point_in_folder_grid) OVERRIDE; 104effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch virtual void DispatchEndDragEventForReparent( 105010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) bool events_forwarded_to_drag_drop_host, 106010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) bool cancel_drag) OVERRIDE; 107effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch virtual bool IsPointOutsideOfFolderBoundary(const gfx::Point& point) OVERRIDE; 108effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch virtual bool IsOEMFolder() const OVERRIDE; 109010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles) virtual void SetRootLevelDragViewVisible(bool visible) OVERRIDE; 110effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch 1111e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) AppsContainerView* container_view_; // Not owned. 112a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) AppListMainView* app_list_main_view_; // Not Owned. 1131e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) FolderHeaderView* folder_header_view_; // Owned by views hierarchy. 1141e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) AppsGridView* items_grid_view_; // Owned by the views hierarchy. 1151e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 1161e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) scoped_ptr<views::ViewModel> view_model_; 1171e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 1185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) AppListModel* model_; // Not owned. 1191e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) AppListFolderItem* folder_item_; // Not owned. 1201e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 1215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) bool hide_for_reparent_; 1225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 123c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch base::string16 accessible_name_; 124c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch 1251e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(AppListFolderView); 1261e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)}; 1271e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 1281e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)} // namespace app_list 1291e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles) 1301e9bf3e0803691d0a228da41fc608347b6db4340Torne (Richard Coles)#endif // UI_APP_LIST_VIEWS_APP_LIST_FOLDER_VIEW_H_ 131