public final class ImGuiListClipper extends ImGuiStructDestroyable
ImGuiListClipper clipper;
clipper.Begin(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);
Generally what happens is:
- Clipper lets you process the first element (DisplayStart = 0, DisplayEnd = 1) regardless of it being visible or not.
- User code submit that one element.
- Clipper can measure the height of the first element
- Clipper calculate the actual range of elements to display based on the current clipping rectangle, position the cursor before the first visible element.
- User code submit visible elements.
- The clipper also handles various subtleties related to keyboard/gamepad navigation, wrapping etc.ptr
Constructor and Description |
---|
ImGuiListClipper() |
ImGuiListClipper(long ptr) |
Modifier and Type | Method and Description |
---|---|
void |
begin(int itemsCount) |
void |
begin(int itemsCount,
float itemsHeight) |
protected long |
create() |
void |
end()
Automatically called on the last call of Step() that returns false.
|
static void |
forEach(java.util.function.Consumer<ImGuiListClipper> clipAction)
Shortcut to use
ImGuiListClipper instance. |
static void |
forEach(int itemsCount,
ImListClipperCallback callback) |
static void |
forEach(int itemsCount,
int itemsHeight,
ImListClipperCallback callback) |
ImGuiContext |
getCtx()
Parent UI context
|
int |
getDisplayEnd() |
int |
getDisplayStart() |
int |
getItemsCount() |
float |
getItemsHeight() |
float |
getStartPosY() |
void |
includeItemByIndex(int itemIndex)
Call IncludeItemByIndex() or IncludeItemsByIndex() *BEFORE* first call to Step() if you need a range of items to not be clipped, regardless of their visibility.
|
void |
includeItemsByIndex(int itemBegin,
int itemEnd)
Call IncludeItemByIndex() or IncludeItemsByIndex() *BEFORE* first call to Step() if you need a range of items to not be clipped, regardless of their visibility.
|
void |
setCtx(ImGuiContext value)
Parent UI context
|
void |
setDisplayEnd(int value) |
void |
setDisplayStart(int value) |
boolean |
step()
Call until it returns false.
|
destroy
isNotValidPtr, isValidPtr
public ImGuiListClipper()
public ImGuiListClipper(long ptr)
protected long create()
create
in class ImGuiStructDestroyable
public ImGuiContext getCtx()
public void setCtx(ImGuiContext value)
public int getDisplayStart()
public void setDisplayStart(int value)
public int getDisplayEnd()
public void setDisplayEnd(int value)
public int getItemsCount()
public float getItemsHeight()
public float getStartPosY()
public void begin(int itemsCount)
public void begin(int itemsCount, float itemsHeight)
public void end()
public boolean step()
public void includeItemByIndex(int itemIndex)
public void includeItemsByIndex(int itemBegin, int itemEnd)
itemEnd
- is exclusive e.g. use (42, 42+1) to make item 42 never clipped.public static void forEach(java.util.function.Consumer<ImGuiListClipper> clipAction)
ImGuiListClipper
instance.clipAction
- action to use inside the ImGuiListClipper
instancepublic 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