mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-13 09:39:33 +01:00
Settings: Clicking the current tab goes back up to its root page
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
7cb6276a00
commit
e57c8ba756
6 files changed
+29
No files matched your search
@@ -244,6 +244,13 @@ void TabHolder::OnTabClick(EventParams &e) {
|
||||
// We have e.b set when it was an explicit click action.
|
||||
// In that case, we make the view gone and then visible - this scrolls scrollviews to the top.
|
||||
if (e.b != 0) {
|
||||
if ((int)e.a == currentTab_) {
|
||||
UI::EventParams e2{};
|
||||
e2.v = this;
|
||||
e2.a = currentTab_;
|
||||
OnReselectTab.Trigger(e2);
|
||||
return;
|
||||
}
|
||||
// SetCurrentTab calls EnsureTab if needed.
|
||||
SetCurrentTab((int)e.a);
|
||||
}
|
||||
|
||||
@@ -53,6 +53,8 @@ public:
|
||||
bool EnsureTab(int index); // return true if it actually created a tab.
|
||||
|
||||
Event OnChangeTab;
|
||||
// A click on the tab that's already shown.
|
||||
Event OnReselectTab;
|
||||
|
||||
private:
|
||||
void AddTabContents(std::string_view title, ImageID imageId, ViewGroup *tabContents);
|
||||
|
||||
@@ -594,3 +594,17 @@ int SettingsPagesDialogScreen::InitialTab() {
|
||||
void SettingsPagesDialogScreen::TabChanged(int tab) {
|
||||
SetSearchText("");
|
||||
}
|
||||
|
||||
// Picking the tab that's shown leaves the search, and goes back up to the tab's root page.
|
||||
void SettingsPagesDialogScreen::TabReselected(int tab) {
|
||||
SetSearchText("");
|
||||
int settingsTab = CurrentSettingsTab();
|
||||
if (settingsTab < 0) {
|
||||
return;
|
||||
}
|
||||
const std::vector<int> &path = pagePaths_[settingsTabs_[settingsTab].tag];
|
||||
if (path.empty()) {
|
||||
return;
|
||||
}
|
||||
ShowPage(settingsTab, {}, path[0]); // Focuses the link to the page we're leaving.
|
||||
}
|
||||
@@ -58,6 +58,7 @@ protected:
|
||||
// with the page, like lists read from disk, doesn't need to be read again.
|
||||
bool RecreatingForPageChange() const { return pageChange_; }
|
||||
void TabChanged(int tab) override;
|
||||
void TabReselected(int tab) override;
|
||||
|
||||
// Whether there's a way to type a search.
|
||||
static bool CanShowSearch();
|
||||
|
||||
@@ -111,6 +111,9 @@ void UITabbedBaseDialogScreen::CreateViews() {
|
||||
}
|
||||
TabChanged(e.a);
|
||||
});
|
||||
tabHolder_->OnReselectTab.Add([this](UI::EventParams &e) {
|
||||
TabReselected(e.a);
|
||||
});
|
||||
|
||||
int initialTab = InitialTab();
|
||||
if (initialTab >= 0) {
|
||||
|
||||
@@ -50,6 +50,8 @@ protected:
|
||||
// The tab to show first, after CreateTabs, if not the saved one (-1).
|
||||
virtual int InitialTab() { return -1; }
|
||||
virtual void TabChanged(int tab) {}
|
||||
// The tab already shown was clicked.
|
||||
virtual void TabReselected(int tab) {}
|
||||
|
||||
int GetCurrentTab() const;
|
||||
void SetCurrentTab(int tab);
|
||||
|
||||
Reference in new issue
Block a user