git.s-ol.nu ~forks/DiligentTools / e619cfc
Minor update to ImGuiUtils assiduous 1 year, 22 days ago
1 changed file(s) with 18 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
9999 return value_changed;
100100 }
101101
102 template <typename T>
103 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)
102 namespace
103 {
104
105 inline const char* c_str(const std::string& str)
106 {
107 return str.c_str();
108 }
109
110 inline const char* c_str(const char* str)
111 {
112 return str;
113 }
114
115 } // namespace
116
117 template <typename ItemType, typename StrType>
118 bool Combo(const char* label, ItemType* current_item, const std::pair<ItemType, StrType> items[], int items_count, int popup_max_height_in_items = -1)
104119 {
105120 int item_idx = 0;
106121 while (item_idx < items_count && items[item_idx].first != *current_item)
112127 }
113128 std::vector<const char*> names(items_count);
114129 for (int i = 0; i < items_count; ++i)
115 names[i] = items[i].second;
130 names[i] = c_str(items[i].second);
116131 auto value_changed = Combo(label, &item_idx, names.data(), items_count, popup_max_height_in_items);
117132 if (value_changed)
118133 *current_item = items[item_idx].first;