mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-22 11:57:00 +00:00
Tables: Columns with no policy in a scrolling table will default to WidthFixed instead of WidthAlwaysAutoResize if an explicit value is passed to TableSetupColumn()
This commit is contained in:
parent
e06a36ab12
commit
eee82e0451
@ -499,8 +499,8 @@ static float TableGetMinColumnWidth()
|
|||||||
|
|
||||||
// Layout columns for the frame
|
// Layout columns for the frame
|
||||||
// Runs on the first call to TableNextRow(), to give a chance for TableSetupColumn() to be called first.
|
// Runs on the first call to TableNextRow(), to give a chance for TableSetupColumn() to be called first.
|
||||||
// FIXME-TABLE: Our width (and therefore our WorkRect) will be minimal in the first frame for WidthAuto columns,
|
// FIXME-TABLE: Our width (and therefore our WorkRect) will be minimal in the first frame for WidthAlwaysAutoResize columns,
|
||||||
// increase feedback side-effect with widgets relying on WorkRect.Max.x. Maybe provide a default distribution for WidthAuto columns?
|
// increase feedback side-effect with widgets relying on WorkRect.Max.x. Maybe provide a default distribution for WidthAlwaysAutoResize columns?
|
||||||
void ImGui::TableUpdateLayout(ImGuiTable* table)
|
void ImGui::TableUpdateLayout(ImGuiTable* table)
|
||||||
{
|
{
|
||||||
IM_ASSERT(table->IsLayoutLocked == false);
|
IM_ASSERT(table->IsLayoutLocked == false);
|
||||||
@ -522,6 +522,7 @@ void ImGui::TableUpdateLayout(ImGuiTable* table)
|
|||||||
ImGuiTableColumn* column = &table->Columns[column_n];
|
ImGuiTableColumn* column = &table->Columns[column_n];
|
||||||
|
|
||||||
// Adjust flags: default width mode + weighted columns are not allowed when auto extending
|
// Adjust flags: default width mode + weighted columns are not allowed when auto extending
|
||||||
|
// FIXME-TABLE: Clarify why we need to do this again here and not just in TableSetupColumn()
|
||||||
column->Flags = TableFixColumnFlags(table, column->FlagsIn);
|
column->Flags = TableFixColumnFlags(table, column->FlagsIn);
|
||||||
|
|
||||||
// We have a unusual edge case where if the user doesn't call TableGetSortSpecs() but has sorting enabled
|
// We have a unusual edge case where if the user doesn't call TableGetSortSpecs() but has sorting enabled
|
||||||
@ -1269,6 +1270,12 @@ void ImGui::TableSetupColumn(const char* label, ImGuiTableColumnFlags flags,
|
|||||||
ImGuiTableColumn* column = &table->Columns[table->DeclColumnsCount];
|
ImGuiTableColumn* column = &table->Columns[table->DeclColumnsCount];
|
||||||
table->DeclColumnsCount++;
|
table->DeclColumnsCount++;
|
||||||
|
|
||||||
|
// When passing a width automatically enforce WidthFixed policy (vs TableFixColumnFlags would default to WidthAlwaysAutoResize)
|
||||||
|
// (we write down to FlagsIn which is a little misleading, another solution would be to pass init_width_or_weight to TableFixColumnFlags)
|
||||||
|
if ((flags & ImGuiTableColumnFlags_WidthMask_) == 0)
|
||||||
|
if ((table->Flags & ImGuiTableFlags_SizingPolicyFixedX) && (init_width_or_weight > 0.0f))
|
||||||
|
flags |= ImGuiTableColumnFlags_WidthFixed;
|
||||||
|
|
||||||
column->UserID = user_id;
|
column->UserID = user_id;
|
||||||
column->FlagsIn = flags;
|
column->FlagsIn = flags;
|
||||||
column->Flags = TableFixColumnFlags(table, column->FlagsIn);
|
column->Flags = TableFixColumnFlags(table, column->FlagsIn);
|
||||||
|
Loading…
Reference in New Issue
Block a user