mirror of
https://github.com/ocornut/imgui.git
synced 2024-11-30 18:34:34 +01:00
Tables: fixed ColumnsAutoFitWidth for resizable fixed columns reporting ideal width.
This commit is contained in:
parent
3e712631da
commit
4d419d1211
@ -4600,7 +4600,7 @@ static void ShowDemoWindowTables()
|
|||||||
static ImGuiTableFlags flags1 = ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable | ImGuiTableFlags_Borders | ImGuiTableFlags_ContextMenuInBody;
|
static ImGuiTableFlags flags1 = ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_Hideable | ImGuiTableFlags_Borders | ImGuiTableFlags_ContextMenuInBody;
|
||||||
|
|
||||||
PushStyleCompact();
|
PushStyleCompact();
|
||||||
ImGui::CheckboxFlags("ImGuiTableFlags_ContextMenuInBody", (unsigned int*)&flags1, ImGuiTableFlags_ContextMenuInBody);
|
ImGui::CheckboxFlags("ImGuiTableFlags_ContextMenuInBody", &flags1, ImGuiTableFlags_ContextMenuInBody);
|
||||||
PopStyleCompact();
|
PopStyleCompact();
|
||||||
|
|
||||||
// Context Menus: first example
|
// Context Menus: first example
|
||||||
|
@ -1234,7 +1234,13 @@ void ImGui::EndTable()
|
|||||||
table->ColumnsAutoFitWidth = width_spacings + (table->CellPaddingX * 2.0f) * table->ColumnsEnabledCount;
|
table->ColumnsAutoFitWidth = width_spacings + (table->CellPaddingX * 2.0f) * table->ColumnsEnabledCount;
|
||||||
for (int column_n = 0; column_n < table->ColumnsCount; column_n++)
|
for (int column_n = 0; column_n < table->ColumnsCount; column_n++)
|
||||||
if (table->EnabledMaskByIndex & ((ImU64)1 << column_n))
|
if (table->EnabledMaskByIndex & ((ImU64)1 << column_n))
|
||||||
table->ColumnsAutoFitWidth += TableGetColumnWidthAuto(table, &table->Columns[column_n]);
|
{
|
||||||
|
ImGuiTableColumn* column = &table->Columns[column_n];
|
||||||
|
if ((column->Flags & ImGuiTableColumnFlags_WidthFixed) && !(column->Flags & ImGuiTableColumnFlags_NoResize))
|
||||||
|
table->ColumnsAutoFitWidth += column->WidthRequest;
|
||||||
|
else
|
||||||
|
table->ColumnsAutoFitWidth += TableGetColumnWidthAuto(table, column);
|
||||||
|
}
|
||||||
|
|
||||||
// Update scroll
|
// Update scroll
|
||||||
if ((table->Flags & ImGuiTableFlags_ScrollX) == 0 && inner_window != outer_window)
|
if ((table->Flags & ImGuiTableFlags_ScrollX) == 0 && inner_window != outer_window)
|
||||||
@ -1457,7 +1463,7 @@ ImRect ImGui::TableGetCellBgRect(const ImGuiTable* table, int column_n)
|
|||||||
// Return the resizing ID for the right-side of the given column.
|
// Return the resizing ID for the right-side of the given column.
|
||||||
ImGuiID ImGui::TableGetColumnResizeID(const ImGuiTable* table, int column_n, int instance_no)
|
ImGuiID ImGui::TableGetColumnResizeID(const ImGuiTable* table, int column_n, int instance_no)
|
||||||
{
|
{
|
||||||
IM_ASSERT(column_n < table->ColumnsCount);
|
IM_ASSERT(column_n >= 0 && column_n < table->ColumnsCount);
|
||||||
ImGuiID id = table->ID + 1 + (instance_no * table->ColumnsCount) + column_n;
|
ImGuiID id = table->ID + 1 + (instance_no * table->ColumnsCount) + column_n;
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user