Home / Forums / How to handle text clipping and auto-scroll in custom Dear ImGui log consoles? [Discussion #4]

UnreliableCode Community

Developer Research, Reverse Engineering & Coding Community

Question

How to handle text clipping and auto-scroll in custom Dear ImGui log consoles? [Discussion #4]

ImGuiAddict
GUI Developer
MEMBER
Rep: 261
Join Date: Sep 2022
Posts: 6
Thanks: 73
5y ago · Aug 22, 2021 9:51 AM
#1
I am building an in-game debug console in Dear ImGui. How can I implement smooth auto-scrolling to the bottom when new logs arrive, while allowing the user to scroll up without fighting the view?
ImGuiAddict · GUI Developer
Building debug consoles, inspector panels, and telemetry das...
The following users thanked ImGuiAddict for this post:
ConsoleKing
Terminal & CLI Tools
MEMBER
Rep: 195
Join Date: Jan 2020
Posts: 6
Thanks: 59
4y ago · Aug 22, 2021 12:10 PM
#2
Check ImGui::GetScrollY() >= ImGui::GetScrollMaxY() before adding new items! If the user was already at the bottom, call ImGui::SetScrollHereY(1.0f) after rendering the new log entries. If the user scrolled up to inspect previous logs, skip the SetScrollHereY call so the view stays fixed.
ConsoleKing · Terminal & CLI Tools
Building sleek command-line tools with Spectre.Console and A...
ShadowPwn
Security Researcher
MEMBER
Rep: 150
Join Date: Feb 2024
Posts: 19
Thanks: 35
4y ago · Aug 22, 2021 3:10 PM
#3
Also use ImGuiListClipper for large log lists (10,000+ items)! It only renders the visible lines on screen, preventing framerate drops.
ShadowPwn · Security & Anticheat Analysis