diff --git a/es-core/src/ThemeData.cpp b/es-core/src/ThemeData.cpp index 568c5c01e..6b1f40af1 100644 --- a/es-core/src/ThemeData.cpp +++ b/es-core/src/ThemeData.cpp @@ -133,6 +133,7 @@ std::map> {"imageColor", COLOR}, {"imageColorEnd", COLOR}, {"imageGradientType", STRING}, + {"imageSaturation", FLOAT}, {"itemTransitions", STRING}, {"itemHorizontalAlignment", STRING}, {"itemVerticalAlignment", STRING}, @@ -184,6 +185,7 @@ std::map> {"imageColor", COLOR}, {"imageColorEnd", COLOR}, {"imageGradientType", STRING}, + {"imageSaturation", FLOAT}, {"backgroundImage", PATH}, {"backgroundRelativeScale", FLOAT}, {"backgroundColor", COLOR}, diff --git a/es-core/src/components/primary/CarouselComponent.h b/es-core/src/components/primary/CarouselComponent.h index f8056084c..6d2467fe9 100644 --- a/es-core/src/components/primary/CarouselComponent.h +++ b/es-core/src/components/primary/CarouselComponent.h @@ -147,6 +147,7 @@ private: unsigned int mImageColorShift; unsigned int mImageColorShiftEnd; bool mImageColorGradientHorizontal; + float mImageSaturation; bool mInstantItemTransitions; Alignment mItemHorizontalAlignment; Alignment mItemVerticalAlignment; @@ -199,6 +200,7 @@ CarouselComponent::CarouselComponent() , mImageColorShift {0xFFFFFFFF} , mImageColorShiftEnd {0xFFFFFFFF} , mImageColorGradientHorizontal {true} + , mImageSaturation {1.0f} , mInstantItemTransitions {false} , mItemHorizontalAlignment {ALIGN_CENTER} , mItemVerticalAlignment {ALIGN_CENTER} @@ -263,6 +265,8 @@ void CarouselComponent::addEntry(Entry& entry, const std::shared_ptrsetMaxSize(glm::round(mItemSize * (mItemScale >= 1.0f ? mItemScale : 1.0f))); item->setImage(entry.data.imagePath); item->applyTheme(theme, "system", "", ThemeFlags::ALL); + if (mImageSaturation != 1.0) + item->setSaturation(mImageSaturation); if (mImageColorShift != 0xFFFFFFFF) item->setColorShift(mImageColorShift); if (mImageColorShiftEnd != mImageColorShift) @@ -281,6 +285,8 @@ void CarouselComponent::addEntry(Entry& entry, const std::shared_ptr= 1.0f ? mItemScale : 1.0f))); defaultImage->setImage(entry.data.defaultImagePath); defaultImage->applyTheme(theme, "system", "", ThemeFlags::ALL); + if (mImageSaturation != 1.0) + defaultImage->setSaturation(mImageSaturation); if (mImageColorShift != 0xFFFFFFFF) defaultImage->setColorShift(mImageColorShift); if (mImageColorShiftEnd != mImageColorShift) @@ -348,6 +354,8 @@ void CarouselComponent::updateEntry(Entry& entry, const std::shared_ptrsetMaxSize(glm::round(mItemSize * (mItemScale >= 1.0f ? mItemScale : 1.0f))); item->setImage(entry.data.imagePath); item->applyTheme(theme, "system", "", ThemeFlags::ALL); + if (mImageSaturation != 1.0) + item->setSaturation(mImageSaturation); if (mImageColorShift != 0xFFFFFFFF) item->setColorShift(mImageColorShift); if (mImageColorShiftEnd != mImageColorShift) @@ -1116,6 +1124,9 @@ void CarouselComponent::applyTheme(const std::shared_ptr& theme, } } + if (elem->has("imageSaturation")) + mImageSaturation = glm::clamp(elem->get("imageSaturation"), 0.0f, 1.0f); + if (elem->has("imageInterpolation")) { const std::string& imageInterpolation {elem->get("imageInterpolation")}; if (imageInterpolation == "linear") { diff --git a/es-core/src/components/primary/GridComponent.h b/es-core/src/components/primary/GridComponent.h index 2a09cbce9..a9b4c48ca 100644 --- a/es-core/src/components/primary/GridComponent.h +++ b/es-core/src/components/primary/GridComponent.h @@ -148,6 +148,7 @@ private: unsigned int mImageColor; unsigned int mImageColorEnd; bool mImageColorGradientHorizontal; + float mImageSaturation; std::unique_ptr mBackgroundImage; std::string mBackgroundImagePath; float mBackgroundRelativeScale; @@ -204,6 +205,7 @@ GridComponent::GridComponent() , mImageColor {0xFFFFFFFF} , mImageColorEnd {0xFFFFFFFF} , mImageColorGradientHorizontal {true} + , mImageSaturation {1.0f} , mBackgroundRelativeScale {1.0f} , mBackgroundColor {0xFFFFFFFF} , mBackgroundColorEnd {0xFFFFFFFF} @@ -256,6 +258,8 @@ void GridComponent::addEntry(Entry& entry, const std::shared_ptr& item->setCroppedSize(mItemSize * mImageRelativeScale); item->setImage(entry.data.imagePath); item->applyTheme(theme, "system", "", ThemeFlags::ALL); + if (mImageSaturation != 1.0) + item->setSaturation(mImageSaturation); if (mImageColor != 0xFFFFFFFF) item->setColorShift(mImageColor); if (mImageColorEnd != mImageColor) { @@ -280,6 +284,8 @@ void GridComponent::addEntry(Entry& entry, const std::shared_ptr& defaultImage->setCroppedSize(mItemSize * mImageRelativeScale); defaultImage->setImage(entry.data.defaultImagePath); defaultImage->applyTheme(theme, "system", "", ThemeFlags::ALL); + if (mImageSaturation != 1.0) + defaultImage->setSaturation(mImageSaturation); if (mImageColor != 0xFFFFFFFF) defaultImage->setColorShift(mImageColor); if (mImageColorEnd != mImageColor) { @@ -329,6 +335,8 @@ void GridComponent::updateEntry(Entry& entry, const std::shared_ptrsetCroppedSize(mItemSize * mImageRelativeScale); item->setImage(entry.data.imagePath); item->applyTheme(theme, "system", "", ThemeFlags::ALL); + if (mImageSaturation != 1.0) + item->setSaturation(mImageSaturation); if (mImageColor != 0xFFFFFFFF) item->setColorShift(mImageColor); if (mImageColorEnd != mImageColor) { @@ -1019,6 +1027,9 @@ void GridComponent::applyTheme(const std::shared_ptr& theme, } } + if (elem->has("imageSaturation")) + mImageSaturation = glm::clamp(elem->get("imageSaturation"), 0.0f, 1.0f); + if (elem->has("unfocusedItemOpacity")) mUnfocusedItemOpacity = glm::clamp(elem->get("unfocusedItemOpacity"), 0.1f, 1.0f);