Browse Source

Nav: fixed abnormal clipping disable over large ranges, could lead to stall. (#3841, #1725)

Amend 93cccd27f
ocornut 3 months ago
parent
commit
c3a3a39e92
2 changed files with 6 additions and 1 deletions
  1. 2 0
      docs/CHANGELOG.txt
  2. 4 1
      imgui.cpp

+ 2 - 0
docs/CHANGELOG.txt

@@ -113,6 +113,8 @@ Other changes:
   CTRL+Tab windowing + pressing a keyboard key. (#8525)
   CTRL+Tab windowing + pressing a keyboard key. (#8525)
 - Nav: fixed scroll fallback (when there are no interactive widgets to jump to) not
 - Nav: fixed scroll fallback (when there are no interactive widgets to jump to) not
   being enabled on windows with menu or title bar.
   being enabled on windows with menu or title bar.
+- Nav: fixed an issue handling PageUp/PageDown on windows with abnormally large contents
+  range which could lead to clipper requesting very large ranges.
 - Error Handling: added better error report and recovery for extraneous
 - Error Handling: added better error report and recovery for extraneous
   EndPopup() call. (#1651, #8499)
   EndPopup() call. (#1651, #8499)
 - Error Handling: added better error report and recovery when calling EndFrame()
 - Error Handling: added better error report and recovery when calling EndFrame()

+ 4 - 1
imgui.cpp

@@ -3229,7 +3229,10 @@ static bool ImGuiListClipper_StepInternal(ImGuiListClipper* clipper)
             // Add range selected to be included for navigation
             // Add range selected to be included for navigation
             const bool is_nav_request = (g.NavMoveScoringItems && g.NavWindow && g.NavWindow->RootWindowForNav == window->RootWindowForNav);
             const bool is_nav_request = (g.NavMoveScoringItems && g.NavWindow && g.NavWindow->RootWindowForNav == window->RootWindowForNav);
             if (is_nav_request)
             if (is_nav_request)
+            {
+                data->Ranges.push_back(ImGuiListClipperRange::FromPositions(g.NavScoringRect.Min.y, g.NavScoringRect.Max.y, 0, 0));
                 data->Ranges.push_back(ImGuiListClipperRange::FromPositions(g.NavScoringNoClipRect.Min.y, g.NavScoringNoClipRect.Max.y, 0, 0));
                 data->Ranges.push_back(ImGuiListClipperRange::FromPositions(g.NavScoringNoClipRect.Min.y, g.NavScoringNoClipRect.Max.y, 0, 0));
+            }
             if (is_nav_request && (g.NavMoveFlags & ImGuiNavMoveFlags_IsTabbing) && g.NavTabbingDir == -1)
             if (is_nav_request && (g.NavMoveFlags & ImGuiNavMoveFlags_IsTabbing) && g.NavTabbingDir == -1)
                 data->Ranges.push_back(ImGuiListClipperRange::FromIndices(clipper->ItemsCount - 1, clipper->ItemsCount));
                 data->Ranges.push_back(ImGuiListClipperRange::FromIndices(clipper->ItemsCount - 1, clipper->ItemsCount));
 
 
@@ -13379,7 +13382,7 @@ void ImGui::NavUpdateCreateMoveRequest()
         //if (!g.NavScoringNoClipRect.IsInverted()) { GetForegroundDrawList()->AddRect(g.NavScoringNoClipRect.Min, g.NavScoringNoClipRect.Max, IM_COL32(255, 200, 0, 255)); } // [DEBUG]
         //if (!g.NavScoringNoClipRect.IsInverted()) { GetForegroundDrawList()->AddRect(g.NavScoringNoClipRect.Min, g.NavScoringNoClipRect.Max, IM_COL32(255, 200, 0, 255)); } // [DEBUG]
     }
     }
     g.NavScoringRect = scoring_rect;
     g.NavScoringRect = scoring_rect;
-    g.NavScoringNoClipRect.Add(scoring_rect);
+    //g.NavScoringNoClipRect.Add(scoring_rect);
 }
 }
 
 
 void ImGui::NavUpdateCreateTabbingRequest()
 void ImGui::NavUpdateCreateTabbingRequest()