//  Created by Pieter Omvlee on 15/02/2011.
//  Copyright 2011 Bohemian Coding. All rights reserved.

#import <GlyphsKit/BCCollectionViewLayoutOperation.h>

@class BCCollectionView;
@interface BCCollectionViewLayoutManager : NSObject {
	BCCollectionView *__unsafe_unretained collectionView;
	NSArray <BCCollectionViewLayoutItem *> *itemLayouts;
}
@property (strong) NSArray *itemLayouts;
- (instancetype)initWithCollectionView:(BCCollectionView *)collectionView; //assigned
- (void)enumerateItems:(BCCollectionViewLayoutOperationIterator)itemIterator completionBlock:(dispatch_block_t)completionBlock;

#pragma mark Primitives
- (NSUInteger)maximumNumberOfItemsPerRow;
- (NSSize)cellSize;
// updated once when layouted. So faster than maximumNumberOfItemsPerRow;
@property NSInteger numberOfItemsPerRow;

#pragma mark Rows and Columns
- (NSUInteger)indexOfItemAtRow:(NSUInteger)rowIdx column:(NSUInteger)colIdx;
- (NSPoint)rowAndColumnPositionOfItemAtIndex:(NSUInteger)idx;

#pragma mark From Point to Index
- (NSUInteger)indexOfItemAtPoint:(NSPoint)p;
- (NSUInteger)indexOfItemContentRectAtPoint:(NSPoint)p;

// use a smaller search window to improve performance.
- (NSUInteger)indexOfItemAtPoint:(NSPoint)p closeToIndex:(NSInteger)closeToIndex;
- (NSUInteger)indexOfItemContentRectAtPoint:(NSPoint)p closeToIndex:(NSInteger)closeToIndex;

#pragma mark From Index to Rect
- (NSRect)rectOfItemAtIndex:(NSUInteger)idx;
- (NSRect)contentRectOfItemAtIndex:(NSUInteger)idx;
@end
