From 2bf5e6f3f1eddb8ac08097d2901bab21abf30de6 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Mon, 31 Jan 2022 22:53:21 +0100 Subject: [PATCH] Fixed two text color issues when resetting ScrollableContainer. --- es-core/src/components/ScrollableContainer.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/es-core/src/components/ScrollableContainer.cpp b/es-core/src/components/ScrollableContainer.cpp index d7462c4a5..d299ce680 100644 --- a/es-core/src/components/ScrollableContainer.cpp +++ b/es-core/src/components/ScrollableContainer.cpp @@ -165,8 +165,14 @@ void ScrollableContainer::update(int deltaTime) mAutoScrollResetAccumulator += deltaTime; if (mAutoScrollResetAccumulator >= static_cast(mAutoScrollResetDelayConstant)) { // Fade in the text as it resets to the start position. - auto func = [this](float t) { - this->setOpacity(static_cast(glm::mix(0.0f, 1.0f, t) * 255)); + float maxOpacity {static_cast(mChildren.front()->getColor() & 0x000000FF) / + 255.0f}; + auto func = [this, maxOpacity](float t) { + unsigned int color {mChildren.front()->getColor()}; + unsigned int opacity { + static_cast(glm::mix(0.0f, maxOpacity, t) * 255)}; + color = (color & 0xFFFFFF00) + opacity; + this->mChildren.front()->setColor(color); mScrollPos = glm::vec2 {}; mAutoScrollResetAccumulator = 0; mAutoScrollAccumulator = -mAutoScrollDelay + mAutoScrollSpeed;