mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-04-10 19:15:13 +00:00
Fixed multiple navigation issues in GridComponent.
This commit is contained in:
parent
1631cbd30f
commit
3ec8ec14ca
|
@ -350,8 +350,10 @@ protected:
|
||||||
|
|
||||||
mLastCursor = mCursor;
|
mLastCursor = mCursor;
|
||||||
|
|
||||||
if (!doScroll)
|
if (!doScroll) {
|
||||||
|
onCursorChanged(CursorState::CURSOR_STOPPED);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int cursor {mCursor + amt};
|
int cursor {mCursor + amt};
|
||||||
int absAmt {amt < 0 ? -amt : amt};
|
int absAmt {amt < 0 ? -amt : amt};
|
||||||
|
|
|
@ -416,17 +416,10 @@ template <typename T> bool GridComponent<T>::input(InputConfig* config, Input in
|
||||||
config->isMappedLike("up", input) || config->isMappedLike("down", input) ||
|
config->isMappedLike("up", input) || config->isMappedLike("down", input) ||
|
||||||
config->isMappedLike("lefttrigger", input) ||
|
config->isMappedLike("lefttrigger", input) ||
|
||||||
config->isMappedLike("righttrigger", input)) {
|
config->isMappedLike("righttrigger", input)) {
|
||||||
if constexpr (std::is_same_v<T, SystemData*>) {
|
|
||||||
if (isScrolling())
|
if (isScrolling())
|
||||||
onCursorChanged(CursorState::CURSOR_STOPPED);
|
onCursorChanged(CursorState::CURSOR_STOPPED);
|
||||||
List::listInput(0);
|
List::listInput(0);
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
if (isScrolling())
|
|
||||||
onCursorChanged(CursorState::CURSOR_STOPPED);
|
|
||||||
List::listInput(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -630,22 +623,25 @@ void GridComponent<T>::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
|
|
||||||
template <typename T> void GridComponent<T>::onCursorChanged(const CursorState& state)
|
template <typename T> void GridComponent<T>::onCursorChanged(const CursorState& state)
|
||||||
{
|
{
|
||||||
|
if (mColumns == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
if (mColumns != 0 && (mScrollVelocity == mColumns || mPreviousScrollVelocity == mColumns) &&
|
if (mWasScrolling && state == CursorState::CURSOR_STOPPED && mScrollVelocity != 0) {
|
||||||
size() - mCursor <= size() % mColumns) {
|
|
||||||
mWasScrolling = false;
|
mWasScrolling = false;
|
||||||
}
|
|
||||||
else if (mWasScrolling && state == CursorState::CURSOR_STOPPED) {
|
|
||||||
if (mCursorChangedCallback)
|
if (mCursorChangedCallback)
|
||||||
mCursorChangedCallback(state);
|
mCursorChangedCallback(state);
|
||||||
mWasScrolling = false;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mCursor == mLastCursor && !mJustCalculatedLayout)
|
if (mCursor == mLastCursor && !mJustCalculatedLayout) {
|
||||||
|
mWasScrolling = false;
|
||||||
|
if (mCursorChangedCallback)
|
||||||
|
mCursorChangedCallback(state);
|
||||||
return;
|
return;
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
mJustCalculatedLayout = false;
|
mJustCalculatedLayout = false;
|
||||||
|
}
|
||||||
|
|
||||||
float startPos {mEntryOffset};
|
float startPos {mEntryOffset};
|
||||||
float posMax {static_cast<float>(mEntries.size())};
|
float posMax {static_cast<float>(mEntries.size())};
|
||||||
|
@ -699,34 +695,15 @@ template <typename T> void GridComponent<T>::onCursorChanged(const CursorState&
|
||||||
// animTime);
|
// animTime);
|
||||||
|
|
||||||
const float visibleRows {mVisibleRows - 1.0f};
|
const float visibleRows {mVisibleRows - 1.0f};
|
||||||
float startRow {static_cast<float>(mLastCursor / mColumns)};
|
const float startRow {static_cast<float>(mScrollPos)};
|
||||||
float endRow {static_cast<float>(mCursor / mColumns)};
|
float endRow {static_cast<float>(mCursor / mColumns)};
|
||||||
|
|
||||||
if (endRow <= visibleRows) {
|
if (endRow <= visibleRows)
|
||||||
if (startRow == endRow || startRow <= visibleRows) {
|
|
||||||
startRow = mScrollPos;
|
|
||||||
}
|
|
||||||
else if (startRow > visibleRows) {
|
|
||||||
if (!mFractionalRows)
|
|
||||||
startRow = mScrollPos + 1.0f;
|
|
||||||
startRow -= visibleRows;
|
|
||||||
}
|
|
||||||
endRow = 0.0f;
|
endRow = 0.0f;
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (startRow <= visibleRows) {
|
|
||||||
startRow = mScrollPos;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (mFractionalRows)
|
|
||||||
startRow = mScrollPos + visibleRows;
|
|
||||||
else
|
else
|
||||||
startRow = mScrollPos + 1.0f;
|
|
||||||
startRow -= visibleRows;
|
|
||||||
}
|
|
||||||
endRow -= visibleRows;
|
endRow -= visibleRows;
|
||||||
}
|
|
||||||
|
|
||||||
|
if (startPos != endPos) {
|
||||||
Animation* anim {new LambdaAnimation(
|
Animation* anim {new LambdaAnimation(
|
||||||
[this, startPos, endPos, posMax, startRow, endRow](float t) {
|
[this, startPos, endPos, posMax, startRow, endRow](float t) {
|
||||||
// Non-linear interpolation.
|
// Non-linear interpolation.
|
||||||
|
@ -754,6 +731,7 @@ template <typename T> void GridComponent<T>::onCursorChanged(const CursorState&
|
||||||
static_cast<int>(animTime))};
|
static_cast<int>(animTime))};
|
||||||
|
|
||||||
GuiComponent::setAnimation(anim, 0, nullptr, false, 0);
|
GuiComponent::setAnimation(anim, 0, nullptr, false, 0);
|
||||||
|
}
|
||||||
|
|
||||||
if (mCursorChangedCallback)
|
if (mCursorChangedCallback)
|
||||||
mCursorChangedCallback(state);
|
mCursorChangedCallback(state);
|
||||||
|
|
Loading…
Reference in a new issue