From db0e15f5e831fbcf301c8d77365df9f3dd3f9bc6 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Sun, 13 Sep 2020 19:08:17 +0200 Subject: [PATCH] Fixed an annoying scrolling issue that also affected the application performance. --- es-app/src/views/ViewController.cpp | 4 ++++ es-app/src/views/gamelist/BasicGameListView.h | 4 +++- es-app/src/views/gamelist/IGameListView.cpp | 2 ++ es-app/src/views/gamelist/ISimpleGameListView.cpp | 10 ++++++++++ es-core/src/GuiComponent.h | 4 +++- es-core/src/components/IList.h | 9 ++------- es-core/src/components/TextListComponent.h | 5 ----- 7 files changed, 24 insertions(+), 14 deletions(-) diff --git a/es-app/src/views/ViewController.cpp b/es-app/src/views/ViewController.cpp index 8aa218c2d..7cab16e0e 100644 --- a/es-app/src/views/ViewController.cpp +++ b/es-app/src/views/ViewController.cpp @@ -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; diff --git a/es-app/src/views/gamelist/BasicGameListView.h b/es-app/src/views/gamelist/BasicGameListView.h index f0c54c881..f3138d059 100644 --- a/es-app/src/views/gamelist/BasicGameListView.h +++ b/es-app/src/views/gamelist/BasicGameListView.h @@ -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 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; diff --git a/es-app/src/views/gamelist/IGameListView.cpp b/es-app/src/views/gamelist/IGameListView.cpp index 2faffc5fd..f29f9bc60 100644 --- a/es-app/src/views/gamelist/IGameListView.cpp +++ b/es-app/src/views/gamelist/IGameListView.cpp @@ -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; } diff --git a/es-app/src/views/gamelist/ISimpleGameListView.cpp b/es-app/src/views/gamelist/ISimpleGameListView.cpp index a331f4186..ce838b2f7 100644 --- a/es-app/src/views/gamelist/ISimpleGameListView.cpp +++ b/es-app/src/views/gamelist/ISimpleGameListView.cpp @@ -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()); diff --git a/es-core/src/GuiComponent.h b/es-core/src/GuiComponent.h index 92646b941..26c2e891e 100644 --- a/es-core/src/GuiComponent.h +++ b/es-core/src/GuiComponent.h @@ -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 #include @@ -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; diff --git a/es-core/src/components/IList.h b/es-core/src/components/IList.h index e79da1a26..f5a07896e 100644 --- a/es-core/src/components/IList.h +++ b/es-core/src/components/IList.h @@ -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; diff --git a/es-core/src/components/TextListComponent.h b/es-core/src/components/TextListComponent.h index 5c452679f..4794b3c69 100644 --- a/es-core/src/components/TextListComponent.h +++ b/es-core/src/components/TextListComponent.h @@ -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::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); }