Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fullscreen changes

  • Loading branch information...
commit df4a3bc50e121af275f47e5c35c67d1a6433049b 1 parent dbf78ea
@pieteromvlee pieteromvlee authored
Showing with 9 additions and 10 deletions.
  1. +6 −6 BCCollectionView+Mouse.m
  2. +3 −4 BCCollectionViewLayoutManager.m
View
12 BCCollectionView+Mouse.m
@@ -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;
}
}
View
7 BCCollectionViewLayoutManager.m
@@ -15,7 +15,6 @@ - (id)initWithCollectionView:(BCCollectionView *)aCollectionView
return self;
}
-
- (NSUInteger)numberOfRows
{
return MAX(1, ceil((float)[[collectionView contentArray] count]/(float)[self numberOfItemsPerRow]));
@@ -23,7 +22,7 @@ - (NSUInteger)numberOfRows
- (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
Please sign in to comment.
Something went wrong with that request. Please try again.