From 3e54c59656429ed4f7f666a6c16d57853443e6f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Thu, 3 Jul 2014 19:39:45 +0200 Subject: [PATCH] add applied classes api --- include/llmr/map/map.hpp | 1 + include/llmr/style/style.hpp | 1 + src/map/map.cpp | 8 ++++++++ src/style/style.cpp | 5 +++++ 4 files changed, 15 insertions(+) diff --git a/include/llmr/map/map.hpp b/include/llmr/map/map.hpp index 75090f941..0f359b1a5 100644 --- a/include/llmr/map/map.hpp +++ b/include/llmr/map/map.hpp @@ -52,6 +52,7 @@ public: void resize(uint16_t width, uint16_t height, float ratio, uint16_t fb_width, uint16_t fb_height); // Styling + void setAppliedClasses(const std::vector &classes); void toggleClass(const std::string &name); const std::vector &getAppliedClasses() const; void setDefaultTransitionDuration(uint64_t duration_milliseconds = 0); diff --git a/include/llmr/style/style.hpp b/include/llmr/style/style.hpp index dcdfa36bc..c92e95a7f 100644 --- a/include/llmr/style/style.hpp +++ b/include/llmr/style/style.hpp @@ -37,6 +37,7 @@ public: const std::set> getActiveSources() const; + void setAppliedClasses(const std::vector &classes); const std::vector &getAppliedClasses() const; void toggleClass(const std::string &name); diff --git a/src/map/map.cpp b/src/map/map.cpp index 50c172caa..5aa69b287 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -378,6 +378,14 @@ bool Map::getDebug() const { return debug; } +void Map::setAppliedClasses(const std::vector &classes) { + style->setAppliedClasses(classes); + if (style->hasTransitions()) { + update(); + } +} + + void Map::toggleClass(const std::string &name) { style->toggleClass(name); if (style->hasTransitions()) { diff --git a/src/style/style.cpp b/src/style/style.cpp index b11cd9226..6092280af 100644 --- a/src/style/style.cpp +++ b/src/style/style.cpp @@ -63,6 +63,11 @@ const std::vector &Style::getAppliedClasses() const { return appliedClasses; } +void Style::setAppliedClasses(const std::vector &classes) { + appliedClasses = classes; + updateClasses(); +} + void Style::toggleClass(const std::string &name) { if (name.length()) { auto it = std::find(appliedClasses.begin(), appliedClasses.end(), name);