12a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved.
22a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
32a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// found in the LICENSE file.
42a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
52a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#ifndef UI_APP_LIST_COCOA_APPS_GRID_VIEW_ITEM_H_
62a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#define UI_APP_LIST_COCOA_APPS_GRID_VIEW_ITEM_H_
72a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
82a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#import <Cocoa/Cocoa.h>
92a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/memory/scoped_ptr.h"
11c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)#include "ui/app_list/app_list_export.h"
122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#import "ui/base/cocoa/tracking_area.h"
132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)namespace app_list {
155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class AppListItem;
162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class ItemModelObserverBridge;
172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// AppsGridViewItem is the controller for an NSButton representing an app item
202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// on an NSCollectionView controlled by an AppsGridController.
21c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)APP_LIST_EXPORT
222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)@interface AppsGridViewItem : NSCollectionViewItem {
232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) @private
242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  scoped_ptr<app_list::ItemModelObserverBridge> observerBridge_;
257dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  base::scoped_nsobject<NSProgressIndicator> progressIndicator_;
262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Used to highlight the background on hover.
282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  ui::ScopedCrTrackingArea trackingArea_;
292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
317dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch@property(readonly, nonatomic) NSProgressIndicator* progressIndicator;
32eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch
337dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch// Designated initializer. |tileSize| is the size of tiles in the grid.
342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)- (id)initWithSize:(NSSize)tileSize;
352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
367dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch// Set the represented model, updating views. Clears if |itemModel| is NULL.
375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)- (void)setModel:(app_list::AppListItem*)itemModel;
385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
397dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch// Model accessor, via the |observerBridge_|.
405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)- (app_list::AppListItem*)model;
412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
427dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch// Return the button portion of the item, showing the icon and title.
432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)- (NSButton*)button;
442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
457dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch// Generate and return a context menu, populated using the represented model.
46eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch- (NSMenu*)contextMenu;
47eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch
487dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch// Take a snapshot of the grid cell with correct layout, then hide the button.
497dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch// If |isRestore| is true, the snapshot includes the label and items hidden for
507dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch// the initial snapshot are restored.
517dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch- (NSBitmapImageRep*)dragRepresentationForRestore:(BOOL)isRestore;
527dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch
532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)@end
542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#endif  // UI_APP_LIST_COCOA_APPS_GRID_VIEW_ITEM_H_
56