mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-25 15:45:38 +00:00
The scroll indicators don't fade in and out any longer if quick jumping in a list.
This commit is contained in:
parent
4c556fc820
commit
690083a123
|
@ -15,6 +15,7 @@ ComponentList::ComponentList(Window* window)
|
|||
, mFocused{false}
|
||||
, mSetupCompleted{false}
|
||||
, mBottomCameraOffset{false}
|
||||
, mSingleRowScroll{false}
|
||||
, mSelectorBarOffset{0.0f}
|
||||
, mCameraOffset{0.0f}
|
||||
, mScrollIndicatorStatus{SCROLL_NONE}
|
||||
|
@ -63,6 +64,8 @@ bool ComponentList::input(InputConfig* config, Input input)
|
|||
if (size() == 0)
|
||||
return false;
|
||||
|
||||
mSingleRowScroll = false;
|
||||
|
||||
if (input.value &&
|
||||
(config->isMappedTo("a", input) || config->isMappedLike("lefttrigger", input) ||
|
||||
config->isMappedLike("righttrigger", input))) {
|
||||
|
@ -86,9 +89,11 @@ bool ComponentList::input(InputConfig* config, Input input)
|
|||
|
||||
// Input handler didn't consume the input - try to scroll.
|
||||
if (config->isMappedLike("up", input)) {
|
||||
mSingleRowScroll = true;
|
||||
return listInput(input.value != 0 ? -1 : 0);
|
||||
}
|
||||
else if (config->isMappedLike("down", input)) {
|
||||
mSingleRowScroll = true;
|
||||
return listInput(input.value != 0 ? 1 : 0);
|
||||
}
|
||||
else if (config->isMappedLike("leftshoulder", input)) {
|
||||
|
@ -142,7 +147,7 @@ void ComponentList::update(int deltaTime)
|
|||
}
|
||||
|
||||
if (scrollIndicatorChanged == true && mScrollIndicatorChangedCallback != nullptr)
|
||||
mScrollIndicatorChangedCallback(mScrollIndicatorStatus);
|
||||
mScrollIndicatorChangedCallback(mScrollIndicatorStatus, mSingleRowScroll);
|
||||
|
||||
listUpdate(deltaTime);
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ public:
|
|||
{
|
||||
mScrollIndicatorStatus = SCROLL_NONE;
|
||||
if (mScrollIndicatorChangedCallback != nullptr)
|
||||
mScrollIndicatorChangedCallback(mScrollIndicatorStatus);
|
||||
mScrollIndicatorChangedCallback(mScrollIndicatorStatus, false);
|
||||
}
|
||||
|
||||
void setCursorChangedCallback(const std::function<void(CursorState state)>& callback)
|
||||
|
@ -102,7 +102,7 @@ public:
|
|||
return mCursorChangedCallback;
|
||||
}
|
||||
void setScrollIndicatorChangedCallback(
|
||||
const std::function<void(ScrollIndicator state)>& callback)
|
||||
const std::function<void(ScrollIndicator state, bool singleRowScroll)>& callback)
|
||||
{
|
||||
mScrollIndicatorChangedCallback = callback;
|
||||
}
|
||||
|
@ -114,6 +114,7 @@ private:
|
|||
bool mFocused;
|
||||
bool mSetupCompleted;
|
||||
bool mBottomCameraOffset;
|
||||
bool mSingleRowScroll;
|
||||
|
||||
void updateCameraOffset();
|
||||
void updateElementPosition(const ComponentListRow& row);
|
||||
|
@ -126,7 +127,8 @@ private:
|
|||
float mCameraOffset;
|
||||
|
||||
std::function<void(CursorState state)> mCursorChangedCallback;
|
||||
std::function<void(ScrollIndicator state)> mScrollIndicatorChangedCallback;
|
||||
std::function<void(ScrollIndicator state, bool singleRowScroll)>
|
||||
mScrollIndicatorChangedCallback;
|
||||
|
||||
ScrollIndicator mScrollIndicatorStatus;
|
||||
};
|
||||
|
|
|
@ -34,7 +34,7 @@ public:
|
|||
// If the scroll indicators setting is disabled, then show a permanent down arrow
|
||||
// symbol when the component list contains more entries than can fit on screen.
|
||||
componentList.get()->setScrollIndicatorChangedCallback(
|
||||
[scrollUp, scrollDown](ComponentList::ScrollIndicator state) {
|
||||
[scrollUp, scrollDown](ComponentList::ScrollIndicator state, bool singleRowScroll) {
|
||||
if (state == ComponentList::SCROLL_UP ||
|
||||
state == ComponentList::SCROLL_UP_DOWN ||
|
||||
state == ComponentList::SCROLL_DOWN) {
|
||||
|
@ -46,8 +46,9 @@ public:
|
|||
// If the scroll indicator setting is enabled, then also show the up and up/down
|
||||
// combination and switch between these as the list is scrolled.
|
||||
componentList.get()->setScrollIndicatorChangedCallback(
|
||||
[this, scrollUp, scrollDown](ComponentList::ScrollIndicator state) {
|
||||
float fadeInTime{FADE_IN_TIME};
|
||||
[this, scrollUp, scrollDown](ComponentList::ScrollIndicator state,
|
||||
bool singleRowScroll) {
|
||||
float fadeTime{FADE_IN_TIME};
|
||||
|
||||
bool upFadeIn = false;
|
||||
bool upFadeOut = false;
|
||||
|
@ -68,7 +69,7 @@ public:
|
|||
else if (state == ComponentList::SCROLL_UP &&
|
||||
mPreviousScrollState == ComponentList::SCROLL_DOWN) {
|
||||
upFadeIn = true;
|
||||
fadeInTime *= 1.5f;
|
||||
fadeTime *= 2.0f;
|
||||
scrollDown->setOpacity(0);
|
||||
}
|
||||
else if (state == ComponentList::SCROLL_UP_DOWN &&
|
||||
|
@ -95,17 +96,22 @@ public:
|
|||
else if (state == ComponentList::SCROLL_DOWN &&
|
||||
mPreviousScrollState == ComponentList::SCROLL_UP) {
|
||||
downFadeIn = true;
|
||||
fadeInTime *= 1.5f;
|
||||
fadeTime *= 2.0f;
|
||||
scrollUp->setOpacity(0);
|
||||
}
|
||||
|
||||
// If jumping more than one row using the shoulder or trigger buttons, then
|
||||
// don't fade the indicators.
|
||||
if (!singleRowScroll)
|
||||
fadeTime = 0.0f;
|
||||
|
||||
if (upFadeIn) {
|
||||
auto upFadeInFunc = [scrollUp](float t) {
|
||||
scrollUp->setOpacity(
|
||||
static_cast<unsigned char>(glm::mix(0.0f, 1.0f, t) * 255));
|
||||
};
|
||||
scrollUp->setAnimation(
|
||||
new LambdaAnimation(upFadeInFunc, static_cast<int>(fadeInTime)), 0,
|
||||
new LambdaAnimation(upFadeInFunc, static_cast<int>(fadeTime)), 0,
|
||||
nullptr, false);
|
||||
}
|
||||
|
||||
|
@ -115,7 +121,7 @@ public:
|
|||
static_cast<unsigned char>(glm::mix(0.0f, 1.0f, t) * 255));
|
||||
};
|
||||
scrollUp->setAnimation(
|
||||
new LambdaAnimation(upFadeOutFunc, static_cast<int>(fadeInTime)), 0,
|
||||
new LambdaAnimation(upFadeOutFunc, static_cast<int>(fadeTime)), 0,
|
||||
nullptr, true);
|
||||
}
|
||||
|
||||
|
@ -125,7 +131,7 @@ public:
|
|||
static_cast<unsigned char>(glm::mix(0.0f, 1.0f, t) * 255));
|
||||
};
|
||||
scrollDown->setAnimation(
|
||||
new LambdaAnimation(downFadeInFunc, static_cast<int>(fadeInTime)), 0,
|
||||
new LambdaAnimation(downFadeInFunc, static_cast<int>(fadeTime)), 0,
|
||||
nullptr, false);
|
||||
}
|
||||
|
||||
|
@ -135,7 +141,7 @@ public:
|
|||
static_cast<unsigned char>(glm::mix(0.0f, 1.0f, t) * 255));
|
||||
};
|
||||
scrollDown->setAnimation(
|
||||
new LambdaAnimation(downFadeOutFunc, static_cast<int>(fadeInTime)), 0,
|
||||
new LambdaAnimation(downFadeOutFunc, static_cast<int>(fadeTime)), 0,
|
||||
nullptr, true);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue