Authored by Thomas Rasch

o Use pointers for RMScrollView delegate methods

... ... @@ -12,8 +12,8 @@
@protocol RMMapScrollViewDelegate <NSObject>
- (CGPoint)scrollView:(RMMapScrollView *)aScrollView correctedOffsetForContentOffset:(CGPoint)aContentOffset;
- (CGSize)scrollView:(RMMapScrollView *)aScrollView correctedSizeForContentSize:(CGSize)aContentSize;
- (void)scrollView:(RMMapScrollView *)aScrollView correctedContentOffset:(inout CGPoint *)aContentOffset;
- (void)scrollView:(RMMapScrollView *)aScrollView correctedContentSize:(inout CGSize *)aContentSize;
@end
... ...
... ... @@ -15,7 +15,7 @@
- (void)setContentOffset:(CGPoint)contentOffset
{
if (self.mapScrollViewDelegate)
contentOffset = [self.mapScrollViewDelegate scrollView:self correctedOffsetForContentOffset:contentOffset];
[self.mapScrollViewDelegate scrollView:self correctedContentOffset:&contentOffset];
[super setContentOffset:contentOffset];
}
... ... @@ -23,7 +23,7 @@
- (void)setContentOffset:(CGPoint)contentOffset animated:(BOOL)animated
{
if (self.mapScrollViewDelegate)
contentOffset = [self.mapScrollViewDelegate scrollView:self correctedOffsetForContentOffset:contentOffset];
[self.mapScrollViewDelegate scrollView:self correctedContentOffset:&contentOffset];
[super setContentOffset:contentOffset animated:animated];
}
... ... @@ -31,7 +31,7 @@
- (void)setContentSize:(CGSize)contentSize
{
if (self.mapScrollViewDelegate)
contentSize = [self.mapScrollViewDelegate scrollView:self correctedSizeForContentSize:contentSize];
[self.mapScrollViewDelegate scrollView:self correctedContentSize:&contentSize];
[super setContentSize:contentSize];
}
... ...
... ... @@ -1200,16 +1200,16 @@
// Detect dragging/zooming
- (CGPoint)scrollView:(RMMapScrollView *)aScrollView correctedOffsetForContentOffset:(CGPoint)aContentOffset
- (void)scrollView:(RMMapScrollView *)aScrollView correctedContentOffset:(inout CGPoint *)aContentOffset
{
if ( ! _constrainMovement)
return aContentOffset;
return;
RMProjectedRect planetBounds = projection.planetBounds;
double currentMetersPerPixel = planetBounds.size.width / aScrollView.contentSize.width;
CGPoint bottomLeft = CGPointMake(aContentOffset.x,
aScrollView.contentSize.height - (aContentOffset.y + aScrollView.bounds.size.height));
CGPoint bottomLeft = CGPointMake((*aContentOffset).x,
aScrollView.contentSize.height - ((*aContentOffset).y + aScrollView.bounds.size.height));
RMProjectedRect normalizedProjectedRect;
normalizedProjectedRect.origin.x = (bottomLeft.x * currentMetersPerPixel) - fabs(planetBounds.origin.x);
... ... @@ -1218,7 +1218,7 @@
normalizedProjectedRect.size.height = aScrollView.bounds.size.height * currentMetersPerPixel;
if (RMProjectedRectContainsProjectedRect(_constrainingProjectedBounds, normalizedProjectedRect))
return aContentOffset;
return;
RMProjectedRect fittedProjectedRect = [self fitProjectedRect:normalizedProjectedRect intoRect:_constrainingProjectedBounds];
... ... @@ -1228,23 +1228,23 @@
CGPoint correctedContentOffset = CGPointMake(normalizedProjectedPoint.x / currentMetersPerPixel,
aScrollView.contentSize.height - ((normalizedProjectedPoint.y / currentMetersPerPixel) + aScrollView.bounds.size.height));
return correctedContentOffset;
*aContentOffset = correctedContentOffset;
}
- (CGSize)scrollView:(RMMapScrollView *)aScrollView correctedSizeForContentSize:(CGSize)aContentSize
- (void)scrollView:(RMMapScrollView *)aScrollView correctedContentSize:(inout CGSize *)aContentSize
{
if ( ! _constrainMovement)
return aContentSize;
return;
RMProjectedRect planetBounds = projection.planetBounds;
double currentMetersPerPixel = planetBounds.size.width / aContentSize.width;
double currentMetersPerPixel = planetBounds.size.width / (*aContentSize).width;
RMProjectedSize projectedSize;
projectedSize.width = aScrollView.bounds.size.width * currentMetersPerPixel;
projectedSize.height = aScrollView.bounds.size.height * currentMetersPerPixel;
if (RMProjectedSizeContainsProjectedSize(_constrainingProjectedBounds.size, projectedSize))
return aContentSize;
return;
CGFloat factor = 1.0;
if (projectedSize.width > _constrainingProjectedBounds.size.width)
... ... @@ -1255,7 +1255,7 @@
// \bug: Move this to RMMapScrollView
aScrollView.zoomScale *= factor;
return CGSizeMake(aContentSize.width * factor, aContentSize.height * factor);
*aContentSize = CGSizeMake((*aContentSize).width * factor, (*aContentSize).height * factor);
}
- (void)observeValueForKeyPath:(NSString *)aKeyPath ofObject:(id)anObject change:(NSDictionary *)change context:(void *)context
... ...