MCPcopy Create free account
hub / github.com/RenderKit/embree / TableSetupColumn

Method TableSetupColumn

tutorials/common/imgui/imgui_tables.cpp:1410–1475  ·  view source on GitHub ↗

See "COLUMN SIZING POLICIES" comments at the top of this file If (init_width_or_weight <= 0.0f) it is ignored

Source from the content-addressed store, hash-verified

1408// See "COLUMN SIZING POLICIES" comments at the top of this file
1409// If (init_width_or_weight <= 0.0f) it is ignored
1410void ImGui::TableSetupColumn(const char* label, ImGuiTableColumnFlags flags, float init_width_or_weight, ImGuiID user_id)
1411{
1412 ImGuiContext& g = *GImGui;
1413 ImGuiTable* table = g.CurrentTable;
1414 IM_ASSERT(table != NULL && "Need to call TableSetupColumn() after BeginTable()!");
1415 IM_ASSERT(table->IsLayoutLocked == false && "Need to call call TableSetupColumn() before first row!");
1416 IM_ASSERT((flags & ImGuiTableColumnFlags_StatusMask_) == 0 && "Illegal to pass StatusMask values to TableSetupColumn()");
1417 if (table->DeclColumnsCount >= table->ColumnsCount)
1418 {
1419 IM_ASSERT_USER_ERROR(table->DeclColumnsCount < table->ColumnsCount, "Called TableSetupColumn() too many times!");
1420 return;
1421 }
1422
1423 ImGuiTableColumn* column = &table->Columns[table->DeclColumnsCount];
1424 table->DeclColumnsCount++;
1425
1426 // Assert when passing a width or weight if policy is entirely left to default, to avoid storing width into weight and vice-versa.
1427 // Give a grace to users of ImGuiTableFlags_ScrollX.
1428 if (table->IsDefaultSizingPolicy && (flags & ImGuiTableColumnFlags_WidthMask_) == 0 && (flags & ImGuiTableFlags_ScrollX) == 0)
1429 IM_ASSERT(init_width_or_weight <= 0.0f && "Can only specify width/weight if sizing policy is set explicitly in either Table or Column.");
1430
1431 // When passing a width automatically enforce WidthFixed policy
1432 // (whereas TableSetupColumnFlags would default to WidthAuto if table is not Resizable)
1433 if ((flags & ImGuiTableColumnFlags_WidthMask_) == 0 && init_width_or_weight > 0.0f)
1434 if ((table->Flags & ImGuiTableFlags_SizingMask_) == ImGuiTableFlags_SizingFixedFit || (table->Flags & ImGuiTableFlags_SizingMask_) == ImGuiTableFlags_SizingFixedSame)
1435 flags |= ImGuiTableColumnFlags_WidthFixed;
1436
1437 TableSetupColumnFlags(table, column, flags);
1438 column->UserID = user_id;
1439 flags = column->Flags;
1440
1441 // Initialize defaults
1442 column->InitStretchWeightOrWidth = init_width_or_weight;
1443 if (table->IsInitializing)
1444 {
1445 // Init width or weight
1446 if (column->WidthRequest < 0.0f && column->StretchWeight < 0.0f)
1447 {
1448 if ((flags & ImGuiTableColumnFlags_WidthFixed) && init_width_or_weight > 0.0f)
1449 column->WidthRequest = init_width_or_weight;
1450 if (flags & ImGuiTableColumnFlags_WidthStretch)
1451 column->StretchWeight = (init_width_or_weight > 0.0f) ? init_width_or_weight : -1.0f;
1452
1453 // Disable auto-fit if an explicit width/weight has been specified
1454 if (init_width_or_weight > 0.0f)
1455 column->AutoFitQueue = 0x00;
1456 }
1457
1458 // Init default visibility/sort state
1459 if ((flags & ImGuiTableColumnFlags_DefaultHide) && (table->SettingsLoadedFlags & ImGuiTableFlags_Hideable) == 0)
1460 column->IsUserEnabled = column->IsUserEnabledNextFrame = false;
1461 if (flags & ImGuiTableColumnFlags_DefaultSort && (table->SettingsLoadedFlags & ImGuiTableFlags_Sortable) == 0)
1462 {
1463 column->SortOrder = 0; // Multiple columns using _DefaultSort will be reassigned unique SortOrder values when building the sort specs.
1464 column->SortDirection = (column->Flags & ImGuiTableColumnFlags_PreferSortDescending) ? (ImS8)ImGuiSortDirection_Descending : (ImU8)(ImGuiSortDirection_Ascending);
1465 }
1466 }
1467

Callers

nothing calls this directly

Calls 3

TableSetupColumnFlagsFunction · 0.85
appendMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected