From 09bbd58b626c2dac75cf416e03499d0537369ce1 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Tue, 12 Dec 2017 21:34:17 -0800 Subject: [PATCH] UI: Allow skipping transitions on set current tab. --- UI/MainScreen.cpp | 10 +++++----- ext/native/ui/viewgroup.cpp | 30 ++++++++++++++++++------------ ext/native/ui/viewgroup.h | 2 +- 3 files changed, 24 insertions(+), 18 deletions(-) diff --git a/UI/MainScreen.cpp b/UI/MainScreen.cpp index 32287e0a43..64ab0f8052 100644 --- a/UI/MainScreen.cpp +++ b/UI/MainScreen.cpp @@ -799,13 +799,13 @@ void MainScreen::CreateViews() { tabHomebrew->OnHighlight.Handle(this, &MainScreen::OnGameHighlight); if (g_Config.recentIsos.size() > 0) { - leftColumn->SetCurrentTab(0); + tabHolder_->SetCurrentTab(0, true); } else if (g_Config.iMaxRecent > 0) { - leftColumn->SetCurrentTab(1); + tabHolder_->SetCurrentTab(1, true); } if (backFromStore_ || showHomebrewTab) { - leftColumn->SetCurrentTab(2); + tabHolder_->SetCurrentTab(2, true); backFromStore_ = false; showHomebrewTab = false; } @@ -1224,9 +1224,9 @@ void UmdReplaceScreen::CreateViews() { rightColumnItems->Add(new Choice(mm->T("Game Settings")))->OnClick.Handle(this, &UmdReplaceScreen::OnGameSettings); if (g_Config.recentIsos.size() > 0) { - leftColumn->SetCurrentTab(0); + leftColumn->SetCurrentTab(0, true); } else if (g_Config.iMaxRecent > 0) { - leftColumn->SetCurrentTab(1); + leftColumn->SetCurrentTab(1, true); } root_ = new LinearLayout(ORIENT_HORIZONTAL); diff --git a/ext/native/ui/viewgroup.cpp b/ext/native/ui/viewgroup.cpp index 04edc5104a..5a9b4b425b 100644 --- a/ext/native/ui/viewgroup.cpp +++ b/ext/native/ui/viewgroup.cpp @@ -1162,7 +1162,7 @@ void TabHolder::AddTabContents(const std::string &title, View *tabContents) { tabTweens_.push_back(nullptr); } -void TabHolder::SetCurrentTab(int tab) { +void TabHolder::SetCurrentTab(int tab, bool skipTween) { if (tab >= (int)tabs_.size()) { // Ignore return; @@ -1190,18 +1190,24 @@ void TabHolder::SetCurrentTab(int tab) { setupTween(tabs_[tab], tabTweens_[tab]); // Currently displayed, so let's reset it. - tabTweens_[currentTab_]->Reset(Point(0.0f, 0.0f)); - - if (orient == ORIENT_HORIZONTAL) { - tabTweens_[tab]->Reset(Point(bounds_.w * dir, 0.0f)); - tabTweens_[currentTab_]->Divert(Point(bounds_.w * -dir, 0.0f)); + if (skipTween) { + tabs_[currentTab_]->SetVisibility(V_GONE); + tabTweens_[tab]->Reset(Point(0.0f, 0.0f)); + tabTweens_[tab]->Apply(tabs_[tab]); } else { - tabTweens_[tab]->Reset(Point(0.0f, bounds_.h * dir)); - tabTweens_[currentTab_]->Divert(Point(0.0f, bounds_.h * -dir)); + tabTweens_[currentTab_]->Reset(Point(0.0f, 0.0f)); + + if (orient == ORIENT_HORIZONTAL) { + tabTweens_[tab]->Reset(Point(bounds_.w * dir, 0.0f)); + tabTweens_[currentTab_]->Divert(Point(bounds_.w * -dir, 0.0f)); + } else { + tabTweens_[tab]->Reset(Point(0.0f, bounds_.h * dir)); + tabTweens_[currentTab_]->Divert(Point(0.0f, bounds_.h * -dir)); + } + // Actually move it to the initial position now, just to avoid any flicker. + tabTweens_[tab]->Apply(tabs_[tab]); + tabTweens_[tab]->Divert(Point(0.0f, 0.0f)); } - // Actually move it to the initial position now, just to avoid any flicker. - tabTweens_[tab]->Apply(tabs_[tab]); - tabTweens_[tab]->Divert(Point(0.0f, 0.0f)); tabs_[tab]->SetVisibility(V_VISIBLE); currentTab_ = tab; @@ -1235,7 +1241,7 @@ void TabHolder::PersistData(PersistStatus status, std::string anonId, PersistMap case PERSIST_RESTORE: if (buffer.size() == 1) { - SetCurrentTab(buffer[0]); + SetCurrentTab(buffer[0], true); } break; } diff --git a/ext/native/ui/viewgroup.h b/ext/native/ui/viewgroup.h index efda9a4009..b7de8c539c 100644 --- a/ext/native/ui/viewgroup.h +++ b/ext/native/ui/viewgroup.h @@ -310,7 +310,7 @@ public: return tabContents; } - void SetCurrentTab(int tab); + void SetCurrentTab(int tab, bool skipTween = false); int GetCurrentTab() const { return currentTab_; } std::string Describe() const override { return "TabHolder: " + View::Describe(); }