diff options
| author | assiduous <assiduous@diligentgraphics.com> | 2020-05-31 20:20:57 +0000 |
|---|---|---|
| committer | assiduous <assiduous@diligentgraphics.com> | 2020-05-31 20:20:57 +0000 |
| commit | e619cfcf45b3f6b044fc8a508c2e9ede70cc9a3d (patch) | |
| tree | 02a1a2f488d5fbe5b74fd1b878e7c86bd9271ef0 /Imgui/interface | |
| parent | Imgui: fixed display size debug checks for minimized window (diff) | |
| download | DiligentTools-e619cfcf45b3f6b044fc8a508c2e9ede70cc9a3d.tar.gz DiligentTools-e619cfcf45b3f6b044fc8a508c2e9ede70cc9a3d.zip | |
Minor update to ImGuiUtils
Diffstat (limited to 'Imgui/interface')
| -rw-r--r-- | Imgui/interface/ImGuiUtils.hpp | 21 |
1 files changed, 18 insertions, 3 deletions
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 <typename T> -bool Combo(const char* label, T* current_item, const std::pair<T, const char*> 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 <typename ItemType, typename StrType> +bool Combo(const char* label, ItemType* current_item, const std::pair<ItemType, StrType> 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<T, const char*> i } std::vector<const char*> 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; |
