MCPcopy Create free account
hub / github.com/RenderKit/embree / ImGuiListClipper_SortAndFuseRanges

Function ImGuiListClipper_SortAndFuseRanges

tutorials/common/imgui/imgui.cpp:2614–2636  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2612#endif
2613
2614static void ImGuiListClipper_SortAndFuseRanges(ImVector<ImGuiListClipperRange>& ranges, int offset = 0)
2615{
2616 if (ranges.Size - offset <= 1)
2617 return;
2618
2619 // Helper to order ranges and fuse them together if possible (bubble sort is fine as we are only sorting 2-3 entries)
2620 for (int sort_end = ranges.Size - offset - 1; sort_end > 0; --sort_end)
2621 for (int i = offset; i < sort_end + offset; ++i)
2622 if (ranges[i].Min > ranges[i + 1].Min)
2623 ImSwap(ranges[i], ranges[i + 1]);
2624
2625 // Now fuse ranges together as much as possible.
2626 for (int i = 1 + offset; i < ranges.Size; i++)
2627 {
2628 IM_ASSERT(!ranges[i].PosToIndexConvert && !ranges[i - 1].PosToIndexConvert);
2629 if (ranges[i - 1].Max < ranges[i].Min)
2630 continue;
2631 ranges[i - 1].Min = ImMin(ranges[i - 1].Min, ranges[i].Min);
2632 ranges[i - 1].Max = ImMax(ranges[i - 1].Max, ranges[i].Max);
2633 ranges.erase(ranges.Data + i);
2634 i--;
2635 }
2636}
2637
2638static void ImGuiListClipper_SeekCursorAndSetupPrevLine(float pos_y, float line_height)
2639{

Callers 1

Calls 3

ImSwapFunction · 0.85
ImMinFunction · 0.85
ImMaxFunction · 0.85

Tested by

no test coverage detected