MCPcopy Create free account
hub / github.com/RenderKit/embree / TableDrawBorders

Method TableDrawBorders

tutorials/common/imgui/imgui_tables.cpp:2512–2606  ·  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

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

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