| 4567 | } |
| 4568 | |
| 4569 | void ImGui::EndColumns() |
| 4570 | { |
| 4571 | ImGuiContext& g = *GImGui; |
| 4572 | ImGuiWindow* window = GetCurrentWindow(); |
| 4573 | ImGuiOldColumns* columns = window->DC.CurrentColumns; |
| 4574 | IM_ASSERT(columns != NULL); |
| 4575 | |
| 4576 | PopItemWidth(); |
| 4577 | if (columns->Count > 1) |
| 4578 | { |
| 4579 | PopClipRect(); |
| 4580 | columns->Splitter.Merge(window->DrawList); |
| 4581 | } |
| 4582 | |
| 4583 | const ImGuiOldColumnFlags flags = columns->Flags; |
| 4584 | columns->LineMaxY = ImMax(columns->LineMaxY, window->DC.CursorPos.y); |
| 4585 | window->DC.CursorPos.y = columns->LineMaxY; |
| 4586 | if (!(flags & ImGuiOldColumnFlags_GrowParentContentsSize)) |
| 4587 | window->DC.CursorMaxPos.x = columns->HostCursorMaxPosX; // Restore cursor max pos, as columns don't grow parent |
| 4588 | |
| 4589 | // Draw columns borders and handle resize |
| 4590 | // The IsBeingResized flag ensure we preserve pre-resize columns width so back-and-forth are not lossy |
| 4591 | bool is_being_resized = false; |
| 4592 | if (!(flags & ImGuiOldColumnFlags_NoBorder) && !window->SkipItems) |
| 4593 | { |
| 4594 | // We clip Y boundaries CPU side because very long triangles are mishandled by some GPU drivers. |
| 4595 | const float y1 = ImMax(columns->HostCursorPosY, window->ClipRect.Min.y); |
| 4596 | const float y2 = ImMin(window->DC.CursorPos.y, window->ClipRect.Max.y); |
| 4597 | int dragging_column = -1; |
| 4598 | for (int n = 1; n < columns->Count; n++) |
| 4599 | { |
| 4600 | ImGuiOldColumnData* column = &columns->Columns[n]; |
| 4601 | float x = window->Pos.x + GetColumnOffset(n); |
| 4602 | const ImGuiID column_id = columns->ID + ImGuiID(n); |
| 4603 | const float column_hit_hw = ImTrunc(COLUMNS_HIT_RECT_HALF_THICKNESS * g.CurrentDpiScale); |
| 4604 | const ImRect column_hit_rect(ImVec2(x - column_hit_hw, y1), ImVec2(x + column_hit_hw, y2)); |
| 4605 | if (!ItemAdd(column_hit_rect, column_id, NULL, ImGuiItemFlags_NoNav)) |
| 4606 | continue; |
| 4607 | |
| 4608 | bool hovered = false, held = false; |
| 4609 | if (!(flags & ImGuiOldColumnFlags_NoResize)) |
| 4610 | { |
| 4611 | ButtonBehavior(column_hit_rect, column_id, &hovered, &held); |
| 4612 | if (hovered || held) |
| 4613 | SetMouseCursor(ImGuiMouseCursor_ResizeEW); |
| 4614 | if (held && !(column->Flags & ImGuiOldColumnFlags_NoResize)) |
| 4615 | dragging_column = n; |
| 4616 | } |
| 4617 | |
| 4618 | // Draw column |
| 4619 | const ImU32 col = GetColorU32(held ? ImGuiCol_SeparatorActive : hovered ? ImGuiCol_SeparatorHovered : ImGuiCol_Separator); |
| 4620 | const float xi = IM_TRUNC(x); |
| 4621 | window->DrawList->AddLineV(xi, y1 + 1.0f, y2, col); |
| 4622 | } |
| 4623 | |
| 4624 | // Apply dragging after drawing the column lines, so our rendered lines are in sync with how items were displayed during the frame. |
| 4625 | if (dragging_column != -1) |
| 4626 | { |
nothing calls this directly
no test coverage detected