From 3e712631dad571b78e6fa9bbd946a90bfa22c65b Mon Sep 17 00:00:00 2001 From: ocornut Date: Fri, 15 Jan 2021 14:03:15 +0100 Subject: [PATCH] Tables: more moving of code in EndTable(), should have no side-effect. --- imgui_tables.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/imgui_tables.cpp b/imgui_tables.cpp index 424fb43bf..de7b5ec18 100644 --- a/imgui_tables.cpp +++ b/imgui_tables.cpp @@ -1178,16 +1178,14 @@ void ImGui::EndTable() inner_window->DC.PrevLineSize = table->HostBackupPrevLineSize; inner_window->DC.CurrLineSize = table->HostBackupCurrLineSize; inner_window->DC.CursorMaxPos = table->HostBackupCursorMaxPos; - + const float inner_content_max_y = table->RowPosY2; + IM_ASSERT(table->RowPosY2 == inner_window->DC.CursorPos.y); if (inner_window != outer_window) - { - inner_window->DC.CursorMaxPos.y = table->RowPosY2; - } + inner_window->DC.CursorMaxPos.y = inner_content_max_y; else if (!(flags & ImGuiTableFlags_NoHostExtendY)) - { - table->OuterRect.Max.y = table->InnerRect.Max.y = ImMax(table->OuterRect.Max.y, inner_window->DC.CursorPos.y); // Patch OuterRect/InnerRect height - outer_window->DC.CursorMaxPos.y = table->RowPosY2; - } + table->OuterRect.Max.y = table->InnerRect.Max.y = ImMax(table->OuterRect.Max.y, inner_content_max_y); // Patch OuterRect/InnerRect height + table->WorkRect.Max.y = ImMax(table->WorkRect.Max.y, table->OuterRect.Max.y); + table->LastOuterHeight = table->OuterRect.GetHeight(); // Setup inner scrolling range // FIXME: This ideally should be done earlier, in BeginTable() SetNextWindowContentSize call, just like writing to inner_window->DC.CursorMaxPos.y, @@ -1203,9 +1201,7 @@ void ImGui::EndTable() table->InnerWindow->DC.CursorMaxPos.x = max_pos_x; } - table->WorkRect.Max.y = ImMax(table->WorkRect.Max.y, table->OuterRect.Max.y); - table->LastOuterHeight = table->OuterRect.GetHeight(); - + // Pop clipping rect if (!(flags & ImGuiTableFlags_NoClip)) inner_window->DrawList->PopClipRect(); inner_window->ClipRect = inner_window->DrawList->_ClipRectStack.back(); @@ -1302,6 +1298,10 @@ void ImGui::EndTable() else outer_window->DC.CursorMaxPos.x = ImMax(backup_outer_max_pos.x, table->WorkRect.Min.x + outer_width); // For auto-fit + // Override declared contents height + if (inner_window == outer_window && !(flags & ImGuiTableFlags_NoHostExtendY)) + outer_window->DC.CursorMaxPos.y = ImMax(outer_window->DC.CursorMaxPos.y, inner_content_max_y); + // Save settings if (table->IsSettingsDirty) TableSaveSettings(table);