Authored by Thomas Rasch

o Use pointers for RMScrollView delegate methods

@@ -12,8 +12,8 @@ @@ -12,8 +12,8 @@
12 12
13 @protocol RMMapScrollViewDelegate <NSObject> 13 @protocol RMMapScrollViewDelegate <NSObject>
14 14
15 -- (CGPoint)scrollView:(RMMapScrollView *)aScrollView correctedOffsetForContentOffset:(CGPoint)aContentOffset;  
16 -- (CGSize)scrollView:(RMMapScrollView *)aScrollView correctedSizeForContentSize:(CGSize)aContentSize; 15 +- (void)scrollView:(RMMapScrollView *)aScrollView correctedContentOffset:(inout CGPoint *)aContentOffset;
  16 +- (void)scrollView:(RMMapScrollView *)aScrollView correctedContentSize:(inout CGSize *)aContentSize;
17 17
18 @end 18 @end
19 19
@@ -15,7 +15,7 @@ @@ -15,7 +15,7 @@
15 - (void)setContentOffset:(CGPoint)contentOffset 15 - (void)setContentOffset:(CGPoint)contentOffset
16 { 16 {
17 if (self.mapScrollViewDelegate) 17 if (self.mapScrollViewDelegate)
18 - contentOffset = [self.mapScrollViewDelegate scrollView:self correctedOffsetForContentOffset:contentOffset]; 18 + [self.mapScrollViewDelegate scrollView:self correctedContentOffset:&contentOffset];
19 19
20 [super setContentOffset:contentOffset]; 20 [super setContentOffset:contentOffset];
21 } 21 }
@@ -23,7 +23,7 @@ @@ -23,7 +23,7 @@
23 - (void)setContentOffset:(CGPoint)contentOffset animated:(BOOL)animated 23 - (void)setContentOffset:(CGPoint)contentOffset animated:(BOOL)animated
24 { 24 {
25 if (self.mapScrollViewDelegate) 25 if (self.mapScrollViewDelegate)
26 - contentOffset = [self.mapScrollViewDelegate scrollView:self correctedOffsetForContentOffset:contentOffset]; 26 + [self.mapScrollViewDelegate scrollView:self correctedContentOffset:&contentOffset];
27 27
28 [super setContentOffset:contentOffset animated:animated]; 28 [super setContentOffset:contentOffset animated:animated];
29 } 29 }
@@ -31,7 +31,7 @@ @@ -31,7 +31,7 @@
31 - (void)setContentSize:(CGSize)contentSize 31 - (void)setContentSize:(CGSize)contentSize
32 { 32 {
33 if (self.mapScrollViewDelegate) 33 if (self.mapScrollViewDelegate)
34 - contentSize = [self.mapScrollViewDelegate scrollView:self correctedSizeForContentSize:contentSize]; 34 + [self.mapScrollViewDelegate scrollView:self correctedContentSize:&contentSize];
35 35
36 [super setContentSize:contentSize]; 36 [super setContentSize:contentSize];
37 } 37 }
@@ -1200,16 +1200,16 @@ @@ -1200,16 +1200,16 @@
1200 1200
1201 // Detect dragging/zooming 1201 // Detect dragging/zooming
1202 1202
1203 -- (CGPoint)scrollView:(RMMapScrollView *)aScrollView correctedOffsetForContentOffset:(CGPoint)aContentOffset 1203 +- (void)scrollView:(RMMapScrollView *)aScrollView correctedContentOffset:(inout CGPoint *)aContentOffset
1204 { 1204 {
1205 if ( ! _constrainMovement) 1205 if ( ! _constrainMovement)
1206 - return aContentOffset; 1206 + return;
1207 1207
1208 RMProjectedRect planetBounds = projection.planetBounds; 1208 RMProjectedRect planetBounds = projection.planetBounds;
1209 double currentMetersPerPixel = planetBounds.size.width / aScrollView.contentSize.width; 1209 double currentMetersPerPixel = planetBounds.size.width / aScrollView.contentSize.width;
1210 1210
1211 - CGPoint bottomLeft = CGPointMake(aContentOffset.x,  
1212 - aScrollView.contentSize.height - (aContentOffset.y + aScrollView.bounds.size.height)); 1211 + CGPoint bottomLeft = CGPointMake((*aContentOffset).x,
  1212 + aScrollView.contentSize.height - ((*aContentOffset).y + aScrollView.bounds.size.height));
1213 1213
1214 RMProjectedRect normalizedProjectedRect; 1214 RMProjectedRect normalizedProjectedRect;
1215 normalizedProjectedRect.origin.x = (bottomLeft.x * currentMetersPerPixel) - fabs(planetBounds.origin.x); 1215 normalizedProjectedRect.origin.x = (bottomLeft.x * currentMetersPerPixel) - fabs(planetBounds.origin.x);
@@ -1218,7 +1218,7 @@ @@ -1218,7 +1218,7 @@
1218 normalizedProjectedRect.size.height = aScrollView.bounds.size.height * currentMetersPerPixel; 1218 normalizedProjectedRect.size.height = aScrollView.bounds.size.height * currentMetersPerPixel;
1219 1219
1220 if (RMProjectedRectContainsProjectedRect(_constrainingProjectedBounds, normalizedProjectedRect)) 1220 if (RMProjectedRectContainsProjectedRect(_constrainingProjectedBounds, normalizedProjectedRect))
1221 - return aContentOffset; 1221 + return;
1222 1222
1223 RMProjectedRect fittedProjectedRect = [self fitProjectedRect:normalizedProjectedRect intoRect:_constrainingProjectedBounds]; 1223 RMProjectedRect fittedProjectedRect = [self fitProjectedRect:normalizedProjectedRect intoRect:_constrainingProjectedBounds];
1224 1224
@@ -1228,23 +1228,23 @@ @@ -1228,23 +1228,23 @@
1228 1228
1229 CGPoint correctedContentOffset = CGPointMake(normalizedProjectedPoint.x / currentMetersPerPixel, 1229 CGPoint correctedContentOffset = CGPointMake(normalizedProjectedPoint.x / currentMetersPerPixel,
1230 aScrollView.contentSize.height - ((normalizedProjectedPoint.y / currentMetersPerPixel) + aScrollView.bounds.size.height)); 1230 aScrollView.contentSize.height - ((normalizedProjectedPoint.y / currentMetersPerPixel) + aScrollView.bounds.size.height));
1231 - return correctedContentOffset; 1231 + *aContentOffset = correctedContentOffset;
1232 } 1232 }
1233 1233
1234 -- (CGSize)scrollView:(RMMapScrollView *)aScrollView correctedSizeForContentSize:(CGSize)aContentSize 1234 +- (void)scrollView:(RMMapScrollView *)aScrollView correctedContentSize:(inout CGSize *)aContentSize
1235 { 1235 {
1236 if ( ! _constrainMovement) 1236 if ( ! _constrainMovement)
1237 - return aContentSize; 1237 + return;
1238 1238
1239 RMProjectedRect planetBounds = projection.planetBounds; 1239 RMProjectedRect planetBounds = projection.planetBounds;
1240 - double currentMetersPerPixel = planetBounds.size.width / aContentSize.width; 1240 + double currentMetersPerPixel = planetBounds.size.width / (*aContentSize).width;
1241 1241
1242 RMProjectedSize projectedSize; 1242 RMProjectedSize projectedSize;
1243 projectedSize.width = aScrollView.bounds.size.width * currentMetersPerPixel; 1243 projectedSize.width = aScrollView.bounds.size.width * currentMetersPerPixel;
1244 projectedSize.height = aScrollView.bounds.size.height * currentMetersPerPixel; 1244 projectedSize.height = aScrollView.bounds.size.height * currentMetersPerPixel;
1245 1245
1246 if (RMProjectedSizeContainsProjectedSize(_constrainingProjectedBounds.size, projectedSize)) 1246 if (RMProjectedSizeContainsProjectedSize(_constrainingProjectedBounds.size, projectedSize))
1247 - return aContentSize; 1247 + return;
1248 1248
1249 CGFloat factor = 1.0; 1249 CGFloat factor = 1.0;
1250 if (projectedSize.width > _constrainingProjectedBounds.size.width) 1250 if (projectedSize.width > _constrainingProjectedBounds.size.width)
@@ -1255,7 +1255,7 @@ @@ -1255,7 +1255,7 @@
1255 // \bug: Move this to RMMapScrollView 1255 // \bug: Move this to RMMapScrollView
1256 aScrollView.zoomScale *= factor; 1256 aScrollView.zoomScale *= factor;
1257 1257
1258 - return CGSizeMake(aContentSize.width * factor, aContentSize.height * factor); 1258 + *aContentSize = CGSizeMake((*aContentSize).width * factor, (*aContentSize).height * factor);
1259 } 1259 }
1260 1260
1261 - (void)observeValueForKeyPath:(NSString *)aKeyPath ofObject:(id)anObject change:(NSDictionary *)change context:(void *)context 1261 - (void)observeValueForKeyPath:(NSString *)aKeyPath ofObject:(id)anObject change:(NSDictionary *)change context:(void *)context