Browse Source

Clipper: Fixed incorrect end-list positioning when using ImGuiListClipper with 1 item (bug in 1.79). (#3663)

nyorain 4 years ago
parent
commit
a640698123
2 changed files with 10 additions and 2 deletions
  1. 1 0
      docs/CHANGELOG.txt
  2. 9 2
      imgui.cpp

+ 1 - 0
docs/CHANGELOG.txt

@@ -80,6 +80,7 @@ Other Changes:
 - Drag and Drop: Fix drag and drop to tie same-size drop targets by choosen the later one. Fixes dragging
 - Drag and Drop: Fix drag and drop to tie same-size drop targets by choosen the later one. Fixes dragging
   into a full-window-sized dockspace inside a zero-padded window. (#3519, #2717) [@Black-Cat]
   into a full-window-sized dockspace inside a zero-padded window. (#3519, #2717) [@Black-Cat]
 - Checkbox: Added CheckboxFlags() helper with int* type.
 - Checkbox: Added CheckboxFlags() helper with int* type.
+- Clipper: Fixed incorrect end-list positioning when using ImGuiListClipper with 1 item (bug in 1.79). (#3663) [@nyorain]
 - InputText: Fixed updating cursor/selection position when a callback altered the buffer in a way
 - InputText: Fixed updating cursor/selection position when a callback altered the buffer in a way
   where the byte count is unchanged but the decoded character count changes. (#3587) [@gqw]
   where the byte count is unchanged but the decoded character count changes. (#3587) [@gqw]
 - InputText: Fixed swiching from single to multi-line while preserving same ID.
 - InputText: Fixed swiching from single to multi-line while preserving same ID.

+ 9 - 2
imgui.cpp

@@ -2266,8 +2266,8 @@ bool ImGuiListClipper::Step()
     if (table && table->IsInsideRow)
     if (table && table->IsInsideRow)
         ImGui::TableEndRow(table);
         ImGui::TableEndRow(table);
 
 
-    // Reached end of list
-    if (DisplayEnd >= ItemsCount || GetSkipItemForListClipping())
+    // No items
+    if (ItemsCount == 0 || GetSkipItemForListClipping())
     {
     {
         End();
         End();
         return false;
         return false;
@@ -2320,6 +2320,13 @@ bool ImGuiListClipper::Step()
         StepNo = 2;
         StepNo = 2;
     }
     }
 
 
+    // Reached end of list
+    if (DisplayEnd >= ItemsCount)
+    {
+        End();
+        return false;
+    }
+
     // Step 2: calculate the actual range of elements to display, and position the cursor before the first element
     // Step 2: calculate the actual range of elements to display, and position the cursor before the first element
     if (StepNo == 2)
     if (StepNo == 2)
     {
     {