MCPcopy Create free account
hub / github.com/BlitterStudio/amiberry / TableSetupColumn

Method TableSetupColumn

external/imgui/imgui_tables.cpp:1659–1709  ·  view source on GitHub ↗

See "COLUMNS 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

1657// See "COLUMNS SIZING POLICIES" comments at the top of this file
1658// If (init_width_or_weight <= 0.0f) it is ignored
1659void ImGui::TableSetupColumn(const char* label, ImGuiTableColumnFlags flags, float init_width_or_weight, ImGuiID user_id)
1660{
1661 ImGuiContext& g = *GImGui;
1662 ImGuiTable* table = g.CurrentTable;
1663 IM_ASSERT_USER_ERROR_RET(table != NULL, "Call should only be done while in BeginTable() scope!");
1664 IM_ASSERT_USER_ERROR_RET(table->DeclColumnsCount < table->ColumnsCount, "TableSetupColumn(): called too many times!");
1665 IM_ASSERT_USER_ERROR_RET(table->IsLayoutLocked == false, "TableSetupColumn(): need to call before first row!"); // Table layout is locked when submitting a row or when calling BeginMultiSelect() with box-select.
1666 IM_ASSERT((flags & ImGuiTableColumnFlags_StatusMask_) == 0 && "Illegal to pass StatusMask values to TableSetupColumn()");
1667
1668 ImGuiTableColumn* column = &table->Columns[table->DeclColumnsCount];
1669 table->DeclColumnsCount++;
1670
1671 // Assert when passing a width or weight if policy is entirely left to default, to avoid storing width into weight and vice-versa.
1672 // Give a grace to users of ImGuiTableFlags_ScrollX.
1673 if (table->IsDefaultSizingPolicy && (flags & ImGuiTableColumnFlags_WidthMask_) == 0 && (flags & ImGuiTableFlags_ScrollX) == 0)
1674 IM_ASSERT_USER_ERROR_RET(init_width_or_weight <= 0.0f, "TableSetupColumn(): can only specify width/weight if sizing policy is set explicitly in either Table or Column.");
1675
1676 // When passing a width automatically enforce WidthFixed policy
1677 // (whereas TableSetupColumnFlags would default to WidthAuto if table is not resizable)
1678 if ((flags & ImGuiTableColumnFlags_WidthMask_) == 0 && init_width_or_weight > 0.0f)
1679 if ((table->Flags & ImGuiTableFlags_SizingMask_) == ImGuiTableFlags_SizingFixedFit || (table->Flags & ImGuiTableFlags_SizingMask_) == ImGuiTableFlags_SizingFixedSame)
1680 flags |= ImGuiTableColumnFlags_WidthFixed;
1681 if (flags & ImGuiTableColumnFlags_AngledHeader)
1682 {
1683 flags |= ImGuiTableColumnFlags_NoHeaderLabel;
1684 table->AngledHeadersCount++;
1685 }
1686
1687 TableSetupColumnFlags(table, column, flags);
1688 column->UserID = user_id;
1689 flags = column->Flags;
1690
1691 // Initialize defaults
1692 column->InitStretchWeightOrWidth = init_width_or_weight;
1693 if (table->IsInitializing)
1694 {
1695 ImGuiTableFlags init_flags = ~table->SettingsLoadedFlags;
1696 if (column->WidthRequest < 0.0f && column->StretchWeight < 0.0f)
1697 init_flags |= ImGuiTableFlags_Resizable;
1698 TableInitColumnDefaults(table, column, init_flags);
1699 }
1700
1701 // Store name (append with zero-terminator in contiguous buffer)
1702 // FIXME: If we recorded the number of \n in names we could compute header row height
1703 column->NameOffset = -1;
1704 if (label != NULL && label[0] != 0)
1705 {
1706 column->NameOffset = (ImS16)table->ColumnsNames.size();
1707 table->ColumnsNames.append(label, label + ImStrlen(label) + 1);
1708 }
1709}
1710
1711// [Public]
1712void ImGui::TableSetupScrollFreeze(int columns, int rows)

Callers

nothing calls this directly

Calls 4

TableSetupColumnFlagsFunction · 0.85
TableInitColumnDefaultsFunction · 0.85
sizeMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected