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



2219
2220
2221
# File 'lib/imgui.rb', line 2219

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

Instance Method Details

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



2211
2212
2213
# File 'lib/imgui.rb', line 2211

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

#destroyObject



2239
2240
2241
# File 'lib/imgui.rb', line 2239

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

#EndObject



2215
2216
2217
# File 'lib/imgui.rb', line 2215

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

#IncludeItemByIndex(item_index) ⇒ Object



2223
2224
2225
# File 'lib/imgui.rb', line 2223

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

#IncludeItemsByIndex(item_begin, item_end) ⇒ Object



2227
2228
2229
# File 'lib/imgui.rb', line 2227

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

#SeekCursorForItem(item_index) ⇒ Object



2231
2232
2233
# File 'lib/imgui.rb', line 2231

def SeekCursorForItem(item_index)
  ImGui::ImGuiListClipper_SeekCursorForItem(self, item_index)
end

#StepObject



2235
2236
2237
# File 'lib/imgui.rb', line 2235

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