MCPcopy Create free account
hub / github.com/cinder/Cinder / ImGuiListClipper_SortAndFuseRanges

Function ImGuiListClipper_SortAndFuseRanges

src/imgui/imgui.cpp:3105–3127  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3103}
3104
3105static void ImGuiListClipper_SortAndFuseRanges(ImVector<ImGuiListClipperRange>& ranges, int offset = 0)
3106{
3107 if (ranges.Size - offset <= 1)
3108 return;
3109
3110 // Helper to order ranges and fuse them together if possible (bubble sort is fine as we are only sorting 2-3 entries)
3111 for (int sort_end = ranges.Size - offset - 1; sort_end > 0; --sort_end)
3112 for (int i = offset; i < sort_end + offset; ++i)
3113 if (ranges[i].Min > ranges[i + 1].Min)
3114 ImSwap(ranges[i], ranges[i + 1]);
3115
3116 // Now fuse ranges together as much as possible.
3117 for (int i = 1 + offset; i < ranges.Size; i++)
3118 {
3119 IM_ASSERT(!ranges[i].PosToIndexConvert && !ranges[i - 1].PosToIndexConvert);
3120 if (ranges[i - 1].Max < ranges[i].Min)
3121 continue;
3122 ranges[i - 1].Min = ImMin(ranges[i - 1].Min, ranges[i].Min);
3123 ranges[i - 1].Max = ImMax(ranges[i - 1].Max, ranges[i].Max);
3124 ranges.erase(ranges.Data + i);
3125 i--;
3126 }
3127}
3128
3129static void ImGuiListClipper_SeekCursorAndSetupPrevLine(ImGuiListClipper* clipper, float pos_y, float line_height)
3130{

Callers 1

Calls 4

ImSwapFunction · 0.85
ImMinFunction · 0.85
ImMaxFunction · 0.85
eraseMethod · 0.45

Tested by

no test coverage detected