Allocate draw channels. Called by TableUpdateLayout() - We allocate them following storage order instead of display order so reordering columns won't needlessly increase overall dormant memory cost. - We isolate headers draw commands in their own channels instead of just altering clip rects. This is in order to facilitate merging of draw commands. - After crossing FreezeRowsCount, all columns see
| 2528 | // - FreezeRows || FreezeColunns --> 3+D+N*2 (unless scrolling value is zero) |
| 2529 | // Where D is 1 if any column is clipped or hidden (dummy channel) otherwise 0. |
| 2530 | void ImGui::TableSetupDrawChannels(ImGuiTable* table) |
| 2531 | { |
| 2532 | const int freeze_row_multiplier = (table->FreezeRowsCount > 0) ? 2 : 1; |
| 2533 | const int channels_for_row = (table->Flags & ImGuiTableFlags_NoClip) ? 1 : table->ColumnsEnabledCount; |
| 2534 | const int channels_for_bg = 1 + 1 * freeze_row_multiplier; |
| 2535 | const int channels_for_dummy = (table->ColumnsEnabledCount < table->ColumnsCount || (memcmp(table->VisibleMaskByIndex, table->EnabledMaskByIndex, ImBitArrayGetStorageSizeInBytes(table->ColumnsCount)) != 0)) ? +1 : 0; |
| 2536 | const int channels_total = channels_for_bg + (channels_for_row * freeze_row_multiplier) + channels_for_dummy; |
| 2537 | table->DrawSplitter->Split(table->InnerWindow->DrawList, channels_total); |
| 2538 | table->DummyDrawChannel = (ImGuiTableDrawChannelIdx)((channels_for_dummy > 0) ? channels_total - 1 : -1); |
| 2539 | table->Bg2DrawChannelCurrent = TABLE_DRAW_CHANNEL_BG2_FROZEN; |
| 2540 | table->Bg2DrawChannelUnfrozen = (ImGuiTableDrawChannelIdx)((table->FreezeRowsCount > 0) ? 2 + channels_for_row : TABLE_DRAW_CHANNEL_BG2_FROZEN); |
| 2541 | |
| 2542 | int draw_channel_current = 2; |
| 2543 | for (int column_n = 0; column_n < table->ColumnsCount; column_n++) |
| 2544 | { |
| 2545 | ImGuiTableColumn* column = &table->Columns[column_n]; |
| 2546 | if (column->IsVisibleX && column->IsVisibleY) |
| 2547 | { |
| 2548 | column->DrawChannelFrozen = (ImGuiTableDrawChannelIdx)(draw_channel_current); |
| 2549 | column->DrawChannelUnfrozen = (ImGuiTableDrawChannelIdx)(draw_channel_current + (table->FreezeRowsCount > 0 ? channels_for_row + 1 : 0)); |
| 2550 | if (!(table->Flags & ImGuiTableFlags_NoClip)) |
| 2551 | draw_channel_current++; |
| 2552 | } |
| 2553 | else |
| 2554 | { |
| 2555 | column->DrawChannelFrozen = column->DrawChannelUnfrozen = table->DummyDrawChannel; |
| 2556 | } |
| 2557 | column->DrawChannelCurrent = column->DrawChannelFrozen; |
| 2558 | } |
| 2559 | |
| 2560 | // Initial draw cmd starts with a BgClipRect that matches the one of its host, to facilitate merge draw commands by default. |
| 2561 | // All our cell highlight are manually clipped with BgClipRect. When unfreezing it will be made smaller to fit scrolling rect. |
| 2562 | // (This technically isn't part of setting up draw channels, but is reasonably related to be done here) |
| 2563 | table->BgClipRect = table->InnerClipRect; |
| 2564 | table->Bg0ClipRectForDrawCmd = table->OuterWindow->ClipRect; |
| 2565 | table->Bg2ClipRectForDrawCmd = table->HostClipRect; |
| 2566 | IM_ASSERT(table->BgClipRect.Min.y <= table->BgClipRect.Max.y); |
| 2567 | } |
| 2568 | |
| 2569 | // This function reorder draw channels based on matching clip rectangle, to facilitate merging them. Called by EndTable(). |
| 2570 | // For simplicity we call it TableMergeDrawChannels() but in fact it only reorder channels + overwrite ClipRect, |
nothing calls this directly
no test coverage detected