diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2014-02-21 11:31:24 +0100 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2014-02-21 11:31:24 +0100 |
commit | d5c611d7076e901b524b0d941b29b1a8180429e3 (patch) | |
tree | 3bf9bbcacb9786629b93213d28daa607f584c35d /macosx | |
parent | a9198570eaeefa97b3a22358e85e338123afbc4a (diff) | |
download | qtlocation-mapboxgl-d5c611d7076e901b524b0d941b29b1a8180429e3.tar.gz |
add timeouts for panning,scaling,rotating
Diffstat (limited to 'macosx')
-rw-r--r-- | macosx/main.mm | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/macosx/main.mm b/macosx/main.mm index ff8e91e338..4eba7e0475 100644 --- a/macosx/main.mm +++ b/macosx/main.mm @@ -5,6 +5,8 @@ #include <llmr/platform/platform.hpp> #include "settings.hpp" +#include <cstdio> + #include <thread> NSString *const MBXNeedsRenderNotification = @"MBXNeedsRenderNotification"; @@ -116,6 +118,7 @@ public: scale = 1.0 / scale; } + mapView->map.startScaling(); mapView->map.scaleBy(scale, mapView->last_x, mapView->last_y); } @@ -138,11 +141,14 @@ public: if (mapView->rotating) { mapView->start_x = mapView->last_x; mapView->start_y = mapView->last_y; + } else { + mapView->map.stopRotating(); } } else if (button == GLFW_MOUSE_BUTTON_LEFT) { mapView->tracking = action == GLFW_PRESS; if (action == GLFW_RELEASE) { + mapView->map.stopPanning(); double now = glfwGetTime(); if (now - mapView->last_click < 0.4) { mapView->map.scaleBy(2.0, mapView->last_x, mapView->last_y); @@ -155,8 +161,14 @@ public: static void mousemove(GLFWwindow *window, double x, double y) { MapView *mapView = (MapView *)glfwGetWindowUserPointer(window); if (mapView->tracking) { - mapView->map.moveBy(x - mapView->last_x, y - mapView->last_y); + double dx = x - mapView->last_x; + double dy = y - mapView->last_y; + if (dx || dy) { + mapView->map.startPanning(); + mapView->map.moveBy(dx, dy); + } } else if (mapView->rotating) { + mapView->map.startRotating(); mapView->map.rotateBy(mapView->start_x, mapView->start_y, mapView->last_x, mapView->last_y, x, y); } mapView->last_x = x; |