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}
|
, mFocused{false}
|
||||||
, mSetupCompleted{false}
|
, mSetupCompleted{false}
|
||||||
, mBottomCameraOffset{false}
|
, mBottomCameraOffset{false}
|
||||||
|
, mSingleRowScroll{false}
|
||||||
, mSelectorBarOffset{0.0f}
|
, mSelectorBarOffset{0.0f}
|
||||||
, mCameraOffset{0.0f}
|
, mCameraOffset{0.0f}
|
||||||
, mScrollIndicatorStatus{SCROLL_NONE}
|
, mScrollIndicatorStatus{SCROLL_NONE}
|
||||||
|
@ -63,6 +64,8 @@ bool ComponentList::input(InputConfig* config, Input input)
|
||||||
if (size() == 0)
|
if (size() == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
mSingleRowScroll = false;
|
||||||
|
|
||||||
if (input.value &&
|
if (input.value &&
|
||||||
(config->isMappedTo("a", input) || config->isMappedLike("lefttrigger", input) ||
|
(config->isMappedTo("a", input) || config->isMappedLike("lefttrigger", input) ||
|
||||||
config->isMappedLike("righttrigger", 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.
|
// Input handler didn't consume the input - try to scroll.
|
||||||
if (config->isMappedLike("up", input)) {
|
if (config->isMappedLike("up", input)) {
|
||||||
|
mSingleRowScroll = true;
|
||||||
return listInput(input.value != 0 ? -1 : 0);
|
return listInput(input.value != 0 ? -1 : 0);
|
||||||
}
|
}
|
||||||
else if (config->isMappedLike("down", input)) {
|
else if (config->isMappedLike("down", input)) {
|
||||||
|
mSingleRowScroll = true;
|
||||||
return listInput(input.value != 0 ? 1 : 0);
|
return listInput(input.value != 0 ? 1 : 0);
|
||||||
}
|
}
|
||||||
else if (config->isMappedLike("leftshoulder", input)) {
|
else if (config->isMappedLike("leftshoulder", input)) {
|
||||||
|
@ -142,7 +147,7 @@ void ComponentList::update(int deltaTime)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scrollIndicatorChanged == true && mScrollIndicatorChangedCallback != nullptr)
|
if (scrollIndicatorChanged == true && mScrollIndicatorChangedCallback != nullptr)
|
||||||
mScrollIndicatorChangedCallback(mScrollIndicatorStatus);
|
mScrollIndicatorChangedCallback(mScrollIndicatorStatus, mSingleRowScroll);
|
||||||
|
|
||||||
listUpdate(deltaTime);
|
listUpdate(deltaTime);
|
||||||
|
|
||||||
|
|
|
@ -90,7 +90,7 @@ public:
|
||||||
{
|
{
|
||||||
mScrollIndicatorStatus = SCROLL_NONE;
|
mScrollIndicatorStatus = SCROLL_NONE;
|
||||||
if (mScrollIndicatorChangedCallback != nullptr)
|
if (mScrollIndicatorChangedCallback != nullptr)
|
||||||
mScrollIndicatorChangedCallback(mScrollIndicatorStatus);
|
mScrollIndicatorChangedCallback(mScrollIndicatorStatus, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setCursorChangedCallback(const std::function<void(CursorState state)>& callback)
|
void setCursorChangedCallback(const std::function<void(CursorState state)>& callback)
|
||||||
|
@ -102,7 +102,7 @@ public:
|
||||||
return mCursorChangedCallback;
|
return mCursorChangedCallback;
|
||||||
}
|
}
|
||||||
void setScrollIndicatorChangedCallback(
|
void setScrollIndicatorChangedCallback(
|
||||||
const std::function<void(ScrollIndicator state)>& callback)
|
const std::function<void(ScrollIndicator state, bool singleRowScroll)>& callback)
|
||||||
{
|
{
|
||||||
mScrollIndicatorChangedCallback = callback;
|
mScrollIndicatorChangedCallback = callback;
|
||||||
}
|
}
|
||||||
|
@ -114,6 +114,7 @@ private:
|
||||||
bool mFocused;
|
bool mFocused;
|
||||||
bool mSetupCompleted;
|
bool mSetupCompleted;
|
||||||
bool mBottomCameraOffset;
|
bool mBottomCameraOffset;
|
||||||
|
bool mSingleRowScroll;
|
||||||
|
|
||||||
void updateCameraOffset();
|
void updateCameraOffset();
|
||||||
void updateElementPosition(const ComponentListRow& row);
|
void updateElementPosition(const ComponentListRow& row);
|
||||||
|
@ -126,7 +127,8 @@ private:
|
||||||
float mCameraOffset;
|
float mCameraOffset;
|
||||||
|
|
||||||
std::function<void(CursorState state)> mCursorChangedCallback;
|
std::function<void(CursorState state)> mCursorChangedCallback;
|
||||||
std::function<void(ScrollIndicator state)> mScrollIndicatorChangedCallback;
|
std::function<void(ScrollIndicator state, bool singleRowScroll)>
|
||||||
|
mScrollIndicatorChangedCallback;
|
||||||
|
|
||||||
ScrollIndicator mScrollIndicatorStatus;
|
ScrollIndicator mScrollIndicatorStatus;
|
||||||
};
|
};
|
||||||
|
|
|
@ -34,7 +34,7 @@ public:
|
||||||
// If the scroll indicators setting is disabled, then show a permanent down arrow
|
// 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.
|
// symbol when the component list contains more entries than can fit on screen.
|
||||||
componentList.get()->setScrollIndicatorChangedCallback(
|
componentList.get()->setScrollIndicatorChangedCallback(
|
||||||
[scrollUp, scrollDown](ComponentList::ScrollIndicator state) {
|
[scrollUp, scrollDown](ComponentList::ScrollIndicator state, bool singleRowScroll) {
|
||||||
if (state == ComponentList::SCROLL_UP ||
|
if (state == ComponentList::SCROLL_UP ||
|
||||||
state == ComponentList::SCROLL_UP_DOWN ||
|
state == ComponentList::SCROLL_UP_DOWN ||
|
||||||
state == ComponentList::SCROLL_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
|
// 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.
|
// combination and switch between these as the list is scrolled.
|
||||||
componentList.get()->setScrollIndicatorChangedCallback(
|
componentList.get()->setScrollIndicatorChangedCallback(
|
||||||
[this, scrollUp, scrollDown](ComponentList::ScrollIndicator state) {
|
[this, scrollUp, scrollDown](ComponentList::ScrollIndicator state,
|
||||||
float fadeInTime{FADE_IN_TIME};
|
bool singleRowScroll) {
|
||||||
|
float fadeTime{FADE_IN_TIME};
|
||||||
|
|
||||||
bool upFadeIn = false;
|
bool upFadeIn = false;
|
||||||
bool upFadeOut = false;
|
bool upFadeOut = false;
|
||||||
|
@ -68,7 +69,7 @@ public:
|
||||||
else if (state == ComponentList::SCROLL_UP &&
|
else if (state == ComponentList::SCROLL_UP &&
|
||||||
mPreviousScrollState == ComponentList::SCROLL_DOWN) {
|
mPreviousScrollState == ComponentList::SCROLL_DOWN) {
|
||||||
upFadeIn = true;
|
upFadeIn = true;
|
||||||
fadeInTime *= 1.5f;
|
fadeTime *= 2.0f;
|
||||||
scrollDown->setOpacity(0);
|
scrollDown->setOpacity(0);
|
||||||
}
|
}
|
||||||
else if (state == ComponentList::SCROLL_UP_DOWN &&
|
else if (state == ComponentList::SCROLL_UP_DOWN &&
|
||||||
|
@ -95,17 +96,22 @@ public:
|
||||||
else if (state == ComponentList::SCROLL_DOWN &&
|
else if (state == ComponentList::SCROLL_DOWN &&
|
||||||
mPreviousScrollState == ComponentList::SCROLL_UP) {
|
mPreviousScrollState == ComponentList::SCROLL_UP) {
|
||||||
downFadeIn = true;
|
downFadeIn = true;
|
||||||
fadeInTime *= 1.5f;
|
fadeTime *= 2.0f;
|
||||||
scrollUp->setOpacity(0);
|
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) {
|
if (upFadeIn) {
|
||||||
auto upFadeInFunc = [scrollUp](float t) {
|
auto upFadeInFunc = [scrollUp](float t) {
|
||||||
scrollUp->setOpacity(
|
scrollUp->setOpacity(
|
||||||
static_cast<unsigned char>(glm::mix(0.0f, 1.0f, t) * 255));
|
static_cast<unsigned char>(glm::mix(0.0f, 1.0f, t) * 255));
|
||||||
};
|
};
|
||||||
scrollUp->setAnimation(
|
scrollUp->setAnimation(
|
||||||
new LambdaAnimation(upFadeInFunc, static_cast<int>(fadeInTime)), 0,
|
new LambdaAnimation(upFadeInFunc, static_cast<int>(fadeTime)), 0,
|
||||||
nullptr, false);
|
nullptr, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,7 +121,7 @@ public:
|
||||||
static_cast<unsigned char>(glm::mix(0.0f, 1.0f, t) * 255));
|
static_cast<unsigned char>(glm::mix(0.0f, 1.0f, t) * 255));
|
||||||
};
|
};
|
||||||
scrollUp->setAnimation(
|
scrollUp->setAnimation(
|
||||||
new LambdaAnimation(upFadeOutFunc, static_cast<int>(fadeInTime)), 0,
|
new LambdaAnimation(upFadeOutFunc, static_cast<int>(fadeTime)), 0,
|
||||||
nullptr, true);
|
nullptr, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,7 +131,7 @@ public:
|
||||||
static_cast<unsigned char>(glm::mix(0.0f, 1.0f, t) * 255));
|
static_cast<unsigned char>(glm::mix(0.0f, 1.0f, t) * 255));
|
||||||
};
|
};
|
||||||
scrollDown->setAnimation(
|
scrollDown->setAnimation(
|
||||||
new LambdaAnimation(downFadeInFunc, static_cast<int>(fadeInTime)), 0,
|
new LambdaAnimation(downFadeInFunc, static_cast<int>(fadeTime)), 0,
|
||||||
nullptr, false);
|
nullptr, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,7 +141,7 @@ public:
|
||||||
static_cast<unsigned char>(glm::mix(0.0f, 1.0f, t) * 255));
|
static_cast<unsigned char>(glm::mix(0.0f, 1.0f, t) * 255));
|
||||||
};
|
};
|
||||||
scrollDown->setAnimation(
|
scrollDown->setAnimation(
|
||||||
new LambdaAnimation(downFadeOutFunc, static_cast<int>(fadeInTime)), 0,
|
new LambdaAnimation(downFadeOutFunc, static_cast<int>(fadeTime)), 0,
|
||||||
nullptr, true);
|
nullptr, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue