Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed calculation of x position in grid view to avoid position jitter #132

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
10 changes: 4 additions & 6 deletions JNWCollectionView/JNWCollectionViewCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -157,15 +157,13 @@ - (NSImage *)backgroundImage {
return self.backgroundView.image;
}

- (void)mouseDown:(NSEvent *)theEvent {
[super mouseDown:theEvent];

- (void)mouseDown:(NSEvent *)theEvent
{
[self.collectionView mouseDownInCollectionViewCell:self withEvent:theEvent];
}

- (void)mouseUp:(NSEvent *)theEvent {
[super mouseUp:theEvent];

- (void)mouseUp:(NSEvent *)theEvent
{
[self.collectionView mouseUpInCollectionViewCell:self withEvent:theEvent];

if (theEvent.clickCount == 2) {
Expand Down
29 changes: 17 additions & 12 deletions JNWCollectionView/JNWCollectionViewFramework.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,16 @@ typedef NS_ENUM(NSInteger, JNWCollectionViewScrollPosition) {
/// Tells the delegate that the specified index path has been scrolled to.
- (void)collectionView:(JNWCollectionView *)collectionView didScrollToItemAtIndexPath:(NSIndexPath *)indexPath;

- (void)collectionView:(JNWCollectionView *)collectionView willDisplayCell:(JNWCollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath;

/// Tells the delegate that the cell for the specified index path has been put
/// back into the reuse queue.
- (void)collectionView:(JNWCollectionView *)collectionView didEndDisplayingCell:(JNWCollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath;

/// Tells the delegate that the collection view is about to reload the cells,
/// view size has already been calculated,
/// gives the delegate the chance the update the scroll position
- (void)collectionViewWillRelayoutCells:(JNWCollectionView *)collectionView;
@end

#pragma mark Reloading and customizing
Expand Down Expand Up @@ -184,18 +190,6 @@ typedef NS_ENUM(NSInteger, JNWCollectionViewScrollPosition) {
/// Defaults to nil.
@property (nonatomic, strong) JNWCollectionViewLayout *collectionViewLayout;

/// The background color determines what is drawn underneath any cells that might be visible
/// at the time. If this is a repeating pattern image, it will scroll along with the content.
///
/// Defaults to a white color.
@property (nonatomic, strong) NSColor *backgroundColor;

/// Whether or not the collection view draws the background color. If the collection view
/// background color needs to be transparent, this should be disabled.
///
/// Defaults to YES.
@property (nonatomic, assign) BOOL drawsBackground;

#pragma mark - Information

/// Returns the total number of sections.
Expand Down Expand Up @@ -267,6 +261,11 @@ typedef NS_ENUM(NSInteger, JNWCollectionViewScrollPosition) {
/// Defaults to YES.
@property (nonatomic, assign) BOOL allowsEmptySelection;

/// If set to NO, the collection view will not extend the selection when using command and shift modifier keys
///
/// Defaults to YES.
@property (nonatomic, assign) BOOL allowsMultipleSelection;

/// Scrolls the collection view to the item at the specified path, optionally animated. The scroll position determines
/// where the item is positioned on the screen.
- (void)scrollToItemAtIndexPath:(NSIndexPath *)indexPath atScrollPosition:(JNWCollectionViewScrollPosition)scrollPosition animated:(BOOL)animated;
Expand All @@ -276,6 +275,12 @@ typedef NS_ENUM(NSInteger, JNWCollectionViewScrollPosition) {
/// desired, pass in JNWCollectionViewScrollPositionNone to prevent the scroll..
- (void)selectItemAtIndexPath:(NSIndexPath *)indexPath atScrollPosition:(JNWCollectionViewScrollPosition)scrollPosition animated:(BOOL)animated;

/// Selects the item at the specified index path, deselecting any other selected items in the process, optionally animated.
/// The collection view will then scroll to that item in the position as determined by scrollPosition. If no scroll is
/// desired, pass in JNWCollectionViewScrollPositionNone to prevent the scroll..
/// extendSelection: A BOOL value that specifies whether to extend the current selection. Pass YES to extends the selection; NO replaces the current selection.
- (void)selectItemAtIndexPath:(NSIndexPath *)indexPath atScrollPosition:(JNWCollectionViewScrollPosition)scrollPosition byExtendingSelection:(BOOL)extendSelection animated:(BOOL)animated;

/// Selects all items in the collection view.
- (void)selectAllItems;

Expand Down
Loading