diff options
-rw-r--r-- | include/mbgl/platform/default/glfw_view.hpp | 1 | ||||
-rw-r--r-- | include/mbgl/platform/default/settings_json.hpp | 1 | ||||
-rw-r--r-- | linux/main.cpp | 10 | ||||
-rw-r--r-- | macosx/main.mm | 2 | ||||
-rw-r--r-- | platform/default/glfw_view.cpp | 8 | ||||
-rw-r--r-- | platform/default/settings_json.cpp | 3 |
6 files changed, 24 insertions, 1 deletions
diff --git a/include/mbgl/platform/default/glfw_view.hpp b/include/mbgl/platform/default/glfw_view.hpp index 17050d64db..a434b71bb1 100644 --- a/include/mbgl/platform/default/glfw_view.hpp +++ b/include/mbgl/platform/default/glfw_view.hpp @@ -65,6 +65,7 @@ private: const bool benchmark = false; bool tracking = false; bool rotating = false; + bool pitching = false; // Frame timer int frames = 0; diff --git a/include/mbgl/platform/default/settings_json.hpp b/include/mbgl/platform/default/settings_json.hpp index 25c2179ba0..154a7e3769 100644 --- a/include/mbgl/platform/default/settings_json.hpp +++ b/include/mbgl/platform/default/settings_json.hpp @@ -15,6 +15,7 @@ public: double latitude = 0; double zoom = 0; double bearing = 0; + double pitch = 0; bool debug = false; }; diff --git a/linux/main.cpp b/linux/main.cpp index 4bc45041d1..97f400dd41 100644 --- a/linux/main.cpp +++ b/linux/main.cpp @@ -35,7 +35,7 @@ int main(int argc, char *argv[]) { bool benchmark = false; std::string style; double latitude = 0, longitude = 0; - double bearing = 0, zoom = 1; + double bearing = 0, zoom = 1, pitch = 0; bool skipConfig = false; const struct option long_options[] = { @@ -46,6 +46,7 @@ int main(int argc, char *argv[]) { {"lat", required_argument, 0, 'y'}, {"zoom", required_argument, 0, 'z'}, {"bearing", required_argument, 0, 'r'}, + {"pitch", required_argument, 0, 'p'}, {0, 0, 0, 0} }; @@ -83,6 +84,10 @@ int main(int argc, char *argv[]) { bearing = atof(optarg); skipConfig = true; break; + case 'p': + pitch = atof(optarg); + skipConfig = true; + break; default: break; } @@ -121,10 +126,12 @@ int main(int argc, char *argv[]) { if (skipConfig) { map.setLatLngZoom(mbgl::LatLng(latitude, longitude), zoom); map.setBearing(bearing); + map.setPitch(pitch); mbgl::Log::Info(mbgl::Event::General, "Location: %f/%f (z%.2f, %.2f deg)", latitude, longitude, zoom, bearing); } else { map.setLatLngZoom(mbgl::LatLng(settings.latitude, settings.longitude), settings.zoom); map.setBearing(settings.bearing); + map.setPitch(settings.pitch); map.setDebug(settings.debug); } @@ -159,6 +166,7 @@ int main(int argc, char *argv[]) { settings.longitude = latLng.longitude; settings.zoom = map.getZoom(); settings.bearing = map.getBearing(); + settings.pitch = map.getPitch(); settings.debug = map.getDebug(); if (!skipConfig) { settings.save(); diff --git a/macosx/main.mm b/macosx/main.mm index fceec13116..264924edcf 100644 --- a/macosx/main.mm +++ b/macosx/main.mm @@ -167,6 +167,7 @@ int main(int argc, char* argv[]) { mbgl::Settings_NSUserDefaults settings; map.setLatLngZoom(mbgl::LatLng(settings.latitude, settings.longitude), settings.zoom); map.setBearing(settings.bearing); + map.setPitch(settings.pitch); map.setDebug(settings.debug); view.setChangeStyleCallback([&map, &view] () { @@ -203,6 +204,7 @@ int main(int argc, char* argv[]) { settings.longitude = latLng.longitude; settings.zoom = map.getZoom(); settings.bearing = map.getBearing(); + settings.pitch = map.getPitch(); settings.debug = map.getDebug(); settings.save(); diff --git a/platform/default/glfw_view.cpp b/platform/default/glfw_view.cpp index 71c808ddb1..c8df32c375 100644 --- a/platform/default/glfw_view.cpp +++ b/platform/default/glfw_view.cpp @@ -305,6 +305,9 @@ void GLFWView::onMouseClick(GLFWwindow *window, int button, int action, int modi (button == GLFW_MOUSE_BUTTON_LEFT && modifiers & GLFW_MOD_CONTROL)) { view->rotating = action == GLFW_PRESS; view->map->setGestureInProgress(view->rotating); + } else if (button == GLFW_MOUSE_BUTTON_LEFT && (modifiers & GLFW_MOD_SHIFT)) { + view->pitching = action == GLFW_PRESS; + view->map->setGestureInProgress(view->pitching); } else if (button == GLFW_MOUSE_BUTTON_LEFT) { view->tracking = action == GLFW_PRESS; view->map->setGestureInProgress(view->tracking); @@ -336,6 +339,11 @@ void GLFWView::onMouseMove(GLFWwindow *window, double x, double y) { } } else if (view->rotating) { view->map->rotateBy({ view->lastX, view->lastY }, { x, y }); + } else if (view->pitching) { + const double dy = y - view->lastY; + if (dy) { + view->map->setPitch(view->map->getPitch() - dy / 2); + } } view->lastX = x; view->lastY = y; diff --git a/platform/default/settings_json.cpp b/platform/default/settings_json.cpp index 9b2ae654a5..8c1c8ff739 100644 --- a/platform/default/settings_json.cpp +++ b/platform/default/settings_json.cpp @@ -12,6 +12,7 @@ void Settings_JSON::load() { file >> latitude; file >> zoom; file >> bearing; + file >> pitch; file >> debug; } } @@ -23,6 +24,7 @@ void Settings_JSON::save() { file << latitude << std::endl; file << zoom << std::endl; file << bearing << std::endl; + file << pitch << std::endl; file << debug << std::endl; } } @@ -32,5 +34,6 @@ void Settings_JSON::clear() { latitude = 0; zoom = 0; bearing = 0; + pitch = 0; debug = false; } |