From 4a448f869db2de74c4958a262112e7e47c56339b Mon Sep 17 00:00:00 2001 From: thedmd Date: Fri, 16 Oct 2026 22:48:02 +0200 Subject: [PATCH] Tables: fixed items in a cell being laid out on one line when the table is submitted in a horizontal layout (e.g. a menu bar). Items in cells used the layout type of the host window, so each ItemSize() in a cell ended with SameLine(). BeginTable() now sets a vertical layout until EndTable(). Tables with their own child window were not affected. --- imgui_internal.h | 1 + imgui_tables.cpp | 3 +++ 2 files changed, 4 insertions(+) diff --git a/imgui_internal.h b/imgui_internal.h index 875c51f42..26a6b024b 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -3273,6 +3273,7 @@ struct IMGUI_API ImGuiTableTempData ImVec1 HostBackupColumnsOffset; // Backup of OuterWindow->DC.ColumnsOffset at the end of BeginTable() float HostBackupItemWidth; // Backup of OuterWindow->DC.ItemWidth at the end of BeginTable() int HostBackupItemWidthStackSize;//Backup of OuterWindow->DC.ItemWidthStack.Size at the end of BeginTable() + ImGuiLayoutType HostBackupLayoutType; // Backup of InnerWindow->DC.LayoutType at the end of BeginTable() ImGuiTableTempData() { memset((void*)this, 0, sizeof(*this)); LastTimeActive = -1.0f; } }; diff --git a/imgui_tables.cpp b/imgui_tables.cpp index ee208d160..573f06857 100644 --- a/imgui_tables.cpp +++ b/imgui_tables.cpp @@ -476,7 +476,9 @@ bool ImGui::BeginTableEx(const char* name, ImGuiID id, int columns_count, ImG temp_data->HostBackupCursorMaxPos = inner_window->DC.CursorMaxPos; temp_data->HostBackupItemWidth = outer_window->DC.ItemWidth; temp_data->HostBackupItemWidthStackSize = outer_window->DC.ItemWidthStack.Size; + temp_data->HostBackupLayoutType = inner_window->DC.LayoutType; inner_window->DC.PrevLineSize = inner_window->DC.CurrLineSize = ImVec2(0.0f, 0.0f); + inner_window->DC.LayoutType = ImGuiLayoutType_Vertical; // Make borders not overlap our contents by offsetting HostClipRect (#6765, #7428, #3752) // (we normally shouldn't alter HostClipRect as we rely on TableMergeDrawChannels() expanding non-clipped column toward the @@ -1487,6 +1489,7 @@ void ImGui::EndTable() // Finalize table height ImGuiTableInstanceData* table_instance = TableGetInstanceData(table, table->InstanceCurrent); inner_window->DC.PrevLineSize = temp_data->HostBackupPrevLineSize; + inner_window->DC.LayoutType = temp_data->HostBackupLayoutType; inner_window->DC.CurrLineSize = temp_data->HostBackupCurrLineSize; inner_window->DC.CursorMaxPos = temp_data->HostBackupCursorMaxPos; const float inner_content_max_y = ImCeil(table->RowPosY2); // Rounding final position is important as we currently don't round row height ('Demo->Tables->Outer Size' demo uses non-integer heights)