mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-08-20 21:33:40 -07:00
Add second column to search results for non-widget results.
This commit is contained in:
parent
36014bb347
commit
b0befbc2b2
2 changed files with 13 additions and 12 deletions
|
@ -437,7 +437,8 @@ void PresetsCustomWidget(WidgetInfo& info) {
|
||||||
void RegisterPresetsWidgets() {
|
void RegisterPresetsWidgets() {
|
||||||
SohGui::mSohMenu->AddSidebarEntry("Settings", "Presets", 1);
|
SohGui::mSohMenu->AddSidebarEntry("Settings", "Presets", 1);
|
||||||
WidgetPath path = { "Settings", "Presets", SECTION_COLUMN_1 };
|
WidgetPath path = { "Settings", "Presets", SECTION_COLUMN_1 };
|
||||||
SohGui::mSohMenu->AddWidget(path, "PresetsWidget", WIDGET_CUSTOM).CustomFunction(PresetsCustomWidget);
|
SohGui::mSohMenu->AddWidget(path, "PresetsWidget", WIDGET_CUSTOM).CustomFunction(PresetsCustomWidget)
|
||||||
|
.HideInSearch(true);
|
||||||
presetFolder = Ship::Context::GetInstance()->GetPathRelativeToAppDirectory("presets");
|
presetFolder = Ship::Context::GetInstance()->GetPathRelativeToAppDirectory("presets");
|
||||||
std::fill_n(saveSection, PRESET_SECTION_MAX, true);
|
std::fill_n(saveSection, PRESET_SECTION_MAX, true);
|
||||||
LoadPresets();
|
LoadPresets();
|
||||||
|
|
|
@ -186,7 +186,9 @@ bool ModernMenuHeaderEntry(std::string label) {
|
||||||
|
|
||||||
uint32_t Menu::DrawSearchResults(std::string& menuSearchText) {
|
uint32_t Menu::DrawSearchResults(std::string& menuSearchText) {
|
||||||
int searchCount = 0;
|
int searchCount = 0;
|
||||||
if (ImGui::BeginChild("Search Results")) {
|
ImGui::SetNextWindowSizeConstraints({ ImGui::GetContentRegionAvail().x / 2, 0}, {ImGui::GetContentRegionAvail().x / 2, ImGui::GetContentRegionAvail().y});
|
||||||
|
if (ImGui::BeginChild("Search Results Col 1", { ImGui::GetContentRegionAvail().x / 2, windowHeight * 4 }, ImGuiChildFlags_AutoResizeY,
|
||||||
|
ImGuiWindowFlags_NoTitleBar)) {
|
||||||
for (auto& menuLabel : menuOrder) {
|
for (auto& menuLabel : menuOrder) {
|
||||||
auto& menuEntry = menuEntries.at(menuLabel);
|
auto& menuEntry = menuEntries.at(menuLabel);
|
||||||
for (auto& sidebarLabel : menuEntry.sidebarOrder) {
|
for (auto& sidebarLabel : menuEntry.sidebarOrder) {
|
||||||
|
@ -219,6 +221,7 @@ uint32_t Menu::DrawSearchResults(std::string& menuSearchText) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ImGui::EndChild();
|
||||||
}
|
}
|
||||||
return searchCount;
|
return searchCount;
|
||||||
}
|
}
|
||||||
|
@ -474,7 +477,6 @@ void Menu::MenuDrawItem(WidgetInfo& widget, uint32_t width, UIWidgets::Colors me
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
DrawSearchResults(menuSearchText);
|
DrawSearchResults(menuSearchText);
|
||||||
ImGui::EndChild();
|
|
||||||
} break;
|
} break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -798,12 +800,6 @@ void Menu::DrawElement() {
|
||||||
ImGuiWindowFlags_NoTitleBar);
|
ImGuiWindowFlags_NoTitleBar);
|
||||||
}
|
}
|
||||||
if (headerSearch && menuSearchText.length() > 0) {
|
if (headerSearch && menuSearchText.length() > 0) {
|
||||||
uint32_t searchCount = DrawSearchResults(menuSearchText);
|
|
||||||
if (searchCount == 0) {
|
|
||||||
ImGui::SetCursorPosX((ImGui::GetWindowWidth() - ImGui::CalcTextSize("No results found").x) / 2);
|
|
||||||
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 10.0f);
|
|
||||||
ImGui::TextColored(ImVec4(1.0f, 1.0f, 1.0f, 0.4f), "No results found");
|
|
||||||
}
|
|
||||||
ImGui::SetCursorPosX((ImGui::GetWindowWidth() - ImGui::CalcTextSize("Clear Search").x) / 2 - 10.0f);
|
ImGui::SetCursorPosX((ImGui::GetWindowWidth() - ImGui::CalcTextSize("Clear Search").x) / 2 - 10.0f);
|
||||||
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 10.0f);
|
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 10.0f);
|
||||||
UIWidgets::ButtonOptions clearBtnOpts = {};
|
UIWidgets::ButtonOptions clearBtnOpts = {};
|
||||||
|
@ -811,8 +807,12 @@ void Menu::DrawElement() {
|
||||||
if (UIWidgets::Button("Clear Search", clearBtnOpts)) {
|
if (UIWidgets::Button("Clear Search", clearBtnOpts)) {
|
||||||
menuSearch.Clear();
|
menuSearch.Clear();
|
||||||
}
|
}
|
||||||
|
uint32_t searchCount = DrawSearchResults(menuSearchText);
|
||||||
ImGui::EndChild();
|
if (searchCount == 0) {
|
||||||
|
ImGui::SetCursorPosX((ImGui::GetWindowWidth() - ImGui::CalcTextSize("No results found").x) / 2);
|
||||||
|
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 10.0f);
|
||||||
|
ImGui::TextColored(ImVec4(1.0f, 1.0f, 1.0f, 0.4f), "No results found");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
std::string menuLabel = menuEntries.at(headerIndex).label;
|
std::string menuLabel = menuEntries.at(headerIndex).label;
|
||||||
if (MenuInit::GetUpdateFuncs().contains(menuLabel)) {
|
if (MenuInit::GetUpdateFuncs().contains(menuLabel)) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue