ImGui: fix console scrollbar feedback loop bug

Make use of newly added flag "ImGuiWindowFlags_OverlayHorizontalScrollbar" as per commit 60e4514b7b5c56db89102a3d66ef28a14118b8fd. Also removed flag "ImGuiWindowFlags_AlwaysVerticalScrollbar", only show the vertical scrollbar when its visible. Enabled code that takes the scrollbar into account in function CTextLogger::EnsureCursorVisible().
This commit is contained in:
Kawe Mazidjatari 2024-04-04 16:13:39 +02:00
parent 60e4514b7b
commit a75219825d
2 changed files with 5 additions and 7 deletions

View File

@ -252,8 +252,8 @@ bool CConsole::DrawSurface(void)
const static int colorLoggerWindowFlags =
ImGuiWindowFlags_NoMove |
ImGuiWindowFlags_HorizontalScrollbar |
ImGuiWindowFlags_AlwaysVerticalScrollbar |
ImGuiWindowFlags_NoNavInputs;
ImGuiWindowFlags_NoNavInputs |
ImGuiWindowFlags_OverlayHorizontalScrollbar;
ImGui::BeginChild(m_loggerLabel, ImVec2(0, -footerHeightReserve), loggerFlags, colorLoggerWindowFlags);

View File

@ -1507,14 +1507,12 @@ void CTextLogger::EnsureCursorVisible()
const float left = ImCeil(scrollX / m_CharAdvance.x);
const float right = ImCeil((scrollX + width) / m_CharAdvance.x);
//const ImGuiWindow* const window = ImGui::GetCurrentWindow();
const ImGuiWindow* const window = ImGui::GetCurrentWindow();
// For right offset, +.1f as otherwise it would render right below the
// first pixel making up the right perimeter.
// TODO: when the scrollbar feedback issue is fixed, uncomment the window
// scrollbar check !!!
const float rightOffsetAmount = 3.1f;// window->ScrollbarY ? 3.1f : 1.1f;
const float bottomOffsetAmount = 3.f; // window->ScrollbarX ? 3.f : 2.f;
const float rightOffsetAmount = window->ScrollbarY ? 3.1f : 1.1f;
const float bottomOffsetAmount = window->ScrollbarX ? 3.f : 2.f;
if (pos.m_nColumn < left)
ImGui::SetScrollX(ImMax(0.0f, (pos.m_nColumn) * m_CharAdvance.x));