Fixed an issue where the cursor stack would not work correctly with the Grid view style.

This commit is contained in:
Leon Styhre 2021-03-13 12:19:56 +01:00
parent 5ad03f3043
commit a7f431ae9f
4 changed files with 26 additions and 8 deletions

View file

@ -115,8 +115,8 @@ void BasicGameListView::setCursor(FileData* cursor)
populateList(cursor->getParent()->getChildrenListToDisplay(), cursor->getParent());
mList.setCursor(cursor);
// Update our cursor stack in case our cursor just
// got set to some folder we weren't in before.
// Update our cursor stack in case our cursor just got set to some folder
// we weren't in before.
if (mCursorStack.empty() || mCursorStack.top() != cursor->getParent()) {
std::stack<FileData*> tmp;
FileData* ptr = cursor->getParent();

View file

@ -23,7 +23,7 @@ public:
virtual void onThemeChanged(const std::shared_ptr<ThemeData>& theme) override;
virtual FileData* getCursor() override;
virtual void setCursor(FileData* file) override;
virtual void setCursor(FileData* cursor) override;
virtual FileData* getNextEntry() override;
virtual FileData* getPreviousEntry() override;
virtual FileData* getFirstEntry() override;

View file

@ -171,11 +171,29 @@ FileData* GridGameListView::getCursor()
return mGrid.getSelected();
}
void GridGameListView::setCursor(FileData* file)
void GridGameListView::setCursor(FileData* cursor)
{
if (!mGrid.setCursor(file) && (!file->isPlaceHolder())) {
populateList(file->getParent()->getChildrenListToDisplay(), file->getParent());
mGrid.setCursor(file);
if (!mGrid.setCursor(cursor) && (!cursor->isPlaceHolder())) {
populateList(cursor->getParent()->getChildrenListToDisplay(), cursor->getParent());
mGrid.setCursor(cursor);
// Update our cursor stack in case our cursor just got set to some folder
// we weren't in before.
if (mCursorStack.empty() || mCursorStack.top() != cursor->getParent()) {
std::stack<FileData*> tmp;
FileData* ptr = cursor->getParent();
while (ptr && ptr != mRoot) {
tmp.push(ptr);
ptr = ptr->getParent();
}
// Flip the stack and put it in mCursorStack.
mCursorStack = std::stack<FileData*>();
while (!tmp.empty()) {
mCursorStack.push(tmp.top());
tmp.pop();
}
}
}
}

View file

@ -30,7 +30,7 @@ public:
virtual void onThemeChanged(const std::shared_ptr<ThemeData>& theme) override;
virtual FileData* getCursor() override;
virtual void setCursor(FileData*) override;
virtual void setCursor(FileData* cursor) override;
virtual FileData* getNextEntry() override;
virtual FileData* getPreviousEntry() override;
virtual FileData* getFirstEntry() override;