FIXME-TABLE: This is a mess, need to redesign how we render borders (as some are also done in TableEndRow)
| 2475 | |
| 2476 | // FIXME-TABLE: This is a mess, need to redesign how we render borders (as some are also done in TableEndRow) |
| 2477 | void ImGui::TableDrawBorders(ImGuiTable* table) |
| 2478 | { |
| 2479 | ImGuiWindow* inner_window = table->InnerWindow; |
| 2480 | if (!table->OuterWindow->ClipRect.Overlaps(table->OuterRect)) |
| 2481 | return; |
| 2482 | |
| 2483 | ImDrawList* inner_drawlist = inner_window->DrawList; |
| 2484 | table->DrawSplitter->SetCurrentChannel(inner_drawlist, TABLE_DRAW_CHANNEL_BG0); |
| 2485 | inner_drawlist->PushClipRect(table->Bg0ClipRectForDrawCmd.Min, table->Bg0ClipRectForDrawCmd.Max, false); |
| 2486 | |
| 2487 | // Draw inner border and resizing feedback |
| 2488 | const float border_size = TABLE_BORDER_SIZE; |
| 2489 | const float draw_y1 = table->InnerRect.Min.y; |
| 2490 | const float draw_y2_body = table->InnerRect.Max.y; |
| 2491 | const float draw_y2_head = table->IsUsingHeaders ? ImMin(table->InnerRect.Max.y, (table->FreezeRowsCount >= 1 ? table->InnerRect.Min.y : table->WorkRect.Min.y) + table->LastFirstRowHeight) : draw_y1; |
| 2492 | if (table->Flags & ImGuiTableFlags_BordersInnerV) |
| 2493 | { |
| 2494 | for (int order_n = 0; order_n < table->ColumnsCount; order_n++) |
| 2495 | { |
| 2496 | if (!(table->EnabledMaskByDisplayOrder & ((ImU64)1 << order_n))) |
| 2497 | continue; |
| 2498 | |
| 2499 | const int column_n = table->DisplayOrderToIndex[order_n]; |
| 2500 | ImGuiTableColumn* column = &table->Columns[column_n]; |
| 2501 | const bool is_hovered = (table->HoveredColumnBorder == column_n); |
| 2502 | const bool is_resized = (table->ResizedColumn == column_n) && (table->InstanceInteracted == table->InstanceCurrent); |
| 2503 | const bool is_resizable = (column->Flags & (ImGuiTableColumnFlags_NoResize | ImGuiTableColumnFlags_NoDirectResize_)) == 0; |
| 2504 | const bool is_frozen_separator = (table->FreezeColumnsCount != -1 && table->FreezeColumnsCount == order_n + 1); |
| 2505 | if (column->MaxX > table->InnerClipRect.Max.x && !is_resized) |
| 2506 | continue; |
| 2507 | |
| 2508 | // Decide whether right-most column is visible |
| 2509 | if (column->NextEnabledColumn == -1 && !is_resizable) |
| 2510 | if ((table->Flags & ImGuiTableFlags_SizingMask_) != ImGuiTableFlags_SizingFixedSame || (table->Flags & ImGuiTableFlags_NoHostExtendX)) |
| 2511 | continue; |
| 2512 | 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.. |
| 2513 | continue; |
| 2514 | |
| 2515 | // Draw in outer window so right-most column won't be clipped |
| 2516 | // Always draw full height border when being resized/hovered, or on the delimitation of frozen column scrolling. |
| 2517 | ImU32 col; |
| 2518 | float draw_y2; |
| 2519 | if (is_hovered || is_resized || is_frozen_separator) |
| 2520 | { |
| 2521 | draw_y2 = draw_y2_body; |
| 2522 | col = is_resized ? GetColorU32(ImGuiCol_SeparatorActive) : is_hovered ? GetColorU32(ImGuiCol_SeparatorHovered) : table->BorderColorStrong; |
| 2523 | } |
| 2524 | else |
| 2525 | { |
| 2526 | draw_y2 = (table->Flags & (ImGuiTableFlags_NoBordersInBody | ImGuiTableFlags_NoBordersInBodyUntilResize)) ? draw_y2_head : draw_y2_body; |
| 2527 | col = (table->Flags & (ImGuiTableFlags_NoBordersInBody | ImGuiTableFlags_NoBordersInBodyUntilResize)) ? table->BorderColorStrong : table->BorderColorLight; |
| 2528 | } |
| 2529 | |
| 2530 | if (draw_y2 > draw_y1) |
| 2531 | inner_drawlist->AddLine(ImVec2(column->MaxX, draw_y1), ImVec2(column->MaxX, draw_y2), col, border_size); |
| 2532 | } |
| 2533 | } |
| 2534 |
nothing calls this directly
no test coverage detected