Skip to content

Commit 081aec4

Browse files
authored
Merge pull request ocornut#931 from nlguillemot/master
Combo, ListBox: Extra const correctness.
2 parents baa2e3b + 36d78e0 commit 081aec4

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

imgui.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8399,7 +8399,7 @@ bool ImGui::InputInt4(const char* label, int v[4], ImGuiInputTextFlags extra_fla
83998399

84008400
static bool Items_ArrayGetter(void* data, int idx, const char** out_text)
84018401
{
8402-
const char** items = (const char**)data;
8402+
const char* const* items = (const char* const*)data;
84038403
if (out_text)
84048404
*out_text = items[idx];
84058405
return true;
@@ -8426,7 +8426,7 @@ static bool Items_SingleStringGetter(void* data, int idx, const char** out_text)
84268426
}
84278427

84288428
// Combo box helper allowing to pass an array of strings.
8429-
bool ImGui::Combo(const char* label, int* current_item, const char** items, int items_count, int height_in_items)
8429+
bool ImGui::Combo(const char* label, int* current_item, const char* const* items, int items_count, int height_in_items)
84308430
{
84318431
const bool value_changed = Combo(label, current_item, Items_ArrayGetter, (void*)items, items_count, height_in_items);
84328432
return value_changed;
@@ -8703,7 +8703,7 @@ void ImGui::ListBoxFooter()
87038703
EndGroup();
87048704
}
87058705

8706-
bool ImGui::ListBox(const char* label, int* current_item, const char** items, int items_count, int height_items)
8706+
bool ImGui::ListBox(const char* label, int* current_item, const char* const* items, int items_count, int height_items)
87078707
{
87088708
const bool value_changed = ListBox(label, current_item, Items_ArrayGetter, (void*)items, items_count, height_items);
87098709
return value_changed;

imgui.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ namespace ImGui
265265
IMGUI_API bool CheckboxFlags(const char* label, unsigned int* flags, unsigned int flags_value);
266266
IMGUI_API bool RadioButton(const char* label, bool active);
267267
IMGUI_API bool RadioButton(const char* label, int* v, int v_button);
268-
IMGUI_API bool Combo(const char* label, int* current_item, const char** items, int items_count, int height_in_items = -1);
268+
IMGUI_API bool Combo(const char* label, int* current_item, const char* const* items, int items_count, int height_in_items = -1);
269269
IMGUI_API bool Combo(const char* label, int* current_item, const char* items_separated_by_zeros, int height_in_items = -1); // separate items with \0, end item-list with \0\0
270270
IMGUI_API bool Combo(const char* label, int* current_item, bool (*items_getter)(void* data, int idx, const char** out_text), void* data, int items_count, int height_in_items = -1);
271271
IMGUI_API bool ColorButton(const ImVec4& col, bool small_height = false, bool outline_border = true);
@@ -339,7 +339,7 @@ namespace ImGui
339339
// Widgets: Selectable / Lists
340340
IMGUI_API bool Selectable(const char* label, bool selected = false, ImGuiSelectableFlags flags = 0, const ImVec2& size = ImVec2(0,0)); // size.x==0.0: use remaining width, size.x>0.0: specify width. size.y==0.0: use label height, size.y>0.0: specify height
341341
IMGUI_API bool Selectable(const char* label, bool* p_selected, ImGuiSelectableFlags flags = 0, const ImVec2& size = ImVec2(0,0));
342-
IMGUI_API bool ListBox(const char* label, int* current_item, const char** items, int items_count, int height_in_items = -1);
342+
IMGUI_API bool ListBox(const char* label, int* current_item, const char* const* items, int items_count, int height_in_items = -1);
343343
IMGUI_API bool ListBox(const char* label, int* current_item, bool (*items_getter)(void* data, int idx, const char** out_text), void* data, int items_count, int height_in_items = -1);
344344
IMGUI_API bool ListBoxHeader(const char* label, const ImVec2& size = ImVec2(0,0)); // use if you want to reimplement ListBox() will custom data or interactions. make sure to call ListBoxFooter() afterwards.
345345
IMGUI_API bool ListBoxHeader(const char* label, int items_count, int height_in_items = -1); // "

0 commit comments

Comments
 (0)