apps_grid_controller.h revision 2a99a7e74a7f215066514fe81d2bfa6639d9eddd
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
10#include "base/memory/scoped_nsobject.h"
11#include "base/memory/scoped_ptr.h"
12#import "ui/app_list/cocoa/scroll_view_with_no_scrollbars.h"
13
14namespace app_list {
15class AppListModel;
16class AppListViewDelegate;
17class AppsGridDelegateBridge;
18}
19
20@class AppsGridViewItem;
21@protocol AppsPaginationModelObserver;
22
23// Controls a grid of views, representing AppListModel::Apps sub models.
24@interface AppsGridController : NSViewController<GestureScrollDelegate> {
25 @private
26  scoped_ptr<app_list::AppListModel> model_;
27  app_list::AppListViewDelegate* delegate_;  // Weak. Owned by view controller.
28  scoped_ptr<app_list::AppsGridDelegateBridge> bridge_;
29
30  scoped_nsobject<NSMutableArray> pages_;
31  scoped_nsobject<NSMutableArray> items_;
32
33  id<AppsPaginationModelObserver> paginationObserver_;
34
35  // Index of the currently visible page.
36  size_t visiblePage_;
37
38  // Whether we are currently animating a scroll to the nearest page.
39  BOOL animatingScroll_;
40}
41
42@property(assign, nonatomic) id<AppsPaginationModelObserver> paginationObserver;
43
44+ (void)setScrollAnimationDuration:(NSTimeInterval)duration;
45
46- (NSCollectionView*)collectionViewAtPageIndex:(size_t)pageIndex;
47
48- (AppsGridViewItem*)itemAtIndex:(size_t)itemIndex;
49
50- (app_list::AppListModel*)model;
51
52- (void)setModel:(scoped_ptr<app_list::AppListModel>)newModel;
53
54- (void)setDelegate:(app_list::AppListViewDelegate*)newDelegate;
55
56- (size_t)visiblePage;
57
58// Calls delegate_->ActivateAppListItem for the currently selected item by
59// simulating a click.
60- (void)activateSelection;
61
62// Return the number of pages of icons in the grid.
63- (size_t)pageCount;
64
65// Scroll to a page in the grid view with an animation.
66- (void)scrollToPage:(size_t)pageIndex;
67
68@end
69
70#endif  // UI_APP_LIST_COCOA_APPS_GRID_CONTROLLER_H_
71