MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/SPlisHSPlasH / TableDrawBorders

Method TableDrawBorders

extern/imgui/imgui_tables.cpp:2511–2605  ·  view source on GitHub ↗

FIXME-TABLE: This is a mess, need to redesign how we render borders (as some are also done in TableEndRow)

Source from the content-addressed store, hash-verified

2509
2510// FIXME-TABLE: This is a mess, need to redesign how we render borders (as some are also done in TableEndRow)
2511void ImGui::TableDrawBorders(ImGuiTable* table)
2512{
2513 ImGuiWindow* inner_window = table->InnerWindow;
2514 if (!table->OuterWindow->ClipRect.Overlaps(table->OuterRect))
2515 return;
2516
2517 ImDrawList* inner_drawlist = inner_window->DrawList;
2518 table->DrawSplitter->SetCurrentChannel(inner_drawlist, TABLE_DRAW_CHANNEL_BG0);
2519 inner_drawlist->PushClipRect(table->Bg0ClipRectForDrawCmd.Min, table->Bg0ClipRectForDrawCmd.Max, false);
2520
2521 // Draw inner border and resizing feedback
2522 ImGuiTableInstanceData* table_instance = TableGetInstanceData(table, table->InstanceCurrent);
2523 const float border_size = TABLE_BORDER_SIZE;
2524 const float draw_y1 = table->InnerRect.Min.y;
2525 const float draw_y2_body = table->InnerRect.Max.y;
2526 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;
2527 if (table->Flags & ImGuiTableFlags_BordersInnerV)
2528 {
2529 for (int order_n = 0; order_n < table->ColumnsCount; order_n++)
2530 {
2531 if (!(table->EnabledMaskByDisplayOrder & ((ImU64)1 << order_n)))
2532 continue;
2533
2534 const int column_n = table->DisplayOrderToIndex[order_n];
2535 ImGuiTableColumn* column = &table->Columns[column_n];
2536 const bool is_hovered = (table->HoveredColumnBorder == column_n);
2537 const bool is_resized = (table->ResizedColumn == column_n) && (table->InstanceInteracted == table->InstanceCurrent);
2538 const bool is_resizable = (column->Flags & (ImGuiTableColumnFlags_NoResize | ImGuiTableColumnFlags_NoDirectResize_)) == 0;
2539 const bool is_frozen_separator = (table->FreezeColumnsCount == order_n + 1);
2540 if (column->MaxX > table->InnerClipRect.Max.x && !is_resized)
2541 continue;
2542
2543 // Decide whether right-most column is visible
2544 if (column->NextEnabledColumn == -1 && !is_resizable)
2545 if ((table->Flags & ImGuiTableFlags_SizingMask_) != ImGuiTableFlags_SizingFixedSame || (table->Flags & ImGuiTableFlags_NoHostExtendX))
2546 continue;
2547 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..
2548 continue;
2549
2550 // Draw in outer window so right-most column won't be clipped
2551 // Always draw full height border when being resized/hovered, or on the delimitation of frozen column scrolling.
2552 ImU32 col;
2553 float draw_y2;
2554 if (is_hovered || is_resized || is_frozen_separator)
2555 {
2556 draw_y2 = draw_y2_body;
2557 col = is_resized ? GetColorU32(ImGuiCol_SeparatorActive) : is_hovered ? GetColorU32(ImGuiCol_SeparatorHovered) : table->BorderColorStrong;
2558 }
2559 else
2560 {
2561 draw_y2 = (table->Flags & (ImGuiTableFlags_NoBordersInBody | ImGuiTableFlags_NoBordersInBodyUntilResize)) ? draw_y2_head : draw_y2_body;
2562 col = (table->Flags & (ImGuiTableFlags_NoBordersInBody | ImGuiTableFlags_NoBordersInBodyUntilResize)) ? table->BorderColorStrong : table->BorderColorLight;
2563 }
2564
2565 if (draw_y2 > draw_y1)
2566 inner_drawlist->AddLine(ImVec2(column->MaxX, draw_y1), ImVec2(column->MaxX, draw_y2), col, border_size);
2567 }
2568 }

Callers

nothing calls this directly

Calls 8

TableGetInstanceDataFunction · 0.85
ImMinFunction · 0.85
ImVec2Function · 0.85
SetCurrentChannelMethod · 0.80
AddLineMethod · 0.80
AddRectMethod · 0.80
PushClipRectMethod · 0.45
PopClipRectMethod · 0.45

Tested by

no test coverage detected