Skip to content
Snippets Groups Projects

Add ImGui::Combo and ListBox utilities for tg::span

Merged Jonathan Kunstwald requested to merge feature/more-imgui-utils into develop
2 files
+ 37
3
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -3,6 +3,17 @@
#include <imgui/imgui.h>
namespace
{
bool span_getter(void* data, int i, const char** out)
{
if (i < 0)
return false;
*out = static_cast<std::string*>(data)[unsigned(i)].c_str();
return true;
};
}
void glow::debugging::applyGlowImguiTheme(bool darkMode)
{
ImGuiStyle& style = ImGui::GetStyle();
@@ -144,4 +155,18 @@ void glow::debugging::applyGlowImguiTheme(bool darkMode)
#endif
}
bool glow::debugging::imgui::Combo(char const* label, int* currIndex, tg::span<std::string> values)
{
if (values.empty())
return false;
return ::ImGui::Combo(label, currIndex, span_getter, values.data(), int(values.size()));
}
bool glow::debugging::imgui::ListBox(char const* label, int* currIndex, tg::span<std::string> values)
{
if (values.empty())
return false;
return ::ImGui::ListBox(label, currIndex, span_getter, values.data(), int(values.size()));
}
#endif
Loading