Fixed an annoying scrolling issue that also affected the application performance.

This commit is contained in:
Leon Styhre 2020-09-13 19:08:17 +02:00
parent 02c9b4fb28
commit db0e15f5e8
7 changed files with 24 additions and 14 deletions

View file

@ -459,6 +459,10 @@ bool ViewController::input(InputConfig* config, Input input)
// to play when we've closed the menu.
if (mSystemListView->isAnimationPlaying(0))
mSystemListView->finishAnimation(0);
// Stop the gamelist scrolling as well as it would otherwise
// also continue to run after closing the menu.
if (mCurrentView->isListScrolling())
mCurrentView->stopListScrolling();
mWindow->pushGui(new GuiMenu(mWindow));
return true;

View file

@ -4,7 +4,6 @@
// Interface that defines a GameListView of the type 'basic'.
//
#pragma once
#ifndef ES_APP_VIEWS_GAME_LIST_BASIC_GAME_LIST_VIEW_H
#define ES_APP_VIEWS_GAME_LIST_BASIC_GAME_LIST_VIEW_H
@ -31,6 +30,9 @@ public:
virtual std::vector<HelpPrompt> getHelpPrompts() override;
virtual void launch(FileData* game) override;
virtual bool isListScrolling() override { return mList.isScrolling(); };
virtual void stopListScrolling() override { mList.stopScrolling(); };
protected:
virtual std::string getQuickSystemSelectRightButton() override;
virtual std::string getQuickSystemSelectLeftButton() override;

View file

@ -17,6 +17,8 @@ bool IGameListView::input(InputConfig* config, Input input)
// Select button opens GuiGamelistOptions.
if (!UIModeController::getInstance()->isUIModeKid() &&
config->isMappedTo("select", input) && input.value) {
if (isListScrolling())
stopListScrolling();
mWindow->pushGui(new GuiGamelistOptions(mWindow, this->mRoot->getSystem()));
return true;
}

View file

@ -101,6 +101,8 @@ bool ISimpleGameListView::input(InputConfig* config, Input input)
if (config->isMappedTo("a", input)) {
FileData* cursor = getCursor();
if (cursor->getType() == GAME) {
if (isListScrolling())
stopListScrolling();
launch(cursor);
}
else {
@ -126,6 +128,8 @@ bool ISimpleGameListView::input(InputConfig* config, Input input)
else {
NavigationSounds::getInstance()->playThemeNavigationSound(BACKSOUND);
onFocusLost();
if (isListScrolling())
stopListScrolling();
SystemData* systemToView = getCursor()->getSystem();
if (systemToView->isCollection())
systemToView = CollectionSystemManager::get()->getSystemToView(systemToView);
@ -138,6 +142,8 @@ bool ISimpleGameListView::input(InputConfig* config, Input input)
else if (config->isMappedLike(getQuickSystemSelectRightButton(), input)) {
if (Settings::getInstance()->getBool("QuickSystemSelect")) {
onFocusLost();
if (isListScrolling())
stopListScrolling();
ViewController::get()->goToNextGameList();
return true;
}
@ -145,12 +151,16 @@ bool ISimpleGameListView::input(InputConfig* config, Input input)
else if (config->isMappedLike(getQuickSystemSelectLeftButton(), input)) {
if (Settings::getInstance()->getBool("QuickSystemSelect")) {
onFocusLost();
if (isListScrolling())
stopListScrolling();
ViewController::get()->goToPrevGameList();
return true;
}
}
else if (config->isMappedTo("x", input)) {
if (mRoot->getSystem()->isGameSystem() && getCursor()->getType() != PLACEHOLDER) {
if (isListScrolling())
stopListScrolling();
// Go to random system game.
NavigationSounds::getInstance()->playThemeNavigationSound(SCROLLSOUND);
FileData* randomGame = getCursor()->getSystem()->getRandomGame(getCursor());

View file

@ -4,7 +4,6 @@
// Basic GUI component handling such as placement, rotation, Z-order, rendering and animation.
//
#pragma once
#ifndef ES_CORE_GUI_COMPONENT_H
#define ES_CORE_GUI_COMPONENT_H
@ -13,6 +12,7 @@
#include "HelpPrompt.h"
#include "HelpStyle.h"
#include "InputConfig.h"
#include <functional>
#include <memory>
@ -137,6 +137,8 @@ public:
void stopAllAnimations();
void cancelAllAnimations();
virtual bool isListScrolling() { return false; };
virtual void stopListScrolling() {};
virtual unsigned char getOpacity() const;
virtual void setOpacity(unsigned char opacity);
virtual unsigned int getColor() const;

View file

@ -4,7 +4,6 @@
// Gamelist base class.
//
#pragma once
#ifndef ES_CORE_COMPONENTS_ILIST_H
#define ES_CORE_COMPONENTS_ILIST_H
@ -117,7 +116,8 @@ public:
void stopScrolling()
{
listInput(0);
onCursorChanged(CURSOR_STOPPED);
if (mScrollVelocity == 0)
onCursorChanged(CURSOR_STOPPED);
}
void clear()
@ -225,11 +225,6 @@ protected:
{
PowerSaver::setState(velocity == 0);
// Generate an onCursorChanged event in the stopped state when the user
// lets go of the key.
if (velocity == 0 && mScrollVelocity != 0)
onCursorChanged(CURSOR_STOPPED);
mScrollVelocity = velocity;
mScrollTier = 0;
mScrollTierAccumulator = 0;

View file

@ -4,7 +4,6 @@
// Used for displaying and navigating the gamelists.
//
#pragma once
#ifndef ES_APP_COMPONENTS_TEXT_LIST_COMPONENT_H
#define ES_APP_COMPONENTS_TEXT_LIST_COMPONENT_H
@ -315,10 +314,6 @@ bool TextListComponent<T>::input(InputConfig* config, Input input)
stopScrolling();
}
}
// Explicitly stop the scrolling, otherwise it will go forever in case
// the menu was openened or another gamelist was selected using the
// quick system selector etc.
stopScrolling();
return GuiComponent::input(config, input);
}