| 4044 | } |
| 4045 | |
| 4046 | void ImGui::EndColumns() |
| 4047 | { |
| 4048 | ImGuiContext& g = *GImGui; |
| 4049 | ImGuiWindow* window = GetCurrentWindow(); |
| 4050 | ImGuiOldColumns* columns = window->DC.CurrentColumns; |
| 4051 | IM_ASSERT(columns != NULL); |
| 4052 | |
| 4053 | PopItemWidth(); |
| 4054 | if (columns->Count > 1) |
| 4055 | { |
| 4056 | PopClipRect(); |
| 4057 | columns->Splitter.Merge(window->DrawList); |
| 4058 | } |
| 4059 | |
| 4060 | const ImGuiOldColumnFlags flags = columns->Flags; |
| 4061 | columns->LineMaxY = ImMax(columns->LineMaxY, window->DC.CursorPos.y); |
| 4062 | window->DC.CursorPos.y = columns->LineMaxY; |
| 4063 | if (!(flags & ImGuiOldColumnFlags_GrowParentContentsSize)) |
| 4064 | window->DC.CursorMaxPos.x = columns->HostCursorMaxPosX; // Restore cursor max pos, as columns don't grow parent |
| 4065 | |
| 4066 | // Draw columns borders and handle resize |
| 4067 | // The IsBeingResized flag ensure we preserve pre-resize columns width so back-and-forth are not lossy |
| 4068 | bool is_being_resized = false; |
| 4069 | if (!(flags & ImGuiOldColumnFlags_NoBorder) && !window->SkipItems) |
| 4070 | { |
| 4071 | // We clip Y boundaries CPU side because very long triangles are mishandled by some GPU drivers. |
| 4072 | const float y1 = ImMax(columns->HostCursorPosY, window->ClipRect.Min.y); |
| 4073 | const float y2 = ImMin(window->DC.CursorPos.y, window->ClipRect.Max.y); |
| 4074 | int dragging_column = -1; |
| 4075 | for (int n = 1; n < columns->Count; n++) |
| 4076 | { |
| 4077 | ImGuiOldColumnData* column = &columns->Columns[n]; |
| 4078 | float x = window->Pos.x + GetColumnOffset(n); |
| 4079 | const ImGuiID column_id = columns->ID + ImGuiID(n); |
| 4080 | const float column_hit_hw = COLUMNS_HIT_RECT_HALF_WIDTH; |
| 4081 | const ImRect column_hit_rect(ImVec2(x - column_hit_hw, y1), ImVec2(x + column_hit_hw, y2)); |
| 4082 | if (!ItemAdd(column_hit_rect, column_id, NULL, ImGuiItemFlags_NoNav)) |
| 4083 | continue; |
| 4084 | |
| 4085 | bool hovered = false, held = false; |
| 4086 | if (!(flags & ImGuiOldColumnFlags_NoResize)) |
| 4087 | { |
| 4088 | ButtonBehavior(column_hit_rect, column_id, &hovered, &held); |
| 4089 | if (hovered || held) |
| 4090 | g.MouseCursor = ImGuiMouseCursor_ResizeEW; |
| 4091 | if (held && !(column->Flags & ImGuiOldColumnFlags_NoResize)) |
| 4092 | dragging_column = n; |
| 4093 | } |
| 4094 | |
| 4095 | // Draw column |
| 4096 | const ImU32 col = GetColorU32(held ? ImGuiCol_SeparatorActive : hovered ? ImGuiCol_SeparatorHovered : ImGuiCol_Separator); |
| 4097 | const float xi = IM_FLOOR(x); |
| 4098 | window->DrawList->AddLine(ImVec2(xi, y1 + 1.0f), ImVec2(xi, y2), col); |
| 4099 | } |
| 4100 | |
| 4101 | // Apply dragging after drawing the column lines, so our rendered lines are in sync with how items were displayed during the frame. |
| 4102 | if (dragging_column != -1) |
| 4103 | { |
nothing calls this directly
no test coverage detected