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