9 namespace ImGuiUtilities
22 vec.erase( std::unique( vec.begin(), vec.end() ), vec.end() );
35 std::sort( vec.begin(), vec.end() );
36 vec.erase( unique( vec.begin(), vec.end() ), vec.end() );
44 static void HelpMarker(
const char* desc)
46 ImGui::TextDisabled(
"(?)");
47 if (ImGui::IsItemHovered())
49 ImGui::BeginTooltip();
50 ImGui::PushTextWrapPos(ImGui::GetFontSize() * 35.0f);
51 ImGui::TextUnformatted(desc);
52 ImGui::PopTextWrapPos();
63 static auto vector_getter = [](
void* vec,
int idx,
const char** out_text)
65 auto& vector = *
static_cast<std::vector<std::string>*
>(vec);
66 if (idx < 0 || idx >= static_cast<int>(vector.size())) {
return false; }
67 *out_text = vector.at(idx).c_str();
76 bool Combo(
const char* label,
int* currIndex, std::vector<std::string>& values)
78 if (values.empty()) {
return false; }
79 return ImGui::Combo(label, currIndex, vector_getter, static_cast<void*>(&values), values.size());
87 bool ListBox(
const char* label,
int* currIndex, std::vector<std::string>& values)
89 if (values.empty()) {
return false; }
90 return ImGui::ListBox(label, currIndex, vector_getter, static_cast<void*>(&values), values.size());
void removeDuplicates(std::vector< std::string > &vec)
Sort a vector and remove duplicates from it. Useful for Combo and ListBox when duplicate entries are ...
Definition: ImGuiUtilities.hpp:33
bool Combo(const char *label, int *currIndex, std::vector< std::string > &values)
Wrapper function that takes a std::vector<std::string> and converts it in place to build an ImGui::Co...
Definition: ImGuiUtilities.hpp:76
void removeDuplicatesSorted(std::vector< std::string > &vec)
Removes duplicate strings from a sorted vector. Useful for Combo and ListBox when duplicate entries a...
Definition: ImGuiUtilities.hpp:20
bool ListBox(const char *label, int *currIndex, std::vector< std::string > &values)
Wrapper function that takes a std::vector<std::string> and converts it in place to build an ImGui::Li...
Definition: ImGuiUtilities.hpp:87