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. // to play when we've closed the menu.
if (mSystemListView->isAnimationPlaying(0)) if (mSystemListView->isAnimationPlaying(0))
mSystemListView->finishAnimation(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)); mWindow->pushGui(new GuiMenu(mWindow));
return true; return true;

View file

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

View file

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

View file

@ -101,6 +101,8 @@ bool ISimpleGameListView::input(InputConfig* config, Input input)
if (config->isMappedTo("a", input)) { if (config->isMappedTo("a", input)) {
FileData* cursor = getCursor(); FileData* cursor = getCursor();
if (cursor->getType() == GAME) { if (cursor->getType() == GAME) {
if (isListScrolling())
stopListScrolling();
launch(cursor); launch(cursor);
} }
else { else {
@ -126,6 +128,8 @@ bool ISimpleGameListView::input(InputConfig* config, Input input)
else { else {
NavigationSounds::getInstance()->playThemeNavigationSound(BACKSOUND); NavigationSounds::getInstance()->playThemeNavigationSound(BACKSOUND);
onFocusLost(); onFocusLost();
if (isListScrolling())
stopListScrolling();
SystemData* systemToView = getCursor()->getSystem(); SystemData* systemToView = getCursor()->getSystem();
if (systemToView->isCollection()) if (systemToView->isCollection())
systemToView = CollectionSystemManager::get()->getSystemToView(systemToView); systemToView = CollectionSystemManager::get()->getSystemToView(systemToView);
@ -138,6 +142,8 @@ bool ISimpleGameListView::input(InputConfig* config, Input input)
else if (config->isMappedLike(getQuickSystemSelectRightButton(), input)) { else if (config->isMappedLike(getQuickSystemSelectRightButton(), input)) {
if (Settings::getInstance()->getBool("QuickSystemSelect")) { if (Settings::getInstance()->getBool("QuickSystemSelect")) {
onFocusLost(); onFocusLost();
if (isListScrolling())
stopListScrolling();
ViewController::get()->goToNextGameList(); ViewController::get()->goToNextGameList();
return true; return true;
} }
@ -145,12 +151,16 @@ bool ISimpleGameListView::input(InputConfig* config, Input input)
else if (config->isMappedLike(getQuickSystemSelectLeftButton(), input)) { else if (config->isMappedLike(getQuickSystemSelectLeftButton(), input)) {
if (Settings::getInstance()->getBool("QuickSystemSelect")) { if (Settings::getInstance()->getBool("QuickSystemSelect")) {
onFocusLost(); onFocusLost();
if (isListScrolling())
stopListScrolling();
ViewController::get()->goToPrevGameList(); ViewController::get()->goToPrevGameList();
return true; return true;
} }
} }
else if (config->isMappedTo("x", input)) { else if (config->isMappedTo("x", input)) {
if (mRoot->getSystem()->isGameSystem() && getCursor()->getType() != PLACEHOLDER) { if (mRoot->getSystem()->isGameSystem() && getCursor()->getType() != PLACEHOLDER) {
if (isListScrolling())
stopListScrolling();
// Go to random system game. // Go to random system game.
NavigationSounds::getInstance()->playThemeNavigationSound(SCROLLSOUND); NavigationSounds::getInstance()->playThemeNavigationSound(SCROLLSOUND);
FileData* randomGame = getCursor()->getSystem()->getRandomGame(getCursor()); 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. // Basic GUI component handling such as placement, rotation, Z-order, rendering and animation.
// //
#pragma once
#ifndef ES_CORE_GUI_COMPONENT_H #ifndef ES_CORE_GUI_COMPONENT_H
#define ES_CORE_GUI_COMPONENT_H #define ES_CORE_GUI_COMPONENT_H
@ -13,6 +12,7 @@
#include "HelpPrompt.h" #include "HelpPrompt.h"
#include "HelpStyle.h" #include "HelpStyle.h"
#include "InputConfig.h" #include "InputConfig.h"
#include <functional> #include <functional>
#include <memory> #include <memory>
@ -137,6 +137,8 @@ public:
void stopAllAnimations(); void stopAllAnimations();
void cancelAllAnimations(); void cancelAllAnimations();
virtual bool isListScrolling() { return false; };
virtual void stopListScrolling() {};
virtual unsigned char getOpacity() const; virtual unsigned char getOpacity() const;
virtual void setOpacity(unsigned char opacity); virtual void setOpacity(unsigned char opacity);
virtual unsigned int getColor() const; virtual unsigned int getColor() const;

View file

@ -4,7 +4,6 @@
// Gamelist base class. // Gamelist base class.
// //
#pragma once
#ifndef ES_CORE_COMPONENTS_ILIST_H #ifndef ES_CORE_COMPONENTS_ILIST_H
#define ES_CORE_COMPONENTS_ILIST_H #define ES_CORE_COMPONENTS_ILIST_H
@ -117,7 +116,8 @@ public:
void stopScrolling() void stopScrolling()
{ {
listInput(0); listInput(0);
onCursorChanged(CURSOR_STOPPED); if (mScrollVelocity == 0)
onCursorChanged(CURSOR_STOPPED);
} }
void clear() void clear()
@ -225,11 +225,6 @@ protected:
{ {
PowerSaver::setState(velocity == 0); 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; mScrollVelocity = velocity;
mScrollTier = 0; mScrollTier = 0;
mScrollTierAccumulator = 0; mScrollTierAccumulator = 0;

View file

@ -4,7 +4,6 @@
// Used for displaying and navigating the gamelists. // Used for displaying and navigating the gamelists.
// //
#pragma once
#ifndef ES_APP_COMPONENTS_TEXT_LIST_COMPONENT_H #ifndef ES_APP_COMPONENTS_TEXT_LIST_COMPONENT_H
#define 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(); 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); return GuiComponent::input(config, input);
} }