From 7dbe768ffc91859ace1ea1947698be4db6be9701 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20K=C3=A4fer?= Date: Thu, 7 May 2015 10:57:37 +0200 Subject: [PATCH] change the window title to indicate the current style --- include/mbgl/platform/default/glfw_view.hpp | 2 ++ linux/main.cpp | 5 ++++- macosx/main.mm | 4 +++- platform/default/glfw_view.cpp | 4 ++++ 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/include/mbgl/platform/default/glfw_view.hpp b/include/mbgl/platform/default/glfw_view.hpp index 1afb25d14..74dc6fe43 100644 --- a/include/mbgl/platform/default/glfw_view.hpp +++ b/include/mbgl/platform/default/glfw_view.hpp @@ -31,6 +31,8 @@ public: void setShouldClose(); + void setWindowTitle(const std::string&); + void run(); void fps(); diff --git a/linux/main.cpp b/linux/main.cpp index c295eb18e..d279e9d8f 100644 --- a/linux/main.cpp +++ b/linux/main.cpp @@ -87,6 +87,7 @@ int main(int argc, char *argv[]) { const auto& newStyle = mbgl::util::defaultStyles[currentStyleIndex]; map.setStyleURL(newStyle.first); + view->setWindowTitle(newStyle.second); mbgl::Log::Info(mbgl::Event::Setup, std::string("Changed style to: ") + newStyle.first); }); @@ -101,7 +102,9 @@ int main(int argc, char *argv[]) { // Load style if (style.empty()) { - style = mbgl::util::defaultStyles.front().first; + const auto& newStyle = mbgl::util::defaultStyles.front(); + style = newStyle.first; + view->setWindowTitle(newStyle.second); } map.setStyleURL(style); diff --git a/macosx/main.mm b/macosx/main.mm index 7922ee7c0..e5a711753 100644 --- a/macosx/main.mm +++ b/macosx/main.mm @@ -126,7 +126,7 @@ int main() { map.setBearing(settings.bearing); map.setDebug(settings.debug); - view.setChangeStyleCallback([&map] () { + view.setChangeStyleCallback([&map, &view] () { static uint8_t currentStyleIndex; if (++currentStyleIndex == mbgl::util::defaultStyles.size()) { @@ -135,6 +135,7 @@ int main() { const auto& newStyle = mbgl::util::defaultStyles[currentStyleIndex]; map.setStyleURL(newStyle.first); + view.setWindowTitle(newStyle.second); mbgl::Log::Info(mbgl::Event::Setup, std::string("Changed style to: ") + newStyle.first); }); @@ -147,6 +148,7 @@ int main() { // Load style const auto& newStyle = mbgl::util::defaultStyles.front(); map.setStyleURL(newStyle.first); + view.setWindowTitle(newStyle.second); view.run(); diff --git a/platform/default/glfw_view.cpp b/platform/default/glfw_view.cpp index 286be5d8a..789d2d4b6 100644 --- a/platform/default/glfw_view.cpp +++ b/platform/default/glfw_view.cpp @@ -319,6 +319,10 @@ void GLFWView::setShouldClose() { glfwPostEmptyEvent(); } +void GLFWView::setWindowTitle(const std::string& title) { + glfwSetWindowTitle(window, (std::string { "Mapbox GL: " } + title).c_str()); +} + namespace mbgl { namespace platform {