Skip to content

Commit

Permalink
UI: Fix L/R tab navigation.
Browse files Browse the repository at this point in the history
  • Loading branch information
unknownbrackets committed Mar 3, 2021
1 parent c42a03c commit 7f036f8
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions Common/UI/ViewGroup.cpp
Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
Expand All @@ -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);
}
}
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion Common/UI/ViewGroup.h
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion UI/ComboKeyMappingScreen.cpp
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion UI/DisplayLayoutScreen.cpp
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion UI/MainScreen.cpp
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion UI/SavedataScreen.cpp
Expand Up @@ -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<SavedataScreen>(this, &SavedataScreen::OnSortClick);

root_->Add(main);
Expand Down
2 changes: 1 addition & 1 deletion UI/TouchControlLayoutScreen.cpp
Expand Up @@ -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);
Expand Down

0 comments on commit 7f036f8

Please sign in to comment.