Fixed a GridComponent slide transition issue when used in the system view.

Also fixed a general navigation issue.
This commit is contained in:
Leon Styhre 2022-11-25 22:35:35 +01:00
parent 0cd814a4d1
commit dfcf041efc
2 changed files with 20 additions and 13 deletions

View file

@ -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};

View file

@ -348,9 +348,10 @@ template <typename T> bool GridComponent<T>::input(InputConfig* config, Input in
return true;
}
if (config->isMappedLike("down", input)) {
if (mCursor >= (mColumns * mRowCount) - mColumns &&
static_cast<int>(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();