From dfcf041efc5b432b60761e784d957851b03262fd Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Fri, 25 Nov 2022 22:35:35 +0100 Subject: [PATCH] Fixed a GridComponent slide transition issue when used in the system view. Also fixed a general navigation issue. --- es-app/src/views/SystemView.cpp | 26 ++++++++++++------- .../src/components/primary/GridComponent.h | 7 ++--- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/es-app/src/views/SystemView.cpp b/es-app/src/views/SystemView.cpp index 78797261d..e89b863ee 100644 --- a/es-app/src/views/SystemView.cpp +++ b/es-app/src/views/SystemView.cpp @@ -318,18 +318,24 @@ void SystemView::onCursorChanged(const CursorState& state) Animation* anim; float animTime {380.0f}; - float timeDiff {1.0f}; - // If startPos is inbetween two positions then reduce the time slightly as the distance will - // be shorter meaning the animation would play for too long if not compensated for. - if (scrollVelocity == 1) - timeDiff = endPos - startPos; - else if (scrollVelocity == -1) - timeDiff = startPos - endPos; + if (mGrid != nullptr) { + animTime = 250.0f; + } + else { + float timeDiff {1.0f}; - if (timeDiff != 1.0f) - animTime = - glm::clamp(std::fabs(glm::mix(0.0f, animTime, timeDiff * 1.5f)), 200.0f, animTime); + // If startPos is inbetween two positions then reduce the time slightly as the distance will + // be shorter meaning the animation would play for too long if not compensated for. + if (scrollVelocity == 1) + timeDiff = endPos - startPos; + else if (scrollVelocity == -1) + timeDiff = startPos - endPos; + + if (timeDiff != 1.0f) + animTime = + glm::clamp(std::fabs(glm::mix(0.0f, animTime, timeDiff * 1.5f)), 200.0f, animTime); + } if (transitionStyle == "fade") { float startFade {mFadeOpacity}; diff --git a/es-core/src/components/primary/GridComponent.h b/es-core/src/components/primary/GridComponent.h index 95d67ae17..e09ac83a7 100644 --- a/es-core/src/components/primary/GridComponent.h +++ b/es-core/src/components/primary/GridComponent.h @@ -348,9 +348,10 @@ template bool GridComponent::input(InputConfig* config, Input in return true; } if (config->isMappedLike("down", input)) { - if (mCursor >= (mColumns * mRowCount) - mColumns && - static_cast(mEntries.size()) - mCursor <= mColumns && - mEntries.size() % mColumns == 0) + if (mCursor >= (mColumns * mRowCount) - mColumns && size() - mCursor <= mColumns && + size() % mColumns == 0) + return true; + if (size() < mColumns) return true; if (mCancelTransitionsCallback) mCancelTransitionsCallback();