From f1167f86c9fecfaf05e8865f9d91f78258fd88f7 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 8cd102b61..0e4ab4104 100644 --- a/imgui.h +++ b/imgui.h @@ -595,7 +595,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" @@ -722,7 +721,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 0205377c0..a610e649d 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -2023,12 +2023,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) { @@ -2094,11 +2088,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) { @@ -8288,11 +8277,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) {