diff --git a/imgui_tables.cpp b/imgui_tables.cpp index 424fb43b..de7b5ec1 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);