From 168d7c4f171b44b0e3cd4ef78bc4e6b5e8181953 Mon Sep 17 00:00:00 2001 From: "Thiago Marcos P. Santos" Date: Wed, 6 May 2015 15:22:43 +0300 Subject: 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. --- platform/default/default_styles.cpp | 18 ++++++++++++++++++ platform/default/default_styles.hpp | 17 +++++++++++++++++ platform/default/glfw_view.cpp | 8 ++++++++ 3 files changed, 43 insertions(+) create mode 100644 platform/default/default_styles.cpp create mode 100644 platform/default/default_styles.hpp (limited to 'platform') 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> 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 +#include + +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> 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 callback) { + changeStyleCallback = callback; +} + namespace mbgl { namespace platform { -- cgit v1.2.1