diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2014-02-21 12:07:46 +0100 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2014-02-21 12:07:46 +0100 |
commit | 1fb44511929d7ddb0f972334bb95ff779cf77481 (patch) | |
tree | 7d9f897d04eba2411303d358ccc7008d75cd5a12 /macosx | |
parent | bd2d865fc474f752b48b88b4b8fd2c8eb307f301 (diff) | |
parent | d5c611d7076e901b524b0d941b29b1a8180429e3 (diff) | |
download | qtlocation-mapboxgl-1fb44511929d7ddb0f972334bb95ff779cf77481.tar.gz |
Merge pull request #68 from mapbox/poi-render
refs #60: first cut of POI rendering
Diffstat (limited to 'macosx')
-rw-r--r-- | macosx/main.mm | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/macosx/main.mm b/macosx/main.mm index 18229f9f4f..1c1d77eeef 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"; @@ -39,8 +41,14 @@ public: glfwSetWindowUserPointer(window, this); glfwMakeContextCurrent(window); + + int width, height; + glfwGetWindowSize(window, &width, &height); + int fb_width, fb_height; + glfwGetFramebufferSize(window, &fb_width, &fb_height); + settings.load(); - map.setup(); + map.setup((double)fb_width / width); resize(window, 0, 0); @@ -110,6 +118,7 @@ public: scale = 1.0 / scale; } + mapView->map.startScaling(); mapView->map.scaleBy(scale, mapView->last_x, mapView->last_y); } @@ -132,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); @@ -149,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; |