Permalink
Browse files

UI: Allow skipping transitions on set current tab.

  • Loading branch information...
unknownbrackets committed Dec 13, 2017
1 parent e7c9bb2 commit 09bbd58b626c2dac75cf416e03499d0537369ce1
Showing with 24 additions and 18 deletions.
  1. +5 −5 UI/MainScreen.cpp
  2. +18 −12 ext/native/ui/viewgroup.cpp
  3. +1 −1 ext/native/ui/viewgroup.h
View
@@ -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);
@@ -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;
}
@@ -310,7 +310,7 @@ class TabHolder : public LinearLayout {
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(); }

0 comments on commit 09bbd58

Please sign in to comment.