diff --git a/include/igl/opengl/glfw/imgui/ImGuiHelpers.h b/include/igl/opengl/glfw/imgui/ImGuiHelpers.h index f35f097..8dcb3af 100644 --- a/include/igl/opengl/glfw/imgui/ImGuiHelpers.h +++ b/include/igl/opengl/glfw/imgui/ImGuiHelpers.h @@ -25,28 +25,25 @@ namespace ImGui { -static auto vector_getter = [](void* vec, int idx, const char** out_text) +static auto vector_getter = [](void* vec, int idx) -> const char* { auto& vector = *static_cast*>(vec); - if (idx < 0 || idx >= static_cast(vector.size())) { return false; } - *out_text = vector.at(idx).c_str(); - return true; + if (idx < 0 || idx >= static_cast(vector.size())) { return nullptr; } + return vector.at(idx).c_str(); }; inline bool Combo(const char* label, int* idx, std::vector& values) { if (values.empty()) { return false; } return Combo(label, idx, vector_getter, - static_cast(&values), values.size()); + static_cast(&values), static_cast(values.size())); } inline bool Combo(const char* label, int* idx, std::function getter, int items_count) { - auto func = [](void* data, int i, const char** out_text) { + auto func = [](void* data, int i) -> const char* { auto &getter = *reinterpret_cast *>(data); - const char *s = getter(i); - if (s) { *out_text = s; return true; } - else { return false; } + return getter(i); }; return Combo(label, idx, func, reinterpret_cast(&getter), items_count); } @@ -55,7 +52,7 @@ inline bool ListBox(const char* label, int* idx, std::vector& value { if (values.empty()) { return false; } return ListBox(label, idx, vector_getter, - static_cast(&values), values.size()); + static_cast(&values), static_cast(values.size())); } inline bool InputText(const char* label, std::string &str, ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = NULL, void* user_data = NULL)