// Update the button image after ensuring its dimensions are |kIconSize|.
- (void)updateButtonImage;
-// Ensure the page this item is on is the visible page in the grid.
-- (void)ensureVisible;
-
// Add or remove a progress bar from the view.
- (void)setItemIsInstalling:(BOOL)isInstalling;
class ItemModelObserverBridge : public app_list::AppListItemObserver {
public:
ItemModelObserverBridge(AppsGridViewItem* parent, AppListItem* model);
- virtual ~ItemModelObserverBridge();
+ ~ItemModelObserverBridge() override;
AppListItem* model() { return model_; }
NSMenu* GetContextMenu();
- virtual void ItemIconChanged() OVERRIDE;
- virtual void ItemNameChanged() OVERRIDE;
- virtual void ItemHighlightedChanged() OVERRIDE;
- virtual void ItemIsInstallingChanged() OVERRIDE;
- virtual void ItemPercentDownloadedChanged() OVERRIDE;
+ void ItemIconChanged() override;
+ void ItemNameChanged() override;
+ void ItemIsInstallingChanged() override;
+ void ItemPercentDownloadedChanged() override;
private:
AppsGridViewItem* parent_; // Weak. Owns us.
[parent_ updateButtonTitle];
}
-void ItemModelObserverBridge::ItemHighlightedChanged() {
- if (model_->highlighted())
- [parent_ ensureVisible];
-}
-
void ItemModelObserverBridge::ItemIsInstallingChanged() {
[parent_ setItemIsInstalling:model_->is_installing()];
}
return imageRep;
}
-- (void)ensureVisible {
- NSCollectionView* collectionView = [self collectionView];
- AppsGridController* gridController =
- base::mac::ObjCCastStrict<AppsGridController>([collectionView delegate]);
- size_t pageIndex = [gridController pageIndexForCollectionView:collectionView];
- [gridController scrollToPage:pageIndex];
-}
-
- (void)setItemIsInstalling:(BOOL)isInstalling {
if (!isInstalling == !progressIndicator_)
return;
- [self ensureVisible];
if (!isInstalling) {
[progressIndicator_ removeFromSuperview];
progressIndicator_.reset();