Skip to content

Commit 44f90bb

Browse files
committed
Move the setting popup button in the tab holder, show it in recent game tab too
1 parent eb115e1 commit 44f90bb

File tree

4 files changed

+32
-23
lines changed

4 files changed

+32
-23
lines changed

Common/UI/ViewGroup.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1321,16 +1321,22 @@ std::string GridLayoutList::DescribeText() const {
13211321
TabHolder::TabHolder(Orientation orientation, float stripSize, LayoutParams *layoutParams)
13221322
: LinearLayout(Opposite(orientation), layoutParams), stripSize_(stripSize) {
13231323
SetSpacing(0.0f);
1324+
1325+
choiceStrip_ = new LinearLayout(orientation, new LayoutParams(WRAP_CONTENT, WRAP_CONTENT));
1326+
choiceStrip_->SetSpacing(0.0f);
1327+
13241328
if (orientation == ORIENT_HORIZONTAL) {
13251329
tabStrip_ = new ChoiceStrip(orientation, new LayoutParams(WRAP_CONTENT, WRAP_CONTENT));
13261330
tabStrip_->SetTopTabs(true);
13271331
tabScroll_ = new ScrollView(orientation, new LayoutParams(FILL_PARENT, WRAP_CONTENT));
1328-
tabScroll_->Add(tabStrip_);
1332+
choiceStrip_->Add(tabStrip_);
1333+
tabScroll_->Add(choiceStrip_);
13291334
Add(tabScroll_);
13301335
} else {
13311336
tabStrip_ = new ChoiceStrip(orientation, new LayoutParams(stripSize, WRAP_CONTENT));
13321337
tabStrip_->SetTopTabs(true);
1333-
Add(tabStrip_);
1338+
choiceStrip_->Add(tabStrip_);
1339+
Add(choiceStrip_);
13341340
}
13351341
tabStrip_->OnChoice.Handle(this, &TabHolder::OnTabClick);
13361342

Common/UI/ViewGroup.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,11 @@ class TabHolder : public LinearLayout {
361361
return tabContents;
362362
}
363363

364+
// Add a custom choice next to tab switching strip (current only used for main screen setting).
365+
Choice *AddChoice(Choice *c) {
366+
return choiceStrip_->Add(c);
367+
}
368+
364369
void SetCurrentTab(int tab, bool skipTween = false);
365370

366371
int GetCurrentTab() const { return currentTab_; }
@@ -375,6 +380,7 @@ class TabHolder : public LinearLayout {
375380
ChoiceStrip *tabStrip_ = nullptr;
376381
ScrollView *tabScroll_ = nullptr;
377382
AnchorLayout *contents_ = nullptr;
383+
LinearLayout *choiceStrip_ = nullptr;
378384

379385
float stripSize_;
380386
int currentTab_ = 0;

UI/MainScreen.cpp

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,6 @@ void GameBrowser::Refresh() {
695695
layoutChoice->AddChoice(ImageID("I_LINES"));
696696
layoutChoice->SetSelection(*gridStyle_ ? 0 : 1, false);
697697
layoutChoice->OnChoice.Handle(this, &GameBrowser::LayoutChange);
698-
topBar->Add(new Choice(ImageID("I_GEAR"), new LayoutParams(64.0f, 64.0f)))->OnClick.Handle(this, &GameBrowser::GridSettingsClick);
699698
Add(topBar);
700699

701700
if (*gridStyle_) {
@@ -715,17 +714,6 @@ void GameBrowser::Refresh() {
715714
gl->SetSpacing(4.0f);
716715
gameList_ = gl;
717716
}
718-
// Until we can come up with a better space to put it (next to the tabs?) let's get rid of the icon config
719-
// button on the Recent tab, it's ugly. You can use the button from the other tabs.
720-
721-
// LinearLayout *gridOptionColumn = new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(64.0, 64.0f));
722-
// gridOptionColumn->Add(new Spacer(12.0));
723-
// gridOptionColumn->Add(new Choice(ImageID("I_GEAR"), new LayoutParams(64.0f, 64.0f)))->OnClick.Handle(this, &GameBrowser::GridSettingsClick);
724-
// LinearLayout *grid = new LinearLayout(ORIENT_HORIZONTAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT));
725-
// gameList_->ReplaceLayoutParams(new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT, 0.75));
726-
// grid->Add(gameList_);
727-
// grid->Add(gridOptionColumn);
728-
// Add(grid);
729717
Add(gameList_);
730718
}
731719

@@ -929,21 +917,24 @@ UI::EventReturn GameBrowser::NavigateClick(UI::EventParams &e) {
929917
return UI::EVENT_DONE;
930918
}
931919

932-
UI::EventReturn GameBrowser::GridSettingsClick(UI::EventParams &e) {
920+
UI::EventReturn MainScreen::OnGridSettings(UI::EventParams &e) {
933921
auto sy = GetI18NCategory("System");
934922
auto gridSettings = new GridSettingsScreen(sy->T("Games list settings"));
935-
gridSettings->OnRecentChanged.Handle(this, &GameBrowser::OnRecentClear);
923+
gridSettings->OnRecentChanged.Handle(this, &MainScreen::OnRecentClear);
936924
if (e.v)
937925
gridSettings->SetPopupOrigin(e.v);
938926

939-
screenManager_->push(gridSettings);
927+
screenManager()->push(gridSettings);
940928
return UI::EVENT_DONE;
941929
}
942930

943-
UI::EventReturn GameBrowser::OnRecentClear(UI::EventParams &e) {
944-
screenManager_->RecreateAllViews();
945-
if (host) {
946-
host->UpdateUI();
931+
UI::EventReturn MainScreen::OnRecentClear(UI::EventParams &e) {
932+
if (tabHolder_->GetCurrentTab() == 0) {
933+
// If we are in recent tab update the tab below
934+
RecreateViews();
935+
} else {
936+
// If not schedule for dialog finish (avoid losing the current game list)
937+
recreateViewOnDialogFinish_ = true;
947938
}
948939
return UI::EVENT_DONE;
949940
}
@@ -1091,6 +1082,7 @@ void MainScreen::CreateViews() {
10911082
leftColumn->Add(new Spacer(new LinearLayoutParams(0.1f)));
10921083
}
10931084

1085+
tabHolder_->AddChoice(new Choice(ImageID("I_GEAR"), new LayoutParams(64.0f, 64.0f)))->OnClick.Handle(this, &MainScreen::OnGridSettings);
10941086
ViewGroup *rightColumn = new ScrollView(ORIENT_VERTICAL);
10951087
LinearLayout *rightColumnItems = new LinearLayout(ORIENT_VERTICAL, new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT));
10961088
rightColumnItems->SetSpacing(0.0f);
@@ -1426,6 +1418,10 @@ void MainScreen::dialogFinished(const Screen *dialog, DialogResult result) {
14261418
backFromStore_ = true;
14271419
RecreateViews();
14281420
}
1421+
if (recreateViewOnDialogFinish_) {
1422+
recreateViewOnDialogFinish_ = false;
1423+
RecreateViews();
1424+
}
14291425
if (dialog->tag() == "game") {
14301426
if (!restoreFocusGamePath_.empty() && UI::IsFocusMovementEnabled()) {
14311427
// Prevent the background from fading, since we just were displaying it.

UI/MainScreen.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,6 @@ class GameBrowser : public UI::LinearLayout {
7676
UI::EventReturn StorageClick(UI::EventParams &e);
7777
UI::EventReturn OnHomeClick(UI::EventParams &e);
7878
UI::EventReturn PinToggleClick(UI::EventParams &e);
79-
UI::EventReturn GridSettingsClick(UI::EventParams &e);
80-
UI::EventReturn OnRecentClear(UI::EventParams &e);
8179
UI::EventReturn OnHomebrewStore(UI::EventParams &e);
8280

8381
UI::ViewGroup *gameList_ = nullptr;
@@ -130,6 +128,8 @@ class MainScreen : public UIScreenWithBackground {
130128
UI::EventReturn OnDismissUpgrade(UI::EventParams &e);
131129
UI::EventReturn OnAllowStorage(UI::EventParams &e);
132130
UI::EventReturn OnFullScreenToggle(UI::EventParams &e);
131+
UI::EventReturn OnGridSettings(UI::EventParams &e);
132+
UI::EventReturn OnRecentClear(UI::EventParams &e);
133133

134134
UI::LinearLayout *upgradeBar_ = nullptr;
135135
UI::TabHolder *tabHolder_ = nullptr;
@@ -143,6 +143,7 @@ class MainScreen : public UIScreenWithBackground {
143143
float highlightProgress_ = 0.0f;
144144
float prevHighlightProgress_ = 0.0f;
145145
bool backFromStore_ = false;
146+
bool recreateViewOnDialogFinish_ = false;
146147
bool lockBackgroundAudio_ = false;
147148
bool lastVertical_;
148149
bool confirmedTemporary_ = false;

0 commit comments

Comments
 (0)