UI: Allow skipping transitions on set current tab.

This commit is contained in:
Unknown W. Brackets 2017-12-12 21:34:17 -08:00
parent e7c9bb2a17
commit 09bbd58b62
3 changed files with 24 additions and 18 deletions

View File

@ -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);

View File

@ -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;
}

View File

@ -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(); }