From b9e6cdd9da564eee16ac152b34518e07f8c1391b Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Mon, 5 Dec 2022 21:15:15 +0100 Subject: [PATCH] Fixed some GridComponent animation glitches when marking games as favorites. --- es-app/src/views/GamelistBase.cpp | 11 +++++++++++ es-app/src/views/GamelistView.cpp | 5 +++++ es-core/src/components/primary/GridComponent.h | 6 ++++++ 3 files changed, 22 insertions(+) diff --git a/es-app/src/views/GamelistBase.cpp b/es-app/src/views/GamelistBase.cpp index 5fd0dfbb4..ccf7f00f7 100644 --- a/es-app/src/views/GamelistBase.cpp +++ b/es-app/src/views/GamelistBase.cpp @@ -435,11 +435,18 @@ bool GamelistBase::input(InputConfig* config, Input input) } else if (CollectionSystemsManager::getInstance()->toggleGameInCollection( entryToUpdate)) { + // Needed to avoid some minor transition animation glitches. + auto grid = + ViewController::getInstance()->getGamelistView(system).get()->mGrid.get(); + if (grid != nullptr) + grid->setSuppressTransitions(true); + // As the toggling of the game destroyed this object, we need to get the view // from ViewController instead of using the reference that existed before the // destruction. Otherwise we get random crashes. GamelistView* view { ViewController::getInstance()->getGamelistView(system).get()}; + // Jump to the first entry in the gamelist if the last favorite was unmarked. if (foldersOnTop && removedLastFavorite && !entryToUpdate->getSystem()->isCustomCollection()) { @@ -457,6 +464,10 @@ bool GamelistBase::input(InputConfig* config, Input input) else if (selectLastEntry && view->getPrimary()->size() > 0) { view->setCursor(view->getLastEntry()); } + + if (grid != nullptr) + grid->setSuppressTransitions(false); + // Display the indication icons which show what games are part of the // custom collection currently being edited. This is done cheaply using // onFileChanged() which will trigger populateList(). diff --git a/es-app/src/views/GamelistView.cpp b/es-app/src/views/GamelistView.cpp index 97cbf24b5..a21214f13 100644 --- a/es-app/src/views/GamelistView.cpp +++ b/es-app/src/views/GamelistView.cpp @@ -49,7 +49,12 @@ void GamelistView::onFileChanged(FileData* file, bool reloadGamelist) FileData* cursor {getCursor()}; if (!cursor->isPlaceHolder()) { populateList(cursor->getParent()->getChildrenListToDisplay(), cursor->getParent()); + // Needed to avoid some minor transition animation glitches. + if (mGrid != nullptr) + mGrid->setSuppressTransitions(true); setCursor(cursor); + if (mGrid != nullptr) + mGrid->setSuppressTransitions(false); } else { populateList(mRoot->getChildrenListToDisplay(), mRoot); diff --git a/es-core/src/components/primary/GridComponent.h b/es-core/src/components/primary/GridComponent.h index c9fe5317e..08ba06d39 100644 --- a/es-core/src/components/primary/GridComponent.h +++ b/es-core/src/components/primary/GridComponent.h @@ -44,6 +44,7 @@ public: const int getColumnCount() const { return mColumns; } const int getRowCount() const { return mRows; } void setScrollVelocity(int velocity) { mScrollVelocity = velocity; } + void setSuppressTransitions(bool state) { mSuppressTransitions = state; } void setCancelTransitionsCallback(const std::function& func) override { @@ -138,6 +139,7 @@ private: bool mLayoutValid; bool mWasScrolling; bool mJustCalculatedLayout; + bool mSuppressTransitions; }; template @@ -172,6 +174,7 @@ GridComponent::GridComponent() , mLayoutValid {false} , mWasScrolling {false} , mJustCalculatedLayout {false} + , mSuppressTransitions {false} { } @@ -725,6 +728,9 @@ template void GridComponent::onCursorChanged(const CursorState& // glm::clamp(std::fabs(glm::mix(0.0f, animTime, timeDiff * 1.5f)), 180.0f, // animTime); + if (mSuppressTransitions) + animTime = 0.0f; + const float visibleRows {mVisibleRows - 1.0f}; const float startRow {static_cast(mScrollPos)}; float endRow {static_cast(mCursor / mColumns)};