From 721da6a34c220b53eaa6f2dec0105123f5a6ea37 Mon Sep 17 00:00:00 2001 From: ocornut Date: Mon, 15 Jun 2026 18:14:28 +0200 Subject: [PATCH] Tables: apply queued requests in TableUpdateLayout() To allow calling TableQueueSetColumnDisplayOrder() between TableSetupColumn() and between TableUpdateLayout() # Conflicts: # imgui_tables.cpp --- imgui_internal.h | 2 +- imgui_tables.cpp | 20 +++++++++++--------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/imgui_internal.h b/imgui_internal.h index da8122e63..87de72045 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -3197,7 +3197,7 @@ namespace ImGui IMGUI_API ImGuiTable* TableFindByID(ImGuiID id); IMGUI_API bool BeginTableEx(const char* name, ImGuiID id, int columns_count, ImGuiTableFlags flags = 0, const ImVec2& outer_size = ImVec2(0, 0), float inner_width = 0.0f); IMGUI_API void TableBeginInitMemory(ImGuiTable* table, int columns_count); - IMGUI_API void TableBeginApplyRequests(ImGuiTable* table); + IMGUI_API void TableApplyQueuedRequests(ImGuiTable* table); IMGUI_API void TableSetupDrawChannels(ImGuiTable* table); IMGUI_API void TableUpdateLayout(ImGuiTable* table); IMGUI_API void TableUpdateBorders(ImGuiTable* table); diff --git a/imgui_tables.cpp b/imgui_tables.cpp index 30fddf627..d49478de1 100644 --- a/imgui_tables.cpp +++ b/imgui_tables.cpp @@ -40,14 +40,16 @@ Index of this file: // | TableBeginInitMemory() - first time table is used // | TableResetSettings() - on settings reset // | TableLoadSettings() - on settings load -// | TableBeginApplyRequests() - apply queued resizing/reordering/hiding requests -// | - TableSetColumnWidth() - apply resizing width (for mouse resize, often requested by previous frame) -// | - TableUpdateColumnsWeightFromWidth()- recompute columns weights (of stretch columns) from their respective width //----------------------------------------------------------------------------- // - TableSetupColumn() user submit columns details (optional) // - TableSetupScrollFreeze() user submit scroll freeze information (optional) //----------------------------------------------------------------------------- // - TableUpdateLayout() [Internal] followup to BeginTable(): setup everything: widths, columns positions, clipping rectangles. Automatically called by the FIRST call to TableNextRow() or TableHeadersRow(). +// | TableLoadSettingsForColumns() - on settings load +// | TableApplyQueuedRequests() - apply queued resizing/reordering/hiding requests +// | - TableSetColumnWidth() - apply resizing width (for mouse resize, often requested by previous frame) +// | - TableUpdateColumnsWeightFromWidth()- recompute columns weights (of stretch columns) from their respective width +// | - TableSetColumnDisplayOrder() - apply reordering a column // | TableSetupDrawChannels() - setup ImDrawList channels // | TableUpdateBorders() - detect hovering columns for resize, ahead of contents submission // | TableBeginContextMenuPopup() @@ -253,7 +255,7 @@ Index of this file: // - BeginTable() // - BeginTableEx() [Internal] // - TableBeginInitMemory() [Internal] -// - TableBeginApplyRequests() [Internal] +// - TableApplyQueuedRequests() [Internal] // - TableSetupColumnFlags() [Internal] // - TableUpdateLayout() [Internal] // - TableUpdateBorders() [Internal] @@ -626,10 +628,7 @@ bool ImGui::BeginTableEx(const char* name, ImGuiID id, int columns_count, ImG // At this point the ->NameOffset field of each column will be invalid until TableUpdateLayout() or the first call to TableSetupColumn() if (table->ColumnsNames.Buf.Size > 0) table->ColumnsNames.Buf.resize(0); - - // Apply queued resizing/reordering/hiding requests - TableBeginApplyRequests(table); - + return true; } @@ -664,7 +663,7 @@ void ImGui::TableBeginInitMemory(ImGuiTable* table, int columns_count) } // Apply queued resizing/reordering/hiding requests -void ImGui::TableBeginApplyRequests(ImGuiTable* table) +void ImGui::TableApplyQueuedRequests(ImGuiTable* table) { // Handle resizing request // (We process this in the TableBegin() of the first instance of each table) @@ -845,6 +844,9 @@ void ImGui::TableUpdateLayout(ImGuiTable* table) ImGuiContext& g = *GImGui; IM_ASSERT(table->IsLayoutLocked == false); + // Apply queued resizing/reordering/hiding requests + TableApplyQueuedRequests(table); + // Handle DPI/font resize // This is designed to facilitate DPI changes with the assumption that e.g. style.CellPadding has been scaled as well. // It will also react to changing fonts with mixed results. It doesn't need to be perfect but merely provide a decent transition.