diff --git a/es-core/src/ThemeData.cpp b/es-core/src/ThemeData.cpp index e359c5ed5..31d00e395 100644 --- a/es-core/src/ThemeData.cpp +++ b/es-core/src/ThemeData.cpp @@ -468,6 +468,8 @@ std::map> {"verticalAlignment", STRING}, {"color", COLOR}, {"backgroundColor", COLOR}, + {"backgroundMargins", NORMALIZED_PAIR}, + {"backgroundCornerRadius", FLOAT}, {"letterCase", STRING}, {"lineSpacing", FLOAT}, {"format", STRING}, diff --git a/es-core/src/components/DateTimeComponent.cpp b/es-core/src/components/DateTimeComponent.cpp index 6e99ae444..61fcd59bd 100644 --- a/es-core/src/components/DateTimeComponent.cpp +++ b/es-core/src/components/DateTimeComponent.cpp @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT // -// ES-DE +// ES-DE Frontend // DateTimeComponent.cpp // // Provides the date and time, in absolute (actual date) or relative @@ -29,6 +29,7 @@ DateTimeComponent::DateTimeComponent(const std::string& text, glm::vec2 size, unsigned int bgcolor) : TextComponent {text, font, color, horizontalAlignment, ALIGN_CENTER, pos, size, bgcolor} + , mRenderer {Renderer::getInstance()} , mDisplayRelative {false} { // ISO 8601 date format. @@ -153,6 +154,17 @@ void DateTimeComponent::applyTheme(const std::shared_ptr& theme, setRenderBackground(true); } + if (elem->has("backgroundMargins")) { + setBackgroundMargins(glm::clamp(elem->get("backgroundMargins"), 0.0f, 0.5f) * + mRenderer->getScreenWidth()); + } + + if (elem->has("backgroundCornerRadius")) { + setBackgroundCornerRadius( + glm::clamp(elem->get("backgroundCornerRadius"), 0.0f, 0.5f) * + mRenderer->getScreenWidth()); + } + if (properties & ALIGNMENT && elem->has("horizontalAlignment")) { const std::string& horizontalAlignment {elem->get("horizontalAlignment")}; if (horizontalAlignment == "left") diff --git a/es-core/src/components/DateTimeComponent.h b/es-core/src/components/DateTimeComponent.h index a952e7b34..3fb76bb4e 100644 --- a/es-core/src/components/DateTimeComponent.h +++ b/es-core/src/components/DateTimeComponent.h @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT // -// ES-DE +// ES-DE Frontend // DateTimeComponent.h // // Provides the date and time, in absolute (actual date) or relative @@ -48,6 +48,7 @@ protected: private: std::string getDisplayString() const; + Renderer* mRenderer; std::string mDefaultValue; Utils::Time::DateTime mTime; std::string mFormat; diff --git a/es-core/src/components/TextComponent.h b/es-core/src/components/TextComponent.h index 68ff7ece8..a056eea04 100644 --- a/es-core/src/components/TextComponent.h +++ b/es-core/src/components/TextComponent.h @@ -52,6 +52,8 @@ public: void setNoTopMargin(bool margin); void setBackgroundColor(unsigned int color) override; void setRenderBackground(bool render) { mRenderBackground = render; } + void setBackgroundMargins(const glm::vec2 margins) { mBackgroundMargins = margins; } + void setBackgroundCornerRadius(const float radius) { mBackgroundCornerRadius = radius; } void render(const glm::mat4& parentTrans) override; void onFocusLost() override { resetComponent(); }