From e619cfcf45b3f6b044fc8a508c2e9ede70cc9a3d Mon Sep 17 00:00:00 2001 From: assiduous Date: Sun, 31 May 2020 13:20:57 -0700 Subject: Minor update to ImGuiUtils --- Imgui/interface/ImGuiUtils.hpp | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'Imgui/interface') diff --git a/Imgui/interface/ImGuiUtils.hpp b/Imgui/interface/ImGuiUtils.hpp index f3c5a91..3cbfd7f 100644 --- a/Imgui/interface/ImGuiUtils.hpp +++ b/Imgui/interface/ImGuiUtils.hpp @@ -100,8 +100,23 @@ bool SliderIntT(const char* label, T* v, int v_min, int v_max, const char* forma return value_changed; } -template -bool Combo(const char* label, T* current_item, const std::pair items[], int items_count, int popup_max_height_in_items = -1) +namespace +{ + +inline const char* c_str(const std::string& str) +{ + return str.c_str(); +} + +inline const char* c_str(const char* str) +{ + return str; +} + +} // namespace + +template +bool Combo(const char* label, ItemType* current_item, const std::pair items[], int items_count, int popup_max_height_in_items = -1) { int item_idx = 0; while (item_idx < items_count && items[item_idx].first != *current_item) @@ -113,7 +128,7 @@ bool Combo(const char* label, T* current_item, const std::pair i } std::vector names(items_count); for (int i = 0; i < items_count; ++i) - names[i] = items[i].second; + names[i] = c_str(items[i].second); auto value_changed = Combo(label, &item_idx, names.data(), items_count, popup_max_height_in_items); if (value_changed) *current_item = items[item_idx].first; -- cgit v1.2.3