diff --git a/es-core/src/GuiComponent.cpp b/es-core/src/GuiComponent.cpp index 18a171bac..90333da2a 100644 --- a/es-core/src/GuiComponent.cpp +++ b/es-core/src/GuiComponent.cpp @@ -20,6 +20,9 @@ GuiComponent::GuiComponent(Window* window) : mWindow(window), mParent(nullptr), + mColor(0), + mColorShift(0), + mColorShiftEnd(0), mOpacity(255), mSaturation(1.0), mPosition(Vector3f::Zero()), @@ -269,6 +272,11 @@ unsigned int GuiComponent::getColor() const return mColor; } +unsigned int GuiComponent::getColorShift() const +{ + return mColorShift; +} + void GuiComponent::setColor(unsigned int color) { mColor = color; diff --git a/es-core/src/GuiComponent.h b/es-core/src/GuiComponent.h index 4b66caa7a..e330726cb 100644 --- a/es-core/src/GuiComponent.h +++ b/es-core/src/GuiComponent.h @@ -20,6 +20,7 @@ #define DEFAULT_TEXTCOLOR 0x777777FF #define DEFAULT_INVERTED_TEXTCOLOR 0x444444FF +#define DEFAULT_INVERTED_IMAGECOLOR 0x666666FF #define DEFAULT_COLORSHIFT 0xFFFFFFFF #define ICONCOLOR_SCRAPERMARKED 0xFF5555FF #define ICONCOLOR_USERMARKED 0x5555FFFF @@ -145,6 +146,7 @@ public: virtual unsigned char getOpacity() const; virtual void setOpacity(unsigned char opacity); virtual unsigned int getColor() const; + virtual unsigned int getColorShift() const; virtual void setColor(unsigned int color); virtual float getSaturation() const; virtual void setSaturation(float saturation); diff --git a/es-core/src/components/ComponentList.cpp b/es-core/src/components/ComponentList.cpp index 37d118430..6e577dd65 100644 --- a/es-core/src/components/ComponentList.cpp +++ b/es-core/src/components/ComponentList.cpp @@ -196,11 +196,17 @@ void ComponentList::render(const Transform4x4f& parentTrans) for (auto it = entry.data.elements.cbegin(); it != entry.data.elements.cend(); it++) { if (drawAll || it->invert_when_selected) { // For the row where the cursor is at, we want to remove any hue from the - // font color before inverting, as it would otherwise lead to an ugly - // inverted color (e.g. red text inverting to a green hue). + // font or image before inverting, as it would otherwise lead to an ugly + // inverted color (e.g. red inverting to a green hue). if (i == mCursor && it->component->getValue() != "" ) { - // Check if the text color is neutral. + // Check if we're dealing with text or an image component. + bool isTextComponent = true; unsigned int origColor = it->component->getColor(); + if (origColor == 0) { + origColor = it->component->getColorShift(); + isTextComponent = false; + } + // Check if the color is neutral. unsigned char byteRed = origColor >> 24 & 0xFF; unsigned char byteGreen = origColor >> 16 & 0xFF; unsigned char byteBlue = origColor >> 8 & 0xFF; @@ -210,22 +216,28 @@ void ComponentList::render(const Transform4x4f& parentTrans) } else { // Note: I've disabled this code as it's overly complicated, - // instead we're now using a simple constant which should be + // instead we're now using simple constants which should be // good enough. Let's keep the code though if needed in the // future for some reason. // // If there is a hue, average the brightness values to make -// // an equivalent gray value before inverting the text. +// // an equivalent gray value before inverting. // // This is not the proper way to do a BW conversion as the RGB values // // should not be evenly distributed, but it's definitely good enough // // for this situation. // unsigned char byteAverage = (byteRed + byteGreen + byteBlue) / 3; // unsigned int averageColor = byteAverage << 24 | byteAverage << 16 | // byteAverage << 8 | 0xFF; -// it->component->setColor(averageColor); - it->component->setColor(DEFAULT_INVERTED_TEXTCOLOR); + if (isTextComponent) + it->component->setColor(DEFAULT_INVERTED_TEXTCOLOR); + else + it->component->setColorShift(DEFAULT_INVERTED_IMAGECOLOR); + it->component->render(trans); // Revert to the original color after rendering. - it->component->setColor(origColor); + if (isTextComponent) + it->component->setColor(origColor); + else + it->component->setColorShift(origColor); } } else { diff --git a/es-core/src/components/RatingComponent.h b/es-core/src/components/RatingComponent.h index a3f1cbd04..747c6a310 100644 --- a/es-core/src/components/RatingComponent.h +++ b/es-core/src/components/RatingComponent.h @@ -40,6 +40,7 @@ public: // Multiply all pixels in the image by this color when rendering. void setColorShift(unsigned int color) override; + unsigned int getColorShift() const override { return mColorShift; }; void setOriginalColor(unsigned int color) override { mColorOriginalValue = color; }; void setChangedColor(unsigned int color) override { mColorChangedValue = color; }; diff --git a/es-core/src/components/SwitchComponent.cpp b/es-core/src/components/SwitchComponent.cpp index 8b313223c..05f5c5f59 100644 --- a/es-core/src/components/SwitchComponent.cpp +++ b/es-core/src/components/SwitchComponent.cpp @@ -89,6 +89,11 @@ void SwitchComponent::setColorShift(unsigned int color) mImage.setColorShift(color); } +unsigned int SwitchComponent::getColorShift() const +{ + return mImage.getColorShift(); +} + void SwitchComponent::onStateChanged() { mImage.setImage(mState ? ":/graphics/on.svg" : ":/graphics/off.svg"); diff --git a/es-core/src/components/SwitchComponent.h b/es-core/src/components/SwitchComponent.h index 1236e52d1..101ea74e4 100644 --- a/es-core/src/components/SwitchComponent.h +++ b/es-core/src/components/SwitchComponent.h @@ -34,6 +34,8 @@ public: // Multiply all pixels in the image by this color when rendering. void setColorShift(unsigned int color) override; + unsigned int getColorShift() const override; + virtual std::vector getHelpPrompts() override; private: