Tables: apply queued requests in TableUpdateLayout()

To allow calling TableQueueSetColumnDisplayOrder() between TableSetupColumn() and between TableUpdateLayout()

# Conflicts:
#	imgui_tables.cpp
This commit is contained in:
ocornut
2026-06-15 18:14:28 +02:00
parent 360183924b
commit 721da6a34c
2 changed files with 12 additions and 10 deletions

View File

@@ -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);

View File

@@ -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]
@@ -627,9 +629,6 @@ bool ImGui::BeginTableEx(const char* name, ImGuiID id, int columns_count, ImG
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.