change the window title to indicate the current style
This commit is contained in:
@@ -31,6 +31,8 @@ public:
|
||||
|
||||
void setShouldClose();
|
||||
|
||||
void setWindowTitle(const std::string&);
|
||||
|
||||
void run();
|
||||
void fps();
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user