Skip to content

Instantly share code, notes, and snippets.

View RohacekD's full-sized avatar

Dominik Roháček RohacekD

View GitHub Profile
@nem0
nem0 / imgui_treeview_clipper.cpp
Last active January 9, 2022 14:44
Simple treeview clipper for imgui
// only handles coplexity on top level, if you have a node with 1M children, you are out of luck
// changes in clipped parts are not detected, so if somebody deleted nodes in clipped, scrollbar is not updated until user actually scrolls
// scrolling and changes refresh the clipper == that part is as slow as no clipping at all
// only single list in BeginChild/EndChild is tested
struct TreeViewClipper {
// persist
float cursor_end = 0;
float cursor_visible_start = 0;
uint first_visible_index = 0;
float last_scroll = 0;