From 23d4d10c4da746e78025726ad70d35a11cf34a65 Mon Sep 17 00:00:00 2001 From: ocornut Date: Wed, 3 Apr 2024 10:02:32 +0900 Subject: [PATCH] ImStrv: Combo(), ListBox(): maybe seems better to not introducte the ImStrv [] versions? As 1) user is unlikely to store that on their end. 2) nowadays with lambdas isn't an easy user-side conversion. Then we limit explosion of an already messy API. --- imgui.h | 2 -- imgui_widgets.cpp | 17 +---------------- 2 files changed, 1 insertion(+), 18 deletions(-) diff --git a/imgui.h b/imgui.h index 0297a031f..1aa9bf6ec 100644 --- a/imgui.h +++ b/imgui.h @@ -594,7 +594,6 @@ namespace ImGui IMGUI_API bool BeginCombo(ImStrv label, ImStrv preview_value, ImGuiComboFlags flags = 0); IMGUI_API void EndCombo(); // only call EndCombo() if BeginCombo() returns true! IMGUI_API bool Combo(ImStrv label, int* current_item, const char* const items[], int items_count, int popup_max_height_in_items = -1); - IMGUI_API bool Combo(ImStrv label, int* current_item, ImStrv const items[], int items_count, int popup_max_height_in_items = -1); IMGUI_API bool Combo(ImStrv label, int* current_item, ImStrv (*getter)(void* user_data, int idx), void* user_data, int items_count, int popup_max_height_in_items = -1); IMGUI_API bool Combo(ImStrv label, int* current_item, const char* items_separated_by_zeros, int popup_max_height_in_items = -1); // Separate items with \0 within a string, end item-list with \0\0. e.g. "One\0Two\0Three\0" @@ -721,7 +720,6 @@ namespace ImGui IMGUI_API bool BeginListBox(ImStrv label, const ImVec2& size = ImVec2(0, 0)); // open a framed scrolling region IMGUI_API void EndListBox(); // only call EndListBox() if BeginListBox() returned true! IMGUI_API bool ListBox(ImStrv label, int* current_item, const char* const items[], int items_count, int height_in_items = -1); - IMGUI_API bool ListBox(ImStrv label, int* current_item, ImStrv const items[], int items_count, int height_in_items = -1); IMGUI_API bool ListBox(ImStrv label, int* current_item, ImStrv (*getter)(void* user_data, int idx), void* user_data, int items_count, int height_in_items = -1); // Widgets: Data Plotting diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index 4d0056240..8fa977818 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -2024,12 +2024,6 @@ static ImStrv Items_CharArrayGetter(void* data, int idx) return items[idx]; } -static ImStrv Items_StrvArrayGetter(void* data, int idx) -{ - ImStrv const* items = (ImStrv const*)data; - return items[idx]; -} - // Getter for the old Combo() API: "item1\0item2\0item3\0" static ImStrv Items_SingleStringGetter(void* data, int idx) { @@ -2095,11 +2089,6 @@ bool ImGui::Combo(ImStrv label, int* current_item, ImStrv (*getter)(void* user_d } // Combo box helper allowing to pass an array of strings. -bool ImGui::Combo(ImStrv label, int* current_item, ImStrv const items[], int items_count, int height_in_items) -{ - return Combo(label, current_item, Items_StrvArrayGetter, (void*)items, items_count, height_in_items); -} - // We cannot easily obsolete the 'const char* []' version as this would be stored on user side.. bool ImGui::Combo(ImStrv label, int* current_item, const char* const items[], int items_count, int height_in_items) { @@ -8278,11 +8267,7 @@ void ImGui::EndListBox() EndGroup(); // This is only required to be able to do IsItemXXX query on the whole ListBox including label } -bool ImGui::ListBox(ImStrv label, int* current_item, ImStrv const items[], int items_count, int height_items) -{ - return ListBox(label, current_item, Items_StrvArrayGetter, (void*)items, items_count, height_items); -} - +// List box helper allowing to pass an array of strings. // We cannot easily obsolete the 'const char* []' version as this would be stored on user side.. bool ImGui::ListBox(ImStrv label, int* current_item, const char* const items[], int items_count, int height_items) {