Remember game list scroll

This commit is contained in:
iota97 2020-11-23 10:06:48 +01:00
parent 388ac3c9ae
commit a014d7c785
6 changed files with 13 additions and 7 deletions

View file

@ -860,7 +860,7 @@ void ScrollView::PersistData(PersistStatus status, std::string anonId, PersistMa
void ScrollView::SetVisibility(Visibility visibility) {
ViewGroup::SetVisibility(visibility);
if (visibility == V_GONE) {
if (visibility == V_GONE && !rememberPosition_) {
// Since this is no longer shown, forget the scroll position.
// For example, this happens when switching tabs.
ScrollTo(0.0f);

View file

@ -222,8 +222,8 @@ private:
// A scrollview usually contains just a single child - a linear layout or similar.
class ScrollView : public ViewGroup {
public:
ScrollView(Orientation orientation, LayoutParams *layoutParams = 0)
: ViewGroup(layoutParams), orientation_(orientation) {}
ScrollView(Orientation orientation, LayoutParams *layoutParams = 0, bool rememberPosition = false)
: ViewGroup(layoutParams), orientation_(orientation), rememberPosition_(rememberPosition) {}
void Measure(const UIContext &dc, MeasureSpec horiz, MeasureSpec vert) override;
void Layout() override;
@ -262,6 +262,7 @@ private:
float pull_ = 0.0f;
float lastViewSize_ = 0.0f;
bool scrollToTopOnSizeChange_ = false;
bool rememberPosition_;
};
class ViewPager : public ScrollView {

View file

@ -450,6 +450,7 @@ static ConfigSetting generalSettings[] = {
ReportedConfigSetting("EnableCheats", &g_Config.bEnableCheats, false, true, true),
ConfigSetting("CwCheatRefreshRate", &g_Config.iCwCheatRefreshRate, 77, true, true),
ConfigSetting("CwCheatScrollPosition", &g_Config.fCwCheatScrollPosition, 0.0f, true, true),
ConfigSetting("GameListScrollPosition", &g_Config.fGameListScrollPosition, 0.0f),
ConfigSetting("ScreenshotsAsPNG", &g_Config.bScreenshotsAsPNG, false, true, true),
ConfigSetting("UseFFV1", &g_Config.bUseFFV1, false),

View file

@ -207,6 +207,7 @@ public:
bool bReloadCheats;
int iCwCheatRefreshRate;
float fCwCheatScrollPosition;
float fGameListScrollPosition;
int iBloomHack; //0 = off, 1 = safe, 2 = balanced, 3 = aggressive
bool bBlockTransferGPU;
bool bDisableSlowFramebufEffects;

View file

@ -988,8 +988,8 @@ void MainScreen::CreateViews() {
Button *focusButton = nullptr;
if (hasStorageAccess) {
ScrollView *scrollAllGames = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT));
scrollAllGames->SetTag("MainScreenAllGames");
scrollAllGames_ = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT), true);
scrollAllGames_->SetTag("MainScreenAllGames");
ScrollView *scrollHomebrew = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT));
scrollHomebrew->SetTag("MainScreenHomebrew");
@ -1000,13 +1000,14 @@ void MainScreen::CreateViews() {
mm->T("How to get homebrew & demos", "How to get homebrew && demos"), "https://www.ppsspp.org/gethomebrew.html",
new LinearLayoutParams(FILL_PARENT, FILL_PARENT));
scrollAllGames->Add(tabAllGames);
scrollAllGames_->Add(tabAllGames);
gameBrowsers_.push_back(tabAllGames);
scrollHomebrew->Add(tabHomebrew);
gameBrowsers_.push_back(tabHomebrew);
tabHolder_->AddTab(mm->T("Games"), scrollAllGames);
tabHolder_->AddTab(mm->T("Games"), scrollAllGames_);
tabHolder_->AddTab(mm->T("Homebrew & Demos"), scrollHomebrew);
scrollAllGames_->ScrollTo(g_Config.fGameListScrollPosition);
tabAllGames->OnChoice.Handle(this, &MainScreen::OnGameSelectedInstant);
tabHomebrew->OnChoice.Handle(this, &MainScreen::OnGameSelectedInstant);
@ -1202,6 +1203,7 @@ void MainScreen::update() {
RecreateViews();
lastVertical_ = vertical;
}
g_Config.fGameListScrollPosition = scrollAllGames_->GetScrollPosition();
}
bool MainScreen::UseVerticalLayout() const {

View file

@ -138,6 +138,7 @@ protected:
bool lockBackgroundAudio_ = false;
bool lastVertical_;
bool confirmedTemporary_ = false;
UI::ScrollView *scrollAllGames_ = nullptr;
friend class RemoteISOBrowseScreen;
};