Class: ImGuiListClipper

Inherits:
FFI::Struct
  • Object
show all
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

Class Method Details

.createObject



2017
2018
2019
# File 'lib/imgui.rb', line 2017

def self.create()
  return ImGuiListClipper.new(ImGui::ImGuiListClipper_ImGuiListClipper())
end

Instance Method Details

#Begin(items_count, items_height = -1.0)) ⇒ Object



2009
2010
2011
# File 'lib/imgui.rb', line 2009

def Begin(items_count, items_height = -1.0)
  ImGui::ImGuiListClipper_Begin(self, items_count, items_height)
end

#destroyObject



2033
2034
2035
# File 'lib/imgui.rb', line 2033

def destroy()
  ImGui::ImGuiListClipper_destroy(self)
end

#EndObject



2013
2014
2015
# File 'lib/imgui.rb', line 2013

def End()
  ImGui::ImGuiListClipper_End(self)
end

#IncludeItemByIndex(item_index) ⇒ Object



2021
2022
2023
# File 'lib/imgui.rb', line 2021

def IncludeItemByIndex(item_index)
  ImGui::ImGuiListClipper_IncludeItemByIndex(self, item_index)
end

#IncludeItemsByIndex(item_begin, item_end) ⇒ Object



2025
2026
2027
# File 'lib/imgui.rb', line 2025

def IncludeItemsByIndex(item_begin, item_end)
  ImGui::ImGuiListClipper_IncludeItemsByIndex(self, item_begin, item_end)
end

#StepObject



2029
2030
2031
# File 'lib/imgui.rb', line 2029

def Step()
  ImGui::ImGuiListClipper_Step(self)
end