FIXME-TABLE: This is a mess, need to redesign how we render borders (as some are also done in TableEndRow)
| 2567 | |
| 2568 | // FIXME-TABLE: This is a mess, need to redesign how we render borders (as some are also done in TableEndRow) |
| 2569 | void ImGui::TableDrawBorders(ImGuiTable* table) |
| 2570 | { |
| 2571 | ImGuiWindow* inner_window = table->InnerWindow; |
| 2572 | if (!table->OuterWindow->ClipRect.Overlaps(table->OuterRect)) |
| 2573 | return; |
| 2574 | |
| 2575 | ImDrawList* inner_drawlist = inner_window->DrawList; |
| 2576 | table->DrawSplitter->SetCurrentChannel(inner_drawlist, TABLE_DRAW_CHANNEL_BG0); |
| 2577 | inner_drawlist->PushClipRect(table->Bg0ClipRectForDrawCmd.Min, table->Bg0ClipRectForDrawCmd.Max, false); |
| 2578 | |
| 2579 | // Draw inner border and resizing feedback |
| 2580 | ImGuiTableInstanceData* table_instance = TableGetInstanceData(table, table->InstanceCurrent); |
| 2581 | const float border_size = TABLE_BORDER_SIZE; |
| 2582 | const float draw_y1 = table->InnerRect.Min.y; |
| 2583 | const float draw_y2_body = table->InnerRect.Max.y; |
| 2584 | 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->LastFirstRowHeight) : draw_y1; |
| 2585 | if (table->Flags & ImGuiTableFlags_BordersInnerV) |
| 2586 | { |
| 2587 | for (int order_n = 0; order_n < table->ColumnsCount; order_n++) |
| 2588 | { |
| 2589 | if (!IM_BITARRAY_TESTBIT(table->EnabledMaskByDisplayOrder, order_n)) |
| 2590 | continue; |
| 2591 | |
| 2592 | const int column_n = table->DisplayOrderToIndex[order_n]; |
| 2593 | ImGuiTableColumn* column = &table->Columns[column_n]; |
| 2594 | const bool is_hovered = (table->HoveredColumnBorder == column_n); |
| 2595 | const bool is_resized = (table->ResizedColumn == column_n) && (table->InstanceInteracted == table->InstanceCurrent); |
| 2596 | const bool is_resizable = (column->Flags & (ImGuiTableColumnFlags_NoResize | ImGuiTableColumnFlags_NoDirectResize_)) == 0; |
| 2597 | const bool is_frozen_separator = (table->FreezeColumnsCount == order_n + 1); |
| 2598 | if (column->MaxX > table->InnerClipRect.Max.x && !is_resized) |
| 2599 | continue; |
| 2600 | |
| 2601 | // Decide whether right-most column is visible |
| 2602 | if (column->NextEnabledColumn == -1 && !is_resizable) |
| 2603 | if ((table->Flags & ImGuiTableFlags_SizingMask_) != ImGuiTableFlags_SizingFixedSame || (table->Flags & ImGuiTableFlags_NoHostExtendX)) |
| 2604 | continue; |
| 2605 | 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.. |
| 2606 | continue; |
| 2607 | |
| 2608 | // Draw in outer window so right-most column won't be clipped |
| 2609 | // Always draw full height border when being resized/hovered, or on the delimitation of frozen column scrolling. |
| 2610 | ImU32 col; |
| 2611 | float draw_y2; |
| 2612 | if (is_hovered || is_resized || is_frozen_separator) |
| 2613 | { |
| 2614 | draw_y2 = draw_y2_body; |
| 2615 | col = is_resized ? GetColorU32(ImGuiCol_SeparatorActive) : is_hovered ? GetColorU32(ImGuiCol_SeparatorHovered) : table->BorderColorStrong; |
| 2616 | } |
| 2617 | else |
| 2618 | { |
| 2619 | draw_y2 = (table->Flags & (ImGuiTableFlags_NoBordersInBody | ImGuiTableFlags_NoBordersInBodyUntilResize)) ? draw_y2_head : draw_y2_body; |
| 2620 | col = (table->Flags & (ImGuiTableFlags_NoBordersInBody | ImGuiTableFlags_NoBordersInBodyUntilResize)) ? table->BorderColorStrong : table->BorderColorLight; |
| 2621 | } |
| 2622 | |
| 2623 | if (draw_y2 > draw_y1) |
| 2624 | inner_drawlist->AddLine(ImVec2(column->MaxX, draw_y1), ImVec2(column->MaxX, draw_y2), col, border_size); |
| 2625 | } |
| 2626 | } |
nothing calls this directly
no test coverage detected