1 #include "SearchableListWidget.h"
5 elements = std::move(newElements);
6 filteredElements.clear();
7 filteredElements.reserve(elements.size());
8 for (
const std::string& str : elements)
9 filteredElements.push_back(str.data());
10 currentSelectionIndex = 0;
13 void SearchableListWidget::updateFilteredElementsList()
15 filteredElements.clear();
16 for (
const std::string& str : elements)
18 if (textFilter.PassFilter(str.data())) filteredElements.push_back(str.data());
24 if (textFilter.Draw(
"##Filter")) {
25 updateFilteredElementsList();
27 if (!filteredElements.size()) {
28 ImGui::Text(
"No file found.");
31 return ImGui::ListBox(
32 "##List", ¤tSelectionIndex, filteredElements.data(), int(filteredElements.size()),
33 int(ImGui::GetContentRegionAvail().y / ImGui::GetTextLineHeightWithSpacing()) - 1);
38 if (currentSelectionIndex >= 0 &&
size_t(currentSelectionIndex) < filteredElements.size()) {
39 return filteredElements[size_t(currentSelectionIndex)];