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



2319
2320
2321
# File 'lib/imgui.rb', line 2319

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

Instance Method Details

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



2311
2312
2313
# File 'lib/imgui.rb', line 2311

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

#destroyObject



2339
2340
2341
# File 'lib/imgui.rb', line 2339

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

#EndObject



2315
2316
2317
# File 'lib/imgui.rb', line 2315

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

#IncludeItemByIndex(item_index) ⇒ Object



2323
2324
2325
# File 'lib/imgui.rb', line 2323

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

#IncludeItemsByIndex(item_begin, item_end) ⇒ Object



2327
2328
2329
# File 'lib/imgui.rb', line 2327

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

#SeekCursorForItem(item_index) ⇒ Object



2331
2332
2333
# File 'lib/imgui.rb', line 2331

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

#StepObject



2335
2336
2337
# File 'lib/imgui.rb', line 2335

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