Permalink
Browse files

Items space out to fill the width of the view

  • Loading branch information...
1 parent e94ce75 commit 34fa703b516afb44afd3b300ca0fc44c100d8d7f @pieteromvlee pieteromvlee committed Mar 4, 2011
Showing with 4 additions and 3 deletions.
  1. +4 −3 BCCollectionViewLayoutOperation.m
@@ -20,6 +20,7 @@ - (void)main
NSRect visibleRect = [collectionView visibleRect];
NSSize cellSize = [collectionView cellSize];
NSSize inset = NSZeroSize;
+ NSUInteger gap = (NSWidth([collectionView frame]) - [[collectionView layoutManager] maximumNumberOfItemsPerRow]*cellSize.width)/[[collectionView layoutManager] maximumNumberOfItemsPerRow];
if ([[collectionView delegate] respondsToSelector:@selector(insetMarginForSelectingItemsInCollectionView:)])
inset = [[collectionView delegate] insetMarginForSelectingItemsInCollectionView:collectionView];
@@ -52,7 +53,7 @@ - (void)main
}
[item setColumnIndex:colIndex];
[item setItemRect:NSMakeRect(x, y, cellSize.width, cellSize.height)];
- x += cellSize.width;
+ x += cellSize.width + gap;
colIndex++;
} else {
[item setItemRect:NSMakeRect(-cellSize.width*2, y, cellSize.width, cellSize.height)];
@@ -64,11 +65,11 @@ - (void)main
if ([self isCancelled])
return;
- if (layoutCallBack != nil)
+ if (layoutCallBack != nil) {
dispatch_async(dispatch_get_main_queue(), ^{
layoutCallBack(item);
});
-
+ }
if ([group itemRange].location + [group itemRange].length-1 == i)
group = [groupEnum nextObject];
}

0 comments on commit 34fa703

Please sign in to comment.