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

Method BeginColumns

extern/imgui/imgui_tables.cpp:3856–3931  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3854}
3855
3856void ImGui::BeginColumns(const char* str_id, int columns_count, ImGuiOldColumnFlags flags)
3857{
3858 ImGuiContext& g = *GImGui;
3859 ImGuiWindow* window = GetCurrentWindow();
3860
3861 IM_ASSERT(columns_count >= 1);
3862 IM_ASSERT(window->DC.CurrentColumns == NULL); // Nested columns are currently not supported
3863
3864 // Acquire storage for the columns set
3865 ImGuiID id = GetColumnsID(str_id, columns_count);
3866 ImGuiOldColumns* columns = FindOrCreateColumns(window, id);
3867 IM_ASSERT(columns->ID == id);
3868 columns->Current = 0;
3869 columns->Count = columns_count;
3870 columns->Flags = flags;
3871 window->DC.CurrentColumns = columns;
3872
3873 columns->HostCursorPosY = window->DC.CursorPos.y;
3874 columns->HostCursorMaxPosX = window->DC.CursorMaxPos.x;
3875 columns->HostInitialClipRect = window->ClipRect;
3876 columns->HostBackupParentWorkRect = window->ParentWorkRect;
3877 window->ParentWorkRect = window->WorkRect;
3878
3879 // Set state for first column
3880 // We aim so that the right-most column will have the same clipping width as other after being clipped by parent ClipRect
3881 const float column_padding = g.Style.ItemSpacing.x;
3882 const float half_clip_extend_x = ImFloor(ImMax(window->WindowPadding.x * 0.5f, window->WindowBorderSize));
3883 const float max_1 = window->WorkRect.Max.x + column_padding - ImMax(column_padding - window->WindowPadding.x, 0.0f);
3884 const float max_2 = window->WorkRect.Max.x + half_clip_extend_x;
3885 columns->OffMinX = window->DC.Indent.x - column_padding + ImMax(column_padding - window->WindowPadding.x, 0.0f);
3886 columns->OffMaxX = ImMax(ImMin(max_1, max_2) - window->Pos.x, columns->OffMinX + 1.0f);
3887 columns->LineMinY = columns->LineMaxY = window->DC.CursorPos.y;
3888
3889 // Clear data if columns count changed
3890 if (columns->Columns.Size != 0 && columns->Columns.Size != columns_count + 1)
3891 columns->Columns.resize(0);
3892
3893 // Initialize default widths
3894 columns->IsFirstFrame = (columns->Columns.Size == 0);
3895 if (columns->Columns.Size == 0)
3896 {
3897 columns->Columns.reserve(columns_count + 1);
3898 for (int n = 0; n < columns_count + 1; n++)
3899 {
3900 ImGuiOldColumnData column;
3901 column.OffsetNorm = n / (float)columns_count;
3902 columns->Columns.push_back(column);
3903 }
3904 }
3905
3906 for (int n = 0; n < columns_count; n++)
3907 {
3908 // Compute clipping rectangle
3909 ImGuiOldColumnData* column = &columns->Columns[n];
3910 float clip_x1 = IM_ROUND(window->Pos.x + GetColumnOffset(n));
3911 float clip_x2 = IM_ROUND(window->Pos.x + GetColumnOffset(n + 1) - 1.0f);
3912 column->ClipRect = ImRect(clip_x1, -FLT_MAX, clip_x2, +FLT_MAX);
3913 column->ClipRect.ClipWithFull(window->ClipRect);

Callers

nothing calls this directly

Calls 10

GetCurrentWindowFunction · 0.85
ImFloorFunction · 0.85
ImMaxFunction · 0.85
ImMinFunction · 0.85
SplitMethod · 0.80
SetCurrentChannelMethod · 0.80
ImRectFunction · 0.70
resizeMethod · 0.45
reserveMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected