Skip to content
Snippets Groups Projects
Commit 00323a8e authored by Jonathan Kunstwald's avatar Jonathan Kunstwald
Browse files

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

parent de205c59
No related branches found
No related tags found
1 merge request!67Add ImGui::Combo and ListBox utilities for tg::span
...@@ -3,6 +3,17 @@ ...@@ -3,6 +3,17 @@
#include <imgui/imgui.h> #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) void glow::debugging::applyGlowImguiTheme(bool darkMode)
{ {
ImGuiStyle& style = ImGui::GetStyle(); ImGuiStyle& style = ImGui::GetStyle();
...@@ -144,4 +155,18 @@ void glow::debugging::applyGlowImguiTheme(bool darkMode) ...@@ -144,4 +155,18 @@ void glow::debugging::applyGlowImguiTheme(bool darkMode)
#endif #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 #endif
...@@ -2,11 +2,20 @@ ...@@ -2,11 +2,20 @@
#ifdef GLOW_EXTRAS_HAS_IMGUI #ifdef GLOW_EXTRAS_HAS_IMGUI
namespace glow #include <string>
{
namespace debugging #include <typed-geometry/types/span.hh>
namespace glow::debugging
{ {
void applyGlowImguiTheme(bool darkMode = false); void applyGlowImguiTheme(bool darkMode = false);
namespace imgui
{
/// ImGui::Combo for array_like<string>
bool Combo(const char* label, int* currIndex, tg::span<std::string> values);
/// ImGui::ListBox for array_like<string>
bool ListBox(const char* label, int* currIndex, tg::span<std::string> values);
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment