[glfw] Make P pause/resume the network thread
Simple test of the DefaultFileSource pause/resume API.
This commit is contained in:
committed by
Thiago Marcos P. Santos
parent
4c2e720b15
commit
92e6e48699
@@ -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:
|
||||
|
||||
@@ -27,6 +27,10 @@ public:
|
||||
// The expected action is to set a new style, different to the current one.
|
||||
void setChangeStyleCallback(std::function<void()> callback);
|
||||
|
||||
void setPauseResumeCallback(std::function<void()> callback) {
|
||||
pauseResumeCallback = callback;
|
||||
};
|
||||
|
||||
void setShouldClose();
|
||||
|
||||
void setWindowTitle(const std::string&);
|
||||
@@ -104,6 +108,7 @@ private:
|
||||
double lastClick = -1;
|
||||
|
||||
std::function<void()> changeStyleCallback;
|
||||
std::function<void()> pauseResumeCallback;
|
||||
|
||||
mbgl::util::RunLoop runLoop;
|
||||
mbgl::util::Timer frameTick;
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user