mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-15 01:17:00 +00:00
ListBox() uses ImGuiListClipper helper, faster for large lists, assume evenly sized items.
This commit is contained in:
parent
eb4ffd5dbd
commit
bda0269133
@ -7531,8 +7531,10 @@ bool ImGui::ListBox(const char* label, int* current_item, bool (*items_getter)(v
|
||||
if (!ImGui::ListBoxHeader(label, items_count, height_in_items))
|
||||
return false;
|
||||
|
||||
// Assume all items have even height (= 1 line of text). If you need items of different or variable sizes you can create a custom version of ListBox() in your code without using the clipper.
|
||||
bool value_changed = false;
|
||||
for (int i = 0; i < items_count; i++)
|
||||
ImGuiListClipper clipper(items_count, ImGui::GetTextLineHeightWithSpacing());
|
||||
for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++)
|
||||
{
|
||||
const bool item_selected = (i == *current_item);
|
||||
const char* item_text;
|
||||
@ -7547,7 +7549,7 @@ bool ImGui::ListBox(const char* label, int* current_item, bool (*items_getter)(v
|
||||
}
|
||||
ImGui::PopID();
|
||||
}
|
||||
|
||||
clipper.End();
|
||||
ImGui::ListBoxFooter();
|
||||
return value_changed;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user