diff options
author | Thiago Marcos P. Santos <thiago@mapbox.com> | 2015-05-06 15:22:43 +0300 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2015-05-07 11:01:15 +0200 |
commit | 168d7c4f171b44b0e3cd4ef78bc4e6b5e8181953 (patch) | |
tree | 9e3af3663f12a58071151e9405c37d04a6ab7976 /platform | |
parent | 0d16110733a38b4e1510dce15d29c0244e7b69b6 (diff) | |
download | qtlocation-mapboxgl-168d7c4f171b44b0e3cd4ef78bc4e6b5e8181953.tar.gz |
Add style change functionality to the Linux test app
Makes the life of people using Linux as development environment way
easier.
Just press 's' to cycle through 3 different styles.
Diffstat (limited to 'platform')
-rw-r--r-- | platform/default/default_styles.cpp | 18 | ||||
-rw-r--r-- | platform/default/default_styles.hpp | 17 | ||||
-rw-r--r-- | platform/default/glfw_view.cpp | 8 |
3 files changed, 43 insertions, 0 deletions
diff --git a/platform/default/default_styles.cpp b/platform/default/default_styles.cpp new file mode 100644 index 0000000000..727636b3c4 --- /dev/null +++ b/platform/default/default_styles.cpp @@ -0,0 +1,18 @@ +#include "default_styles.hpp" + +namespace mbgl { +namespace util { + +const std::vector<std::pair<std::string, std::string>> defaultStyles = { + { "asset://styles/mapbox-streets-v7.json", "Mapbox Streets" }, + { "asset://styles/emerald-v7.json", "Emerald" }, + { "asset://styles/light-v7.json", "Light" }, + { "asset://styles/dark-v7.json", "Dark" }, + { "asset://styles/bright-v7.json", "Bright" }, + { "asset://styles/basic-v7.json", "Basic" }, + { "asset://styles/outdoors-v7.json", "Outdoors" }, + { "asset://styles/satellite-v7.json", "Satellite" }, +}; + +} // end namespace util +} // end namespace mbgl diff --git a/platform/default/default_styles.hpp b/platform/default/default_styles.hpp new file mode 100644 index 0000000000..dc10009305 --- /dev/null +++ b/platform/default/default_styles.hpp @@ -0,0 +1,17 @@ +#ifndef MBGL_PLATFORM_DEFAULT_STYLES +#define MBGL_PLATFORM_DEFAULT_STYLES + +#include <vector> +#include <string> + +namespace mbgl { +namespace util { + +// A list of default styles, with the first string being the URL +// and the second being the user-visible name. +extern const std::vector<std::pair<std::string, std::string>> defaultStyles; + +} // end namespace util +} // end namespace mbgl + +#endif diff --git a/platform/default/glfw_view.cpp b/platform/default/glfw_view.cpp index 56aeaf30a3..bfe1882608 100644 --- a/platform/default/glfw_view.cpp +++ b/platform/default/glfw_view.cpp @@ -179,6 +179,10 @@ void GLFWView::onKey(GLFWwindow *window, int key, int /*scancode*/, int action, if (!mods) view->map->resetPosition(); break; + case GLFW_KEY_S: + if (view->changeStyleCallback) + view->changeStyleCallback(); + break; case GLFW_KEY_R: if (!mods) { view->map->setDefaultTransitionDuration(std::chrono::milliseconds(300)); @@ -306,6 +310,10 @@ void GLFWView::fps() { } } +void GLFWView::setChangeStyleCallback(std::function<void()> callback) { + changeStyleCallback = callback; +} + namespace mbgl { namespace platform { |