| 1344 | } |
| 1345 | |
| 1346 | void ImGui::EndTable() |
| 1347 | { |
| 1348 | ImGuiContext& g = *GImGui; |
| 1349 | ImGuiTable* table = g.CurrentTable; |
| 1350 | if (table == NULL) |
| 1351 | { |
| 1352 | IM_ASSERT_USER_ERROR(table != NULL, "EndTable() call should only be done while in BeginTable() scope!"); |
| 1353 | return; |
| 1354 | } |
| 1355 | |
| 1356 | // This assert would be very useful to catch a common error... unfortunately it would probably trigger in some |
| 1357 | // cases, and for consistency user may sometimes output empty tables (and still benefit from e.g. outer border) |
| 1358 | //IM_ASSERT(table->IsLayoutLocked && "Table unused: never called TableNextRow(), is that the intent?"); |
| 1359 | |
| 1360 | // If the user never got to call TableNextRow() or TableNextColumn(), we call layout ourselves to ensure all our |
| 1361 | // code paths are consistent (instead of just hoping that TableBegin/TableEnd will work), get borders drawn, etc. |
| 1362 | if (!table->IsLayoutLocked) |
| 1363 | TableUpdateLayout(table); |
| 1364 | |
| 1365 | const ImGuiTableFlags flags = table->Flags; |
| 1366 | ImGuiWindow* inner_window = table->InnerWindow; |
| 1367 | ImGuiWindow* outer_window = table->OuterWindow; |
| 1368 | ImGuiTableTempData* temp_data = table->TempData; |
| 1369 | IM_ASSERT(inner_window == g.CurrentWindow); |
| 1370 | IM_ASSERT(outer_window == inner_window || outer_window == inner_window->ParentWindow); |
| 1371 | |
| 1372 | if (table->IsInsideRow) |
| 1373 | TableEndRow(table); |
| 1374 | |
| 1375 | // Context menu in columns body |
| 1376 | if (flags & ImGuiTableFlags_ContextMenuInBody) |
| 1377 | if (table->HoveredColumnBody != -1 && !IsAnyItemHovered() && IsMouseReleased(ImGuiMouseButton_Right)) |
| 1378 | TableOpenContextMenu((int)table->HoveredColumnBody); |
| 1379 | |
| 1380 | // Finalize table height |
| 1381 | ImGuiTableInstanceData* table_instance = TableGetInstanceData(table, table->InstanceCurrent); |
| 1382 | inner_window->DC.PrevLineSize = temp_data->HostBackupPrevLineSize; |
| 1383 | inner_window->DC.CurrLineSize = temp_data->HostBackupCurrLineSize; |
| 1384 | inner_window->DC.CursorMaxPos = temp_data->HostBackupCursorMaxPos; |
| 1385 | const float inner_content_max_y = table->RowPosY2; |
| 1386 | IM_ASSERT(table->RowPosY2 == inner_window->DC.CursorPos.y); |
| 1387 | if (inner_window != outer_window) |
| 1388 | inner_window->DC.CursorMaxPos.y = inner_content_max_y; |
| 1389 | else if (!(flags & ImGuiTableFlags_NoHostExtendY)) |
| 1390 | table->OuterRect.Max.y = table->InnerRect.Max.y = ImMax(table->OuterRect.Max.y, inner_content_max_y); // Patch OuterRect/InnerRect height |
| 1391 | table->WorkRect.Max.y = ImMax(table->WorkRect.Max.y, table->OuterRect.Max.y); |
| 1392 | table_instance->LastOuterHeight = table->OuterRect.GetHeight(); |
| 1393 | |
| 1394 | // Setup inner scrolling range |
| 1395 | // FIXME: This ideally should be done earlier, in BeginTable() SetNextWindowContentSize call, just like writing to inner_window->DC.CursorMaxPos.y, |
| 1396 | // but since the later is likely to be impossible to do we'd rather update both axes together. |
| 1397 | if (table->Flags & ImGuiTableFlags_ScrollX) |
| 1398 | { |
| 1399 | const float outer_padding_for_border = (table->Flags & ImGuiTableFlags_BordersOuterV) ? TABLE_BORDER_SIZE : 0.0f; |
| 1400 | float max_pos_x = table->InnerWindow->DC.CursorMaxPos.x; |
| 1401 | if (table->RightMostEnabledColumn != -1) |
| 1402 | max_pos_x = ImMax(max_pos_x, table->Columns[table->RightMostEnabledColumn].WorkMaxX + table->CellPaddingX + table->OuterPaddingX - outer_padding_for_border); |
| 1403 | if (table->ResizedColumn != -1) |
nothing calls this directly
no test coverage detected