Use ImGuiListClipper to draw just visible output lines
@@ -69,7 +69,12 @@ void Overlay::DrawImgui(IDXGISwapChain3* apSwapChain)
ImVec2 listboxSize = ImGui::GetContentRegionAvail();
listboxSize.y -= ImGui::GetFrameHeightWithSpacing();
const auto result = ImGui::ListBoxHeader("", listboxSize);
- for (auto& item : m_outputLines)
+ ImGuiListClipper clipper;
+ clipper.Begin(m_outputLines.size());
+ while (clipper.Step())
+ for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; ++i)
+ {
+ auto& item = m_outputLines[i];
if (ImGui::Selectable(item.c_str()))
{
auto str = item;
@@ -78,6 +83,7 @@ void Overlay::DrawImgui(IDXGISwapChain3* apSwapChain)
std::strncpy(command, str.c_str(), sizeof(command) - 1);
}
+ }
if (m_outputScroll)
{
