Skip to content

Commit

Permalink
Clipper: fixed invalid state when number of frozen table row is small…
Browse files Browse the repository at this point in the history
…er than ItemCount.

+ Bonus rather unorthodox coding style.
  • Loading branch information
ocornut committed Dec 6, 2021
1 parent 027a7ba commit 926addb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions docs/CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ Other Changes:
(an additional ItemSpacing.y was declared, affecting scrollbar range).
- Clipper: various and incomplete changes to tame down scrolling and precision issues on very large ranges.
Passing an explicit height to the clipper now allows larger ranges. (#3609, #3962).
- Clipper: fixed invalid state when number of frozen table row is smaller than ItemCount.
- Drag and Drop: BeginDragDropSource() with ImGuiDragDropFlags_SourceAllowNullID doesn't lose
tooltip when scrolling. (#143)
- Metrics: Added a node showing windows in submission order and showing the Begin() stack.
Expand Down
9 changes: 5 additions & 4 deletions imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2435,17 +2435,16 @@ bool ImGuiListClipper::Step()

// No items
if (ItemsCount == 0 || GetSkipItemForListClipping())
{
End();
return false;
}
return (void)End(), false;

// While we are in frozen row state, keep displaying items one by one, unclipped
// FIXME: Could be stored as a table-agnostic state.
if (data->StepNo == 0 && table != NULL && !table->IsUnfrozenRows)
{
DisplayStart = data->ItemsFrozen;
DisplayEnd = data->ItemsFrozen + 1;
if (DisplayStart >= ItemsCount)
return (void)End(), false;
data->ItemsFrozen++;
return true;
}
Expand All @@ -2461,6 +2460,8 @@ bool ImGuiListClipper::Step()
data->Ranges.push_front(ImGuiListClipperRange::FromIndices(data->ItemsFrozen, data->ItemsFrozen + 1));
DisplayStart = ImMax(data->Ranges[0].Min, data->ItemsFrozen);
DisplayEnd = ImMin(data->Ranges[0].Max, ItemsCount);
if (DisplayStart == DisplayEnd)
return (void)End(), false;
data->StepNo = 1;
return true;
}
Expand Down

0 comments on commit 926addb

Please sign in to comment.