Use case A: Begin() called from constructor with items_height<0, then called again from Sync() in StepNo 1 Use case B: Begin() called from constructor with items_height>0 FIXME-LEGACY: Ideally we should remove the Begin/End functions but they are part of the legacy API we still support. This is why some of the code in Step() calling Begin() and reassign some fields, spaghetti style.
| 2189 | // Use case B: Begin() called from constructor with items_height>0 |
| 2190 | // FIXME-LEGACY: Ideally we should remove the Begin/End functions but they are part of the legacy API we still support. This is why some of the code in Step() calling Begin() and reassign some fields, spaghetti style. |
| 2191 | void ImGuiListClipper::Begin(int count, float items_height) |
| 2192 | { |
| 2193 | ImGuiContext& g = *GImGui; |
| 2194 | ImGuiWindow* window = g.CurrentWindow; |
| 2195 | |
| 2196 | StartPosY = window->DC.CursorPos.y; |
| 2197 | ItemsHeight = items_height; |
| 2198 | ItemsCount = count; |
| 2199 | StepNo = 0; |
| 2200 | DisplayEnd = DisplayStart = -1; |
| 2201 | if (ItemsHeight > 0.0f) |
| 2202 | { |
| 2203 | ImGui::CalcListClipping(ItemsCount, ItemsHeight, &DisplayStart, &DisplayEnd); // calculate how many to clip/display |
| 2204 | if (DisplayStart > 0) |
| 2205 | SetCursorPosYAndSetupDummyPrevLine(StartPosY + DisplayStart * ItemsHeight, ItemsHeight); // advance cursor |
| 2206 | StepNo = 2; |
| 2207 | } |
| 2208 | } |
| 2209 | |
| 2210 | void ImGuiListClipper::End() |
| 2211 | { |
no test coverage detected