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

Method BeginColumns

tutorials/common/imgui/imgui_tables.cpp:3857–3932  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 10

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

Tested by

no test coverage detected