mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-03-06 14:27:43 +00:00
Fixed multiple navigation issues in GridComponent.
This commit is contained in:
parent
1631cbd30f
commit
3ec8ec14ca
es-core/src/components
|
@ -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,16 +416,9 @@ 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,62 +695,44 @@ 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
|
||||||
else {
|
|
||||||
if (startRow <= visibleRows) {
|
|
||||||
startRow = mScrollPos;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (mFractionalRows)
|
|
||||||
startRow = mScrollPos + visibleRows;
|
|
||||||
else
|
|
||||||
startRow = mScrollPos + 1.0f;
|
|
||||||
startRow -= visibleRows;
|
|
||||||
}
|
|
||||||
endRow -= visibleRows;
|
endRow -= visibleRows;
|
||||||
|
|
||||||
|
if (startPos != endPos) {
|
||||||
|
Animation* anim {new LambdaAnimation(
|
||||||
|
[this, startPos, endPos, posMax, startRow, endRow](float t) {
|
||||||
|
// Non-linear interpolation.
|
||||||
|
t = 1.0f - (1.0f - t) * (1.0f - t);
|
||||||
|
|
||||||
|
float f {(endPos * t) + (startPos * (1.0f - t))};
|
||||||
|
if (f < 0)
|
||||||
|
f += posMax;
|
||||||
|
if (f >= posMax)
|
||||||
|
f -= posMax;
|
||||||
|
|
||||||
|
mEntryOffset = f;
|
||||||
|
mScrollPos = {(endRow * t) + (startRow * (1.0f - t))};
|
||||||
|
|
||||||
|
if (mInstantItemTransitions) {
|
||||||
|
mTransitionFactor = 1.0f;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Linear interpolation.
|
||||||
|
mTransitionFactor = t;
|
||||||
|
// Non-linear interpolation doesn't seem to be a good match for this component.
|
||||||
|
// mTransitionFactor = {(1.0f * t) + (0.0f * (1.0f - t))};
|
||||||
|
}
|
||||||
|
},
|
||||||
|
static_cast<int>(animTime))};
|
||||||
|
|
||||||
|
GuiComponent::setAnimation(anim, 0, nullptr, false, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
Animation* anim {new LambdaAnimation(
|
|
||||||
[this, startPos, endPos, posMax, startRow, endRow](float t) {
|
|
||||||
// Non-linear interpolation.
|
|
||||||
t = 1.0f - (1.0f - t) * (1.0f - t);
|
|
||||||
|
|
||||||
float f {(endPos * t) + (startPos * (1.0f - t))};
|
|
||||||
if (f < 0)
|
|
||||||
f += posMax;
|
|
||||||
if (f >= posMax)
|
|
||||||
f -= posMax;
|
|
||||||
|
|
||||||
mEntryOffset = f;
|
|
||||||
mScrollPos = {(endRow * t) + (startRow * (1.0f - t))};
|
|
||||||
|
|
||||||
if (mInstantItemTransitions) {
|
|
||||||
mTransitionFactor = 1.0f;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// Linear interpolation.
|
|
||||||
mTransitionFactor = t;
|
|
||||||
// Non-linear interpolation doesn't seem to be a good match for this component.
|
|
||||||
// mTransitionFactor = {(1.0f * t) + (0.0f * (1.0f - t))};
|
|
||||||
}
|
|
||||||
},
|
|
||||||
static_cast<int>(animTime))};
|
|
||||||
|
|
||||||
GuiComponent::setAnimation(anim, 0, nullptr, false, 0);
|
|
||||||
|
|
||||||
if (mCursorChangedCallback)
|
if (mCursorChangedCallback)
|
||||||
mCursorChangedCallback(state);
|
mCursorChangedCallback(state);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue