Permalink
Browse files

Updated to latest Kobo version, complete with bugfixes around animati…

…on and item layout. Bumped version to 1.2.
  • Loading branch information...
Jim Dovey
Jim Dovey committed Jan 10, 2011
1 parent cf2dc26 commit c37e347540cda16bb9d83be898bfb952317f4fa9
@@ -214,7 +214,14 @@
isa = PBXProject;
buildConfigurationList = 1DEB922208733DC00010E9CD /* Build configuration list for PBXProject "AQGridView" */;
compatibilityVersion = "Xcode 3.1";
+ developmentRegion = English;
hasScannedForEncodings = 1;
+ knownRegions = (
+ English,
+ Japanese,
+ French,
+ German,
+ );
mainGroup = 0867D691FE84028FC02AAC07 /* AQGridView */;
productRefGroup = 034768DFFF38A50411DB9C8B /* Products */;
projectDirPath = "";
@@ -316,7 +323,7 @@
IPHONEOS_DEPLOYMENT_TARGET = 3.0;
OTHER_LDFLAGS = "-ObjC";
PREBINDING = NO;
- SDKROOT = iphoneos3.2;
+ SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
@@ -331,7 +338,7 @@
IPHONEOS_DEPLOYMENT_TARGET = 3.0;
OTHER_LDFLAGS = "-ObjC";
PREBINDING = NO;
- SDKROOT = iphoneos3.2;
+ SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
View
@@ -615,11 +615,22 @@ - (void) layoutSubviews
[self layoutAllCells];
}
+
CGRect rect = CGRectZero;
rect.size.width = self.bounds.size.width;
rect.size.height = self.contentSize.height - (_gridData.topPadding + _gridData.bottomPadding);
rect.origin.y += _gridData.topPadding;
- self.backgroundView.frame = rect;
+
+ // Make sure background is an integral number of rows tall. That way, it draws patterned colours correctly on all OSes.
+ CGRect backgroundRect = rect;
+ CGFloat minimumHeight = rect.size.height;
+ CGFloat actualHeight = [_gridData cellSize].height * ([_gridData numberOfItems] / [_gridData numberOfItemsPerRow] + 1);
+ for (; actualHeight < minimumHeight; actualHeight += [_gridData cellSize].height) {
+ }
+ backgroundRect.size.height = actualHeight;
+
+
+ self.backgroundView.frame = backgroundRect;
if ( _headerView != nil )
{
@@ -636,6 +647,7 @@ - (void) layoutSubviews
rect.origin.y = self.contentSize.height - rect.size.height;
rect.size.width = self.bounds.size.width;
_footerView.frame = rect;
+ [self bringSubviewToFront:_footerView];
}
}
@@ -867,9 +879,9 @@ - (void) endUpdateAnimations
[UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration: 0.3];
+
self.animatingCells = [info animateCellUpdatesUsingVisibleContentRect: [self gridViewVisibleBounds]];
- [UIView commitAnimations];
[_gridData release];
_gridData = [[info newGridViewData] retain];
@@ -878,14 +890,15 @@ - (void) endUpdateAnimations
[info release];
_reloadingSuspendedCount--;
+ [UIView commitAnimations];
}
- (void) cellUpdateAnimationStopped: (NSString *) animationID finished: (BOOL) finished context: (void *) context
{
AQGridViewUpdateInfo * info = (AQGridViewUpdateInfo *)context;
// if nothing was animated, we don't have to do anything at all
- if ( self.animatingCells.count != 0 )
+// if ( self.animatingCells.count != 0 )
[self fixCellsFromAnimation];
// NB: info becomes invalid at this point
@@ -1479,7 +1492,7 @@ - (void) updateVisibleGridCellsNow
{
for ( AQGridViewAnimatorItem * item in _animatingCells )
{
- if ( [animatingInserted containsIndex: item.index] == NO )
+ if ( [newVisibleIndices containsIndex: item.index] == NO )
continue;
if ( [item.animatingView isKindOfClass: [AQGridViewCell class]] )
@@ -1525,15 +1538,21 @@ - (void) updateVisibleGridCellsNow
if ( [_visibleCells count] > [newVisibleIndices count] )
{
- NSLog( @"Have to prune visible cell list, I've still got extra cells in there!" );
+ //NSLog( @"Have to prune visible cell list, I've still got extra cells in there!" );
+ NSMutableIndexSet * animatingDestinationIndices = [[NSMutableIndexSet alloc] init];
+ for ( AQGridViewAnimatorItem * item in _animatingCells )
+ {
+ [animatingDestinationIndices addIndex: item.index];
+ }
NSMutableIndexSet * toRemove = [[NSMutableIndexSet alloc] init];
NSMutableIndexSet * seen = [[NSMutableIndexSet alloc] init];
NSUInteger i, count = [_visibleCells count];
for ( i = 0; i < count; i++ )
{
AQGridViewCell * cell = [_visibleCells objectAtIndex: i];
- if ( [newVisibleIndices containsIndex: cell.displayIndex] == NO )
+ if ( [newVisibleIndices containsIndex: cell.displayIndex] == NO &&
+ [animatingDestinationIndices containsIndex: cell.displayIndex] == NO )
{
NSLog( @"Cell for index %lu is still in visible list, removing...", (unsigned long)cell.displayIndex );
[cell removeFromSuperview];
@@ -1547,12 +1566,12 @@ - (void) updateVisibleGridCellsNow
}
[seen addIndex: cell.displayIndex];
- i++;
}
// all removed from superview, just need to remove from the list now
[_visibleCells removeObjectsAtIndexes: toRemove];
[toRemove release];
+ [seen release];
}
if ( [_visibleCells count] < [newVisibleIndices count] )
@@ -1583,6 +1602,8 @@ - (void) updateVisibleGridCellsNow
idx = [missingSet indexGreaterThanIndex: idx];
}
+
+ [missingSet release];
}
// everything should match up now, so update the visible range
@@ -2059,6 +2080,8 @@ - (void) delegateWillDisplayCell: (AQGridViewCell *) cell atIndex: (NSUInteger)
cell.separatorEdge = edge;
}
+
+ //NSLog( @"Displaying cell at index %lu", (unsigned long) index );
if ( _flags.delegateWillDisplayCell == 0 )
return;
@@ -43,9 +43,9 @@ - (NSComparisonResult) compare: (id) obj
{
if ( [obj isKindOfClass: [self class]] == NO )
{
- if ( (id)self < obj )
+ if ( (void *)self < (void *)obj )
return ( NSOrderedAscending );
- if ( (id)self > obj )
+ if ( (void *)self > (void *)obj )
return ( NSOrderedDescending );
return ( NSOrderedSame ); // how ??!?!?
}
View
@@ -38,10 +38,7 @@
#import "AQGridViewCell+AQGridViewCellPrivate.h"
#import "UIColor+AQGridView.h"
#import <QuartzCore/QuartzCore.h>
-
-#ifdef BUILTIN_IMAGES
-#import "AQGridViewCell_png.h"
-#endif
+#import <objc/runtime.h>
@interface AQGridViewCell ()
@property (nonatomic, retain) UIView * contentView;
@@ -300,39 +297,6 @@ - (void) _beginBackgroundHighlight: (BOOL) highlightOn animated: (BOOL) animated
{
if ( (_cellFlags.usingDefaultSelectedBackgroundView == 1) && (_selectedBackgroundView == nil) )
{
-#ifdef BUILTIN_IMAGES
- unsigned char * pngBytes = AQGridSelection_png;
- NSUInteger pngLength = AQGridSelection_png_len;
- switch ( _cellFlags.selectionStyle )
- {
- case AQGridViewCellSelectionStyleBlue:
- default:
- break;
-
- case AQGridViewCellSelectionStyleGray:
- pngBytes = AQGridSelectionGray_png;
- pngLength = AQGridSelectionGray_png_len;
- break;
-
- case AQGridViewCellSelectionStyleBlueGray:
- pngBytes = AQGridSelectionGrayBlue_png;
- pngLength = AQGridSelectionGrayBlue_png_len;
- break;
-
- case AQGridViewCellSelectionStyleGreen:
- pngBytes = AQGridSelectionGreen_png;
- pngLength = AQGridSelectionGreen_png_len;
- break;
-
- case AQGridViewCellSelectionStyleRed:
- pngBytes = AQGridSelectionRed_png;
- pngLength = AQGridSelectionRed_png_len;
- break;
- }
-
- NSData *pngData = [NSData dataWithBytesNoCopy: pngBytes length: pngLength freeWhenDone: NO];
- _selectedBackgroundView = [[UIImageView alloc] initWithImage: [UIImage imageWithData: pngData]];
-#else
NSString * imageName = @"AQGridSelection.png";
switch ( _cellFlags.selectionStyle )
{
@@ -358,7 +322,6 @@ - (void) _beginBackgroundHighlight: (BOOL) highlightOn animated: (BOOL) animated
}
_selectedBackgroundView = [[UIImageView alloc] initWithImage: [UIImage imageNamed: imageName]];
-#endif
_selectedBackgroundView.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
_selectedBackgroundView.contentMode = UIViewContentModeScaleToFill;
}
@@ -39,10 +39,12 @@
#define POPOVER_SIZE CGSizeMake( 345, 525 )
-@interface AQGridViewController : UIViewController <AQGridViewDelegate, AQGridViewDataSource>
+@interface AQGridViewController : UIViewController <AQGridViewDelegate, AQGridViewDataSource, UIPopoverControllerDelegate>
{
@private
BOOL _clearsSelectionOnViewWillAppear;
+ @protected
+ BOOL _popoverShowing;
}
@property (nonatomic, retain) AQGridView * gridView;
@@ -71,6 +71,8 @@ - (void) viewDidLoad
{
[super viewDidLoad];
[self.gridView reloadData];
+
+ _popoverShowing = NO;
}
- (AQGridView *) gridView
@@ -168,4 +170,12 @@ - (AQGridViewCell *) gridView: (AQGridView *) gridView cellForItemAtIndex: (NSUI
return ( nil );
}
+#pragma mark -
+#pragma mark UIPopoverControllerDelegate methods
+
+- (void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController
+{
+ _popoverShowing = NO;
+}
+
@end
Oops, something went wrong.

0 comments on commit c37e347

Please sign in to comment.