Archived
1
Fork 0
This repository has been archived on 2025-04-12. You can view files and clone it, but cannot push or open issues or pull requests.
graphite/3rdparty/imgui/include/imgui_stl.h
2024-01-03 16:05:02 -05:00

30 lines
No EOL
971 B
C++

#pragma once
#include <string>
#include <vector>
//from https://eliasdaler.github.io/using-imgui-with-sfml-pt2/
namespace ImGui
{
static auto vector_getter = [](void* vec, int idx, const char** out_text)
{
auto& vector = *static_cast<std::vector<std::string>*>(vec);
if (idx < 0 || idx >= static_cast<int>(vector.size())) { return false; }
*out_text = vector.at(idx).c_str();
return true;
};
bool Combo(const char* label, int* currIndex, std::vector<std::string>& values)
{
if (values.empty()) { return false; }
return Combo(label, currIndex, vector_getter,
static_cast<void*>(&values), values.size());
}
bool ListBox(const char* label, int* currIndex, std::vector<std::string>& values)
{
if (values.empty()) { return false; }
return ListBox(label, currIndex, vector_getter,
static_cast<void*>(&values), values.size());
}
}