From 7f036f843112bd53e6d4892163e57bb147591cf9 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 28 Feb 2021 12:25:37 -0800 Subject: [PATCH] UI: Fix L/R tab navigation. --- Common/UI/ViewGroup.cpp | 12 ++++++------ Common/UI/ViewGroup.h | 2 +- UI/ComboKeyMappingScreen.cpp | 2 +- UI/DisplayLayoutScreen.cpp | 2 +- UI/MainScreen.cpp | 2 +- UI/SavedataScreen.cpp | 2 +- UI/TouchControlLayoutScreen.cpp | 2 +- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Common/UI/ViewGroup.cpp b/Common/UI/ViewGroup.cpp index 1f8ebd0436f9..7f133a25b62f 100644 --- a/Common/UI/ViewGroup.cpp +++ b/Common/UI/ViewGroup.cpp @@ -1288,7 +1288,7 @@ void TabHolder::SetCurrentTab(int tab, bool skipTween) { currentTab_ = tab; } - tabStrip_->SetSelection(tab); + tabStrip_->SetSelection(tab, false); } EventReturn TabHolder::OnTabClick(EventParams &e) { @@ -1369,7 +1369,7 @@ EventReturn ChoiceStrip::OnChoiceClick(EventParams &e) { return OnChoice.Dispatch(e2); } -void ChoiceStrip::SetSelection(int sel) { +void ChoiceStrip::SetSelection(int sel, bool triggerClick) { int prevSelected = selected_; StickyChoice *prevChoice = Choice(selected_); if (prevChoice) @@ -1384,7 +1384,7 @@ void ChoiceStrip::SetSelection(int sel) { e.v = views_[selected_]; e.a = selected_; // Set to 0 to indicate a selection change (not a click.) - e.b = 0; + e.b = triggerClick ? 1 : 0; OnChoice.Trigger(e); } } @@ -1398,16 +1398,16 @@ void ChoiceStrip::HighlightChoice(unsigned int choice){ bool ChoiceStrip::Key(const KeyInput &input) { bool ret = false; - if (input.flags & KEY_DOWN) { + if (topTabs_ && (input.flags & KEY_DOWN)) { if (IsTabLeftKey(input)) { if (selected_ > 0) { - SetSelection(selected_ - 1); + SetSelection(selected_ - 1, true); UI::PlayUISound(UI::UISound::TOGGLE_OFF); // Maybe make specific sounds for this at some point? } ret = true; } else if (IsTabRightKey(input)) { if (selected_ < (int)views_.size() - 1) { - SetSelection(selected_ + 1); + SetSelection(selected_ + 1, true); UI::PlayUISound(UI::UISound::TOGGLE_ON); } ret = true; diff --git a/Common/UI/ViewGroup.h b/Common/UI/ViewGroup.h index dfedc175d813..5bbac5e06066 100644 --- a/Common/UI/ViewGroup.h +++ b/Common/UI/ViewGroup.h @@ -300,7 +300,7 @@ class ChoiceStrip : public LinearLayout { void AddChoice(ImageID buttonImage); int GetSelection() const { return selected_; } - void SetSelection(int sel); + void SetSelection(int sel, bool triggerClick); void HighlightChoice(unsigned int choice); diff --git a/UI/ComboKeyMappingScreen.cpp b/UI/ComboKeyMappingScreen.cpp index d5742c575a4d..f1582ef9aa1d 100644 --- a/UI/ComboKeyMappingScreen.cpp +++ b/UI/ComboKeyMappingScreen.cpp @@ -52,7 +52,7 @@ void ComboKeyScreen::CreateViews() { for (int i = 0; i < 5; i++) { comboselect->AddChoice(comboKeyImages[i]); } - comboselect->SetSelection(*mode); + comboselect->SetSelection(*mode, false); comboselect->OnChoice.Handle(this, &ComboKeyScreen::onCombo); leftColumn->Add(comboselect); root__->Add(leftColumn); diff --git a/UI/DisplayLayoutScreen.cpp b/UI/DisplayLayoutScreen.cpp index 0ab23394ec57..2211cb6cbbf6 100644 --- a/UI/DisplayLayoutScreen.cpp +++ b/UI/DisplayLayoutScreen.cpp @@ -319,7 +319,7 @@ void DisplayLayoutScreen::CreateViews() { mode_ = new ChoiceStrip(ORIENT_VERTICAL, new AnchorLayoutParams(leftColumnWidth, WRAP_CONTENT, 10 + leftInset, NONE, NONE, 158 + 64 + 10)); mode_->AddChoice(di->T("Move")); mode_->AddChoice(di->T("Resize")); - mode_->SetSelection(0); + mode_->SetSelection(0, false); } displayRepresentation_ = new DragDropDisplay(g_Config.fSmallDisplayOffsetX, g_Config.fSmallDisplayOffsetY, ImageID("I_PSP_DISPLAY"), ScaleSettingToUI(), bounds); displayRepresentation_->SetVisibility(V_VISIBLE); diff --git a/UI/MainScreen.cpp b/UI/MainScreen.cpp index 6b4ab43351e0..8ab0288b8be7 100644 --- a/UI/MainScreen.cpp +++ b/UI/MainScreen.cpp @@ -664,7 +664,7 @@ void GameBrowser::Refresh() { ChoiceStrip *layoutChoice = topBar->Add(new ChoiceStrip(ORIENT_HORIZONTAL)); layoutChoice->AddChoice(ImageID("I_GRID")); layoutChoice->AddChoice(ImageID("I_LINES")); - layoutChoice->SetSelection(*gridStyle_ ? 0 : 1); + layoutChoice->SetSelection(*gridStyle_ ? 0 : 1, false); layoutChoice->OnChoice.Handle(this, &GameBrowser::LayoutChange); topBar->Add(new Choice(ImageID("I_GEAR"), new LayoutParams(64.0f, 64.0f)))->OnClick.Handle(this, &GameBrowser::GridSettingsClick); Add(topBar); diff --git a/UI/SavedataScreen.cpp b/UI/SavedataScreen.cpp index 494af9494184..e42e3e7e50db 100644 --- a/UI/SavedataScreen.cpp +++ b/UI/SavedataScreen.cpp @@ -510,7 +510,7 @@ void SavedataScreen::CreateViews() { sortStrip->AddChoice(sa->T("Filename")); sortStrip->AddChoice(sa->T("Size")); sortStrip->AddChoice(sa->T("Date")); - sortStrip->SetSelection((int)sortOption_); + sortStrip->SetSelection((int)sortOption_, false); sortStrip->OnChoice.Handle(this, &SavedataScreen::OnSortClick); root_->Add(main); diff --git a/UI/TouchControlLayoutScreen.cpp b/UI/TouchControlLayoutScreen.cpp index 9a6b7d061593..25a5a07df020 100644 --- a/UI/TouchControlLayoutScreen.cpp +++ b/UI/TouchControlLayoutScreen.cpp @@ -511,7 +511,7 @@ void TouchControlLayoutScreen::CreateViews() { mode_ = new ChoiceStrip(ORIENT_VERTICAL, new AnchorLayoutParams(leftColumnWidth, WRAP_CONTENT, 10, NONE, NONE, 140 + 158 + 64 + 10)); mode_->AddChoice(di->T("Move")); mode_->AddChoice(di->T("Resize")); - mode_->SetSelection(0); + mode_->SetSelection(0, false); mode_->OnChoice.Handle(this, &TouchControlLayoutScreen::OnMode); reset->OnClick.Handle(this, &TouchControlLayoutScreen::OnReset);