mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-15 02:29:51 +01:00
TabbedDialog: Remove the old search filter
Every screen with a search tab now uses settings pages, so the filter that hid non-matching views and disabled tabs, the filter notice above the tabs, and the GAMESETTINGS_SEARCH message are gone. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
ccf2ba49b2
commit
52042f0e78
3 files changed
+2
-124
No files matched your search
+2
-113
@@ -83,14 +83,6 @@ void UITabbedBaseDialogScreen::CreateViews() {
|
||||
// Scrolling action menu to the right.
|
||||
using namespace UI;
|
||||
|
||||
// Only created with the search tab, which depends on the orientation, so may not be there this time.
|
||||
clearSearchChoice_ = nullptr;
|
||||
noSearchResults_ = nullptr;
|
||||
|
||||
auto se = GetI18NCategory(I18NCat::SEARCH);
|
||||
filterNotice_ = new TextView("(filter notice, you shouldn't see this text", new LinearLayoutParams(Margins(20, 5)));
|
||||
filterNotice_->SetVisibility(V_GONE);
|
||||
|
||||
if (portrait) {
|
||||
auto di = GetI18NCategory(I18NCat::DIALOG);
|
||||
LinearLayout *verticalLayout = new LinearLayout(ORIENT_VERTICAL, new LayoutParams(FILL_PARENT, FILL_PARENT));
|
||||
@@ -107,7 +99,7 @@ void UITabbedBaseDialogScreen::CreateViews() {
|
||||
}, nullptr));
|
||||
};
|
||||
}
|
||||
tabHolder_ = new TabHolder(ORIENT_HORIZONTAL, 200, tabHolderFlags, filterNotice_, contextMenu, new LinearLayoutParams(1.0f));
|
||||
tabHolder_ = new TabHolder(ORIENT_HORIZONTAL, 200, tabHolderFlags, nullptr, contextMenu, new LinearLayoutParams(1.0f));
|
||||
verticalLayout->Add(tabHolder_);
|
||||
if (!(flags_ & TabDialogFlags::ContextMenuInPortrait)) {
|
||||
CreateExtraButtons(verticalLayout, 0);
|
||||
@@ -118,7 +110,7 @@ void UITabbedBaseDialogScreen::CreateViews() {
|
||||
if (flags_ & TabDialogFlags::VerticalShowIcons) {
|
||||
tabHolderFlags |= TabHolderFlags::VerticalShowIcons;
|
||||
}
|
||||
tabHolder_ = new TabHolder(ORIENT_VERTICAL, 300, tabHolderFlags, filterNotice_, nullptr, new AnchorLayoutParams(10, 0, 0, 0));
|
||||
tabHolder_ = new TabHolder(ORIENT_VERTICAL, 300, tabHolderFlags, nullptr, nullptr, new AnchorLayoutParams(10, 0, 0, 0));
|
||||
CreateExtraButtons(tabHolder_->Container(), 10);
|
||||
tabHolder_->AddBack(this);
|
||||
root_ = tabHolder_;
|
||||
@@ -146,24 +138,6 @@ void UITabbedBaseDialogScreen::CreateViews() {
|
||||
AddTab("GameSettingsSearch", ms->T("Search"), ImageID("I_SEARCH"), [this](UI::LinearLayout *parent) {
|
||||
CreateSearchTab(parent);
|
||||
});
|
||||
} else if (ShowSearchControls() && CanShowSearch()) {
|
||||
auto ms = GetI18NCategory(I18NCat::MAINSETTINGS);
|
||||
AddTab("GameSettingsSearch", ms->T("Search"), ImageID("I_SEARCH"), [this](UI::LinearLayout *searchSettings) {
|
||||
auto se = GetI18NCategory(I18NCat::SEARCH);
|
||||
|
||||
searchSettings->Add(new ItemHeader(se->T("Find settings")));
|
||||
searchSettings->Add(new PopupTextInputChoice(GetRequesterToken(), &searchFilter_, se->T("Filter"), "", 64, screenManager()))->OnChange.Add([this](UI::EventParams &e) {
|
||||
System_PostUIMessage(UIMessage::GAMESETTINGS_SEARCH, StripSpaces(searchFilter_));
|
||||
});
|
||||
|
||||
clearSearchChoice_ = searchSettings->Add(new Choice(se->T("Clear filter")));
|
||||
clearSearchChoice_->OnClick.Add([](UI::EventParams &e) {
|
||||
System_PostUIMessage(UIMessage::GAMESETTINGS_SEARCH, "");
|
||||
});
|
||||
clearSearchChoice_->SetVisibility(searchFilter_.empty() ? UI::V_GONE : UI::V_VISIBLE);
|
||||
|
||||
noSearchResults_ = searchSettings->Add(new TextView("", new LinearLayoutParams(Margins(20, 5))));
|
||||
});
|
||||
}
|
||||
|
||||
// After the search tab, which the saved tab can be.
|
||||
@@ -172,22 +146,6 @@ void UITabbedBaseDialogScreen::CreateViews() {
|
||||
} else {
|
||||
tabHolder_->EnsureTab(tabHolder_->GetCurrentTab());
|
||||
}
|
||||
|
||||
// Need to handle recreates, both important and accidental ones.
|
||||
if (!searchFilter_.empty()) {
|
||||
ApplySearchFilter();
|
||||
}
|
||||
}
|
||||
|
||||
void UITabbedBaseDialogScreen::sendMessage(UIMessage message, const char *value) {
|
||||
UIBaseDialogScreen::sendMessage(message, value);
|
||||
if (message == UIMessage::GAMESETTINGS_SEARCH) {
|
||||
std::string filter = value ? value : "";
|
||||
searchFilter_.resize(filter.size());
|
||||
std::transform(filter.begin(), filter.end(), searchFilter_.begin(), tolower);
|
||||
|
||||
ApplySearchFilter();
|
||||
}
|
||||
}
|
||||
|
||||
void UITabbedBaseDialogScreen::EnsureTabs() {
|
||||
@@ -214,75 +172,6 @@ bool UITabbedBaseDialogScreen::CanShowSearch() {
|
||||
return (g_display.dp_xres < g_display.dp_yres || g_display.dp_yres >= 500) && deviceType != DEVICE_TYPE_VR;
|
||||
}
|
||||
|
||||
void UITabbedBaseDialogScreen::ApplySearchFilter() {
|
||||
using namespace UI;
|
||||
// GAMESETTINGS_SEARCH is broadcast to every screen, including ones whose views don't exist yet,
|
||||
// and ones that search some other way.
|
||||
if (!tabHolder_ || !ShowSearchControls()) {
|
||||
return;
|
||||
}
|
||||
auto se = GetI18NCategory(I18NCat::SEARCH);
|
||||
|
||||
EnsureTabs();
|
||||
|
||||
// Show an indicator that a filter is applied.
|
||||
filterNotice_->SetVisibility(searchFilter_.empty() ? UI::V_GONE : UI::V_VISIBLE);
|
||||
filterNotice_->SetText(ApplySafeSubstitutions(se->T("Filtering settings by '%1'"), searchFilter_));
|
||||
|
||||
bool matches = searchFilter_.empty();
|
||||
|
||||
const std::vector<ViewGroup *> settingTabs = tabHolder_->GetTabContentViews();
|
||||
|
||||
for (int t = 0; t < (int)settingTabs.size(); ++t) {
|
||||
const ViewGroup *tabContents = settingTabs[t];
|
||||
std::string_view tag = tabContents->Tag();
|
||||
|
||||
// Dive down to the actual list of settings.
|
||||
// TODO: Do this recursively instead.
|
||||
while (tabContents->GetNumSubviews() == 1) {
|
||||
View *v = tabContents->GetViewByIndex(0);
|
||||
if (v->IsViewGroup()) {
|
||||
tabContents = (ViewGroup *)v;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (tag == "GameSettingsSearch") {
|
||||
continue;
|
||||
}
|
||||
|
||||
bool tabMatches = searchFilter_.empty();
|
||||
|
||||
UI::View *lastHeading = nullptr;
|
||||
for (int i = 1; i < tabContents->GetNumSubviews(); ++i) {
|
||||
UI::View *v = tabContents->GetViewByIndex(i);
|
||||
if (!v->CanBeFocused()) {
|
||||
lastHeading = v;
|
||||
}
|
||||
|
||||
std::string label = v->DescribeText();
|
||||
std::transform(label.begin(), label.end(), label.begin(), tolower);
|
||||
bool match = v->CanBeFocused() && label.find(searchFilter_) != label.npos;
|
||||
tabMatches = tabMatches || match;
|
||||
|
||||
if (match && lastHeading)
|
||||
lastHeading->SetVisibility(UI::V_VISIBLE);
|
||||
v->SetVisibility((searchFilter_.empty() || match) ? UI::V_VISIBLE : UI::V_GONE);
|
||||
}
|
||||
tabHolder_->EnableTab(t, tabMatches);
|
||||
matches = matches || tabMatches;
|
||||
}
|
||||
|
||||
if (noSearchResults_) {
|
||||
noSearchResults_->SetText(ApplySafeSubstitutions(se->T("No settings matched '%1'"), searchFilter_));
|
||||
noSearchResults_->SetVisibility(matches ? UI::V_GONE : UI::V_VISIBLE);
|
||||
}
|
||||
if (clearSearchChoice_) {
|
||||
clearSearchChoice_->SetVisibility(searchFilter_.empty() ? UI::V_GONE : UI::V_VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
static bool SettingTextMatches(const SettingText &text, I18NCat pageCat, std::string_view query) {
|
||||
if (text.empty()) {
|
||||
return false;
|
||||
|
||||
Reference in new issue
Block a user