[Public]
| 1514 | |
| 1515 | // [Public] |
| 1516 | void ImGui::TableSetupScrollFreeze(int columns, int rows) |
| 1517 | { |
| 1518 | ImGuiContext& g = *GImGui; |
| 1519 | ImGuiTable* table = g.CurrentTable; |
| 1520 | IM_ASSERT(table != NULL && "Need to call TableSetupColumn() after BeginTable()!"); |
| 1521 | IM_ASSERT(table->IsLayoutLocked == false && "Need to call TableSetupColumn() before first row!"); |
| 1522 | IM_ASSERT(columns >= 0 && columns < IMGUI_TABLE_MAX_COLUMNS); |
| 1523 | IM_ASSERT(rows >= 0 && rows < 128); // Arbitrary limit |
| 1524 | |
| 1525 | table->FreezeColumnsRequest = (table->Flags & ImGuiTableFlags_ScrollX) ? (ImGuiTableColumnIdx)ImMin(columns, table->ColumnsCount) : 0; |
| 1526 | table->FreezeColumnsCount = (table->InnerWindow->Scroll.x != 0.0f) ? table->FreezeColumnsRequest : 0; |
| 1527 | table->FreezeRowsRequest = (table->Flags & ImGuiTableFlags_ScrollY) ? (ImGuiTableColumnIdx)rows : 0; |
| 1528 | table->FreezeRowsCount = (table->InnerWindow->Scroll.y != 0.0f) ? table->FreezeRowsRequest : 0; |
| 1529 | table->IsUnfrozenRows = (table->FreezeRowsCount == 0); // Make sure this is set before TableUpdateLayout() so ImGuiListClipper can benefit from it.b |
| 1530 | |
| 1531 | // Ensure frozen columns are ordered in their section. We still allow multiple frozen columns to be reordered. |
| 1532 | // FIXME-TABLE: This work for preserving 2143 into 21|43. How about 4321 turning into 21|43? (preserve relative order in each section) |
| 1533 | for (int column_n = 0; column_n < table->FreezeColumnsRequest; column_n++) |
| 1534 | { |
| 1535 | int order_n = table->DisplayOrderToIndex[column_n]; |
| 1536 | if (order_n != column_n && order_n >= table->FreezeColumnsRequest) |
| 1537 | { |
| 1538 | ImSwap(table->Columns[table->DisplayOrderToIndex[order_n]].DisplayOrder, table->Columns[table->DisplayOrderToIndex[column_n]].DisplayOrder); |
| 1539 | ImSwap(table->DisplayOrderToIndex[order_n], table->DisplayOrderToIndex[column_n]); |
| 1540 | } |
| 1541 | } |
| 1542 | } |
| 1543 | |
| 1544 | //----------------------------------------------------------------------------- |
| 1545 | // [SECTION] Tables: Simple accessors |