Permalink
Browse files

Fullscreen changes

  • Loading branch information...
1 parent dbf78ea commit df4a3bc50e121af275f47e5c35c67d1a6433049b @pieteromvlee pieteromvlee committed Feb 20, 2011
Showing with 9 additions and 10 deletions.
  1. +6 −6 BCCollectionView+Mouse.m
  2. +3 −4 BCCollectionViewLayoutManager.m
View
@@ -37,8 +37,6 @@ - (void)mouseDown:(NSEvent *)theEvent
[self deselectItemAtIndex:index];
else
[self selectItemAtIndex:index];
-
- firstDrag = YES;
}
- (void)regularMouseDragged:(NSEvent *)anEvent
@@ -77,11 +75,13 @@ - (void)mouseDragged:(NSEvent *)theEvent
{
if (isDragging) {
NSUInteger index = [layoutManager indexOfItemContentRectAtPoint:mouseDownLocation];
- if (firstDrag && index != NSNotFound && [selectionIndexes count] > 0 && [self delegateSupportsDragForItemsAtIndexes:selectionIndexes])
- [self initiateDraggingSessionWithEvent:theEvent];
- else
+ if (index != NSNotFound && [selectionIndexes count] > 0 && [self delegateSupportsDragForItemsAtIndexes:selectionIndexes]) {
+ NSPoint mouse = [self convertPoint:[theEvent locationInWindow] fromView:nil];
+ CGFloat distance = sqrt(pow(mouse.x-mouseDownLocation.x,2)+pow(mouse.y-mouseDownLocation.y,2));
+ if (distance > 3)
+ [self initiateDraggingSessionWithEvent:theEvent];
+ } else
[self regularMouseDragged:theEvent];
- firstDrag = NO;
}
}
@@ -15,15 +15,14 @@ - (id)initWithCollectionView:(BCCollectionView *)aCollectionView
return self;
}
-
- (NSUInteger)numberOfRows
{
return MAX(1, ceil((float)[[collectionView contentArray] count]/(float)[self numberOfItemsPerRow]));
}
- (NSUInteger)numberOfItemsPerRow
{
- return MAX(1, [collectionView frame].size.width/[self cellSize].width);
+ return MAX(1, NSWidth([collectionView frame])/[self cellSize].width);
}
- (NSUInteger)numberOfItemsAtRow:(NSInteger)rowIndex
@@ -70,8 +69,8 @@ - (NSRect)rectOfItemAtIndex:(NSUInteger)anIndex
NSSize cellSize = [self cellSize];
NSUInteger rowIndex = anIndex / [self numberOfItemsPerRow];
NSUInteger columnIndex = anIndex % [self numberOfItemsPerRow];
-
- return NSMakeRect(columnIndex*cellSize.width, rowIndex*cellSize.height, cellSize.width, cellSize.height);
+ NSInteger gap = (NSWidth([collectionView visibleRect])-[self numberOfItemsPerRow]*cellSize.width)/([self numberOfItemsPerRow]-1);
+ return NSMakeRect(columnIndex*(cellSize.width+gap), rowIndex*cellSize.height, cellSize.width, cellSize.height);
}
- (NSRect)contentRectOfItemAtIndex:(NSUInteger)anIndex

0 comments on commit df4a3bc

Please sign in to comment.