mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-01-17 22:55:38 +00:00
Added support to GridComponent for color shifting the selected item.
This commit is contained in:
parent
6b45cdb0f8
commit
66b416d718
|
@ -251,6 +251,7 @@ public:
|
||||||
virtual unsigned int getColorShift() const { return mColorShift; }
|
virtual unsigned int getColorShift() const { return mColorShift; }
|
||||||
virtual float getLineSpacing() { return 0.0f; }
|
virtual float getLineSpacing() { return 0.0f; }
|
||||||
virtual void setColor(unsigned int color) { mColor = color; }
|
virtual void setColor(unsigned int color) { mColor = color; }
|
||||||
|
virtual void setBackgroundColor(unsigned int color) {};
|
||||||
virtual void setColorShift(unsigned int color)
|
virtual void setColorShift(unsigned int color)
|
||||||
{
|
{
|
||||||
mColorShift = color;
|
mColorShift = color;
|
||||||
|
|
|
@ -206,6 +206,9 @@ std::map<std::string, std::map<std::string, ThemeData::ElementPropertyType>>
|
||||||
{"imageColor", COLOR},
|
{"imageColor", COLOR},
|
||||||
{"imageColorEnd", COLOR},
|
{"imageColorEnd", COLOR},
|
||||||
{"imageGradientType", STRING},
|
{"imageGradientType", STRING},
|
||||||
|
{"imageSelectedColor", COLOR},
|
||||||
|
{"imageSelectedColorEnd", COLOR},
|
||||||
|
{"imageSelectedGradientType", STRING},
|
||||||
{"imageBrightness", FLOAT},
|
{"imageBrightness", FLOAT},
|
||||||
{"imageSaturation", FLOAT},
|
{"imageSaturation", FLOAT},
|
||||||
{"backgroundImage", PATH},
|
{"backgroundImage", PATH},
|
||||||
|
@ -223,6 +226,8 @@ std::map<std::string, std::map<std::string, ThemeData::ElementPropertyType>>
|
||||||
{"textRelativeScale", FLOAT},
|
{"textRelativeScale", FLOAT},
|
||||||
{"textColor", COLOR},
|
{"textColor", COLOR},
|
||||||
{"textBackgroundColor", COLOR},
|
{"textBackgroundColor", COLOR},
|
||||||
|
{"textSelectedColor", COLOR},
|
||||||
|
{"textSelectedBackgroundColor", COLOR},
|
||||||
{"fontPath", PATH},
|
{"fontPath", PATH},
|
||||||
{"fontSize", FLOAT},
|
{"fontSize", FLOAT},
|
||||||
{"letterCase", STRING},
|
{"letterCase", STRING},
|
||||||
|
|
|
@ -44,7 +44,7 @@ public:
|
||||||
void setLineSpacing(float spacing);
|
void setLineSpacing(float spacing);
|
||||||
float getLineSpacing() override { return mLineSpacing; }
|
float getLineSpacing() override { return mLineSpacing; }
|
||||||
void setNoTopMargin(bool margin);
|
void setNoTopMargin(bool margin);
|
||||||
void setBackgroundColor(unsigned int color);
|
void setBackgroundColor(unsigned int color) override;
|
||||||
void setRenderBackground(bool render) { mRenderBackground = render; }
|
void setRenderBackground(bool render) { mRenderBackground = render; }
|
||||||
|
|
||||||
void render(const glm::mat4& parentTrans) override;
|
void render(const glm::mat4& parentTrans) override;
|
||||||
|
|
|
@ -156,6 +156,10 @@ private:
|
||||||
unsigned int mImageColor;
|
unsigned int mImageColor;
|
||||||
unsigned int mImageColorEnd;
|
unsigned int mImageColorEnd;
|
||||||
bool mImageColorGradientHorizontal;
|
bool mImageColorGradientHorizontal;
|
||||||
|
unsigned int mImageSelectedColor;
|
||||||
|
unsigned int mImageSelectedColorEnd;
|
||||||
|
bool mImageSelectedColorGradientHorizontal;
|
||||||
|
bool mHasImageSelectedColor;
|
||||||
float mImageBrightness;
|
float mImageBrightness;
|
||||||
float mImageSaturation;
|
float mImageSaturation;
|
||||||
std::unique_ptr<ImageComponent> mBackgroundImage;
|
std::unique_ptr<ImageComponent> mBackgroundImage;
|
||||||
|
@ -176,6 +180,9 @@ private:
|
||||||
float mTextRelativeScale;
|
float mTextRelativeScale;
|
||||||
unsigned int mTextColor;
|
unsigned int mTextColor;
|
||||||
unsigned int mTextBackgroundColor;
|
unsigned int mTextBackgroundColor;
|
||||||
|
unsigned int mTextSelectedColor;
|
||||||
|
unsigned int mTextSelectedBackgroundColor;
|
||||||
|
bool mHasTextSelectedColor;
|
||||||
std::shared_ptr<Font> mFont;
|
std::shared_ptr<Font> mFont;
|
||||||
LetterCase mLetterCase;
|
LetterCase mLetterCase;
|
||||||
LetterCase mLetterCaseAutoCollections;
|
LetterCase mLetterCaseAutoCollections;
|
||||||
|
@ -216,6 +223,10 @@ GridComponent<T>::GridComponent()
|
||||||
, mImageColor {0xFFFFFFFF}
|
, mImageColor {0xFFFFFFFF}
|
||||||
, mImageColorEnd {0xFFFFFFFF}
|
, mImageColorEnd {0xFFFFFFFF}
|
||||||
, mImageColorGradientHorizontal {true}
|
, mImageColorGradientHorizontal {true}
|
||||||
|
, mImageSelectedColor {0xFFFFFFFF}
|
||||||
|
, mImageSelectedColorEnd {0xFFFFFFFF}
|
||||||
|
, mImageSelectedColorGradientHorizontal {true}
|
||||||
|
, mHasImageSelectedColor {false}
|
||||||
, mImageBrightness {0.0f}
|
, mImageBrightness {0.0f}
|
||||||
, mImageSaturation {1.0f}
|
, mImageSaturation {1.0f}
|
||||||
, mBackgroundRelativeScale {1.0f}
|
, mBackgroundRelativeScale {1.0f}
|
||||||
|
@ -232,6 +243,9 @@ GridComponent<T>::GridComponent()
|
||||||
, mTextRelativeScale {1.0f}
|
, mTextRelativeScale {1.0f}
|
||||||
, mTextColor {0x000000FF}
|
, mTextColor {0x000000FF}
|
||||||
, mTextBackgroundColor {0xFFFFFF00}
|
, mTextBackgroundColor {0xFFFFFF00}
|
||||||
|
, mTextSelectedColor {0x000000FF}
|
||||||
|
, mTextSelectedBackgroundColor {0xFFFFFF00}
|
||||||
|
, mHasTextSelectedColor {false}
|
||||||
, mLetterCase {LetterCase::NONE}
|
, mLetterCase {LetterCase::NONE}
|
||||||
, mLetterCaseAutoCollections {LetterCase::UNDEFINED}
|
, mLetterCaseAutoCollections {LetterCase::UNDEFINED}
|
||||||
, mLetterCaseCustomCollections {LetterCase::UNDEFINED}
|
, mLetterCaseCustomCollections {LetterCase::UNDEFINED}
|
||||||
|
@ -289,6 +303,8 @@ void GridComponent<T>::addEntry(Entry& entry, const std::shared_ptr<ThemeData>&
|
||||||
}
|
}
|
||||||
else if (entry.data.defaultImagePath != "" &&
|
else if (entry.data.defaultImagePath != "" &&
|
||||||
ResourceManager::getInstance().fileExists(entry.data.defaultImagePath)) {
|
ResourceManager::getInstance().fileExists(entry.data.defaultImagePath)) {
|
||||||
|
if (!mGamelistView)
|
||||||
|
entry.data.imagePath = "";
|
||||||
auto defaultImage = std::make_shared<ImageComponent>(false, dynamic);
|
auto defaultImage = std::make_shared<ImageComponent>(false, dynamic);
|
||||||
defaultImage->setLinearInterpolation(true);
|
defaultImage->setLinearInterpolation(true);
|
||||||
defaultImage->setMipmapping(true);
|
defaultImage->setMipmapping(true);
|
||||||
|
@ -317,6 +333,9 @@ void GridComponent<T>::addEntry(Entry& entry, const std::shared_ptr<ThemeData>&
|
||||||
if (!mGamelistView)
|
if (!mGamelistView)
|
||||||
entry.data.item = defaultImage;
|
entry.data.item = defaultImage;
|
||||||
}
|
}
|
||||||
|
else if (!mGamelistView) {
|
||||||
|
entry.data.imagePath = "";
|
||||||
|
}
|
||||||
|
|
||||||
if (!entry.data.item) {
|
if (!entry.data.item) {
|
||||||
// If no item image is present, add item text as fallback.
|
// If no item image is present, add item text as fallback.
|
||||||
|
@ -763,7 +782,37 @@ template <typename T> void GridComponent<T>::render(const glm::mat4& parentTrans
|
||||||
|
|
||||||
mEntries.at(*it).data.item->setScale(scale);
|
mEntries.at(*it).data.item->setScale(scale);
|
||||||
mEntries.at(*it).data.item->setOpacity(opacity);
|
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->setScale(1.0f);
|
||||||
mEntries.at(*it).data.item->setOpacity(1.0f);
|
mEntries.at(*it).data.item->setOpacity(1.0f);
|
||||||
|
|
||||||
|
@ -1098,6 +1147,34 @@ void GridComponent<T>::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mImageSelectedColor = mImageColor;
|
||||||
|
mImageSelectedColorEnd = mImageColorEnd;
|
||||||
|
|
||||||
|
if (elem->has("imageSelectedColor")) {
|
||||||
|
mImageSelectedColor = elem->get<unsigned int>("imageSelectedColor");
|
||||||
|
mImageSelectedColorEnd = mImageSelectedColor;
|
||||||
|
mHasImageSelectedColor = true;
|
||||||
|
}
|
||||||
|
if (elem->has("imageSelectedColorEnd")) {
|
||||||
|
mImageSelectedColorEnd = elem->get<unsigned int>("imageSelectedColorEnd");
|
||||||
|
mHasImageSelectedColor = true;
|
||||||
|
}
|
||||||
|
if (elem->has("imageSelectedGradientType")) {
|
||||||
|
const std::string& gradientType {elem->get<std::string>("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"))
|
if (elem->has("imageBrightness"))
|
||||||
mImageBrightness = glm::clamp(elem->get<float>("imageBrightness"), -2.0f, 2.0f);
|
mImageBrightness = glm::clamp(elem->get<float>("imageBrightness"), -2.0f, 2.0f);
|
||||||
|
|
||||||
|
@ -1117,6 +1194,18 @@ void GridComponent<T>::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
if (elem->has("textBackgroundColor"))
|
if (elem->has("textBackgroundColor"))
|
||||||
mTextBackgroundColor = elem->get<unsigned int>("textBackgroundColor");
|
mTextBackgroundColor = elem->get<unsigned int>("textBackgroundColor");
|
||||||
|
|
||||||
|
mTextSelectedColor = mTextColor;
|
||||||
|
mTextSelectedBackgroundColor = mTextBackgroundColor;
|
||||||
|
|
||||||
|
if (elem->has("textSelectedColor")) {
|
||||||
|
mTextSelectedColor = elem->get<unsigned int>("textSelectedColor");
|
||||||
|
mHasTextSelectedColor = true;
|
||||||
|
}
|
||||||
|
if (elem->has("textSelectedBackgroundColor")) {
|
||||||
|
mTextSelectedBackgroundColor = elem->get<unsigned int>("textSelectedBackgroundColor");
|
||||||
|
mHasTextSelectedColor = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (elem->has("lineSpacing"))
|
if (elem->has("lineSpacing"))
|
||||||
mLineSpacing = glm::clamp(elem->get<float>("lineSpacing"), 0.5f, 3.0f);
|
mLineSpacing = glm::clamp(elem->get<float>("lineSpacing"), 0.5f, 3.0f);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue