diff --git a/platform/glfw/glfw_view.cpp b/platform/glfw/glfw_view.cpp index 3c6ea1ded..15a229d4a 100644 --- a/platform/glfw/glfw_view.cpp +++ b/platform/glfw/glfw_view.cpp @@ -109,10 +109,11 @@ GLFWView::GLFWView(bool fullscreen_, bool benchmark_) printf("- Press `7` through `0` to add increasing numbers of shape annotations for testing\n"); printf("\n"); printf("- Press `Q` to remove annotations\n"); - printf("- Press `P` to add a random custom runtime imagery annotation\n"); + printf("- Press `K` to add a random custom runtime imagery annotation\n"); printf("- Press `L` to add a random line annotation\n"); printf("- Press `W` to pop the last-added annotation off\n"); printf("\n"); + printf("- Press `P` to pause tile requests\n"); printf("- `Control` + mouse drag to rotate\n"); printf("- `Shift` + mouse drag to tilt\n"); printf("\n"); @@ -200,10 +201,13 @@ void GLFWView::onKey(GLFWwindow *window, int key, int /*scancode*/, int action, auto result = view->map->queryPointAnnotations({ {}, { double(view->getSize().width), double(view->getSize().height) } }); printf("visible point annotations: %lu\n", result.size()); } break; + case GLFW_KEY_P: + view->pauseResumeCallback(); + break; case GLFW_KEY_C: view->clearAnnotations(); break; - case GLFW_KEY_P: + case GLFW_KEY_K: view->addRandomCustomPointAnnotations(1); break; case GLFW_KEY_L: diff --git a/platform/glfw/glfw_view.hpp b/platform/glfw/glfw_view.hpp index 835a73b54..a426e58a9 100644 --- a/platform/glfw/glfw_view.hpp +++ b/platform/glfw/glfw_view.hpp @@ -27,6 +27,10 @@ public: // The expected action is to set a new style, different to the current one. void setChangeStyleCallback(std::function callback); + void setPauseResumeCallback(std::function callback) { + pauseResumeCallback = callback; + }; + void setShouldClose(); void setWindowTitle(const std::string&); @@ -104,6 +108,7 @@ private: double lastClick = -1; std::function changeStyleCallback; + std::function pauseResumeCallback; mbgl::util::RunLoop runLoop; mbgl::util::Timer frameTick; diff --git a/platform/glfw/main.cpp b/platform/glfw/main.cpp index 1f683b185..fbfba0b7f 100644 --- a/platform/glfw/main.cpp +++ b/platform/glfw/main.cpp @@ -153,6 +153,18 @@ int main(int argc, char *argv[]) { mbgl::Log::Info(mbgl::Event::Setup, "Changed style to: %s", newStyle.name); }); + view->setPauseResumeCallback([&fileSource] () { + static bool isPaused = false; + + if (isPaused) { + fileSource.resume(); + } else { + fileSource.pause(); + } + + isPaused = !isPaused; + }); + // Load style if (style.empty()) { const char *url = getenv("MAPBOX_STYLE_URL");