Clipper: simplify code and remove cases where true is returned with empty display range as an extra step.

This commit is contained in:
ocornut 2022-08-23 15:38:47 +02:00
parent 07b9999de9
commit 72096bf698

View File

@ -2669,10 +2669,9 @@ static bool ImGuiListClipper_StepInternal(ImGuiListClipper* clipper)
if (data->StepNo == 0 && table != NULL && !table->IsUnfrozenRows)
{
clipper->DisplayStart = data->ItemsFrozen;
clipper->DisplayEnd = data->ItemsFrozen + 1;
if (clipper->DisplayStart >= clipper->ItemsCount)
return false;
data->ItemsFrozen++;
clipper->DisplayEnd = ImMin(data->ItemsFrozen + 1, clipper->ItemsCount);
if (clipper->DisplayStart < clipper->DisplayEnd)
data->ItemsFrozen++;
return true;
}
@ -2687,8 +2686,6 @@ static bool ImGuiListClipper_StepInternal(ImGuiListClipper* clipper)
data->Ranges.push_front(ImGuiListClipperRange::FromIndices(data->ItemsFrozen, data->ItemsFrozen + 1));
clipper->DisplayStart = ImMax(data->Ranges[0].Min, data->ItemsFrozen);
clipper->DisplayEnd = ImMin(data->Ranges[0].Max, clipper->ItemsCount);
if (clipper->DisplayStart == clipper->DisplayEnd)
return false;
data->StepNo = 1;
return true;
}
@ -2778,9 +2775,10 @@ static bool ImGuiListClipper_StepInternal(ImGuiListClipper* clipper)
bool ImGuiListClipper::Step()
{
ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow;
bool need_items_height = (ItemsHeight <= 0.0f);
bool ret = ImGuiListClipper_StepInternal(this);
if (ret && (DisplayStart == DisplayEnd))
ret = false;
if (g.CurrentTable && g.CurrentTable->IsUnfrozenRows == false)
IMGUI_DEBUG_LOG_CLIPPER("Clipper: Step(): inside frozen table row.\n");
if (need_items_height && ItemsHeight > 0.0f)