Class: ImGuiListClipper
- Inherits:
-
FFI::Struct
- Object
- FFI::Struct
- ImGuiListClipper
- Defined in:
- lib/imgui.rb
Overview
Helper: Manually clip large list of items. If you have lots evenly spaced items and you have random access to the list, you can perform coarse clipping based on visibility to only submit items that are in view. The clipper calculates the range of visible items and advance the cursor to compensate for the non-visible items we have skipped. (Dear ImGui already clip items based on their bounds but: it needs to first layout the item to do so, and generally
fetching/submitting your own data incurs additional cost. Coarse clipping using ImGuiListClipper allows you to easily
scale using lists with tens of thousands of items without a problem)
Usage:
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.
Class Method Summary collapse
Instance Method Summary collapse
- #Begin(items_count, items_height = -1.0)) ⇒ Object
- #destroy ⇒ Object
- #End ⇒ Object
- #IncludeItemByIndex(item_index) ⇒ Object
- #IncludeItemsByIndex(item_begin, item_end) ⇒ Object
- #SeekCursorForItem(item_index) ⇒ Object
- #Step ⇒ Object
Class Method Details
.create ⇒ Object
2313 2314 2315 |
# File 'lib/imgui.rb', line 2313 def self.create() return ImGuiListClipper.new(ImGui::ImGuiListClipper_ImGuiListClipper()) end |
Instance Method Details
#Begin(items_count, items_height = -1.0)) ⇒ Object
2305 2306 2307 |
# File 'lib/imgui.rb', line 2305 def Begin(items_count, items_height = -1.0) ImGui::ImGuiListClipper_Begin(self, items_count, items_height) end |
#destroy ⇒ Object
2333 2334 2335 |
# File 'lib/imgui.rb', line 2333 def destroy() ImGui::ImGuiListClipper_destroy(self) end |
#End ⇒ Object
2309 2310 2311 |
# File 'lib/imgui.rb', line 2309 def End() ImGui::ImGuiListClipper_End(self) end |
#IncludeItemByIndex(item_index) ⇒ Object
2317 2318 2319 |
# File 'lib/imgui.rb', line 2317 def IncludeItemByIndex(item_index) ImGui::ImGuiListClipper_IncludeItemByIndex(self, item_index) end |
#IncludeItemsByIndex(item_begin, item_end) ⇒ Object
2321 2322 2323 |
# File 'lib/imgui.rb', line 2321 def IncludeItemsByIndex(item_begin, item_end) ImGui::ImGuiListClipper_IncludeItemsByIndex(self, item_begin, item_end) end |
#SeekCursorForItem(item_index) ⇒ Object
2325 2326 2327 |
# File 'lib/imgui.rb', line 2325 def SeekCursorForItem(item_index) ImGui::ImGuiListClipper_SeekCursorForItem(self, item_index) end |
#Step ⇒ Object
2329 2330 2331 |
# File 'lib/imgui.rb', line 2329 def Step() ImGui::ImGuiListClipper_Step(self) end |