| OLD | NEW |
| (Empty) |
| 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_COCOA_APPS_GRID_CONTROLLER_H_ | |
| 6 #define UI_APP_LIST_COCOA_APPS_GRID_CONTROLLER_H_ | |
| 7 | |
| 8 #import <Cocoa/Cocoa.h> | |
| 9 #include <stddef.h> | |
| 10 | |
| 11 #include <memory> | |
| 12 | |
| 13 #include "base/mac/scoped_nsobject.h" | |
| 14 #include "ui/app_list/app_list_export.h" | |
| 15 #import "ui/app_list/cocoa/app_list_pager_view.h" | |
| 16 #import "ui/app_list/cocoa/scroll_view_with_no_scrollbars.h" | |
| 17 | |
| 18 namespace app_list { | |
| 19 class AppListModel; | |
| 20 class AppListViewDelegate; | |
| 21 class AppsGridDelegateBridge; | |
| 22 } | |
| 23 | |
| 24 @class AppsGridViewItem; | |
| 25 @protocol AppsPaginationModelObserver; | |
| 26 @class AppsCollectionViewDragManager; | |
| 27 | |
| 28 // Controls a grid of views, representing AppListItemList sub models. | |
| 29 APP_LIST_EXPORT | |
| 30 @interface AppsGridController : NSViewController<GestureScrollDelegate, | |
| 31 AppListPagerDelegate, | |
| 32 NSCollectionViewDelegate> { | |
| 33 @private | |
| 34 app_list::AppListViewDelegate* delegate_; // Weak. Owned by view controller. | |
| 35 std::unique_ptr<app_list::AppsGridDelegateBridge> bridge_; | |
| 36 | |
| 37 base::scoped_nsobject<AppsCollectionViewDragManager> dragManager_; | |
| 38 base::scoped_nsobject<NSMutableArray> pages_; | |
| 39 base::scoped_nsobject<NSMutableArray> items_; | |
| 40 base::scoped_nsobject<NSTimer> scrollWhileDraggingTimer_; | |
| 41 | |
| 42 id<AppsPaginationModelObserver> paginationObserver_; | |
| 43 | |
| 44 // Index of the currently visible page. | |
| 45 size_t visiblePage_; | |
| 46 // The page to which the view is currently animating a scroll. | |
| 47 size_t targetScrollPage_; | |
| 48 // The page to start scrolling to when the timer expires. | |
| 49 size_t scheduledScrollPage_; | |
| 50 | |
| 51 // Whether we are currently animating a scroll to the nearest page. | |
| 52 BOOL animatingScroll_; | |
| 53 } | |
| 54 | |
| 55 @property(assign, nonatomic) id<AppsPaginationModelObserver> paginationObserver; | |
| 56 | |
| 57 + (void)setScrollAnimationDuration:(NSTimeInterval)duration; | |
| 58 | |
| 59 // The amount the grid view has been extended to hold the sometimes present | |
| 60 // invisible scroller that allows for gesture scrolling. | |
| 61 + (CGFloat)scrollerPadding; | |
| 62 | |
| 63 // Whether the grid is configured with fewer rows than normal. | |
| 64 + (BOOL)hasFewerRows; | |
| 65 | |
| 66 - (NSCollectionView*)collectionViewAtPageIndex:(size_t)pageIndex; | |
| 67 - (size_t)pageIndexForCollectionView:(NSCollectionView*)page; | |
| 68 | |
| 69 - (AppsGridViewItem*)itemAtIndex:(size_t)itemIndex; | |
| 70 | |
| 71 - (app_list::AppListModel*)model; | |
| 72 | |
| 73 - (void)setDelegate:(app_list::AppListViewDelegate*)newDelegate; | |
| 74 | |
| 75 - (size_t)visiblePage; | |
| 76 | |
| 77 // Calls item->Activate for the currently selected item by simulating a click. | |
| 78 - (void)activateSelection; | |
| 79 | |
| 80 // Return the number of pages of icons in the grid. | |
| 81 - (size_t)pageCount; | |
| 82 | |
| 83 // Return the number of items over all pages in the grid. | |
| 84 - (size_t)itemCount; | |
| 85 | |
| 86 // Scroll to a page in the grid view with an animation. | |
| 87 - (void)scrollToPage:(size_t)pageIndex; | |
| 88 | |
| 89 // Start a timer to scroll to a new page, if |locationInWindow| is to the left | |
| 90 // or the right of the view, or if it is over a pager segment. Cancels any | |
| 91 // existing timer if the target page changes. | |
| 92 - (void)maybeChangePageForPoint:(NSPoint)locationInWindow; | |
| 93 | |
| 94 // Cancel a timer that may have been set by maybeChangePageForPoint(). | |
| 95 - (void)cancelScrollTimer; | |
| 96 | |
| 97 // Moves an item within the view only, for dragging or in response to model | |
| 98 // changes. | |
| 99 - (void)moveItemInView:(size_t)fromIndex | |
| 100 toItemIndex:(size_t)toIndex; | |
| 101 | |
| 102 // Moves an item in the item model. Does not adjust the view. | |
| 103 - (void)moveItemWithIndex:(size_t)itemIndex | |
| 104 toModelIndex:(size_t)modelIndex; | |
| 105 | |
| 106 // Return the index of the selected item. | |
| 107 - (NSUInteger)selectedItemIndex; | |
| 108 | |
| 109 // Moves the selection to the given index. | |
| 110 - (void)selectItemAtIndex:(NSUInteger)index; | |
| 111 | |
| 112 // Handle key actions. Similar to doCommandBySelector from NSResponder but that | |
| 113 // requires this class to be in the responder chain. Instead this method is | |
| 114 // invoked by the AppListViewController. | |
| 115 // Returns YES if this handled navigation or launched an app. | |
| 116 - (BOOL)handleCommandBySelector:(SEL)command; | |
| 117 | |
| 118 @end | |
| 119 | |
| 120 @interface AppsGridController(TestingAPI) | |
| 121 | |
| 122 - (AppsCollectionViewDragManager*)dragManager; | |
| 123 - (size_t)scheduledScrollPage; | |
| 124 | |
| 125 @end | |
| 126 | |
| 127 #endif // UI_APP_LIST_COCOA_APPS_GRID_CONTROLLER_H_ | |
| OLD | NEW |