From 8c9d9d51fc8b64374d0ea73b493434a236e81e21 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Sun, 24 Nov 2024 14:38:54 +0100 Subject: [PATCH] Added a 'textBackgroundCornerRadius' property to the carousel element --- es-core/src/ThemeData.cpp | 1 + es-core/src/components/primary/CarouselComponent.h | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/es-core/src/ThemeData.cpp b/es-core/src/ThemeData.cpp index 23c4013a7..1c3fc752b 100644 --- a/es-core/src/ThemeData.cpp +++ b/es-core/src/ThemeData.cpp @@ -186,6 +186,7 @@ std::map> {"gradientType", STRING}, {"text", STRING}, {"textRelativeScale", FLOAT}, + {"textBackgroundCornerRadius", FLOAT}, {"textColor", COLOR}, {"textBackgroundColor", COLOR}, {"textSelectedColor", COLOR}, diff --git a/es-core/src/components/primary/CarouselComponent.h b/es-core/src/components/primary/CarouselComponent.h index 49d784ad7..8f225591c 100644 --- a/es-core/src/components/primary/CarouselComponent.h +++ b/es-core/src/components/primary/CarouselComponent.h @@ -198,6 +198,7 @@ private: unsigned int mCarouselColorEnd; bool mColorGradientHorizontal; float mTextRelativeScale; + float mTextBackgroundCornerRadius; unsigned int mTextColor; unsigned int mTextBackgroundColor; unsigned int mTextSelectedColor; @@ -276,6 +277,7 @@ CarouselComponent::CarouselComponent() , mCarouselColorEnd {0} , mColorGradientHorizontal {true} , mTextRelativeScale {1.0f} + , mTextBackgroundCornerRadius {0.0f} , mTextColor {0x000000FF} , mTextBackgroundColor {0xFFFFFF00} , mTextSelectedColor {0x000000FF} @@ -386,6 +388,7 @@ void CarouselComponent::addEntry(Entry& entry, const std::shared_ptrsetValue(entry.name); + text->setBackgroundCornerRadius(mTextBackgroundCornerRadius); text->setColor(mTextColor); text->setBackgroundColor(mTextBackgroundColor); text->setRenderBackground(true); @@ -1708,6 +1711,12 @@ void CarouselComponent::applyTheme(const std::shared_ptr& theme, if (elem->has("textRelativeScale")) mTextRelativeScale = glm::clamp(elem->get("textRelativeScale"), 0.2f, 1.0f); + if (elem->has("textBackgroundCornerRadius")) { + mTextBackgroundCornerRadius = + glm::clamp(elem->get("textBackgroundCornerRadius"), 0.0f, 0.5f) * + (mItemScale >= 1.0f ? mItemScale : 1.0f) * mRenderer->getScreenWidth(); + } + if (elem->has("textColor")) mTextColor = elem->get("textColor"); if (elem->has("textBackgroundColor"))