Fixed some fade transition issues in SystemView.

This commit is contained in:
Leon Styhre 2022-09-23 22:47:49 +02:00
parent 00b71c7b27
commit 6a2a3b1259
2 changed files with 17 additions and 5 deletions

View file

@ -35,6 +35,7 @@ SystemView::SystemView()
, mNavigated {false} , mNavigated {false}
, mMaxFade {false} , mMaxFade {false}
, mFadeTransitions {false} , mFadeTransitions {false}
, mTransitionAnim {false}
{ {
setSize(Renderer::getScreenWidth(), Renderer::getScreenHeight()); setSize(Renderer::getScreenWidth(), Renderer::getScreenHeight());
populate(); populate();
@ -54,8 +55,10 @@ SystemView::~SystemView()
void SystemView::onShow() void SystemView::onShow()
{ {
if (mFadeTransitions) if (mFadeTransitions) {
finishAnimation(0); finishAnimation(0);
mTransitionAnim = false;
}
} }
void SystemView::onTransition() void SystemView::onTransition()
@ -65,6 +68,9 @@ void SystemView::onTransition()
for (auto& anim : mSystemElements[mPrimary->getCursor()].GIFAnimComponents) for (auto& anim : mSystemElements[mPrimary->getCursor()].GIFAnimComponents)
anim->setPauseAnimation(true); anim->setPauseAnimation(true);
if (mFadeTransitions)
mTransitionAnim = true;
} }
void SystemView::goToSystem(SystemData* system, bool animate) void SystemView::goToSystem(SystemData* system, bool animate)
@ -284,6 +290,9 @@ void SystemView::onCursorChanged(const CursorState& state)
std::string transitionStyle {Settings::getInstance()->getString("TransitionStyle")}; std::string transitionStyle {Settings::getInstance()->getString("TransitionStyle")};
mFadeTransitions = transitionStyle == "fade"; mFadeTransitions = transitionStyle == "fade";
if (startPos == endPos)
return;
Animation* anim; Animation* anim;
if (transitionStyle == "fade") { if (transitionStyle == "fade") {
@ -1252,10 +1261,10 @@ void SystemView::renderElements(const glm::mat4& parentTrans, bool abovePrimary)
element->getZIndex() < primaryZIndex) element->getZIndex() < primaryZIndex)
element->setDimming(1.0f - mFadeOpacity); element->setDimming(1.0f - mFadeOpacity);
if (mFadeTransitions && isAnimationPlaying(0)) if (mFadeTransitions && isAnimationPlaying(0))
element->setOpacity(mMaxFade ? 1.0f - mFadeOpacity : 0.0f); element->setOpacity(1.0f - mFadeOpacity);
else else
element->setOpacity(1.0f); element->setOpacity(1.0f);
if (mNavigated && mMaxFade) if (mFadeTransitions && mNavigated && mMaxFade)
continue; continue;
element->render(elementTrans); element->render(elementTrans);
} }
@ -1278,7 +1287,7 @@ void SystemView::renderElements(const glm::mat4& parentTrans, bool abovePrimary)
if (mLegacyMode) { if (mLegacyMode) {
if (mFadeTransitions && !abovePrimary) { if (mFadeTransitions && !abovePrimary) {
if (mFadeTransitions && isAnimationPlaying(0)) if (mFadeTransitions && isAnimationPlaying(0))
mLegacySystemInfo->setOpacity(mMaxFade ? 1.0f - mFadeOpacity : 0.0f); mLegacySystemInfo->setOpacity(1.0f - mFadeOpacity);
else else
mLegacySystemInfo->setOpacity(1.0f); mLegacySystemInfo->setOpacity(1.0f);
} }

View file

@ -49,12 +49,14 @@ public:
bool isSystemAnimationPlaying(unsigned char slot) { return mPrimary->isAnimationPlaying(slot); } bool isSystemAnimationPlaying(unsigned char slot) { return mPrimary->isAnimationPlaying(slot); }
void finishSystemAnimation(unsigned char slot) void finishSystemAnimation(unsigned char slot)
{ {
if (mFadeTransitions) { if (mFadeTransitions && mTransitionAnim) {
mPrimary->finishAnimation(slot); mPrimary->finishAnimation(slot);
mTransitionAnim = false;
} }
else { else {
finishAnimation(slot); finishAnimation(slot);
mPrimary->finishAnimation(slot); mPrimary->finishAnimation(slot);
mMaxFade = false;
} }
} }
@ -144,6 +146,7 @@ private:
bool mNavigated; bool mNavigated;
bool mMaxFade; bool mMaxFade;
bool mFadeTransitions; bool mFadeTransitions;
bool mTransitionAnim;
}; };
#endif // ES_APP_VIEWS_SYSTEM_VIEW_H #endif // ES_APP_VIEWS_SYSTEM_VIEW_H