diff --git a/es-core/src/GuiComponent.h b/es-core/src/GuiComponent.h index 97a06364a..e95987d02 100644 --- a/es-core/src/GuiComponent.h +++ b/es-core/src/GuiComponent.h @@ -251,6 +251,7 @@ public: virtual unsigned int getColorShift() const { return mColorShift; } virtual float getLineSpacing() { return 0.0f; } virtual void setColor(unsigned int color) { mColor = color; } + virtual void setBackgroundColor(unsigned int color) {}; virtual void setColorShift(unsigned int color) { mColorShift = color; diff --git a/es-core/src/ThemeData.cpp b/es-core/src/ThemeData.cpp index 9fe858417..52690673b 100644 --- a/es-core/src/ThemeData.cpp +++ b/es-core/src/ThemeData.cpp @@ -206,6 +206,9 @@ std::map> {"imageColor", COLOR}, {"imageColorEnd", COLOR}, {"imageGradientType", STRING}, + {"imageSelectedColor", COLOR}, + {"imageSelectedColorEnd", COLOR}, + {"imageSelectedGradientType", STRING}, {"imageBrightness", FLOAT}, {"imageSaturation", FLOAT}, {"backgroundImage", PATH}, @@ -223,6 +226,8 @@ std::map> {"textRelativeScale", FLOAT}, {"textColor", COLOR}, {"textBackgroundColor", COLOR}, + {"textSelectedColor", COLOR}, + {"textSelectedBackgroundColor", COLOR}, {"fontPath", PATH}, {"fontSize", FLOAT}, {"letterCase", STRING}, diff --git a/es-core/src/components/TextComponent.h b/es-core/src/components/TextComponent.h index 3db640896..0ae19cab1 100644 --- a/es-core/src/components/TextComponent.h +++ b/es-core/src/components/TextComponent.h @@ -44,7 +44,7 @@ public: void setLineSpacing(float spacing); float getLineSpacing() override { return mLineSpacing; } void setNoTopMargin(bool margin); - void setBackgroundColor(unsigned int color); + void setBackgroundColor(unsigned int color) override; void setRenderBackground(bool render) { mRenderBackground = render; } void render(const glm::mat4& parentTrans) override; diff --git a/es-core/src/components/primary/GridComponent.h b/es-core/src/components/primary/GridComponent.h index adfae0f14..2da859804 100644 --- a/es-core/src/components/primary/GridComponent.h +++ b/es-core/src/components/primary/GridComponent.h @@ -156,6 +156,10 @@ private: unsigned int mImageColor; unsigned int mImageColorEnd; bool mImageColorGradientHorizontal; + unsigned int mImageSelectedColor; + unsigned int mImageSelectedColorEnd; + bool mImageSelectedColorGradientHorizontal; + bool mHasImageSelectedColor; float mImageBrightness; float mImageSaturation; std::unique_ptr mBackgroundImage; @@ -176,6 +180,9 @@ private: float mTextRelativeScale; unsigned int mTextColor; unsigned int mTextBackgroundColor; + unsigned int mTextSelectedColor; + unsigned int mTextSelectedBackgroundColor; + bool mHasTextSelectedColor; std::shared_ptr mFont; LetterCase mLetterCase; LetterCase mLetterCaseAutoCollections; @@ -216,6 +223,10 @@ GridComponent::GridComponent() , mImageColor {0xFFFFFFFF} , mImageColorEnd {0xFFFFFFFF} , mImageColorGradientHorizontal {true} + , mImageSelectedColor {0xFFFFFFFF} + , mImageSelectedColorEnd {0xFFFFFFFF} + , mImageSelectedColorGradientHorizontal {true} + , mHasImageSelectedColor {false} , mImageBrightness {0.0f} , mImageSaturation {1.0f} , mBackgroundRelativeScale {1.0f} @@ -232,6 +243,9 @@ GridComponent::GridComponent() , mTextRelativeScale {1.0f} , mTextColor {0x000000FF} , mTextBackgroundColor {0xFFFFFF00} + , mTextSelectedColor {0x000000FF} + , mTextSelectedBackgroundColor {0xFFFFFF00} + , mHasTextSelectedColor {false} , mLetterCase {LetterCase::NONE} , mLetterCaseAutoCollections {LetterCase::UNDEFINED} , mLetterCaseCustomCollections {LetterCase::UNDEFINED} @@ -289,6 +303,8 @@ void GridComponent::addEntry(Entry& entry, const std::shared_ptr& } else if (entry.data.defaultImagePath != "" && ResourceManager::getInstance().fileExists(entry.data.defaultImagePath)) { + if (!mGamelistView) + entry.data.imagePath = ""; auto defaultImage = std::make_shared(false, dynamic); defaultImage->setLinearInterpolation(true); defaultImage->setMipmapping(true); @@ -317,6 +333,9 @@ void GridComponent::addEntry(Entry& entry, const std::shared_ptr& if (!mGamelistView) entry.data.item = defaultImage; } + else if (!mGamelistView) { + entry.data.imagePath = ""; + } if (!entry.data.item) { // If no item image is present, add item text as fallback. @@ -763,7 +782,37 @@ template void GridComponent::render(const glm::mat4& parentTrans mEntries.at(*it).data.item->setScale(scale); mEntries.at(*it).data.item->setOpacity(opacity); - mEntries.at(*it).data.item->render(trans); + if (cursorEntry && (mHasTextSelectedColor || mHasImageSelectedColor)) { + if (mHasTextSelectedColor && mEntries.at(*it).data.imagePath == "" && + mEntries.at(*it).data.defaultImagePath == "") { + mEntries.at(*it).data.item->setColor(mTextSelectedColor); + mEntries.at(*it).data.item->setBackgroundColor(mTextSelectedBackgroundColor); + mEntries.at(*it).data.item->render(trans); + mEntries.at(*it).data.item->setColor(mTextColor); + mEntries.at(*it).data.item->setBackgroundColor(mTextBackgroundColor); + } + else if (mHasImageSelectedColor) { + mEntries.at(*it).data.item->setColorShift(mImageSelectedColor); + if (mImageSelectedColorEnd != mImageSelectedColor) + mEntries.at(*it).data.item->setColorShiftEnd(mImageSelectedColorEnd); + if (mImageSelectedColorGradientHorizontal != mImageColorGradientHorizontal) + mEntries.at(*it).data.item->setColorGradientHorizontal( + mImageSelectedColorGradientHorizontal); + mEntries.at(*it).data.item->render(trans); + if (mImageSelectedColorGradientHorizontal != mImageColorGradientHorizontal) + mEntries.at(*it).data.item->setColorGradientHorizontal( + mImageColorGradientHorizontal); + mEntries.at(*it).data.item->setColorShift(mImageColor); + if (mImageColorEnd != mImageColor) + mEntries.at(*it).data.item->setColorShiftEnd(mImageColorEnd); + } + else { + mEntries.at(*it).data.item->render(trans); + } + } + else { + mEntries.at(*it).data.item->render(trans); + } mEntries.at(*it).data.item->setScale(1.0f); mEntries.at(*it).data.item->setOpacity(1.0f); @@ -1098,6 +1147,34 @@ void GridComponent::applyTheme(const std::shared_ptr& theme, } } + mImageSelectedColor = mImageColor; + mImageSelectedColorEnd = mImageColorEnd; + + if (elem->has("imageSelectedColor")) { + mImageSelectedColor = elem->get("imageSelectedColor"); + mImageSelectedColorEnd = mImageSelectedColor; + mHasImageSelectedColor = true; + } + if (elem->has("imageSelectedColorEnd")) { + mImageSelectedColorEnd = elem->get("imageSelectedColorEnd"); + mHasImageSelectedColor = true; + } + if (elem->has("imageSelectedGradientType")) { + const std::string& gradientType {elem->get("imageSelectedGradientType")}; + if (gradientType == "horizontal") { + mImageSelectedColorGradientHorizontal = true; + } + else if (gradientType == "vertical") { + mImageSelectedColorGradientHorizontal = false; + } + else { + mImageSelectedColorGradientHorizontal = true; + LOG(LogWarning) << "GridComponent: Invalid theme configuration, property " + "\"imageSelectedGradientType\" for element \"" + << element.substr(5) << "\" defined as \"" << gradientType << "\""; + } + } + if (elem->has("imageBrightness")) mImageBrightness = glm::clamp(elem->get("imageBrightness"), -2.0f, 2.0f); @@ -1117,6 +1194,18 @@ void GridComponent::applyTheme(const std::shared_ptr& theme, if (elem->has("textBackgroundColor")) mTextBackgroundColor = elem->get("textBackgroundColor"); + mTextSelectedColor = mTextColor; + mTextSelectedBackgroundColor = mTextBackgroundColor; + + if (elem->has("textSelectedColor")) { + mTextSelectedColor = elem->get("textSelectedColor"); + mHasTextSelectedColor = true; + } + if (elem->has("textSelectedBackgroundColor")) { + mTextSelectedBackgroundColor = elem->get("textSelectedBackgroundColor"); + mHasTextSelectedColor = true; + } + if (elem->has("lineSpacing")) mLineSpacing = glm::clamp(elem->get("lineSpacing"), 0.5f, 3.0f);