Skip to content

Commit

Permalink
Clipper: simplify code and remove cases where true is returned with e…
Browse files Browse the repository at this point in the history
…mpty display range as an extra step.
  • Loading branch information
ocornut committed Aug 23, 2022
1 parent 07b9999 commit 72096bf
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
}
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 72096bf

Please sign in to comment.