| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef UI_APP_LIST_COCOA_APPS_GRID_CONTROLLER_H_ | 5 #ifndef UI_APP_LIST_COCOA_APPS_GRID_CONTROLLER_H_ |
| 6 #define UI_APP_LIST_COCOA_APPS_GRID_CONTROLLER_H_ | 6 #define UI_APP_LIST_COCOA_APPS_GRID_CONTROLLER_H_ |
| 7 | 7 |
| 8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
| 9 | 9 |
| 10 #include "base/mac/scoped_nsobject.h" | 10 #include "base/mac/scoped_nsobject.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "ui/app_list/app_list_export.h" | 12 #include "ui/app_list/app_list_export.h" |
| 13 #import "ui/app_list/cocoa/app_list_pager_view.h" | 13 #import "ui/app_list/cocoa/app_list_pager_view.h" |
| 14 #import "ui/app_list/cocoa/scroll_view_with_no_scrollbars.h" | 14 #include "ui/views_core/bridged_view_mac.h" |
| 15 | 15 |
| 16 namespace app_list { | 16 namespace app_list { |
| 17 class AppListModel; | 17 class AppListModel; |
| 18 class AppListViewDelegate; | 18 class AppListViewDelegate; |
| 19 class AppsGridDelegateBridge; | 19 class AppsGridView; |
| 20 class AppsGridViewDelegateBridge; |
| 21 class PaginationModel; |
| 20 } | 22 } |
| 21 | 23 |
| 22 @class AppsGridViewItem; | |
| 23 @protocol AppsPaginationModelObserver; | 24 @protocol AppsPaginationModelObserver; |
| 24 @class AppsCollectionViewDragManager; | |
| 25 | 25 |
| 26 // Controls a grid of views, representing AppListItemList sub models. | 26 // Controls a grid of views, representing AppListItemList sub models. |
| 27 APP_LIST_EXPORT | 27 APP_LIST_EXPORT |
| 28 @interface AppsGridController : NSViewController<GestureScrollDelegate, | 28 @interface AppsGridController : NSViewController<AppListPagerDelegate> { |
| 29 AppListPagerDelegate, | |
| 30 NSCollectionViewDelegate> { | |
| 31 @private | 29 @private |
| 32 app_list::AppListViewDelegate* delegate_; // Weak. Owned by view controller. | 30 app_list::AppListViewDelegate* delegate_; // Weak. Owned by view controller. |
| 33 scoped_ptr<app_list::AppsGridDelegateBridge> bridge_; | |
| 34 | 31 |
| 35 base::scoped_nsobject<AppsCollectionViewDragManager> dragManager_; | 32 scoped_ptr<app_list::AppsGridViewDelegateBridge> gridDelegate_; |
| 36 base::scoped_nsobject<NSMutableArray> pages_; | 33 scoped_ptr<app_list::PaginationModel> paginationModel_; |
| 37 base::scoped_nsobject<NSMutableArray> items_; | |
| 38 base::scoped_nsobject<NSTimer> scrollWhileDraggingTimer_; | |
| 39 | 34 |
| 35 views::BridgedView<app_list::AppsGridView> gridView_; |
| 40 id<AppsPaginationModelObserver> paginationObserver_; | 36 id<AppsPaginationModelObserver> paginationObserver_; |
| 41 | |
| 42 // Index of the currently visible page. | |
| 43 size_t visiblePage_; | |
| 44 // The page to which the view is currently animating a scroll. | |
| 45 size_t targetScrollPage_; | |
| 46 // The page to start scrolling to when the timer expires. | |
| 47 size_t scheduledScrollPage_; | |
| 48 | |
| 49 // Whether we are currently animating a scroll to the nearest page. | |
| 50 BOOL animatingScroll_; | |
| 51 } | 37 } |
| 52 | 38 |
| 53 @property(assign, nonatomic) id<AppsPaginationModelObserver> paginationObserver; | 39 @property(assign, nonatomic) id<AppsPaginationModelObserver> paginationObserver; |
| 54 | 40 |
| 55 + (void)setScrollAnimationDuration:(NSTimeInterval)duration; | 41 + (void)setScrollAnimationDuration:(NSTimeInterval)duration; |
| 56 | 42 |
| 57 // The amount the grid view has been extended to hold the sometimes present | 43 // The amount the grid view has been extended to hold the sometimes present |
| 58 // invisible scroller that allows for gesture scrolling. | 44 // invisible scroller that allows for gesture scrolling. |
| 59 + (CGFloat)scrollerPadding; | 45 + (CGFloat)scrollerPadding; |
| 60 | 46 |
| 61 - (NSCollectionView*)collectionViewAtPageIndex:(size_t)pageIndex; | 47 - (NSCollectionView*)collectionViewAtPageIndex:(size_t)pageIndex; |
| 62 - (size_t)pageIndexForCollectionView:(NSCollectionView*)page; | 48 - (size_t)pageIndexForCollectionView:(NSCollectionView*)page; |
| 63 | 49 |
| 64 - (AppsGridViewItem*)itemAtIndex:(size_t)itemIndex; | |
| 65 | |
| 66 - (app_list::AppListModel*)model; | 50 - (app_list::AppListModel*)model; |
| 67 | 51 |
| 68 - (void)setDelegate:(app_list::AppListViewDelegate*)newDelegate; | 52 - (void)setDelegate:(app_list::AppListViewDelegate*)newDelegate; |
| 69 | 53 |
| 70 - (size_t)visiblePage; | 54 - (size_t)visiblePage; |
| 71 | 55 |
| 72 // Calls item->Activate for the currently selected item by simulating a click. | 56 // Calls item->Activate for the currently selected item by simulating a click. |
| 73 - (void)activateSelection; | 57 - (void)activateSelection; |
| 74 | 58 |
| 75 // Return the number of pages of icons in the grid. | 59 // Return the number of pages of icons in the grid. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 105 - (void)selectItemAtIndex:(NSUInteger)index; | 89 - (void)selectItemAtIndex:(NSUInteger)index; |
| 106 | 90 |
| 107 // Handle key actions. Similar to doCommandBySelector from NSResponder but that | 91 // Handle key actions. Similar to doCommandBySelector from NSResponder but that |
| 108 // requires this class to be in the responder chain. Instead this method is | 92 // requires this class to be in the responder chain. Instead this method is |
| 109 // invoked by the AppListViewController. | 93 // invoked by the AppListViewController. |
| 110 // Returns YES if this handled navigation or launched an app. | 94 // Returns YES if this handled navigation or launched an app. |
| 111 - (BOOL)handleCommandBySelector:(SEL)command; | 95 - (BOOL)handleCommandBySelector:(SEL)command; |
| 112 | 96 |
| 113 @end | 97 @end |
| 114 | 98 |
| 115 @interface AppsGridController(TestingAPI) | |
| 116 | |
| 117 - (AppsCollectionViewDragManager*)dragManager; | |
| 118 - (size_t)scheduledScrollPage; | |
| 119 | |
| 120 @end | |
| 121 | |
| 122 #endif // UI_APP_LIST_COCOA_APPS_GRID_CONTROLLER_H_ | 99 #endif // UI_APP_LIST_COCOA_APPS_GRID_CONTROLLER_H_ |
| OLD | NEW |