| 1406 | } |
| 1407 | |
| 1408 | void ImGui::EndTable() |
| 1409 | { |
| 1410 | ImGuiContext& g = *GImGui; |
| 1411 | ImGuiTable* table = g.CurrentTable; |
| 1412 | IM_ASSERT_USER_ERROR_RET(table != NULL, "EndTable() call should only be done while in BeginTable() scope!"); |
| 1413 | |
| 1414 | // This assert would be very useful to catch a common error... unfortunately it would probably trigger in some |
| 1415 | // cases, and for consistency user may sometimes output empty tables (and still benefit from e.g. outer border) |
| 1416 | //IM_ASSERT(table->IsLayoutLocked && "Table unused: never called TableNextRow(), is that the intent?"); |
| 1417 | |
| 1418 | // If the user never got to call TableNextRow() or TableNextColumn(), we call layout ourselves to ensure all our |
| 1419 | // code paths are consistent (instead of just hoping that TableBegin/TableEnd will work), get borders drawn, etc. |
| 1420 | if (!table->IsLayoutLocked) |
| 1421 | TableUpdateLayout(table); |
| 1422 | |
| 1423 | const ImGuiTableFlags flags = table->Flags; |
| 1424 | ImGuiWindow* inner_window = table->InnerWindow; |
| 1425 | ImGuiWindow* outer_window = table->OuterWindow; |
| 1426 | ImGuiTableTempData* temp_data = table->TempData; |
| 1427 | IM_ASSERT(inner_window == g.CurrentWindow && inner_window->ID == temp_data->WindowID); |
| 1428 | IM_ASSERT(outer_window == inner_window || outer_window == inner_window->ParentWindow); |
| 1429 | |
| 1430 | if (table->IsInsideRow) |
| 1431 | TableEndRow(table); |
| 1432 | |
| 1433 | // Context menu in columns body |
| 1434 | if (flags & ImGuiTableFlags_ContextMenuInBody) |
| 1435 | if (table->HoveredColumnBody != -1 && !IsAnyItemHovered() && IsMouseReleased(ImGuiMouseButton_Right)) |
| 1436 | TableOpenContextMenu((int)table->HoveredColumnBody); |
| 1437 | |
| 1438 | // Finalize table height |
| 1439 | ImGuiTableInstanceData* table_instance = TableGetInstanceData(table, table->InstanceCurrent); |
| 1440 | inner_window->DC.PrevLineSize = temp_data->HostBackupPrevLineSize; |
| 1441 | inner_window->DC.CurrLineSize = temp_data->HostBackupCurrLineSize; |
| 1442 | inner_window->DC.CursorMaxPos = temp_data->HostBackupCursorMaxPos; |
| 1443 | const float inner_content_max_y = ImCeil(table->RowPosY2); // Rounding final position is important as we currently don't round row height ('Demo->Tables->Outer Size' demo uses non-integer heights) |
| 1444 | IM_ASSERT(table->RowPosY2 == inner_window->DC.CursorPos.y); |
| 1445 | if (inner_window != outer_window) |
| 1446 | inner_window->DC.CursorMaxPos.y = inner_content_max_y; |
| 1447 | else if (!(flags & ImGuiTableFlags_NoHostExtendY)) |
| 1448 | table->OuterRect.Max.y = table->InnerRect.Max.y = ImMax(table->OuterRect.Max.y, inner_content_max_y); // Patch OuterRect/InnerRect height |
| 1449 | table->WorkRect.Max.y = ImMax(table->WorkRect.Max.y, table->OuterRect.Max.y); |
| 1450 | table_instance->LastOuterHeight = table->OuterRect.GetHeight(); |
| 1451 | |
| 1452 | // Setup inner scrolling range |
| 1453 | // FIXME: This ideally should be done earlier, in BeginTable() SetNextWindowContentSize call, just like writing to inner_window->DC.CursorMaxPos.y, |
| 1454 | // but since the later is likely to be impossible to do we'd rather update both axes together. |
| 1455 | if (table->Flags & ImGuiTableFlags_ScrollX) |
| 1456 | { |
| 1457 | const float outer_padding_for_border = (table->Flags & ImGuiTableFlags_BordersOuterV) ? TABLE_BORDER_SIZE : 0.0f; |
| 1458 | float max_pos_x = inner_window->DC.CursorMaxPos.x; |
| 1459 | if (table->RightMostEnabledColumn != -1) |
| 1460 | max_pos_x = ImMax(max_pos_x, table->Columns[table->RightMostEnabledColumn].WorkMaxX + table->CellPaddingX + table->OuterPaddingX - outer_padding_for_border); |
| 1461 | if (table->ResizedColumn != -1) |
| 1462 | max_pos_x = ImMax(max_pos_x, table->ResizeLockMinContentsX2); |
| 1463 | inner_window->DC.CursorMaxPos.x = max_pos_x + table->TempData->AngledHeadersExtraWidth; |
| 1464 | } |
| 1465 |
nothing calls this directly
no test coverage detected