FIXME-TABLE: This is a mess, need to redesign how we render borders (as some are also done in TableEndRow)
| 2640 | |
| 2641 | // FIXME-TABLE: This is a mess, need to redesign how we render borders (as some are also done in TableEndRow) |
| 2642 | void ImGui::TableDrawBorders(ImGuiTable* table) |
| 2643 | { |
| 2644 | ImGuiWindow* inner_window = table->InnerWindow; |
| 2645 | if (!table->OuterWindow->ClipRect.Overlaps(table->OuterRect)) |
| 2646 | return; |
| 2647 | |
| 2648 | ImDrawList* inner_drawlist = inner_window->DrawList; |
| 2649 | table->DrawSplitter->SetCurrentChannel(inner_drawlist, TABLE_DRAW_CHANNEL_BG0); |
| 2650 | inner_drawlist->PushClipRect(table->Bg0ClipRectForDrawCmd.Min, table->Bg0ClipRectForDrawCmd.Max, false); |
| 2651 | |
| 2652 | // Draw inner border and resizing feedback |
| 2653 | ImGuiTableInstanceData* table_instance = TableGetInstanceData(table, table->InstanceCurrent); |
| 2654 | const float border_size = TABLE_BORDER_SIZE; |
| 2655 | const float draw_y1 = ImMax(table->InnerRect.Min.y, (table->FreezeRowsCount >= 1 ? table->InnerRect.Min.y : table->WorkRect.Min.y) + table->AngledHeadersHeight) + ((table->Flags & ImGuiTableFlags_BordersOuterH) ? 1.0f : 0.0f); |
| 2656 | const float draw_y2_body = table->InnerRect.Max.y; |
| 2657 | const float draw_y2_head = table->IsUsingHeaders ? ImMin(table->InnerRect.Max.y, (table->FreezeRowsCount >= 1 ? table->InnerRect.Min.y : table->WorkRect.Min.y) + table_instance->LastTopHeadersRowHeight) : draw_y1; |
| 2658 | if (table->Flags & ImGuiTableFlags_BordersInnerV) |
| 2659 | { |
| 2660 | for (int order_n = 0; order_n < table->ColumnsCount; order_n++) |
| 2661 | { |
| 2662 | if (!IM_BITARRAY_TESTBIT(table->EnabledMaskByDisplayOrder, order_n)) |
| 2663 | continue; |
| 2664 | |
| 2665 | const int column_n = table->DisplayOrderToIndex[order_n]; |
| 2666 | ImGuiTableColumn* column = &table->Columns[column_n]; |
| 2667 | const bool is_hovered = (table->HoveredColumnBorder == column_n); |
| 2668 | const bool is_resized = (table->ResizedColumn == column_n) && (table->InstanceInteracted == table->InstanceCurrent); |
| 2669 | const bool is_resizable = (column->Flags & (ImGuiTableColumnFlags_NoResize | ImGuiTableColumnFlags_NoDirectResize_)) == 0; |
| 2670 | const bool is_frozen_separator = (table->FreezeColumnsCount == order_n + 1); |
| 2671 | if (column->MaxX > table->InnerClipRect.Max.x && !is_resized) |
| 2672 | continue; |
| 2673 | |
| 2674 | // Decide whether right-most column is visible |
| 2675 | if (column->NextEnabledColumn == -1 && !is_resizable) |
| 2676 | if ((table->Flags & ImGuiTableFlags_SizingMask_) != ImGuiTableFlags_SizingFixedSame || (table->Flags & ImGuiTableFlags_NoHostExtendX)) |
| 2677 | continue; |
| 2678 | if (column->MaxX <= column->ClipRect.Min.x) // FIXME-TABLE FIXME-STYLE: Assume BorderSize==1, this is problematic if we want to increase the border size.. |
| 2679 | continue; |
| 2680 | |
| 2681 | // Draw in outer window so right-most column won't be clipped |
| 2682 | // Always draw full height border when being resized/hovered, or on the delimitation of frozen column scrolling. |
| 2683 | float draw_y2 = (is_hovered || is_resized || is_frozen_separator || (table->Flags & (ImGuiTableFlags_NoBordersInBody | ImGuiTableFlags_NoBordersInBodyUntilResize)) == 0) ? draw_y2_body : draw_y2_head; |
| 2684 | if (draw_y2 > draw_y1) |
| 2685 | inner_drawlist->AddLine(ImVec2(column->MaxX, draw_y1), ImVec2(column->MaxX, draw_y2), TableGetColumnBorderCol(table, order_n, column_n), border_size); |
| 2686 | } |
| 2687 | } |
| 2688 | |
| 2689 | // Draw outer border |
| 2690 | // FIXME: could use AddRect or explicit VLine/HLine helper? |
| 2691 | if (table->Flags & ImGuiTableFlags_BordersOuter) |
| 2692 | { |
| 2693 | // Display outer border offset by 1 which is a simple way to display it without adding an extra draw call |
| 2694 | // (Without the offset, in outer_window it would be rendered behind cells, because child windows are above their |
| 2695 | // parent. In inner_window, it won't reach out over scrollbars. Another weird solution would be to display part |
| 2696 | // of it in inner window, and the part that's over scrollbars in the outer window..) |
| 2697 | // Either solution currently won't allow us to use a larger border size: the border would clipped. |
| 2698 | const ImRect outer_border = table->OuterRect; |
| 2699 | const ImU32 outer_col = table->BorderColorStrong; |
nothing calls this directly
no test coverage detected