MCPcopy Create free account
hub / github.com/KebsCS/KBotExt / ImGuiListClipper_SortAndFuseRanges

Function ImGuiListClipper_SortAndFuseRanges

KBotExt/imgui/imgui.cpp:2736–2758  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2734#endif
2735
2736static void ImGuiListClipper_SortAndFuseRanges(ImVector<ImGuiListClipperRange>& ranges, int offset = 0)
2737{
2738 if (ranges.Size - offset <= 1)
2739 return;
2740
2741 // Helper to order ranges and fuse them together if possible (bubble sort is fine as we are only sorting 2-3 entries)
2742 for (int sort_end = ranges.Size - offset - 1; sort_end > 0; --sort_end)
2743 for (int i = offset; i < sort_end + offset; ++i)
2744 if (ranges[i].Min > ranges[i + 1].Min)
2745 ImSwap(ranges[i], ranges[i + 1]);
2746
2747 // Now fuse ranges together as much as possible.
2748 for (int i = 1 + offset; i < ranges.Size; i++)
2749 {
2750 IM_ASSERT(!ranges[i].PosToIndexConvert && !ranges[i - 1].PosToIndexConvert);
2751 if (ranges[i - 1].Max < ranges[i].Min)
2752 continue;
2753 ranges[i - 1].Min = ImMin(ranges[i - 1].Min, ranges[i].Min);
2754 ranges[i - 1].Max = ImMax(ranges[i - 1].Max, ranges[i].Max);
2755 ranges.erase(ranges.Data + i);
2756 i--;
2757 }
2758}
2759
2760static void ImGuiListClipper_SeekCursorAndSetupPrevLine(float pos_y, float line_height)
2761{

Callers 1

Calls 3

ImSwapFunction · 0.85
ImMinFunction · 0.85
ImMaxFunction · 0.85

Tested by

no test coverage detected