MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/SPlisHSPlasH / TableSetupColumn

Method TableSetupColumn

extern/imgui/imgui_tables.cpp:1409–1474  ·  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

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

Callers

nothing calls this directly

Calls 3

TableSetupColumnFlagsFunction · 0.85
sizeMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected