From bccec3eabc7e010841452ea86e5495d2ee495f82 Mon Sep 17 00:00:00 2001 From: ocornut Date: Wed, 8 Apr 2026 20:01:00 +0200 Subject: [PATCH] Tables: fixed IdealMaxPos.y/CursorMaxPos.y computation being wrong when vertically scrolling. (#9352, #7651) See ""table_reported_size_outer" test amends (0f9d1e02b0). --- docs/CHANGELOG.txt | 5 +++-- imgui_tables.cpp | 12 +++++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index c69d92f79..5fd47d3d6 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -48,8 +48,9 @@ Other Changes: multi-line edit is clipped due to being out of view. - Fixed a crash when toggling ReadOnly while active. (#9354) - Tables: - - Fixed an issue reporting ideal size to parent window/container when both scrollbars - are visible but only one of ScrollX/ScrollY was explicitly requested. (#9352, #7651) + - Fixed issues reporting ideal size to parent window/container: (#9352, #7651) + - When both scrollbars are visible but only one of ScrollX/ScrollY was explicitly requested. + - When vertical scrollbar was not at the top, the computation was often incorrect. - Fonts: - imgui_freetype: add FreeType headers & compiled version in 'About Dear ImGui' details. - Clipper: diff --git a/imgui_tables.cpp b/imgui_tables.cpp index 5d67c07ea..9257b8d43 100644 --- a/imgui_tables.cpp +++ b/imgui_tables.cpp @@ -1567,10 +1567,10 @@ void ImGui::EndTable() { // Some references for this: #7651 + tests "table_reported_size", "table_reported_size_outer" equivalent Y block, #9352 // - FIXME-TABLE: Would make sense to pre-compute expected scrollbar visibility/sizes to generally save a frame of feedback? - const float inner_content_max_x = table->OuterRect.Min.x + table->ColumnsAutoFitWidth; // Slightly misleading name but used for code symmetry with inner_content_max_y + const float outer_content_max_x = table->OuterRect.Min.x + table->ColumnsAutoFitWidth; const float decoration_size = table->TempData->AngledHeadersExtraWidth + ((inner_window != outer_window) ? inner_window->ScrollbarSizes.x : 0.0f); - outer_window->DC.IdealMaxPos.x = ImMax(outer_window->DC.IdealMaxPos.x, inner_content_max_x + decoration_size - temp_data->UserOuterSize.x); - outer_window->DC.CursorMaxPos.x = ImMax(backup_outer_max_pos.x, ImMin(table->OuterRect.Max.x, inner_content_max_x + decoration_size)); + outer_window->DC.IdealMaxPos.x = ImMax(outer_window->DC.IdealMaxPos.x, outer_content_max_x + decoration_size - temp_data->UserOuterSize.x); + outer_window->DC.CursorMaxPos.x = ImMax(backup_outer_max_pos.x, ImMin(table->OuterRect.Max.x, outer_content_max_x + decoration_size)); } else { @@ -1578,9 +1578,11 @@ void ImGui::EndTable() } if (temp_data->UserOuterSize.y <= 0.0f) { + const float outer_content_size_y = (inner_window == outer_window) ? (inner_content_max_y - table->InnerRect.Min.y) : (inner_content_max_y - inner_window->DC.CursorStartPos.y); + const float outer_content_max_y = table->OuterRect.Min.y + outer_content_size_y; const float decoration_size = (inner_window != outer_window ? inner_window->ScrollbarSizes.y : 0.0f); - outer_window->DC.IdealMaxPos.y = ImMax(outer_window->DC.IdealMaxPos.y, inner_content_max_y + decoration_size - temp_data->UserOuterSize.y); - outer_window->DC.CursorMaxPos.y = ImMax(backup_outer_max_pos.y, ImMin(table->OuterRect.Max.y, inner_content_max_y + decoration_size)); + outer_window->DC.IdealMaxPos.y = ImMax(outer_window->DC.IdealMaxPos.y, outer_content_max_y + decoration_size - temp_data->UserOuterSize.y); + outer_window->DC.CursorMaxPos.y = ImMax(backup_outer_max_pos.y, ImMin(table->OuterRect.Max.y, outer_content_max_y + decoration_size)); } else {