Conflicts:
	src/map/transform.cpp
This commit is contained in:
Konstantin Käfer
2014-02-07 16:10:00 +01:00
5 changed files with 32 additions and 8 deletions

View File

@@ -32,7 +32,7 @@ public:
void tileFailed(std::shared_ptr<Tile> tile);
/* position */
void moveBy(double dx, double dy);
void moveBy(double dx, double dy, double duration = 0);
// void setLonLat(double lon, double lat);
void resetPosition();

View File

@@ -22,7 +22,7 @@ public:
void cancelAnimations();
// Relative changes
void moveBy(double dx, double dy);
void moveBy(double dx, double dy, double duration = 0);
void scaleBy(double ds, double cx = -1, double cy = -1, double duration = 0);
void rotateBy(double cx, double cy, double sx, double sy, double ex, double ey);

View File

@@ -22,6 +22,7 @@
@property (nonatomic) CGPoint center;
@property (nonatomic) CGFloat scale;
@property (nonatomic) CGFloat angle;
@property (nonatomic) BOOL debug;
@end
@@ -127,7 +128,9 @@ class MBXMapView
if (current - elapsed >= 1)
{
NSLog(@"FPS: %f", frames / (current - elapsed));
if (self.debug)
NSLog(@"FPS: %f", frames / (current - elapsed));
elapsed = current;
frames = 0;
}
@@ -148,6 +151,18 @@ class MBXMapView
self.center = CGPointMake(self.center.x + delta.x, self.center.y + delta.y);
}
else if (pan.state == UIGestureRecognizerStateEnded)
{
if ([pan velocityInView:pan.view].x < 50 && [pan velocityInView:pan.view].y < 50)
return;
CGPoint finalCenter = CGPointMake(self.center.x + (0.1 * [pan velocityInView:pan.view].x),
self.center.y + (0.1 * [pan velocityInView:pan.view].y));
CGFloat duration = ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad ? 0.3 : 0.5);
mapView->map.moveBy(finalCenter.x - self.center.x, finalCenter.y - self.center.y, duration);
}
}
- (void)handlePinchGesture:(UIPinchGestureRecognizer *)pinch
@@ -215,7 +230,11 @@ class MBXMapView
- (void)handleThreeFingerLongPressGesture:(UILongPressGestureRecognizer *)threeFingerLongPress
{
if (threeFingerLongPress.state == UIGestureRecognizerStateBegan)
{
mapView->map.toggleDebug();
self.debug = ! self.debug;
}
}
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer

View File

@@ -57,8 +57,8 @@ void Map::resize(uint32_t width, uint32_t height, uint32_t fb_width, uint32_t fb
update();
}
void Map::moveBy(double dx, double dy) {
transform.moveBy(dx, dy);
void Map::moveBy(double dx, double dy, double duration) {
transform.moveBy(dx, dy, duration);
update();
transform.getLonLat(settings.longitude, settings.latitude);

View File

@@ -32,9 +32,14 @@ void Transform::cancelAnimations() {
animations.clear();
}
void Transform::moveBy(double dx, double dy) {
x += cos(angle) * dx + sin(angle) * dy;
y += cos(angle) * dy + sin(-angle) * dx;
void Transform::moveBy(double dx, double dy, double duration) {
if (duration == 0) {
x += cos(angle) * dx + sin(angle) * dy;
y += cos(angle) * dy + sin(-angle) * dx;
} else {
animations.emplace_front(x, x + cos(angle) * dx + sin(angle) * dy, x, duration);
animations.emplace_front(y, y + cos(angle) * dy + sin(-angle) * dx, y, duration);
}
}
void Transform::scaleBy(double ds, double cx, double cy, double duration) {