MCPcopy Create free account
hub / github.com/DISTRHO/Cardinal / TableSetupColumn

Method TableSetupColumn

plugins/Cardinal/src/DearImGui/imgui_tables.cpp:1397–1462  ·  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

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

Callers

nothing calls this directly

Calls 3

TableSetupColumnFlagsFunction · 0.85
appendMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected