public final class ImGuiListClipper
extends java.lang.Object
ImGuiListClipper clipper(1000); // we have 1000 elements, evenly spaced.
while (clipper.Step())
for (int i = clipper.DisplayStart; i <
clipper.DisplayEnd; i++)
ImGui::Text("line number %d", i);
- Step 0: the clipper let you process the first element, regardless of it being visible or not, so we can measure the element height (step skipped if we passed a known height as second arg to constructor).
- Step 1: the clipper infer height from first element, calculate the actual range of elements to display, and position the cursor before the first element.
- (Step 2: empty step only required if an explicit items_height was passed to constructor or Begin() and user call Step(). Does nothing and switch to Step 3.)
- Step 3: the clipper validate that we have reached the expected Y position (corresponding to element DisplayEnd), advance the cursor to the end of the list and then returns 'false' to end the loop.
BINDING NOTICE:
It's impossible to implement the same API like in the original. Method forEach(int, int, ImListClipperCallback)
could be used instead.
ImGuiListClipper.forEach(1000, new ImListClipperCallback() { public void accept(int index) { ImGui.text(String.format("line number %d", index)); } });
Modifier and Type | Method and Description |
---|---|
static void |
forEach(int itemsCount,
ImListClipperCallback callback) |
static void |
forEach(int itemsCount,
int itemsHeight,
ImListClipperCallback callback) |
public static void forEach(int itemsCount, ImListClipperCallback callback)
itemsCount
- Use -1 to ignore (you can call Begin later).
Use INT_MAX if you don't know how many items you have (in which case the cursor won't be advanced in the final step).callback
- action to do in iterationspublic static void forEach(int itemsCount, int itemsHeight, ImListClipperCallback callback)
itemsCount
- Use -1 to ignore (you can call Begin later).
Use INT_MAX if you don't know how many items you have (in which case the cursor won't be advanced in the final step).itemsHeight
- Use -1.0f to be calculated automatically on first step.
Otherwise pass in the distance between your items, typically GetTextLineHeightWithSpacing() or GetFrameHeightWithSpacing().callback
- action to do in iterations