diff options
author | Konstantin Käfer <github@kkaefer.com> | 2014-01-08 18:45:35 +0100 |
---|---|---|
committer | Konstantin Käfer <github@kkaefer.com> | 2014-01-08 18:45:35 +0100 |
commit | a7205b339e8d1c8dee54eaaa38b3efba2df3820e (patch) | |
tree | 17a38bc2e6e20cae926061341431c9a8a9cb3f36 /macosx | |
parent | 04d9d6b9f906fd65a56a6956ed0d648d99713d75 (diff) | |
download | qtlocation-mapboxgl-a7205b339e8d1c8dee54eaaa38b3efba2df3820e.tar.gz |
double click to zoom
Diffstat (limited to 'macosx')
-rw-r--r-- | macosx/main.mm | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/macosx/main.mm b/macosx/main.mm index 549cd2b059..ac3fcdb31f 100644 --- a/macosx/main.mm +++ b/macosx/main.mm @@ -9,6 +9,8 @@ public: MapView() : dirty(true), tracking(false), + rotating(false), + last_click(-1), platform(new llmr::platform(this)), map(new llmr::map(platform)) { if (!glfwInit()) { @@ -72,8 +74,17 @@ public: static void mouseclick(GLFWwindow *window, int button, int action, int modifiers) { MapView *view = (MapView *)glfwGetWindowUserPointer(window); + if (button == GLFW_MOUSE_BUTTON_LEFT) { view->tracking = action == GLFW_PRESS; + + if (action == GLFW_RELEASE) { + double now = glfwGetTime(); + if (now - view->last_click < 0.4) { + view->map->scaleBy(2.0, view->last_x, view->last_y); + } + view->last_click = now; + } } else if (button == GLFW_MOUSE_BUTTON_RIGHT) { view->rotating = action == GLFW_PRESS; if (view->rotating) { @@ -81,6 +92,7 @@ public: view->start_y = view->last_y; } } + } static void mousemove(GLFWwindow *window, double x, double y) { @@ -144,6 +156,8 @@ public: double start_x, start_y; bool rotating; + double last_click; + GLFWwindow *window; llmr::platform *platform; llmr::map *map; |